All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Claudio Takahasi <claudio.takahasi@openbossa.org>
Subject: [PATCH Bluez 06/11] Disable automatic connections after 60 seconds
Date: Tue,  4 Oct 2011 15:31:32 -0300	[thread overview]
Message-ID: <1317753092-14013-1-git-send-email-claudio.takahasi@openbossa.org> (raw)
In-Reply-To: <1317059308-20038-7-git-send-email-claudio.takahasi@openbossa.org>

---
 src/adapter.c |   24 ++++++++++++++++++++++++
 src/device.c  |    8 ++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 605a9f2..8ff4e3d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -78,6 +78,7 @@
 #define check_address(address) bachk(address)
 
 #define OFF_TIMER 3
+#define AUTO_TIMER	60
 
 static DBusConnection *connection = NULL;
 static GSList *adapter_drivers = NULL;
@@ -134,6 +135,7 @@ struct btd_adapter {
 	GSList *mode_sessions;		/* Request Mode sessions */
 	GSList *disc_sessions;		/* Discovery sessions */
 	guint scheduler_id;		/* Scheduler handle */
+	guint auto_timeout_id;		/* Automatic connections timeout */
 	sdp_list_t *services;		/* Services associated to adapter */
 
 	gboolean pairable;		/* pairable state */
@@ -3417,6 +3419,22 @@ int btd_adapter_switch_offline(struct btd_adapter *adapter)
 	return 0;
 }
 
+static gboolean disable_auto(gpointer user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	GSList *l;
+
+	for (l = adapter->devices; l; l = l->next) {
+		struct btd_device *device = l->data;
+
+		device_set_auto_connect(device, FALSE);
+	}
+
+	adapter->auto_timeout_id = 0;
+
+	return FALSE;
+}
+
 static void set_auto_connect(gpointer data, gpointer user_data)
 {
 	struct btd_device *device = data;
@@ -3431,7 +3449,13 @@ void btd_adapter_enable_auto_connect(struct btd_adapter *adapter)
 
 	DBG("Enabling automatic connections");
 
+	if (adapter->auto_timeout_id)
+		return;
+
 	g_slist_foreach(adapter->devices, set_auto_connect, NULL);
+
+	adapter->auto_timeout_id = g_timeout_add_seconds(AUTO_TIMER,
+						disable_auto, adapter);
 }
 
 void btd_adapter_register_pin_cb(struct btd_adapter *adapter,
diff --git a/src/device.c b/src/device.c
index cde2db3..4317a33 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2036,6 +2036,14 @@ void device_set_auto_connect(struct btd_device *device, gboolean enable)
 
 	device->auto_connect = enable;
 
+	/* Disabling auto connect */
+	if (enable == FALSE) {
+		if (device->auto_id)
+			g_source_remove(device->auto_id);
+		return;
+	}
+
+	/* Enabling auto connect */
 	if (device->auto_id != 0)
 		return;
 
-- 
1.7.7


  reply	other threads:[~2011-10-04 18:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26 17:48 [PATCH BlueZ 00/11] Re-connections triggered by platform event Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 01/11] Remove timer to trigger connection attempts Claudio Takahasi
2011-10-04 18:30   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 02/11] Add set auto connect in device Claudio Takahasi
2011-10-04 18:30   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 03/11] Add continuous connection attempt Claudio Takahasi
2011-10-04 18:30   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 04/11] Add checking if profiles are requesting connection Claudio Takahasi
2011-10-04 18:31   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 05/11] Fix repeated connection attempt to the same remote Claudio Takahasi
2011-10-04 18:31   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 06/11] Disable automatic connections after 60 seconds Claudio Takahasi
2011-10-04 18:31   ` Claudio Takahasi [this message]
2011-09-26 17:48 ` [PATCH BlueZ 07/11] Add display lock watcher on maemo6 plugin Claudio Takahasi
2011-10-04 18:31   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 08/11] Set auto connect from " Claudio Takahasi
2011-10-04 18:31   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 09/11] Add an interval between connection attempts Claudio Takahasi
2011-10-04 18:32   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 10/11] Enable re-connection if reason is Timeout Claudio Takahasi
2011-10-04 18:32   ` [PATCH Bluez " Claudio Takahasi
2011-09-26 17:48 ` [PATCH BlueZ 11/11] Add automatic connect timeout config option Claudio Takahasi
2011-10-04 18:32   ` [PATCH Bluez " Claudio Takahasi
2011-10-04 18:30 ` [PATCH Bluez 00/11] Re-connections triggered by platform event Claudio Takahasi
2011-10-05 15:05 ` [PATCH BlueZ " Johan Hedberg

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=1317753092-14013-1-git-send-email-claudio.takahasi@openbossa.org \
    --to=claudio.takahasi@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /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.