diff options
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/dbus-database.c | 10 | ||||
-rw-r--r-- | hcid/main.c | 52 | ||||
-rw-r--r-- | hcid/manager.c | 53 | ||||
-rw-r--r-- | hcid/manager.h | 2 |
4 files changed, 52 insertions, 65 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index 384df032..29e5b132 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -86,8 +86,6 @@ static void exit_callback(const char *name, void *user_data) else unregister_sdp_record(user_record->handle); - update_class_of_device(); - if (user_record->sender) g_free(user_record->sender); @@ -148,8 +146,6 @@ static DBusHandlerResult add_service_record(DBusConnection *conn, } } - update_class_of_device(); - sender = dbus_message_get_sender(msg); user_record->sender = g_strdup(sender); @@ -211,8 +207,6 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn, sdp_record_free(sdp_record); } - update_class_of_device(); - sender = dbus_message_get_sender(msg); user_record->sender = g_strdup(sender); @@ -262,8 +256,6 @@ static DBusHandlerResult update_record(DBusConnection *conn, DBusMessage *msg, } } - update_class_of_device(); - return send_message_and_unref(conn, dbus_message_new_method_return(msg)); } @@ -366,8 +358,6 @@ static DBusHandlerResult remove_service_record(DBusConnection *conn, else unregister_sdp_record(handle); - update_class_of_device(); - if (user_record->sender) g_free(user_record->sender); diff --git a/hcid/main.c b/hcid/main.c index 6539642d..90461274 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -243,6 +243,57 @@ no_address: return device_opts->discovto; } +void update_service_classes(const bdaddr_t *bdaddr, uint8_t value) +{ + struct hci_dev_list_req *dl; + struct hci_dev_req *dr; + int i, sk; + + sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + if (sk < 0) + return; + + dl = g_malloc0(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl)); + + dl->dev_num = HCI_MAX_DEV; + dr = dl->dev_req; + + if (ioctl(sk, HCIGETDEVLIST, dl) < 0) { + close(sk); + g_free(dl); + return; + } + + dr = dl->dev_req; + + for (i = 0; i < dl->dev_num; i++, dr++) { + struct hci_dev_info di; + uint8_t cls[3]; + int dd; + + if (hci_devinfo(dr->dev_id, &di) < 0) + continue; + + if (hci_test_bit(HCI_RAW, &di.flags)) + continue; + + if (get_device_class(di.dev_id, cls) < 0) + continue; + + dd = hci_open_dev(di.dev_id); + if (dd < 0) + continue; + + set_service_classes(dd, cls, value); + + hci_close_dev(dd); + } + + g_free(dl); + + close(sk); +} + /* * Device name expansion * %d - device id @@ -884,6 +935,7 @@ int main(int argc, char *argv[]) if (sdp) { set_sdp_server_enable(); start_sdp_server(mtu, hcid.deviceid, SDP_SERVER_COMPAT); + set_service_classes_callback(update_service_classes); } notify_init(); diff --git a/hcid/manager.c b/hcid/manager.c index a5588c4b..8e0652cc 100644 --- a/hcid/manager.c +++ b/hcid/manager.c @@ -329,56 +329,3 @@ void set_default_adapter(int new_default) { default_adapter_id = new_default; } - -void update_class_of_device(void) -{ - struct hci_dev_list_req *dl; - struct hci_dev_req *dr; - int i, sk; - - sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); - if (sk < 0) - return; - - dl = g_malloc0(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl)); - - dl->dev_num = HCI_MAX_DEV; - dr = dl->dev_req; - - if (ioctl(sk, HCIGETDEVLIST, dl) < 0) { - close(sk); - g_free(dl); - return; - } - - dr = dl->dev_req; - - for (i = 0; i < dl->dev_num; i++, dr++) { - struct hci_dev_info di; - uint8_t value, cls[3]; - int dd; - - if (hci_devinfo(dr->dev_id, &di) < 0) - continue; - - if (hci_test_bit(HCI_RAW, &di.flags)) - continue; - - if (get_device_class(di.dev_id, cls) < 0) - continue; - - dd = hci_open_dev(di.dev_id); - if (dd < 0) - continue; - - value = get_service_classes(&di.bdaddr); - - set_service_classes(dd, cls, value); - - hci_close_dev(dd); - } - - g_free(dl); - - close(sk); -} diff --git a/hcid/manager.h b/hcid/manager.h index 41127bab..eef0dd36 100644 --- a/hcid/manager.h +++ b/hcid/manager.h @@ -28,5 +28,3 @@ dbus_bool_t manager_init(DBusConnection *conn, const char *path); int get_default_adapter(void); void set_default_adapter(int new_default); - -void update_class_of_device(void); |