diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-03-13 22:27:22 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-03-13 22:27:22 +0000 |
commit | a89312e54979c0ee6cc82f50e423bcdafbe9df43 (patch) | |
tree | 5de94476be7e38742cc805e059342ed89d16be86 /hcid | |
parent | 095a8af653e9d5f7c2cf9c82c19f1281e8ad8b92 (diff) |
Added new function to remove the listener based on integer identification
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/adapter.c | 18 | ||||
-rw-r--r-- | hcid/adapter.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index d46527d0..27ec1f4b 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -3343,6 +3343,12 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err) GSList *uuids; bdaddr_t src, dst; + /* Onwer exitted? */ + if (!adapter->create) { + sdp_list_free(recs, (sdp_free_func_t) sdp_record_free); + return; + } + if (err < 0) { error_connection_attempt_failed(adapter->create->conn, adapter->create->msg, -err); @@ -3410,6 +3416,15 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err) write_device_profiles(&src, &dst, ""); failed: + name_listener_id_remove(adapter->create->id); + dbus_connection_unref(adapter->create->conn); + dbus_message_unref(adapter->create->msg); + g_free(adapter->create); + adapter->create = NULL; +} + +static void create_device_exit(const char *name, struct adapter *adapter) +{ dbus_connection_unref(adapter->create->conn); dbus_message_unref(adapter->create->msg); g_free(adapter->create); @@ -3454,6 +3469,9 @@ static DBusHandlerResult create_device(DBusConnection *conn, create = g_new0(struct create_device_req, 1); create->conn = dbus_connection_ref(conn); create->msg = dbus_message_ref(msg); + create->id = name_listener_add(conn, + dbus_message_get_sender(msg), + (name_cb_t) create_device_exit, adapter); strcpy(create->address, address); adapter->create = create; diff --git a/hcid/adapter.h b/hcid/adapter.h index 9353fcdd..1943fbf2 100644 --- a/hcid/adapter.h +++ b/hcid/adapter.h @@ -84,6 +84,7 @@ struct create_device_req { char address[18]; /* Destination address */ DBusConnection *conn; /* Connection reference */ DBusMessage *msg; /* Message reference */ + guint id; /* Listener id */ }; struct adapter { |