Fun with Vala and DBus
After the lousy semester exams, I decided put in some time to learn vala and dbus to cheer me up. For the unitiated,
- `Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C.‘
- DBus is a low latency IPC system with less overhead with emphasis on desktop applications
I must say the folks at #vala in GimpNet has been patient with me, especially considering the silly questions I had been asking for the last couple of days. I should get commit access to the git repositories of freesmartphone.org in a short while as well
.
I learned a couple of things on the way. Especially the KeyFile API from the GLib library really rocked. Note that odeviced would have configuration file sitting in ‘/etc’ containing various settings like plugins to be loaded, their own internal switches and so on. I would have almost “reinvented the wheel” trying to reimplement stuff thats already provided by GLib if I hadn’t browsed through the API reference of GLib. Implementing something like the above for odeviced in vala looks something like this,
....
private GLib.KeyFile file = new GLib.KeyFile();
private string[] plugins;
private string dev_name = new string();
......
/* vala will warn you if you dont put this under a try, catch block */
file.load_from_file("/etc/odeviced.conf", GLib.KeyFileFlags.NONE);
if (file.has_group("odeviced"))
this.dev_name = file.get_string("odeviced", "device_name");
plugins = file.get_groups();
_load(plugins);
....
Of course, the corresponding configuration file will look something like this,
[odeviced]
device_name=FreeRunner
[powercontrol]
enable=1
In the above example, things within ‘[' and ']‘ are group names and each of these groups consist of a key-value pair.
As for the dbus part, each plugin would set up dbus objects on their own. GModule library will be used to load the .so libraries. So we’d have object paths like /org/freesmartphone/Device/powercontroller. And of course, odeviced will be on the System Bus.
On a related note, the “surprise” gift is on its way
.
Possibly related posts: (automatically generated)
Filed under: FOSS and Linux, Logs, embedded, gsoc, linux, neo1973, odeviced, openmoko | Leave a Comment
Tags: dbus, gsoc, odeviced, openmoko, soc, vala
Categories
Twitter Updates
- the band, #pornophonique is groovy with 8 bit sounds.. #win if you like the old 8 bit games 11 hours ago
- f*cking morons. the guys coming to the gym upstairs are hitting the calling bell and running off.., Next one to do this is gonna get punched 1 day ago
- RT @cnu "we want better chairs" "we want better chairs" "we want better chairs" "we want better chairs" :) 1 day ago
- yes!.. me got negative balance now 1 day ago
- man, these 'super'market chains are the suck. Bought a pizza base from #spencer's daily.. Full of f*cking fungus... #fail 2 days ago
Archives
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
Blogroll
Meta
Pages
No Responses Yet to “Fun with Vala and DBus”