[PATCH v2 1/6] neard: Use service name and not boolean to track if registered to neard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 plugins/neard.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/plugins/neard.c b/plugins/neard.c
index a1b385e..650ee3e 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -49,7 +49,7 @@
 #define ERROR_INTERFACE "org.neard.HandoverAgent.Error"
 
 static guint watcher_id = 0;
-static gboolean agent_registered = FALSE;
+static char *neard_service = NULL;
 static gboolean agent_register_postpone = FALSE;
 
 /* For NFC mimetype limits max OOB EIR size */
@@ -115,7 +115,7 @@ static void register_agent_cb(DBusPendingCall *call, void *user_data)
 	}
 
 	dbus_message_unref(reply);
-	agent_registered = TRUE;
+	neard_service = g_strdup(dbus_message_get_sender(reply));
 }
 
 static void register_agent(void)
@@ -152,7 +152,8 @@ static void unregister_agent(void)
 	DBusMessage *message;
 	const char *path = AGENT_PATH;
 
-	agent_registered = FALSE;
+	g_free(neard_service);
+	neard_service = NULL;
 
 	message = dbus_message_new_method_call(NEARD_NAME, NEARD_PATH,
 			NEARD_MANAGER_INTERFACE, "UnregisterHandoverAgent");
@@ -237,7 +238,7 @@ static void read_local_complete(struct btd_adapter *adapter,
 
 	DBG("");
 
-	if (!agent_registered) {
+	if (neard_service == NULL) {
 		dbus_message_unref(msg);
 
 		if (agent_register_postpone) {
@@ -269,7 +270,7 @@ static void bonding_complete(struct btd_adapter *adapter,
 
 	DBG("");
 
-	if (!agent_registered) {
+	if (neard_service == NULL) {
 		dbus_message_unref(msg);
 
 		if (agent_register_postpone) {
@@ -777,7 +778,9 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 {
 	DBG("");
 
-	agent_registered = FALSE;
+	g_free(neard_service);
+	neard_service = NULL;
+
 	g_dbus_unregister_interface(conn, AGENT_PATH, AGENT_INTERFACE);
 
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -824,8 +827,10 @@ static void neard_vanished(DBusConnection *conn, void *user_data)
 	DBG("");
 
 	/* neard existed without unregistering agent */
-	if (agent_registered) {
-		agent_registered = FALSE;
+	if (neard_service != NULL) {
+		g_free(neard_service);
+		neard_service = NULL;
+
 		g_dbus_unregister_interface(conn, AGENT_PATH, AGENT_INTERFACE);
 	}
 }
@@ -850,7 +855,7 @@ static void neard_exit(void)
 	g_dbus_remove_watch(btd_get_dbus_connection(), watcher_id);
 	watcher_id = 0;
 
-	if (agent_registered)
+	if (neard_service != NULL)
 		unregister_agent();
 }
 
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux