In your case its unnecessary this line: if (strcmp(bus, GEOCLUE_DBUS_NAME) != 0) Only do that if you use the same callback to multiple bus names.
On Wed, Oct 3, 2012 at 12:03 PM, Enlightenment SVN <[email protected]> wrote: > Log: > PROTO/elocation: Use edbus infra to keep track of name owner changes > > Author: stefan > Date: 2012-10-03 08:03:31 -0700 (Wed, 03 Oct 2012) > New Revision: 77371 > Trac: http://trac.enlightenment.org/e/changeset/77371 > > Modified: > trunk/PROTO/elocation/src/lib/elocation.c > > Modified: trunk/PROTO/elocation/src/lib/elocation.c > =================================================================== > --- trunk/PROTO/elocation/src/lib/elocation.c 2012-10-03 14:21:02 UTC (rev > 77370) > +++ trunk/PROTO/elocation/src/lib/elocation.c 2012-10-03 15:03:31 UTC (rev > 77371) > @@ -10,15 +10,12 @@ > #include <elocation_private.h> > > static char *unique_name = NULL; > - > -static EDBus_Signal_Handler *cb_name_owner_changed = NULL; > - > static Elocation_Provider master_provider; > > static Eina_Bool > geoclue_start(void *data, int ev_type, void *event) > { > - printf("GeoClue start event\n"); > + printf("GeoClue start event at %s\n", unique_name); > return ECORE_CALLBACK_DONE; > } > > @@ -41,59 +38,30 @@ > } > > static void > -_system_name_owner_changed(void *data , const EDBus_Message *msg) > +_name_owner_changed(void *data , const char *bus, const char *old, const > char *new) > { > - const char *name, *from, *to; > - > - if (!edbus_message_arguments_get(msg, "sss", &name, &from, &to)) > - { > - return; > - } > - > - if (strcmp(name, GEOCLUE_DBUS_NAME) != 0) > + if (strcmp(bus, GEOCLUE_DBUS_NAME) != 0) > return; > > - if (from[0] == '\0' && to[0] != '\0') > + if (old[0] == '\0' && new[0] != '\0') > { > ecore_event_add(ELOCATION_EVENT_IN, NULL, NULL, NULL); > - unique_name = strdup(to); > + unique_name = strdup(new); > } > - else if (from[0] != '\0' && to[0] == '\0') > + else if (old[0] != '\0' && new[0] == '\0') > { > - if (strcmp(unique_name, from) != 0) > - printf("%s was not the known name %s, ignored.\n", from, > unique_name); > + if (strcmp(unique_name, old) != 0) > + printf("%s was not the known name %s, ignored.\n", old, > unique_name); > else > ecore_event_add(ELOCATION_EVENT_OUT, NULL, NULL, NULL); > } > else > { > - printf("unknow change from %s to %s\n", from, to); > + printf("unknow change from %s to %s\n", old, new); > } > } > > static void > -_get_name_owner(void *data , const EDBus_Message *msg, EDBus_Pending > *pending) > -{ > - const char *uid; > - > - if (!edbus_message_arguments_get(msg, "s", &uid)) return; > - if (!uid) > - return; > - > - printf("enter GeoClue at %s (old was %s)\n", uid, unique_name); > - if (unique_name && strcmp(unique_name, uid) == 0) > - { > - return; > - } > - > - if (unique_name) > - ecore_event_add(ELOCATION_EVENT_IN, NULL, NULL, NULL); > - > - unique_name = strdup(uid); > - return; > -} > - > -static void > status_cb(void *data , const EDBus_Message *reply, EDBus_Pending *pendding) > { > int32_t status; > @@ -185,11 +153,9 @@ > return EXIT_FAILURE; > } > > - cb_name_owner_changed = edbus_signal_handler_add > - (conn, EDBUS_FDO_BUS, EDBUS_FDO_PATH, EDBUS_FDO_INTERFACE, > "NameOwnerChanged", _system_name_owner_changed, NULL); > + edbus_name_owner_changed_callback_add(conn, GEOCLUE_DBUS_NAME, > _name_owner_changed, > + NULL, EINA_TRUE); > > - edbus_name_owner_get(conn, GEOCLUE_DBUS_NAME, _get_name_owner, NULL); > - > ecore_event_handler_add(ELOCATION_EVENT_IN, geoclue_start, NULL); > ecore_event_handler_add(ELOCATION_EVENT_OUT, geoclue_stop, NULL); > > @@ -200,9 +166,5 @@ > void > elocation_shutdown(EDBus_Connection *conn) > { > - if (cb_name_owner_changed) > - { > - //edbus_signal_handler_del(cb_name_owner_changed); > - cb_name_owner_changed = NULL; > - } > + edbus_name_owner_changed_callback_del(conn, GEOCLUE_DBUS_NAME, > _name_owner_changed, NULL); > } > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > enlightenment-svn mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
