summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-02-01 12:39:32 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-02-01 12:39:32 +0000
commit767e85b10ab1ae294e6d9128250544b225a6e680 (patch)
treedb0f2ffa8ea9a1b4c9d0fce6e4e4a33e0aafddc7 /hcid
parent84c6dc354c09626d222c4a67a8105078a21aa5e2 (diff)
Send DefaultAdapterChanged more often
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-api.txt3
-rw-r--r--hcid/dbus-hci.c22
2 files changed, 20 insertions, 5 deletions
diff --git a/hcid/dbus-api.txt b/hcid/dbus-api.txt
index 9372ab21..fb930e72 100644
--- a/hcid/dbus-api.txt
+++ b/hcid/dbus-api.txt
@@ -224,7 +224,8 @@ Signals void AdapterAdded(string path)
void DefaultAdapterChanged(string path)
- Parameter is object path of the new default adapter.
+ Parameter is object path of the new default adapter,
+ or an empty string if there is no available adapters.
void ServiceAdded(string path)
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index e5114517..2a2286b0 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -532,7 +532,7 @@ int hcid_dbus_unregister_device(uint16_t id)
ret = unregister_adapter_path(path);
- if (ret == 0 && get_default_adapter() == id) {
+ if (ret == 0 && (get_default_adapter() == id || get_default_adapter() < 0)) {
int new_default = hci_get_route(NULL);
set_default_adapter(new_default);
if (new_default >= 0) {
@@ -543,6 +543,13 @@ int hcid_dbus_unregister_device(uint16_t id)
"DefaultAdapterChanged",
DBUS_TYPE_STRING, &pptr,
DBUS_TYPE_INVALID);
+ } else {
+ *path = '\0';
+ dbus_connection_emit_signal(connection, BASE_PATH,
+ MANAGER_INTERFACE,
+ "DefaultAdapterChanged",
+ DBUS_TYPE_STRING, &pptr,
+ DBUS_TYPE_INVALID);
}
}
@@ -551,7 +558,7 @@ int hcid_dbus_unregister_device(uint16_t id)
int hcid_dbus_start_device(uint16_t id)
{
- char path[MAX_PATH_LENGTH];
+ char path[MAX_PATH_LENGTH], *pptr;
struct hci_dev_info di;
struct adapter* adapter;
struct hci_conn_list_req *cl = NULL;
@@ -633,10 +640,17 @@ int hcid_dbus_start_device(uint16_t id)
DBUS_TYPE_STRING, &mode,
DBUS_TYPE_INVALID);
-failed:
- if (ret == 0 && get_default_adapter() < 0)
+ if (get_default_adapter() < 0) {
set_default_adapter(id);
+ pptr = path;
+ dbus_connection_emit_signal(connection, BASE_PATH,
+ MANAGER_INTERFACE,
+ "DefaultAdapterChanged",
+ DBUS_TYPE_STRING, &pptr,
+ DBUS_TYPE_INVALID);
+ }
+failed:
if (dd >= 0)
hci_close_dev(dd);