forked from enlightenment/efl
efl/edbus: Fix edbus_name_owner_changed() when bus name is not on bus
If we pass the last argument as TRUE, that means user want to know the actual bus id of the bus name and if the bus name is not registered it never notify the user. This bug was insert when fixing another one, because of that there more code here to fix the previous bug too. Patch by: José Roberto de Souza <zezsouza@gmail.com> SVN revision: 83082
This commit is contained in:
parent
623a73d1ed
commit
ba63fa7ed2
|
@ -125,6 +125,7 @@ extern "C" {
|
|||
#define EDBUS_FDO_INTERFACE_OBJECT_MANAGER "org.freedesktop.DBus.ObjectManager"
|
||||
#define EDBUS_FDO_INTERFACE_INTROSPECTABLE "org.freedesktop.DBus.Introspectable"
|
||||
#define EDBUS_FDO_INTEFACE_PEER "org.freedesktop.DBus.Peer"
|
||||
#define EDBUS_ERROR_PENDING_CANCELED "org.enlightenment.DBus.Canceled"
|
||||
|
||||
typedef struct _EDBus_Version
|
||||
{
|
||||
|
|
|
@ -385,6 +385,9 @@ edbus_connection_name_gc(EDBus_Connection *conn, EDBus_Connection_Name *cn)
|
|||
if (cn->objects)
|
||||
eina_hash_free(cn->objects);
|
||||
eina_stringshare_del(cn->name);
|
||||
if (cn->name_owner_get)
|
||||
edbus_pending_cancel(cn->name_owner_get);
|
||||
if (cn->unique_id)
|
||||
eina_stringshare_del(cn->unique_id);
|
||||
eina_list_free(cn->event_handlers.to_delete);
|
||||
free(cn);
|
||||
|
@ -432,19 +435,19 @@ on_name_owner_changed(void *data, const EDBus_Message *msg)
|
|||
static void
|
||||
on_get_name_owner(void *data, const EDBus_Message *msg, EDBus_Pending *pending EINA_UNUSED)
|
||||
{
|
||||
const char *unique_id = "";
|
||||
const char *unique_id = "", *error_name;
|
||||
EDBus_Connection_Name *cn = data;
|
||||
|
||||
if (edbus_message_error_get(msg, NULL, NULL))
|
||||
cn->name_owner_get = NULL;
|
||||
|
||||
if (edbus_message_error_get(msg, &error_name, NULL))
|
||||
{
|
||||
DBG("GetNameOwner returned an error");
|
||||
if (!strcmp(error_name, EDBUS_ERROR_PENDING_CANCELED))
|
||||
return;
|
||||
DBG("GetNameOwner of bus = %s returned an error", cn->name);
|
||||
}
|
||||
else if (!edbus_message_arguments_get(msg, "s", &unique_id))
|
||||
{
|
||||
ERR("Error getting arguments from GetNameOwner");
|
||||
return;
|
||||
}
|
||||
|
||||
cn->unique_id = eina_stringshare_add(unique_id);
|
||||
edbus_dispatch_name_owner_change(cn, NULL);
|
||||
|
@ -490,7 +493,7 @@ edbus_connection_name_get(EDBus_Connection *conn, const char *name)
|
|||
if (name[0] == ':')
|
||||
cn->unique_id = eina_stringshare_add(name);
|
||||
else
|
||||
edbus_name_owner_get(conn, cn->name, on_get_name_owner, cn);
|
||||
cn->name_owner_get = edbus_name_owner_get(conn, cn->name, on_get_name_owner, cn);
|
||||
|
||||
cn->name_owner_changed = _edbus_signal_handler_add(conn, EDBUS_FDO_BUS,
|
||||
EDBUS_FDO_PATH,
|
||||
|
|
|
@ -218,7 +218,7 @@ edbus_pending_cancel(EDBus_Pending *pending)
|
|||
dbus_pending_call_cancel(pending->dbus_pending);
|
||||
|
||||
error_message = edbus_message_error_new(pending->msg_sent,
|
||||
"org.enlightenment.DBus.Canceled",
|
||||
EDBUS_ERROR_PENDING_CANCELED,
|
||||
"Canceled by user.");
|
||||
edbus_pending_dispatch(pending, error_message);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ typedef struct _EDBus_Connection_Name
|
|||
Eina_List *to_delete;
|
||||
} event_handlers;
|
||||
EDBus_Signal_Handler *name_owner_changed;
|
||||
EDBus_Pending *name_owner_get;
|
||||
} EDBus_Connection_Name;
|
||||
|
||||
typedef struct _EDBus_Object_Context_Event_Cb
|
||||
|
|
|
@ -120,6 +120,38 @@ START_TEST(edbus_test_edbus_conn_object)
|
|||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void name_owner_changed_cb(void *data, const char *bus EINA_UNUSED, const char *old_id EINA_UNUSED, const char *new_id)
|
||||
{
|
||||
const char **id = data;
|
||||
*id = new_id;
|
||||
}
|
||||
|
||||
START_TEST(edbus_test_edbus_name_owner_changed)
|
||||
{
|
||||
EDBus_Connection *conn;
|
||||
const char *id = NULL;
|
||||
|
||||
ecore_init();
|
||||
edbus_init();
|
||||
|
||||
conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SYSTEM);
|
||||
fail_if(conn == NULL);
|
||||
|
||||
edbus_name_owner_changed_callback_add(conn, "org.bus.that.not.exist",
|
||||
name_owner_changed_cb, &id, EINA_TRUE);
|
||||
ecore_timer_add(0.5, _quit_cb, NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
fail_if(id == NULL);
|
||||
|
||||
edbus_connection_unref(conn);
|
||||
|
||||
edbus_shutdown();
|
||||
ecore_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
#endif
|
||||
|
||||
void edbus_test_edbus_init(TCase *tc)
|
||||
|
@ -129,5 +161,6 @@ void edbus_test_edbus_init(TCase *tc)
|
|||
#if 0
|
||||
tcase_add_test(tc, edbus_test_edbus_conn);
|
||||
tcase_add_test(tc, edbus_test_edbus_conn_object);
|
||||
tcase_add_test(tc, edbus_test_edbus_name_owner_changed);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue