X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-service%2Fbt-service-event-receiver.c;h=87ac41ea96c6bd9ad581c573f3dbb75f2d7260cc;hb=baafd71b1294da18908043ccb450a1bfaac62c75;hp=d60b5de732de7ed3f4e53069a98266ec4af245f6;hpb=7ca0c0e08729f387d9b5d0976db8119af4c606dd;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-service/bt-service-event-receiver.c b/bt-service/bt-service-event-receiver.c index d60b5de..87ac41e 100644 --- a/bt-service/bt-service-event-receiver.c +++ b/bt-service/bt-service-event-receiver.c @@ -408,36 +408,6 @@ void __bt_update_remote_cache_devinfo(const char *address, gboolean paired_statu BT_DBG("-"); } -static void __bt_device_remote_connected_properties( - bt_remote_dev_info_t *remote_dev_info, - char *address, gboolean connected) -{ - int result = BLUETOOTH_ERROR_NONE; - int i; - GVariant *param = NULL; - BT_DBG("+"); - - if (remote_dev_info->uuid_count > 0) { - for (i = 0; i < remote_dev_info->uuid_count; i++) { - char *uuid = remote_dev_info->uuids[i]; - if (strcasecmp(uuid, HID_UUID) == 0) { - int event = BLUETOOTH_EVENT_NONE; - - event = (connected == TRUE) ? - BLUETOOTH_HID_CONNECTED : - BLUETOOTH_HID_DISCONNECTED; - param = g_variant_new("(is)", result, - address); - _bt_send_event(BT_HID_EVENT, event, - param); - break; - } - } - } - - BT_DBG("-"); -} - gboolean __bt_handle_is_flight_mode_enabled(void) { #ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED @@ -637,6 +607,9 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path) g_variant_get(val, "b", &discovering); /* Send event to application */ BT_DBG("Discovering %d", discovering); + if (_bt_adapter_get_status() != BT_ACTIVATED) + return; + if (discovering == TRUE) { _bt_set_discovery_status(TRUE); param = g_variant_new("(i)", result); @@ -669,6 +642,11 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path) gboolean le_discovering = FALSE; g_variant_get(val, "b", &le_discovering); + BT_DBG("LEDiscovering %d", le_discovering); + if (_bt_adapter_get_status() != BT_ACTIVATED || + _bt_adapter_get_le_status() != BT_LE_ACTIVATED) + return; + /* Send event to application */ if (le_discovering == TRUE) { _bt_set_le_scan_status(TRUE); @@ -922,7 +900,6 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path) char *property = NULL; char *address; GVariant *param = NULL; - bt_remote_dev_info_t *remote_dev_info; g_variant_iter_init(&value_iter, msg); #ifdef TIZEN_FEATURE_BT_DPM int desktop_state = DPM_BT_ERROR; @@ -945,15 +922,6 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path) BT_DBG("connected: %d", connected); BT_DBG("address: %s", address); - remote_dev_info = _bt_get_remote_device_info_by_object_path(path); - - if (remote_dev_info != NULL) { - __bt_device_remote_connected_properties( - remote_dev_info, address, - connected != BLUETOOTH_CONNECTED_LINK_NONE ? - TRUE : FALSE); - _bt_free_device_info(remote_dev_info); - } param = g_variant_new("(is)", result, address); /* Send event to application */ _bt_send_event(BT_DEVICE_EVENT, @@ -1273,7 +1241,6 @@ static void __bt_media_control_changed_event(GVariant *msg, const char *path) char *address; GVariant *val = NULL; GVariant *child = NULL; - bt_remote_dev_info_t *remote_dev_info; GVariant *param = NULL; g_variant_iter_init(&value_iter, msg); while ((child = g_variant_iter_next_value(&value_iter))) { @@ -1294,13 +1261,6 @@ static void __bt_media_control_changed_event(GVariant *msg, const char *path) BT_DBG("connected: %d", connected); BT_DBG("address: %s", address); - remote_dev_info = _bt_get_remote_device_info(address); - - if (remote_dev_info != NULL) { - __bt_device_remote_connected_properties( - remote_dev_info, address, connected); - _bt_free_device_info(remote_dev_info); - } param = g_variant_new("(is)", result, address); /* Send event to application */ _bt_send_event(BT_AVRCP_EVENT, @@ -1868,7 +1828,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path address = g_malloc0(BT_ADDRESS_STRING_SIZE); _bt_convert_device_path_to_address(path, address); - dev_name = _bt_get_bonded_device_name(address); + dev_name = _bt_get_device_name(address); _bt_convert_addr_string_to_secure_string(secure_address, address); BT_INFO("Address : %s Type : %d", secure_address, addr_type); @@ -1876,6 +1836,9 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path !addr_type ? dev_name : secure_address); g_free(dev_name); + if (addr_type) + _bt_add_le_connected_dev_info(address); + _bt_logging_connection(TRUE, addr_type); param = g_variant_new("(isy)", result, address, addr_type); /*Send event to application*/ @@ -1910,7 +1873,9 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path _bt_headset_set_local_connection(FALSE); _bt_logging_connection(FALSE, addr_type); - if (!addr_type) { + if (addr_type) + _bt_remove_le_connected_dev_info(address); + else { #ifdef TIZEN_BT_A2DP_SINK_AUTO_CONNECT { int bt_device_state = VCONFKEY_BT_DEVICE_NONE; @@ -2280,11 +2245,13 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path address = g_malloc0(BT_ADDRESS_STRING_SIZE); _bt_convert_device_path_to_address(path, address); - BT_DBG("Ipsp BT Interface Name: %s", ifname); - BT_DBG("address: %s", address); + BT_DBG("Ipsp BT Interface Name: %s, address: %s", ifname, address); + param = g_variant_new("(iss)", result, address, ifname); ipsp_param = g_variant_new("(ss)", ifname, address); + g_free(ifname); + /* Set Ipv6 Addr */ GDBusProxy *ipsp_proxy; if (connected) { @@ -2292,6 +2259,9 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path ipsp_proxy = _bt_get_ipsp_proxy(); if (ipsp_proxy == NULL) { BT_ERR("can not get ipsp proxy"); + g_free(address); + g_variant_unref(param); + g_variant_unref(ipsp_param); return; } @@ -2299,10 +2269,13 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path ipsp_param, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); } else { + g_variant_unref(ipsp_param); BT_DBG("IPSP disconnected"); ipsp_proxy = _bt_get_ipsp_proxy(); if (ipsp_proxy == NULL) { BT_ERR("can not get ipsp proxy"); + g_free(address); + g_variant_unref(param); return; } @@ -2312,9 +2285,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path } /* Send event to application */ - _bt_send_event(BT_DEVICE_EVENT, - event, - param); + _bt_send_event(BT_DEVICE_EVENT, event, param); g_free(address); } else if (strcasecmp(member, "AttMtuChanged") == 0) { int result = BLUETOOTH_ERROR_NONE; @@ -2351,7 +2322,7 @@ void __bt_set_audio_values(gboolean connected, char *address) /* Set the headset name */ if (connected == TRUE) - name = _bt_get_bonded_device_name(address); + name = _bt_get_device_name(address); else name = g_strdup(""); @@ -2454,7 +2425,6 @@ void _bt_handle_headset_event(GVariant *msg, const char *path) wait_list->address); _bt_audio_connect(wait_list->req_id, wait_list->type, &device_address, NULL); - _bt_rel_wait_data(); } else if (event == BLUETOOTH_EVENT_AG_CONNECTED) { /* Add data to the connected list */ _bt_add_headset_to_list(BT_AUDIO_HSP, @@ -2922,11 +2892,13 @@ static void __bt_manager_event_filter(GDBusConnection *connection, BT_INFO_C("### Bluetoothd is terminated"); if (_bt_adapter_get_status() != BT_DEACTIVATING && _bt_adapter_get_status() != BT_DEACTIVATED) { - BT_INFO_C("### Recover it"); - _bt_recover_adapter(); + BT_INFO_C("Turn Off Bluetooth"); + _bt_set_le_disabled(BLUETOOTH_ERROR_NONE); + _bt_disable_cb(); } _bt_handle_adapter_removed(); __bt_devices_list_free(); + _bt_service_adapter_le_deinit(); } _bt_obex_server_check_allocation(&value); @@ -2943,6 +2915,9 @@ static void __bt_manager_event_filter(GDBusConnection *connection, _bt_rfcomm_server_check_termination(name); } + /* Reset connection interval */ + _bt_remove_all_le_conn_param_info(name); + /* Stop advertising started by terminated process */ _bt_stop_advertising_by_terminated_process(name); /* Stop LE Scan */ @@ -3259,50 +3234,50 @@ int _bt_register_manager_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_interface_added_id = -1; - static int subs_interface_removed_id = -1; - static int subs_name_owner_id = -1; - static int subs_property_id = -1; - static int subs_adapter_id = -1; - static int subs_gatt_id = -1; + static guint subs_interface_added_id; + static guint subs_interface_removed_id; + static guint subs_name_owner_id; + static guint subs_property_id; + static guint subs_adapter_id; + static guint subs_gatt_id; if (subscribe) { - if (subs_interface_added_id == -1) { + if (subs_interface_added_id == 0) { subs_interface_added_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_ADDED, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_interface_removed_id == -1) { + if (subs_interface_removed_id == 0) { subs_interface_removed_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_REMOVED, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_name_owner_id == -1) { + if (subs_name_owner_id == 0) { subs_name_owner_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_FREEDESKTOP_INTERFACE, BT_NAME_OWNER_CHANGED, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_property_id == -1) { + if (subs_property_id == 0) { subs_property_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_PROPERTIES_INTERFACE, BT_PROPERTIES_CHANGED, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_adapter_id == -1) { + if (subs_adapter_id == 0) { subs_adapter_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_ADAPTER_INTERFACE, NULL, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_gatt_id == -1) { + if (subs_gatt_id == 0) { subs_gatt_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_GATT_CHAR_INTERFACE, NULL, NULL, NULL, 0, @@ -3310,33 +3285,33 @@ int _bt_register_manager_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_interface_added_id != -1) { + if (subs_interface_added_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_interface_added_id); - subs_interface_added_id = -1; + subs_interface_added_id = 0; } - if (subs_interface_removed_id != -1) { + if (subs_interface_removed_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_interface_removed_id); - subs_interface_removed_id = -1; + subs_interface_removed_id = 0; } - if (subs_name_owner_id != -1) { + if (subs_name_owner_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_name_owner_id); - subs_name_owner_id = -1; + subs_name_owner_id = 0; } - if (subs_property_id != -1) { + if (subs_property_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_property_id); - subs_property_id = -1; + subs_property_id = 0; } - if (subs_adapter_id != -1) { + if (subs_adapter_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_adapter_id); - subs_adapter_id = -1; + subs_adapter_id = 0; } - if (subs_gatt_id != -1) { + if (subs_gatt_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_gatt_id); - subs_gatt_id = -1; + subs_gatt_id = 0; } } return 0; @@ -3348,10 +3323,10 @@ int _bt_register_device_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_device_id = -1; + static guint subs_device_id; if (subscribe) { - if (subs_device_id == -1) { + if (subs_device_id == 0) { subs_device_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_DEVICE_INTERFACE, NULL, NULL, NULL, 0, @@ -3359,10 +3334,10 @@ int _bt_register_device_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_device_id != -1) { + if (subs_device_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_device_id); - subs_device_id = -1; + subs_device_id = 0; } } return 0; @@ -3374,10 +3349,10 @@ int _bt_register_input_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_input_id = -1; + static int subs_input_id; if (subscribe) { - if (subs_input_id == -1) { + if (subs_input_id == 0) { subs_input_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_INPUT_INTERFACE, NULL, NULL, NULL, 0, @@ -3385,10 +3360,10 @@ int _bt_register_input_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_input_id != -1) { + if (subs_input_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_input_id); - subs_input_id = -1; + subs_input_id = 0; } } return 0; @@ -3400,18 +3375,18 @@ int _bt_register_network_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_serv_id = -1; - static int subs_client_id = -1; + static guint subs_serv_id; + static guint subs_client_id; if (subscribe) { - if (subs_serv_id == -1) { + if (subs_serv_id == 0) { subs_serv_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_NETWORK_SERVER_INTERFACE, NULL, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_client_id == -1) { + if (subs_client_id == 0) { subs_client_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_NETWORK_CLIENT_INTERFACE, NULL, NULL, NULL, 0, @@ -3419,15 +3394,15 @@ int _bt_register_network_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_serv_id != -1) { + if (subs_serv_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_serv_id); - subs_serv_id = -1; + subs_serv_id = 0; } - if (subs_client_id != -1) { + if (subs_client_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_client_id); - subs_client_id = -1; + subs_client_id = 0; } } return 0; @@ -3439,18 +3414,18 @@ int _bt_register_audio_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_headset_id = -1; - static int subs_sink_id = -1; + static guint subs_headset_id; + static guint subs_sink_id; if (subscribe) { - if (subs_headset_id == -1) { + if (subs_headset_id == 0) { subs_headset_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_HEADSET_INTERFACE, NULL, NULL, NULL, 0, __bt_manager_event_filter, NULL, NULL); } - if (subs_sink_id == -1) { + if (subs_sink_id == 0) { subs_sink_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_SINK_INTERFACE, NULL, NULL, NULL, 0, @@ -3458,15 +3433,15 @@ int _bt_register_audio_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_headset_id != -1) { + if (subs_headset_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_headset_id); - subs_headset_id = -1; + subs_headset_id = 0; } - if (subs_sink_id != -1) { + if (subs_sink_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_sink_id); - subs_sink_id = -1; + subs_sink_id = 0; } } return 0; @@ -3478,27 +3453,27 @@ int _bt_register_opp_server_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_opp_server_interface_added_id = -1; - static int subs_opp_server_interface_removed_id = -1; - static int subs_opp_server_property_id = -1; + static guint subs_opp_server_interface_added_id; + static guint subs_opp_server_interface_removed_id; + static guint subs_opp_server_property_id; if (subscribe) { - if (subs_opp_server_interface_added_id == -1) { + if (subs_opp_server_interface_added_id == 0) { subs_opp_server_interface_added_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_ADDED, NULL, NULL, 0, __bt_obexd_event_filter, NULL, NULL); } - if (subs_opp_server_interface_removed_id == -1) { + if (subs_opp_server_interface_removed_id == 0) { subs_opp_server_interface_removed_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_REMOVED, NULL, NULL, 0, __bt_obexd_event_filter, NULL, NULL); } - if (subs_opp_server_property_id == -1) { + if (subs_opp_server_property_id == 0) { subs_opp_server_property_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_PROPERTIES_INTERFACE, BT_PROPERTIES_CHANGED, NULL, NULL, 0, @@ -3506,20 +3481,20 @@ int _bt_register_opp_server_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_opp_server_interface_added_id != -1) { + if (subs_opp_server_interface_added_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_server_interface_added_id); - subs_opp_server_interface_added_id = -1; + subs_opp_server_interface_added_id = 0; } - if (subs_opp_server_interface_removed_id != -1) { + if (subs_opp_server_interface_removed_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_server_interface_removed_id); - subs_opp_server_interface_removed_id = -1; + subs_opp_server_interface_removed_id = 0; } - if (subs_opp_server_property_id != -1) { + if (subs_opp_server_property_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_server_property_id); - subs_opp_server_property_id = -1; + subs_opp_server_property_id = 0; } } return 0; @@ -3531,27 +3506,27 @@ int _bt_register_opp_client_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_opp_client_interface_added_id = -1; - static int subs_opp_client_interface_removed_id = -1; - static int subs_opp_client_property_id = -1; + static guint subs_opp_client_interface_added_id; + static guint subs_opp_client_interface_removed_id; + static guint subs_opp_client_property_id; if (subscribe) { - if (subs_opp_client_interface_added_id == -1) { + if (subs_opp_client_interface_added_id == 0) { subs_opp_client_interface_added_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_ADDED, NULL, NULL, 0, __bt_opc_event_filter, NULL, NULL); } - if (subs_opp_client_interface_removed_id == -1) { + if (subs_opp_client_interface_removed_id == 0) { subs_opp_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_REMOVED, NULL, NULL, 0, __bt_opc_event_filter, NULL, NULL); } - if (subs_opp_client_property_id == -1) { + if (subs_opp_client_property_id == 0) { subs_opp_client_property_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_PROPERTIES_INTERFACE, BT_PROPERTIES_CHANGED, NULL, NULL, 0, @@ -3559,20 +3534,20 @@ int _bt_register_opp_client_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_opp_client_interface_added_id != -1) { + if (subs_opp_client_interface_added_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_client_interface_added_id); - subs_opp_client_interface_added_id = -1; + subs_opp_client_interface_added_id = 0; } - if (subs_opp_client_interface_removed_id != -1) { + if (subs_opp_client_interface_removed_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_client_interface_removed_id); - subs_opp_client_interface_removed_id = -1; + subs_opp_client_interface_removed_id = 0; } - if (subs_opp_client_property_id != -1) { + if (subs_opp_client_property_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_opp_client_property_id); - subs_opp_client_property_id = -1; + subs_opp_client_property_id = 0; } } return 0; @@ -3584,27 +3559,27 @@ int _bt_register_map_client_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_map_client_interface_added_id = -1; - static int subs_map_client_interface_removed_id = -1; - static int subs_map_client_property_id = -1; + static guint subs_map_client_interface_added_id; + static guint subs_map_client_interface_removed_id; + static guint subs_map_client_property_id; if (subscribe) { - if (subs_map_client_interface_added_id == -1) { + if (subs_map_client_interface_added_id == 0) { subs_map_client_interface_added_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_ADDED, NULL, NULL, 0, __bt_map_event_filter, NULL, NULL); } - if (subs_map_client_interface_removed_id == -1) { + if (subs_map_client_interface_removed_id == 0) { subs_map_client_interface_removed_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_MANAGER_INTERFACE, BT_INTERFACES_REMOVED, NULL, NULL, 0, __bt_map_event_filter, NULL, NULL); } - if (subs_map_client_property_id == -1) { + if (subs_map_client_property_id == 0) { subs_map_client_property_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_PROPERTIES_INTERFACE, BT_PROPERTIES_CHANGED, NULL, NULL, 0, @@ -3612,20 +3587,20 @@ int _bt_register_map_client_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_map_client_interface_added_id != -1) { + if (subs_map_client_interface_added_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_map_client_interface_added_id); - subs_map_client_interface_added_id = -1; + subs_map_client_interface_added_id = 0; } - if (subs_map_client_interface_removed_id != -1) { + if (subs_map_client_interface_removed_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_map_client_interface_removed_id); - subs_map_client_interface_removed_id = -1; + subs_map_client_interface_removed_id = 0; } - if (subs_map_client_property_id != -1) { + if (subs_map_client_property_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_map_client_property_id); - subs_map_client_property_id = -1; + subs_map_client_property_id = 0; } } return 0; @@ -3637,18 +3612,18 @@ int _bt_register_a2dp_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_a2dp_source_id = -1; - static int subs_a2dp_sink_id = -1; + static guint subs_a2dp_source_id; + static guint subs_a2dp_sink_id; if (subscribe) { - if (subs_a2dp_source_id == -1) { + if (subs_a2dp_source_id == 0) { subs_a2dp_source_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_A2DP_SOURCE_INTERFACE, NULL, NULL, NULL, 0, __bt_opc_event_filter, NULL, NULL); } - if (subs_a2dp_sink_id == -1) { + if (subs_a2dp_sink_id == 0) { subs_a2dp_sink_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_SINK_INTERFACE, NULL, NULL, NULL, 0, @@ -3656,15 +3631,15 @@ int _bt_register_a2dp_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_a2dp_source_id != -1) { + if (subs_a2dp_source_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_a2dp_source_id); - subs_a2dp_source_id = -1; + subs_a2dp_source_id = 0; } - if (subs_a2dp_sink_id != -1) { + if (subs_a2dp_sink_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_a2dp_sink_id); - subs_a2dp_sink_id = -1; + subs_a2dp_sink_id = 0; } } return 0; @@ -3675,10 +3650,10 @@ int _bt_register_tds_provider_subscribe_signal(GDBusConnection *conn, int subscr if (conn == NULL) return -1; - static int subs_custom_id = -1; + static guint subs_custom_id; if (subscribe) { - if (subs_custom_id == -1) { + if (subs_custom_id == 0) { subs_custom_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_TDS_PROVIDER_INTERFACE, NULL, NULL, NULL, 0, @@ -3686,10 +3661,10 @@ int _bt_register_tds_provider_subscribe_signal(GDBusConnection *conn, int subscr NULL, NULL); } } else { - if (subs_custom_id != -1) { + if (subs_custom_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_custom_id); - subs_custom_id = -1; + subs_custom_id = 0; } } @@ -3713,10 +3688,10 @@ int __bt_register_dump_subscribe_signal(GDBusConnection *conn, if (conn == NULL) return -1; - static int subs_source_id = -1; + static guint subs_source_id; if (subscribe) { - if (subs_source_id == -1) { + if (subs_source_id == 0) { subs_source_id = g_dbus_connection_signal_subscribe(conn, NULL, BT_DUMP_SERVICE_INTERFACE, BT_DUMP_SERVICE_SIGNAL, BT_DUMP_SERVICE_PATH, NULL, 0, @@ -3724,10 +3699,10 @@ int __bt_register_dump_subscribe_signal(GDBusConnection *conn, NULL, NULL); } } else { - if (subs_source_id != -1) { + if (subs_source_id > 0) { g_dbus_connection_signal_unsubscribe(conn, subs_source_id); - subs_source_id = -1; + subs_source_id = 0; } } return 0;