diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-23 17:42:09 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-09-23 17:54:01 -0700 |
commit | a8a26772d1a5ff139284ec702b269b832fa18dd7 (patch) | |
tree | 5c58d1b4dad5a73c8f954627797b5152ba56b7f3 | |
parent | 7f0d09f7816445818c3c96a54d5f7c7eee733266 (diff) |
Emit Powered and Discoverable properly when adapter comes up and down.
-rw-r--r-- | src/adapter.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/adapter.c b/src/adapter.c index 9575336f..0cb0ccbe 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2293,6 +2293,8 @@ static void adapter_up(struct btd_adapter *adapter, int dd) const char *pmode; char mode[14], srcaddr[18]; int i; + gboolean powered; + gboolean discoverable; ba2str(&adapter->bdaddr, srcaddr); @@ -2365,6 +2367,19 @@ static void adapter_up(struct btd_adapter *adapter, int dd) ADAPTER_INTERFACE, "Mode", DBUS_TYPE_STRING, &pmode); + powered = adapter->scan_mode == SCAN_DISABLED ? FALSE : TRUE; + + dbus_connection_emit_property_changed(connection, adapter->path, + ADAPTER_INTERFACE, "Powered", + DBUS_TYPE_BOOLEAN, &powered); + + discoverable = adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY) ? TRUE + : FALSE; + + dbus_connection_emit_property_changed(connection, adapter->path, + ADAPTER_INTERFACE, "Discoverable", + DBUS_TYPE_BOOLEAN, &discoverable); + load_drivers(adapter); load_devices(adapter); } @@ -2533,6 +2548,7 @@ static void unload_drivers(struct btd_adapter *adapter) int adapter_stop(struct btd_adapter *adapter) { const char *mode = "off"; + gboolean powered, discoverable; /* cancel pending timeout */ if (adapter->discov_timeout_id) { @@ -2578,6 +2594,20 @@ int adapter_stop(struct btd_adapter *adapter) ADAPTER_INTERFACE, "Mode", DBUS_TYPE_STRING, &mode); + powered = FALSE; + + dbus_connection_emit_property_changed(connection, adapter->path, + ADAPTER_INTERFACE, "Powered", + DBUS_TYPE_BOOLEAN, &powered); + + if (adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY)) { + discoverable = FALSE; + + dbus_connection_emit_property_changed(connection, adapter->path, + ADAPTER_INTERFACE, "Discoverable", + DBUS_TYPE_BOOLEAN, &discoverable); + } + adapter->up = 0; adapter->scan_mode = SCAN_DISABLED; adapter->mode = MODE_OFF; |