OSDN Git Service

Add set auto connect in device
authorClaudio Takahasi <claudio.takahasi@openbossa.org>
Tue, 4 Oct 2011 18:30:46 +0000 (15:30 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 5 Oct 2011 15:01:18 +0000 (18:01 +0300)
Skeleton of automatic connections driven by platform/user event.
Two layers will manage connections: Profiles can request on demand
connections registering ATTIO connection callbacks(one attempt) for
a given device and platform/user action can trigger automatic
connections for devices with ATTIO callbacks registered.

src/adapter.c
src/adapter.h
src/device.c
src/device.h

index b3622cb..605a9f2 100644 (file)
@@ -3417,6 +3417,23 @@ int btd_adapter_switch_offline(struct btd_adapter *adapter)
        return 0;
 }
 
+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)
+{
+       if (!adapter->up)
+               return;
+
+       DBG("Enabling automatic connections");
+
+       g_slist_foreach(adapter->devices, set_auto_connect, NULL);
+}
+
 void btd_adapter_register_pin_cb(struct btd_adapter *adapter,
                                                        btd_adapter_pin_cb_t cb)
 {
index 7ef0af0..d30e82a 100644 (file)
@@ -163,6 +163,7 @@ gboolean adapter_powering_down(struct btd_adapter *adapter);
 int btd_adapter_restore_powered(struct btd_adapter *adapter);
 int btd_adapter_switch_online(struct btd_adapter *adapter);
 int btd_adapter_switch_offline(struct btd_adapter *adapter);
+void btd_adapter_enable_auto_connect(struct btd_adapter *adapter);
 
 typedef ssize_t (*btd_adapter_pin_cb_t) (struct btd_adapter *adapter,
                                        struct btd_device *dev, char *out);
index 393d276..5243797 100644 (file)
@@ -151,6 +151,7 @@ struct btd_device {
        gboolean        paired;
        gboolean        blocked;
        gboolean        bonded;
+       gboolean        auto_connect;
 
        gboolean        authorizing;
        gint            ref;
@@ -2005,6 +2006,20 @@ void device_set_bonded(struct btd_device *device, gboolean bonded)
        device->bonded = bonded;
 }
 
+void device_set_auto_connect(struct btd_device *device, gboolean enable)
+{
+       char addr[18];
+
+       if (!device)
+               return;
+
+       ba2str(&device->bdaddr, addr);
+
+       DBG("%s auto connect: %d", addr, enable);
+
+       device->auto_connect = enable;
+}
+
 void device_set_type(struct btd_device *device, device_type_t type)
 {
        if (!device)
index 2e17a83..1ea5ce4 100644 (file)
@@ -77,6 +77,7 @@ void device_set_paired(struct btd_device *device, gboolean paired);
 void device_set_temporary(struct btd_device *device, gboolean temporary);
 void device_set_type(struct btd_device *device, device_type_t type);
 void device_set_bonded(struct btd_device *device, gboolean bonded);
+void device_set_auto_connect(struct btd_device *device, gboolean enable);
 gboolean device_is_connected(struct btd_device *device);
 DBusMessage *device_create_bonding(struct btd_device *device,
                                DBusConnection *conn, DBusMessage *msg,