printf("%s\n", str);
}
+static void
+on_name_owner_changed2(void *data, const char *bus, const char *old_id, const char *new_id)
+{
+ printf("2 - Bus=%s | old=%s | new=%s\n", bus, old_id, new_id);
+}
+
+static void
+on_name_owner_changed(void *data, const char *bus, const char *old_id, const char *new_id)
+{
+ printf("Bus=%s | old=%s | new=%s\n", bus, old_id, new_id);
+}
+
+static Eina_Bool
+add_name_owner2(void *data)
+{
+ EDBus_Connection *conn = data;
+ edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed2,
+ NULL);
+ return EINA_FALSE;
+}
+
int
main(void)
{
edbus_proxy_call(proxy, "SendString", _on_send_string, NULL, -1, "s", string_value);
edbus_proxy_call(proxy, "AsyncTest", _on_async_test, NULL, -1, "");
+ edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed, conn);
+ ecore_timer_add(3, add_name_owner2, conn);
+
ecore_main_loop_begin();
+ edbus_name_owner_changed_callback_del(conn, BUS, on_name_owner_changed, conn);
+ edbus_name_owner_changed_callback_del(conn, BUS, on_name_owner_changed2,
+ NULL);
edbus_connection_unref(conn);
edbus_shutdown();
EDBus_Name_Owner_Changed_Cb cb;
const void *cb_data;
Eina_Bool deleted : 1;
+ Ecore_Idler *idler;
} EDBus_Connection_Context_NOC_Cb;
typedef struct _EDBus_Handler_Data
cn->event_handlers.walking--;
}
+typedef struct _dispach_name_owner_data
+{
+ EDBus_Connection_Context_NOC_Cb *ctx;
+ const EDBus_Connection_Name *cn;
+} dispatch_name_owner_data;
+
+static Eina_Bool
+dispach_name_owner_cb(void *context)
+{
+ dispatch_name_owner_data *data = context;
+ data->ctx->cb((void *)data->ctx->cb_data, data->cn->name, "",
+ data->cn->unique_id);
+ data->ctx->idler = NULL;
+ free(data);
+ return ECORE_CALLBACK_CANCEL;
+}
+
EAPI void
edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data)
{
cn->event_handlers.list = eina_inlist_append(cn->event_handlers.list,
EINA_INLIST_GET(ctx));
+ if (cn->unique_id)
+ {
+ dispatch_name_owner_data *dispatch_data;
+ dispatch_data = malloc(sizeof(dispatch_name_owner_data));
+ EINA_SAFETY_ON_NULL_RETURN(dispatch_data);
+ dispatch_data->cn = cn;
+ dispatch_data->ctx = ctx;
+ ctx->idler = ecore_idler_add(dispach_name_owner_cb, dispatch_data);
+ }
return;
cleanup:
cn->event_handlers.list = eina_inlist_remove(cn->event_handlers.list,
EINA_INLIST_GET(found));
+ if (found->idler)
+ {
+ dispatch_name_owner_data *data;
+ data = ecore_idler_del(found->idler);
+ free(data);
+ }
free(found);
edbus_connection_name_owner_monitor(conn, cn, EINA_FALSE);
}