Thanks Kees,<br><br>Actually I was looking for some API which could poll these messages for me inside my application so that I could attach it to my g_main loop and do other things in the same thread. Luckily for me I found the solution in the source code of ACMonitor. <br>
Here is what I did for battery:<br>battery_info_get kind of registers the callback for battery signals, bme_message_handler is called everytime a signal is sent from com.nokia.bme<br>Code: -<br>#define BME_SIG_PATH "/com/nokia/bme/signal"<br>
#define BME_SIG_IFC "com.nokia.bme.signal"<br>#define BME_REQ_PATH "/com/nokia/bme/request"<br>#define BME_REQ_IFC "com.nokia.bme.request"<br>void battery_info_get()<br>{<br> DBusMessage *db_msg;<br>
DBusConnection *db_conn;<br> DBusError dberror;<br> GMainLoop *loop;<br><br> dbus_error_init(&dberror);<br> prog_data.db_conn = db_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dberror);<br> if(db_conn == NULL)<br>
{<br> printf("Failed to open connection to system message bus: %s\n", dberror.message);<br> dbus_error_free(&dberror);<br> return;<br> }<br> dbus_bus_add_match(db_conn, "type='signal',path='"BME_SIG_PATH"',interface='"BME_SIG_IFC"'",NULL);<br>
dbus_connection_add_filter(db_conn, (DBusHandleMessageFunction)bme_message_handler, NULL, NULL);<br> db_msg = dbus_message_new_signal(BME_REQ_PATH, BME_REQ_IFC, "status_info_req");<br> dbus_connection_send(db_conn, db_msg, NULL);<br>
dbus_connection_flush(db_conn);<br> dbus_message_unref(db_msg);<br> dbus_connection_setup_with_g_main(db_conn, NULL); <br>}<br><br>static DBusHandlerResult bme_message_handler(DBusConnection *_conn, DBusMessage *_msg, gpointer *ctx)<br>
{<br> if(dbus_message_get_type(_msg) == DBUS_MESSAGE_TYPE_SIGNAL)<br> {<br> const char *member;<br> member = dbus_message_get_member(_msg);<br> if(!strcmp(member, "battery_low"))<br> {<br>
prog_data.battery_low = TRUE;<br> /* Do something */<br> }<br> else if(!strcmp(member, "charger_charging_on"))<br> {<br> prog_data.charging = TRUE;<br> }<br>
else if(!strcmp(member, "charger_charging_off"))<br> {<br> prog_data.charging = FALSE;<br> }<br> <br> printf("dbus-printed %s\n", member);<br> }<br> return DBUS_HANDLER_RESULT_HANDLED;<br>
}<br><div class="gmail_quote">On Mon, May 5, 2008 at 12:56 AM, Kees Jongenburger <<a href="mailto:kees.jongenburger@gmail.com">kees.jongenburger@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br>
<br>
I am fairly new to dbus but if you run dbus-monitor --system from a console<br>
and hover over the battery monitor applet you will see what calls are used to<br>
get this information.<br>
<br>
Nokia-N810-50-2:~# dbus-monitor --system<br>
signal sender=org.freedesktop.DBus -> dest=:1.67<br>
path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;<br>
member=NameAcquired<br>
string ":1.67"<br>
signal sender=:1.20 -> dest=(null destination)<br>
path=/com/nokia/bme/request; interface=com.nokia.bme.request;<br>
member=timeleft_info_req<br>
signal sender=:1.9 -> dest=(null destination)<br>
path=/com/nokia/bme/signal; interface=com.nokia.bme.signal;<br>
member=battery_timeleft<br>
uint32 5280<br>
uint32 120<br>
<br>
<br>
Hope this helps greetings<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
On Mon, Apr 28, 2008 at 8:26 AM, kumar lomash <<a href="mailto:kumar.lomash@gmail.com">kumar.lomash@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I have been trying to get a signal when battery status (time left, etc)<br>
> changes. I understand that I will have to use lib osso APIs for this, but I<br>
> am unable to find a service prvider (e.g. com.nokia.battery ???) to connect<br>
> to.<br>
> Is this documented somewhere? I could not find anything on this.<br>
><br>
> Can someone please send details of which service/interface to connect to?<br>
><br>
> Thanks a lot,<br>
> Lomash<br>
><br>
</div></div>> _______________________________________________<br>
> maemo-developers mailing list<br>
> <a href="mailto:maemo-developers@maemo.org">maemo-developers@maemo.org</a><br>
> <a href="https://lists.maemo.org/mailman/listinfo/maemo-developers" target="_blank">https://lists.maemo.org/mailman/listinfo/maemo-developers</a><br>
><br>
><br>
</blockquote></div><br>