|
|
2010-03-08
, 18:07
|
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#11
|
|
|
2010-03-09
, 05:09
|
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#12
|
As promised: http://qwerty12.qole.org/pimp2.tar
Make it, and run it on the N900. Whenever the call state changes, you will see a message. Use the code to implement something similar in your code (like !strcmp in the callback for MCE_CALL_STATE_ACTIVE etc. to know if you're in a call, and if you're using gtk_main, ignore the GMainloop stuff in the example.).
I see you've been posting as I've been posting my sample. Take a look at the code I've given first, please.
Merging my "on demand" code in #8 with this shouldn't be hard.
The thing is I didn't get why there are so many marshal* things needed.
|
|
2010-03-09
, 07:38
|
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#13
|
As I said, I'm back withThe thing is I didn't get why there are so many marshal* things needed.
|
|
2010-03-09
, 09:48
|
|
|
Posts: 664 |
Thanked: 160 times |
Joined on Jul 2008
@ Australia
|
#14
|
As you will have noticed, D-Bus signals are handled like "normal, GObject-type" signals in DBus-GLib (think of dbus_g_proxy_connect_signal () as the D-Bus version of g_signal_connect ()).
g_signal_new requires a marshaller to be able to send whatever it receives (in this case, the two gchars* from MCE) to the callback function (see http://gnomejournal.org/article/36/w...d-gtk28-part-2 for an example on how it's used there).
So, according to http://maemo.org/api_refs/5.0/5.0-fi...5a46afdad43a94 , we receive two gchars*.
So our callback function signature is to look like "static void call_state_changed_cb (DBusGProxy *object G_GNUC_UNUSED, const gchar *call_state, const gchar *emergency_call_state G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED)".
(G_GNUC_UNUSED is only there because I'm [generally] pedantic/anal about GCC warnings...)
But if we look at http://maemo.org/api_refs/5.0/5.0-fi...-Closures.html , we see GLib only comes with a marshaller (g_cclosure_marshal_VOID__STRING) that would only handle "static void call_state_changed_cb (DBusGProxy *object G_GNUC_UNUSED, const gchar *call_state, gpointer user_data G_GNUC_UNUSED)" (i.e. a DBus signal that only sends back one gchar*).
That is not what we want and, in any case, it wouldn't work - the callback function would never be called.
So we use glib-genmarshal to create a marshaller that understands VOID__STRING_STRING, matching the signature of the first callback function and we then use dbus_g_object_register_marshaller () to register it with DBus-GLib.
|
|
2010-03-09
, 11:15
|
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#15
|
Thanks for your time to explain. I'll have to go through it more coz I'm not quite familier with dbus let alone dbus-glib. However, I came across another problem coz as I'm using libhal to listen to hardware property changes and it uses dbus I couldn't think of how I could link dbus-glib and hal so I just made the whole thing which gets the current call state into one method with all the dbus-glib thing and flushes this connection after it gets what it wants while the main loop which uses plain dbus is there. So, I was wondering if there's better way to do it.
Anyway, I've got it to work and quickly created a .deb file and does what it is suppose to do. I guess I'll start a new thread for it and let this one continue coz I have more to implement
| The Following 3 Users Say Thank You to qwerty12 For This Useful Post: | ||