summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorVinicius Gomes <vinicius.gomes@openbossa.org>2008-04-07 22:18:30 +0000
committerVinicius Gomes <vinicius.gomes@openbossa.org>2008-04-07 22:18:30 +0000
commit38e740cddb16d29f4dae3b289dcd0830d6246988 (patch)
treee711d24fa6d548ce909add371ec622f82a00d9b9 /hcid
parent4b9108cea90e4df390092883976b4d3988f0622e (diff)
hcid: temporary devices, now devices created at incoming pairing are removed on disconnect.
Diffstat (limited to 'hcid')
-rw-r--r--hcid/adapter.c2
-rw-r--r--hcid/dbus-hci.c15
-rw-r--r--hcid/device.h2
3 files changed, 14 insertions, 5 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 71b79d83..1ffce314 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -2302,6 +2302,7 @@ struct device *adapter_get_device(DBusConnection *conn,
if (!device)
return NULL;
+ device->temporary = TRUE;
snprintf(path, MAX_PATH_LENGTH, "/hci%d", adapter->dev_id);
adapter->devices = g_slist_append(adapter->devices, device);
@@ -3746,6 +3747,7 @@ static void discover_services_cb(gpointer user_data, sdp_list_t *recs, int err)
if (!device)
goto failed;
+ device->temporary = FALSE;
/* Reply create device request */
reply = dbus_message_new_method_return(adapter->create->msg);
if (!reply)
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index 954a892b..0cc3af6a 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -638,8 +638,10 @@ static void create_stored_device_from_profiles(char *key, char *value,
struct device *device;
device = device_create(connection, adapter, key, uuids);
- if (device)
+ if (device) {
+ device->temporary = FALSE;
adapter->devices = g_slist_append(adapter->devices, device);
+ }
}
static void create_stored_device_from_linkkeys(char *key, char *value,
@@ -653,8 +655,10 @@ static void create_stored_device_from_linkkeys(char *key, char *value,
return;
device = device_create(connection, adapter, key, NULL);
- if (device)
+ if (device) {
+ device->temporary = FALSE;
adapter->devices = g_slist_append(adapter->devices, device);
+ }
}
static void register_devices(bdaddr_t *src, struct adapter *adapter)
@@ -952,14 +956,14 @@ static void passkey_cb(struct agent *agent, DBusError *err, const char *passkey,
str2ba(device->address, &dba);
if (err) {
- if (device->created)
+ if (device->temporary)
device_remove(connection, device);
hci_send_cmd(dev, OGF_LINK_CTL,
OCF_PIN_CODE_NEG_REPLY, 6, &dba);
goto done;
}
- device->created = FALSE;
+ device->temporary = FALSE;
len = strlen(passkey);
@@ -1087,6 +1091,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
device = adapter_get_device(connection, adapter, paddr);
if (device) {
+ device->temporary = FALSE;
dbus_connection_emit_property_changed(connection,
device->path, DEVICE_INTERFACE,
"Paired", DBUS_TYPE_BOOLEAN, &paired);
@@ -2037,6 +2042,8 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
device->path, DEVICE_INTERFACE,
"Connected", DBUS_TYPE_BOOLEAN,
&connected);
+ if (device->temporary)
+ device_remove(connection, device);
}
}
diff --git a/hcid/device.h b/hcid/device.h
index e276a49c..318b2470 100644
--- a/hcid/device.h
+++ b/hcid/device.h
@@ -29,7 +29,7 @@ struct device {
gchar *path;
struct adapter *adapter;
GSList *uuids;
- gboolean created;
+ gboolean temporary;
};
struct device *device_create(DBusConnection *conn, struct adapter *adapter,