libframeworkd-glib is a library conceived to help users develop with frameworkd without bothering about the dbus calls/marshalling/etc... while building a C glib software.

libframeworkd-glib is a library conceived to help users develop with frameworkd without bothering about the dbus calls/marshalling/etc... while building a C glib software.

+

+

It uses dbus-glib to bind to frameworkd, then calls the asynchronous methods of the interfaces. Thus, in order to use one method, you have to implement a callback.

= Integration with other software =

= Integration with other software =

Line 14:

Line 16:

You can find the sources on the [https://projects.openmoko.org/projects/shr/ SHR project page].

You can find the sources on the [https://projects.openmoko.org/projects/shr/ SHR project page].

+

+

Or, use clone the git repository:

+

+

<pre>

+

git clone git://git.freesmartphone.org/libframeworkd-glib.git

+

</pre>

= Example =

= Example =

ophonekitd is a simple example on how to use libframeworkd-glib to listen to events on frameworkd, and then launch the appropriate UI. It handles, in SHR, the whole "call" UI.

ophonekitd is a simple example on how to use libframeworkd-glib to listen to events on frameworkd, and then launch the appropriate UI. It handles, in SHR, the whole "call" UI.

+

+

== Connecting to the bus ==

+

+

To connect to the bus, you have to explicitly ask for it. You also have to give to libframeworkd-glib a list of handlers for the events you want to listen to.

+

<pre>

<pre>

+

FrameworkdHandlers fwHandler;

+

fwHandler.networkStatus = NULL;

+

fwHandler.simAuthStatus = ophonekitd_sim_auth_status_handler;

+

fwHandler.callCallStatus = NULL;

+

fwHandler.smsMessageSent = NULL;

+

fwHandler.smsIncomingMessage = NULL;

+

fwHandler.networkSignalStrength = NULL;

+

dbus_connect_to_bus(&fwHandler);

+

</pre>

+

+

== Calling a method ==

+

+

Libframeworkd-glib reflects the asynchronous nature of dbus. Calls to dbus return immediately, with the return values (or error values) coming back in a later call.

+

+

In order to call a method you have to provide a callback which will give you the information you asked for, or some other stuff (errors as an example).

+

+

<pre>

+

boolean power_up_antenna() {

+

device_set_antenna_power(TRUE, power_up_antenna_callback, NULL);

+

+

return false; // End timeout

+

}

+

+

void power_up_antenna_callback(GError *error, gpointer userdata) {

+

if(error != NULL) {

+

if(IS_SIM_ERROR(error, SIM_ERROR_AUTH_FAILED)) {

+

sim_display_code_UI();

+

}

+

}

+

}

+

</pre>

+

+

== Source code ==

+

+

<pre>

+

#include <glib-2.0/glib.h>

+

#include <glib-2.0/glib-object.h>

+

#include <frameworkd-glib/frameworkd-glib-dbus.h>

+

int main(int argc, char ** argv) {

int main(int argc, char ** argv) {

GMainLoop *mainloop = NULL;

GMainLoop *mainloop = NULL;

Line 51:

Line 103:

}

}

}

}

+

+

void ophonekitd_sim_auth_status_handler(const int status) {

+

if(status == SIM_READY) {

+

phonegui_destroy_pin_UI();

+

}

+

else {

+

phonegui_display_pin_UI(status);

+

}

+

}

+

</pre>

</pre>

−

This example, built with the appropriate headers, listen for events on SIM authentication. It powers up the antenna, and presents the SIM "code" UI, that is to say the UI prompting the user for its PIN.

+

This example, built with the appropriate headers, listens to events on SIM authentication. It powers up the antenna, and presents the SIM "code" UI, that is to say the UI prompting the user for its PIN.

This example, built with the appropriate headers, listens to events on SIM authentication. It powers up the antenna, and presents the SIM "code" UI, that is to say the UI prompting the user for its PIN.

This example, built with the appropriate headers, listen for events on SIM authentication. It powers up the antenna, and presents the SIM "code" UI, that is to say the UI prompting the user for its PIN.