diff options
author | Alok Barsode <alok.barsode@azingo.com> | 2008-09-03 12:46:26 +0530 |
---|---|---|
committer | Alok Barsode <alok.barsode@azingo.com> | 2008-09-03 12:46:26 +0530 |
commit | 96adaa7ebd6e83db29df644f7952370dbea4ac85 (patch) | |
tree | 7a0002af9797005369596ec88ccf1d78472b8d3e | |
parent | 44bebaf5962f0b0a60b66ec8ab65f1d211b60b9d (diff) |
Moving adapter_mode_changed to adapter.c.
-rw-r--r-- | src/adapter.c | 44 | ||||
-rw-r--r-- | src/adapter.h | 1 | ||||
-rw-r--r-- | src/dbus-hci.c | 44 |
3 files changed, 45 insertions, 44 deletions
diff --git a/src/adapter.c b/src/adapter.c index bb2e131f..fe9aaef0 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2850,6 +2850,50 @@ void adapter_remove_oor_device(struct adapter *adapter, char *peer_addr) } } +void adapter_mode_changed(struct adapter *adapter, uint8_t scan_mode) +{ + const char *mode; + const gchar *path = adapter_get_path(adapter); + + adapter_set_scan_mode(adapter, scan_mode); + + switch (scan_mode) { + case SCAN_DISABLED: + mode = "off"; + adapter_set_mode(adapter, MODE_OFF); + break; + case SCAN_PAGE: + mode = "connectable"; + adapter_set_mode(adapter, MODE_CONNECTABLE); + break; + case (SCAN_PAGE | SCAN_INQUIRY): + + if (adapter->discov_timeout != 0) + adapter_set_discov_timeout(adapter, adapter->discov_timeout * 1000); + + if (adapter_get_mode(adapter) == MODE_LIMITED) { + mode = "limited"; + } else { + adapter_set_mode(adapter, MODE_DISCOVERABLE); + mode = "discoverable"; + } + break; + case SCAN_INQUIRY: + /* Address the scenario where another app changed the scan mode */ + if (adapter->discov_timeout != 0) + adapter_set_discov_timeout(adapter, adapter->discov_timeout * 1000); + + /* ignore, this event should not be sent*/ + default: + /* ignore, reserved */ + return; + } + + dbus_connection_emit_property_changed(connection, path, + ADAPTER_INTERFACE, "Mode", + DBUS_TYPE_STRING, &mode); +} + int btd_register_adapter_driver(struct btd_adapter_driver *driver) { adapter_drivers = g_slist_append(adapter_drivers, driver); diff --git a/src/adapter.h b/src/adapter.h index a5e76bc3..5c6e5558 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -173,6 +173,7 @@ int adapter_add_found_device(struct adapter *adapter, bdaddr_t *bdaddr, int adapter_remove_found_device(struct adapter *adapter, bdaddr_t *bdaddr); void adapter_update_oor_devices(struct adapter *adapter); void adapter_remove_oor_device(struct adapter *adapter, char *peer_addr); +void adapter_mode_changed(struct adapter *adapter, uint8_t scan_mode); struct btd_adapter_driver { const char *name; diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 69bafa4f..d0348522 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -172,50 +172,6 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status) } } -static void adapter_mode_changed(struct adapter *adapter, uint8_t scan_mode) -{ - const char *mode; - const gchar *path = adapter_get_path(adapter); - - adapter_set_scan_mode(adapter, scan_mode); - - switch (scan_mode) { - case SCAN_DISABLED: - mode = "off"; - adapter_set_mode(adapter, MODE_OFF); - break; - case SCAN_PAGE: - mode = "connectable"; - adapter_set_mode(adapter, MODE_CONNECTABLE); - break; - case (SCAN_PAGE | SCAN_INQUIRY): - - if (adapter->discov_timeout != 0) - adapter_set_discov_timeout(adapter, adapter->discov_timeout * 1000); - - if (adapter_get_mode(adapter) == MODE_LIMITED) { - mode = "limited"; - } else { - adapter_set_mode(adapter, MODE_DISCOVERABLE); - mode = "discoverable"; - } - break; - case SCAN_INQUIRY: - /* Address the scenario where another app changed the scan mode */ - if (adapter->discov_timeout != 0) - adapter_set_discov_timeout(adapter, adapter->discov_timeout * 1000); - - /* ignore, this event should not be sent*/ - default: - /* ignore, reserved */ - return; - } - - dbus_connection_emit_property_changed(connection, path, - ADAPTER_INTERFACE, "Mode", - DBUS_TYPE_STRING, &mode); -} - /***************************************************************** * * Section reserved to HCI commands confirmation handling and low |