diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-12 18:32:58 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-06-12 18:32:58 +0200 |
commit | c853c2d26dade601aeaac7b13a6303dc11e7e53e (patch) | |
tree | 8700c6242ca53bb73c1de618dbf96cf2319c64ed | |
parent | a72a0c4ad0bf7e95cf4ecc7f58f885aadf66aebb (diff) | |
download | neard-c853c2d26dade601aeaac7b13a6303dc11e7e53e.tar.gz neard-c853c2d26dade601aeaac7b13a6303dc11e7e53e.tar.bz2 neard-c853c2d26dade601aeaac7b13a6303dc11e7e53e.zip |
agent: Do not call NDEF agent Release when agent leaves
The Release method should only be called when neard leaves. neard
doesn't need to notify an agent that's explicitly leaving.
-rw-r--r-- | src/agent.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/agent.c b/src/agent.c index 9ab9a9d..74ec0ed 100644 --- a/src/agent.c +++ b/src/agent.c @@ -58,15 +58,28 @@ struct near_handover_agent { static void ndef_agent_free(gpointer data) { - DBusMessage *message; struct near_ndef_agent *agent = data; DBG(""); + if (agent == NULL || agent->watch == 0) + return; + + g_dbus_remove_watch(connection, agent->watch); + + g_free(agent->sender); + g_free(agent->path); +} + +static void ndef_agent_release(gpointer key, gpointer data, gpointer user_data) +{ + struct near_ndef_agent *agent = data; + DBusMessage *message; + if (agent == NULL) return; - DBG("%s %s %s", agent->sender, agent->path, NFC_NDEF_AGENT_INTERFACE); + DBG("%s %s", agent->sender, agent->path); message = dbus_message_new_method_call(agent->sender, agent->path, NFC_NDEF_AGENT_INTERFACE, "Release"); @@ -76,11 +89,6 @@ static void ndef_agent_free(gpointer data) dbus_message_set_no_reply(message, TRUE); g_dbus_send_message(connection, message); - - g_dbus_remove_watch(connection, agent->watch); - - g_free(agent->sender); - g_free(agent->path); } static void ndef_agent_disconnect(DBusConnection *conn, void *user_data) @@ -665,6 +673,7 @@ void __near_agent_cleanup(void) { DBG(""); + g_hash_table_foreach(ndef_app_hash, ndef_agent_release, NULL); g_hash_table_destroy(ndef_app_hash); ndef_app_hash = NULL; |