edbus: Add flag to name_owner_changed_callback_add to
allow initial call Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 77338
This commit is contained in:
parent
c2e818bd3f
commit
de5d201e7e
|
@ -235,7 +235,7 @@ add_name_owner2(void *data)
|
||||||
{
|
{
|
||||||
EDBus_Connection *conn = data;
|
EDBus_Connection *conn = data;
|
||||||
edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed2,
|
edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed2,
|
||||||
NULL);
|
NULL, EINA_TRUE);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,8 @@ main(void)
|
||||||
edbus_proxy_call(proxy, "SendString", _on_send_string, NULL, -1, "s", string_value);
|
edbus_proxy_call(proxy, "SendString", _on_send_string, NULL, -1, "s", string_value);
|
||||||
edbus_proxy_call(proxy, "AsyncTest", _on_async_test, NULL, -1, "");
|
edbus_proxy_call(proxy, "AsyncTest", _on_async_test, NULL, -1, "");
|
||||||
|
|
||||||
edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed, conn);
|
edbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed,
|
||||||
|
conn, EINA_TRUE);
|
||||||
ecore_timer_add(3, add_name_owner2, conn);
|
ecore_timer_add(3, add_name_owner2, conn);
|
||||||
|
|
||||||
ecore_main_loop_begin();
|
ecore_main_loop_begin();
|
||||||
|
|
|
@ -49,6 +49,7 @@ typedef struct _EDBus_Connection_Context_NOC_Cb
|
||||||
const void *cb_data;
|
const void *cb_data;
|
||||||
Eina_Bool deleted : 1;
|
Eina_Bool deleted : 1;
|
||||||
Ecore_Idler *idler;
|
Ecore_Idler *idler;
|
||||||
|
Eina_Bool allow_initial : 1;
|
||||||
} EDBus_Connection_Context_NOC_Cb;
|
} EDBus_Connection_Context_NOC_Cb;
|
||||||
|
|
||||||
typedef struct _EDBus_Handler_Data
|
typedef struct _EDBus_Handler_Data
|
||||||
|
@ -499,7 +500,7 @@ on_get_name_owner(void *data, const EDBus_Message *msg, EDBus_Pending *pending)
|
||||||
ERR("Error getting arguments from GetNameOwner");
|
ERR("Error getting arguments from GetNameOwner");
|
||||||
|
|
||||||
cn->unique_id = eina_stringshare_add(unique_id);
|
cn->unique_id = eina_stringshare_add(unique_id);
|
||||||
edbus_dispatch_name_owner_change(cn, "");
|
edbus_dispatch_name_owner_change(cn, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1157,11 +1158,14 @@ static void
|
||||||
edbus_dispatch_name_owner_change(EDBus_Connection_Name *cn, const char *old_id)
|
edbus_dispatch_name_owner_change(EDBus_Connection_Name *cn, const char *old_id)
|
||||||
{
|
{
|
||||||
EDBus_Connection_Context_NOC_Cb *ctx;
|
EDBus_Connection_Context_NOC_Cb *ctx;
|
||||||
|
const char *previous_id = !old_id ? "" : old_id;
|
||||||
cn->event_handlers.walking++;
|
cn->event_handlers.walking++;
|
||||||
EINA_INLIST_FOREACH(cn->event_handlers.list, ctx)
|
EINA_INLIST_FOREACH(cn->event_handlers.list, ctx)
|
||||||
{
|
{
|
||||||
if (ctx->deleted) continue;
|
if (ctx->deleted) continue;
|
||||||
ctx->cb((void *)ctx->cb_data, cn->name, old_id, cn->unique_id);
|
if (!old_id && !ctx->allow_initial)
|
||||||
|
continue;
|
||||||
|
ctx->cb((void *)ctx->cb_data, cn->name, previous_id, cn->unique_id);
|
||||||
}
|
}
|
||||||
cn->event_handlers.walking--;
|
cn->event_handlers.walking--;
|
||||||
}
|
}
|
||||||
|
@ -1184,7 +1188,7 @@ dispach_name_owner_cb(void *context)
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data)
|
edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data, Eina_Bool allow_initial_call)
|
||||||
{
|
{
|
||||||
EDBus_Connection_Name *cn;
|
EDBus_Connection_Name *cn;
|
||||||
EDBus_Connection_Context_NOC_Cb *ctx;
|
EDBus_Connection_Context_NOC_Cb *ctx;
|
||||||
|
@ -1209,10 +1213,11 @@ edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, E
|
||||||
EINA_SAFETY_ON_NULL_GOTO(ctx, cleanup);
|
EINA_SAFETY_ON_NULL_GOTO(ctx, cleanup);
|
||||||
ctx->cb = cb;
|
ctx->cb = cb;
|
||||||
ctx->cb_data = cb_data;
|
ctx->cb_data = cb_data;
|
||||||
|
ctx->allow_initial = allow_initial_call;
|
||||||
|
|
||||||
cn->event_handlers.list = eina_inlist_append(cn->event_handlers.list,
|
cn->event_handlers.list = eina_inlist_append(cn->event_handlers.list,
|
||||||
EINA_INLIST_GET(ctx));
|
EINA_INLIST_GET(ctx));
|
||||||
if (cn->unique_id)
|
if (cn->unique_id && allow_initial_call)
|
||||||
{
|
{
|
||||||
dispatch_name_owner_data *dispatch_data;
|
dispatch_name_owner_data *dispatch_data;
|
||||||
dispatch_data = malloc(sizeof(dispatch_name_owner_data));
|
dispatch_data = malloc(sizeof(dispatch_name_owner_data));
|
||||||
|
|
|
@ -37,7 +37,24 @@ EAPI EDBus_Pending *edbus_name_start(EDBus_Connection *conn, const char *
|
||||||
|
|
||||||
typedef void (*EDBus_Name_Owner_Changed_Cb)(void *data, const char *bus, const char *old_id, const char *new_id);
|
typedef void (*EDBus_Name_Owner_Changed_Cb)(void *data, const char *bus, const char *old_id, const char *new_id);
|
||||||
|
|
||||||
EAPI void edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data);
|
/**
|
||||||
|
* Add a callback to be called when unique id of a bus name changed.
|
||||||
|
*
|
||||||
|
* @param conn connection
|
||||||
|
* @param bus name of bus
|
||||||
|
* @param cb callback
|
||||||
|
* @param cb_data context data
|
||||||
|
* @param allow_initial_call allow call callback with actual id of the bus
|
||||||
|
*/
|
||||||
|
EAPI void edbus_name_owner_changed_callback_add(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data, Eina_Bool allow_initial_call);
|
||||||
|
/**
|
||||||
|
* Remove callback added with edbus_name_owner_changed_callback_add().
|
||||||
|
*
|
||||||
|
* @param conn connection
|
||||||
|
* @param bus name of bus
|
||||||
|
* @param cb callback
|
||||||
|
* @param cb_data context data
|
||||||
|
*/
|
||||||
EAPI void edbus_name_owner_changed_callback_del(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data);
|
EAPI void edbus_name_owner_changed_callback_del(EDBus_Connection *conn, const char *bus, EDBus_Name_Owner_Changed_Cb cb, const void *cb_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue