Handling le connection interval
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-event-receiver.c
index 53af13b..d3a550e 100644 (file)
@@ -1618,17 +1618,14 @@ void __bt_gatt_char_property_changed_event(GVariant *msg,
        g_variant_iter_init(&value_iter, msg);
        char_handle = g_strdup(path);
        while ((g_variant_iter_loop(&value_iter, "{sv}", &property, &val))) {
-               BT_INFO("Property %s", property);
+               BT_DBG("Property %s", property);
 
                ret_if(property == NULL);
 
                if (strcasecmp(property, "Notifying") == 0) {
                        gboolean property_flag = FALSE;
                        g_variant_get(val, "b", &property_flag);
-                       if (property_flag == TRUE)
-                               BT_DBG("notifying is enabled");
-                       else
-                               BT_DBG("notifying is disabled");
+                       BT_INFO("Notifying is %s", property_flag ? "enabled" : "disabled");
                } else if (strcasecmp(property, "ChangedValue") == 0) {
                        int len = 0;
                        GByteArray *gp_byte_array = NULL;
@@ -1717,7 +1714,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        gboolean connected = FALSE;
                        char *address;
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
                        g_variant_get(msg, "(b)", &connected);
@@ -1750,7 +1746,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        }
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
 
@@ -1801,7 +1796,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        ret_if(_bt_is_device_creating() == TRUE);
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       ret_if(address == NULL);
 
                        _bt_convert_device_path_to_address(path, address);
 
@@ -1851,7 +1845,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                g_variant_get(msg, "(y)", &addr_type);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
                dev_name = _bt_get_bonded_device_name(address);
@@ -1862,6 +1855,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*/
@@ -1880,7 +1876,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                result = disc_reason;
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
 
@@ -1897,7 +1892,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;
@@ -1946,7 +1943,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                g_variant_get(msg, "(si)", &profile_uuid, &state);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               ret_if(address == NULL);
 
                _bt_convert_device_path_to_address(path, address);
                _bt_convert_addr_string_to_type(bd_addr.addr, address);
@@ -2162,7 +2158,7 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
 
                le_dev_info = g_malloc0(sizeof(bt_remote_le_dev_info_t));
 
-               g_variant_get(msg, "(syyii@ay)", &le_dev_info->address,
+               g_variant_get(msg, "(&syyii@ay)", &le_dev_info->address,
                                                &le_dev_info->addr_type,
                                                &le_dev_info->adv_type,
                                                &le_dev_info->rssi,
@@ -2262,8 +2258,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                ret_if(_bt_is_le_scanning() == FALSE);
 
                ibeacon_dev_info = g_malloc0(sizeof(bt_remote_ibeacon_dev_info_t));
-               if (ibeacon_dev_info == NULL)
-                       return;
 
                g_variant_get(msg, "(syuusuuy)", &ibeacon_dev_info->address,
                                                &ibeacon_dev_info->addr_type,
@@ -2341,8 +2335,6 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
                g_variant_get(value, "b", &property_flag);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-               if (address == NULL)
-                       return;
 
                _bt_convert_device_path_to_address(path, address);
                _bt_convert_addr_string_to_type(bd_addr.addr, address);
@@ -2700,17 +2692,15 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                                bt_cache_info_t *cache_info;
                                bt_remote_dev_info_t *dev_info;
 
-                               ret_if(_bt_is_discovering() == FALSE &&
-                                               _bt_is_le_scanning() == FALSE);
+                               if (_bt_is_discovering() == FALSE &&
+                                   _bt_is_le_scanning() == FALSE) {
+                                       g_variant_unref(value);
+                                       return;
+                               }
 
                                cache_info = g_malloc0(sizeof(bt_cache_info_t));
-                               ret_if(cache_info == NULL);
 
                                dev_info = g_malloc0(sizeof(bt_remote_dev_info_t));
-                               if (dev_info == NULL) {
-                                       __bt_free_cache_info(cache_info);
-                                       return;
-                               }
 
                                cache_info->dev_info = dev_info;
 
@@ -2851,10 +2841,15 @@ 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 */
                _bt_stop_le_scan(name);
+
                g_free(name);
                g_free(previous);
                g_free(current);