aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2012-05-21 19:22:44 -0300
committerJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-06-21 18:00:18 -0300
commitfa96b43a8023c0506844d7bd2f815640942fa076 (patch)
tree9b9b8f628384a0406de07c4c3bb5d4d16810db1f
parent66c23ab8cfc5a0989416691f450d0151d0f1695c (diff)
downloadbluez-fa96b43a8023c0506844d7bd2f815640942fa076.tar.gz
bluez-fa96b43a8023c0506844d7bd2f815640942fa076.tar.xz
bluez-fa96b43a8023c0506844d7bd2f815640942fa076.zip
core: Control connections based on adapter state
This patch disable automatic ATTIO connections when the adapter is powered down and enable automatic connection when the adapter is powered on.
-rw-r--r--src/adapter.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 5c1c217f..bd7f8e28 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2131,6 +2131,14 @@ static int get_pairable_timeout(const char *src)
return main_opts.pairto;
}
+static void set_auto_connect(gpointer data, gpointer user_data)
+{
+ struct btd_device *device = data;
+ gboolean enable = GPOINTER_TO_INT(user_data);
+
+ device_set_auto_connect(device, enable);
+}
+
static void call_adapter_powered_callbacks(struct btd_adapter *adapter,
gboolean powered)
{
@@ -2140,7 +2148,10 @@ static void call_adapter_powered_callbacks(struct btd_adapter *adapter,
btd_adapter_powered_cb cb = l->data;
cb(adapter, powered);
- }
+ }
+
+ g_slist_foreach(adapter->devices, set_auto_connect,
+ GINT_TO_POINTER(powered));
}
static void emit_device_disappeared(gpointer data, gpointer user_data)
@@ -3360,15 +3371,10 @@ static gboolean disable_auto(gpointer user_data)
return FALSE;
}
-static void set_auto_connect(gpointer data, gpointer user_data)
-{
- struct btd_device *device = data;
-
- device_set_auto_connect(device, TRUE);
-}
-
void btd_adapter_enable_auto_connect(struct btd_adapter *adapter)
{
+ gboolean enable = TRUE;
+
if (!adapter->up)
return;
@@ -3377,7 +3383,8 @@ void btd_adapter_enable_auto_connect(struct btd_adapter *adapter)
if (adapter->auto_timeout_id)
return;
- g_slist_foreach(adapter->devices, set_auto_connect, NULL);
+ g_slist_foreach(adapter->devices, set_auto_connect,
+ GINT_TO_POINTER(enable));
adapter->auto_timeout_id = g_timeout_add_seconds(main_opts.autoto,
disable_auto, adapter);