summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-09-25 19:47:09 -0700
committerJohan Hedberg <johan.hedberg@nokia.com>2008-09-25 19:47:09 -0700
commit013d376e47dc68ec385e9f88d6bc6c07c921ee1a (patch)
tree9323178aa89987d9a39b4a9ed50525e65838454b /src/device.c
parentfa2f213673116a81e9d6ac9740f96acd92987073 (diff)
Do service discovery also for pairings initiated from the other side
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 9b28ae41..b694d299 100644
--- a/src/device.c
+++ b/src/device.c
@@ -58,6 +58,7 @@
#define DEFAULT_XML_BUF_SIZE 1024
#define DISCONNECT_TIMER 2
+#define DISCOVERY_TIMER 2000
struct btd_driver_data {
struct btd_device_driver *driver;
@@ -76,6 +77,7 @@ struct btd_device {
int discov_active; /* Service discovery active */
char *discov_requestor; /* discovery requestor unique name */
guint discov_listener;
+ guint discov_timer;
/* For Secure Simple Pairing */
uint8_t cap;
@@ -566,6 +568,20 @@ static GDBusSignalTable device_signals[] = {
{ }
};
+void device_set_connected(DBusConnection *conn, struct btd_device *device,
+ gboolean connected)
+{
+ if (!connected && device->discov_timer) {
+ g_source_remove(device->discov_timer);
+ device->discov_timer = 0;
+ }
+
+ dbus_connection_emit_property_changed(conn, device->path,
+ DEVICE_INTERFACE,
+ "Connected", DBUS_TYPE_BOOLEAN,
+ &connected);
+}
+
struct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapter,
const gchar *address)
{
@@ -1239,6 +1255,27 @@ uint8_t device_get_auth(struct btd_device *device)
return device->auth;
}
+static gboolean start_discovery(gpointer user_data)
+{
+ struct btd_device *device = user_data;
+
+ device_browse(device, NULL, NULL, NULL);
+
+ device->discov_timer = 0;
+
+ return FALSE;
+}
+
+void device_schedule_service_discovery(struct btd_device *device)
+{
+ if (device->discov_timer)
+ return;
+
+ device->discov_timer = g_timeout_add(DISCOVERY_TIMER,
+ start_discovery,
+ device);
+}
+
int btd_register_device_driver(struct btd_device_driver *driver)
{
device_drivers = g_slist_append(device_drivers, driver);