All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>,
	Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH 09/14] neard: Use path instead of boolean to track if registered to neard
Date: Thu, 7 Feb 2013 09:13:59 +0100	[thread overview]
Message-ID: <1360224844-12280-10-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1360224844-12280-1-git-send-email-szymon.janc@tieto.com>

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

diff --git a/plugins/neard.c b/plugins/neard.c
index 0bd376b..20cfe03 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_path = 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_path = 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_path);
+	neard_path = 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_path == 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_path == 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_path);
+	neard_path = 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_path != NULL) {
+		g_free(neard_path);
+		neard_path = 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_path != NULL)
 		unregister_agent();
 }
 
-- 
1.8.1.1


  parent reply	other threads:[~2013-02-07  8:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07  8:13 [PATCH 00/14] neard plugin update Szymon Janc
2013-02-07  8:13 ` [PATCH 01/14] neard: Adjust errors to latest API changes Szymon Janc
2013-02-07  8:13 ` [PATCH 02/14] neard: Refactor message processing Szymon Janc
2013-02-07  8:13 ` [PATCH 03/14] neard: Add ability to parse 'State' field Szymon Janc
2013-02-07  8:13 ` [PATCH 04/14] neard: Move pairable check from check_adapter Szymon Janc
2013-02-07  8:13 ` [PATCH 05/14] adapter: Add btd_adapter_get_powered function Szymon Janc
2013-02-07  8:13 ` [PATCH 06/14] neard: Check if adapter is powered in PushOOB Szymon Janc
2013-02-07  8:13 ` [PATCH 07/14] adapter: Add btd_adapter_get_connectable function Szymon Janc
2013-02-07  8:13 ` [PATCH 08/14] neard: Add support for setting power state in RequestOOB reply Szymon Janc
2013-02-07  8:13 ` Szymon Janc [this message]
2013-02-15  8:46   ` [PATCH 09/14] neard: Use path instead of boolean to track if registered to neard Johan Hedberg
2013-02-07  8:14 ` [PATCH 10/14] neard: Restrict method calls only to neard process Szymon Janc
2013-02-07  8:14 ` [PATCH 11/14] neard: Use bool instead of gboolean for agent_register_postpone Szymon Janc
2013-02-07  8:14 ` [PATCH 12/14] neard: Update copyright information Szymon Janc
2013-02-07  8:14 ` [PATCH 13/14] neard: Updated neard handover registration agent api calls Szymon Janc
2013-02-07  8:14 ` [PATCH 14/14] neard: Add fallback to legacy register if register failed Szymon Janc
2013-02-11  9:52 ` [PATCH 00/14] neard plugin update Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360224844-12280-10-git-send-email-szymon.janc@tieto.com \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=ravikumar.veeramally@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.