Fix dlog format issues
[platform/core/connectivity/bluetooth-agent.git] / ag-agent / bluetooth-ag-manager.c
index ef81942..339bacd 100644 (file)
@@ -124,7 +124,7 @@ static const char *agent_supported_character_set[] = {
        "\"UTF-8\"", "\"IRA\""
 };
 
-#if defined(TIZEN_WEARABLE) && defined(TIZEN_BT_HFP_AG_ENABLE)
+#if defined(TIZEN_PROFILE_WEARABLE) && defined(TIZEN_FEATURE_BT_HFP_AG)
 static const char *ag_chld_str = "0,1,2";
 #else
 static const char *ag_chld_str = "0,1,2,3";
@@ -154,6 +154,7 @@ static struct {
        .charset_id = 0
 };
 
+/* LCOV_EXCL_START */
 static gboolean __bt_hfp_check_for_callpath(const char *call_path,
                                        const char *call_sender)
 {
@@ -214,6 +215,7 @@ static void __bt_hfp_free_call(struct telephony_call *t_call)
        g_free(t_call->call_sender);
        g_free(t_call);
 }
+/* LCOV_EXCL_STOP */
 
 static void __bt_hfp_reset_indicators(void)
 {
@@ -326,6 +328,7 @@ void _bt_hfp_deinitialize_telephony_manager(void)
        _bt_hfp_deinitialize();
 }
 
+/* LCOV_EXCL_START */
 bt_hfp_agent_error_t _bt_hfp_register_telephony_agent(gboolean register_flag,
                const char *path_to_register,
                const char *sender)
@@ -436,10 +439,11 @@ static struct telephony_call *__bt_hfp_create_new_call(
        }
        return t_call;
 }
+/* LCOV_EXCL_STOP */
 
 gboolean _bt_hfp_is_call_exist(void)
 {
-       DBG("_bt_hfp_is_call_exist [%x]", existing_call_list);
+       DBG("_bt_hfp_is_call_exist [%p]", existing_call_list);
        if (existing_call_list)
                return TRUE;
        else
@@ -453,26 +457,29 @@ static struct telephony_call *__bt_hfp_get_call_with_status(int call_status)
        GSList *temp_list = existing_call_list;
 
        if (existing_call_list != NULL) {
+               /* LCOV_EXCL_START */
                while (temp_list != NULL) {
                        struct telephony_call *t_call = temp_list->data;
                        if (t_call->call_status == call_status)
                                return t_call;
                        temp_list = temp_list->next;
                }
+               /* LCOV_EXCL_STOP */
        }
 
        DBG("Existing call list is NULL. So return NULL");
        return NULL;
 }
 
+/* LCOV_EXCL_START */
 static bt_hfp_agent_error_t __bt_hfp_modify_indicator(
                        const char *indicator_name,
                        int update_value)
 {
        bt_ag_indicators_t *hf_ind = NULL;
        int i;
-#ifdef TIZEN_MEDIA_ENHANCE
-       if(g_strcmp0(indicator_name,
+#ifdef TIZEN_FEATURE_BT_MEDIA_ENHANCE
+       if (g_strcmp0(indicator_name,
                HFP_AGENT_CALLSETUP_INDICATOR) == 0)
                _bt_ag_agent_check_transport_state();
 #endif
@@ -528,6 +535,11 @@ static void __bt_hfp_handle_call_conference(void)
 
                struct telephony_call *t_call = t_call_list->data;
 
+               if (t_call == NULL) {
+                       ERR("t_call is NULL");
+                       break;
+               }
+
                if (t_call->call_status == HFP_CALL_STATUS_ACTIVE) {
                        if (t_active_call == NULL)
                                t_active_call = t_call;
@@ -535,7 +547,7 @@ static void __bt_hfp_handle_call_conference(void)
                        t_active_call_count++;
 
                        if (t_active_call_count >= 2) {
-                               if (!t_active_call->call_conference)
+                               if (t_active_call->call_conference == FALSE)
                                        t_active_call->call_conference = TRUE;
                                t_call->call_conference = TRUE;
                        }
@@ -547,22 +559,18 @@ static void __bt_hfp_handle_call_conference(void)
                        t_held_call_count++;
 
                        if (t_held_call_count >= 2) {
-                               if (!t_held_call->call_conference)
+                               if (t_held_call->call_conference == FALSE)
                                        t_held_call->call_conference = TRUE;
                                t_call->call_conference = TRUE;
                        }
                }
        }
 
-       if (t_held_call_count == 1) {
-                       if (t_held_call->call_conference)
-                               t_held_call->call_conference = FALSE;
-               }
+       if (t_held_call != NULL && t_held_call_count == 1)
+               t_held_call->call_conference = FALSE;
 
-       if (t_active_call_count == 1) {
-               if (t_active_call->call_conference)
-                       t_active_call->call_conference = FALSE;
-       }
+       if (t_active_call != NULL && t_active_call_count == 1)
+               t_active_call->call_conference = FALSE;
 }
 
 static gboolean __bt_hfp_on_call_hold_timeout(gpointer t_data)
@@ -701,9 +709,8 @@ static void __bt_hfp_set_call_status(struct telephony_call *t_call,
                        __bt_hfp_modify_indicator("call",
                                        INDICATOR_EVENT_CALL_INACTIVE);
 
-               if (org_status == HFP_CALL_STATUS_HOLD) {
+               if (org_status == HFP_CALL_STATUS_HOLD)
                        __bt_hfp_modify_indicator("callheld", INDICATOR_EVENT_CALLHELD_NONE);
-               }
 
                if ((org_status == HFP_CALL_STATUS_MO_ALERTING) ||
                        (org_status == HFP_CALL_STATUS_COMING) ||
@@ -1030,6 +1037,7 @@ int _bt_hfp_set_property_value(const char *property, int value)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 int _bt_hfp_set_property_name(const char *property, const char *operator_name)
 {
@@ -1054,6 +1062,7 @@ int _bt_hfp_set_property_name(const char *property, const char *operator_name)
        return ret;
 }
 
+/* LCOV_EXCL_START */
 static int __bt_hfp_answer_call(struct telephony_call *t_call)
 {
        if (t_call->call_id != 0 && t_call->call_path != NULL &&
@@ -1065,6 +1074,7 @@ static int __bt_hfp_answer_call(struct telephony_call *t_call)
        }
        return -1;
 }
+/* LCOV_EXCL_STOP */
 
 void _bt_hfp_answer_call_request(void *t_device)
 {
@@ -1090,11 +1100,13 @@ void _bt_hfp_answer_call_request(void *t_device)
                return;
        }
 
+       /* LCOV_EXCL_START */
        if (__bt_hfp_answer_call(t_call) <  0)
                _bt_answer_call_response(t_device,
                                HFP_STATE_MNGR_ERR_AG_FAILURE);
        else
                _bt_answer_call_response(t_device, HFP_STATE_MNGR_ERR_NONE);
+       /* LCOV_EXCL_STOP */
 }
 
 
@@ -1116,7 +1128,7 @@ void _bt_hfp_dial_number_request(const char *dial_number, void *t_device)
 
                if (error_code ==  BT_HFP_AGENT_ERROR_NONE)
                        _bt_dial_number_response(t_device,
-                                       HFP_STATE_MNGR_ERR_NONE);
+                                       HFP_STATE_MNGR_ERR_NONE); /* LCOV_EXCL_LINE */
                else
                        _bt_dial_number_response(t_device,
                                HFP_STATE_MNGR_ERR_AG_FAILURE);
@@ -1130,7 +1142,7 @@ void _bt_hfp_dial_number_request(const char *dial_number, void *t_device)
                return;
        }
 
-       _bt_dial_number_response(t_device, HFP_STATE_MNGR_ERR_AG_FAILURE);
+       _bt_dial_number_response(t_device, HFP_STATE_MNGR_ERR_AG_FAILURE); /* LCOV_EXCL_LINE */
 
 }
 
@@ -1145,6 +1157,7 @@ void _bt_hfp_update_event_request(int indicator, void *t_device)
                                        HFP_STATE_MNGR_ERR_NONE);
 }
 
+/* LCOV_EXCL_START */
 static int __bt_bt_hfp_reject_call(struct telephony_call *t_call)
 {
        gboolean ret;
@@ -1190,6 +1203,7 @@ static int __bt_hfp_release_conference(void)
        }
        return 0;
 }
+/* LCOV_EXCL_STOP */
 
 void _bt_hfp_terminate_call_request(void *t_device)
 {
@@ -1203,12 +1217,14 @@ void _bt_hfp_terminate_call_request(void *t_device)
                DBG("Find non-idle call");
                GSList *temp_call_list = existing_call_list;
                while (temp_call_list != NULL) {
+                       /* LCOV_EXCL_START */
                        t_call = temp_call_list->data;
 
                        if (t_call->call_status == HFP_AGENT_CALL_IDLE)
                                temp_call_list = temp_call_list->next;
                        else
                                break;
+                       /* LCOV_EXCL_STOP */
                }
        }
 
@@ -1219,6 +1235,7 @@ void _bt_hfp_terminate_call_request(void *t_device)
                return;
        }
 
+       /* LCOV_EXCL_START */
        if (__bt_hfp_get_call_with_status(HFP_CALL_STATUS_WAITING) != NULL) {
                int value = 1;
                t_error = _bt_ag_agent_threeway_call(value, t_call->call_path,
@@ -1226,11 +1243,11 @@ void _bt_hfp_terminate_call_request(void *t_device)
        } else if ((t_alert = __bt_hfp_get_call_with_status(
                                HFP_CALL_STATUS_CREATE))
                != NULL) {
-               t_error = __bt_bt_hfp_reject_call(t_alert);
+               t_error = __bt_hfp_release_call(t_alert);
        } else if ((t_alert = __bt_hfp_get_call_with_status(
                                HFP_CALL_STATUS_MO_ALERTING))
                != NULL) {
-               t_error = __bt_bt_hfp_reject_call(t_alert);
+               t_error = __bt_hfp_release_call(t_alert);
        } else if       ((t_alert =  __bt_hfp_get_call_with_status(
                        HFP_CALL_STATUS_COMING)) != NULL) {
                t_error = __bt_bt_hfp_reject_call(t_alert);
@@ -1244,6 +1261,7 @@ void _bt_hfp_terminate_call_request(void *t_device)
                                HFP_STATE_MNGR_ERR_AG_FAILURE);
        else
                _bt_terminate_call_response(t_device, HFP_STATE_MNGR_ERR_NONE);
+       /* LCOV_EXCL_STOP */
 }
 
 void _bt_hfp_call_hold_request(const char *t_cmd, void *t_device)
@@ -1269,6 +1287,7 @@ void _bt_hfp_call_hold_request(const char *t_cmd, void *t_device)
                }
        }
 
+       /* LCOV_EXCL_START */
        while (t_sender_list != NULL) {
                sender_info = t_sender_list->data;
                if (sender_info == NULL) {
@@ -1290,9 +1309,9 @@ void _bt_hfp_call_hold_request(const char *t_cmd, void *t_device)
 
        if (ret == TRUE)
                _bt_call_hold_response(t_device, HFP_STATE_MNGR_ERR_NONE);
-       else {
+       else
                _bt_call_hold_response(t_device, HFP_STATE_MNGR_ERR_AG_FAILURE);
-       }
+       /* LCOV_EXCL_STOP */
 }
 
 void _bt_hfp_key_press_request(const char *t_key_press, void *t_device)
@@ -1370,6 +1389,7 @@ void _bt_hfp_channel_dtmf_request(char t_tone, void *t_device)
                }
        }
 
+       /* LCOV_EXCL_START */
        if (_bt_ag_agent_send_dtmf(tone_buffer, t_call->call_path,
                t_call->call_sender) != BT_HFP_AGENT_ERROR_NONE) {
                _bt_transmit_dtmf_response(t_device,
@@ -1378,6 +1398,7 @@ void _bt_hfp_channel_dtmf_request(char t_tone, void *t_device)
                }
 
        _bt_transmit_dtmf_response(t_device, HFP_STATE_MNGR_ERR_NONE);
+       /* LCOV_EXCL_STOP */
 }
 
 void _bt_hfp_vendor_cmd_request(const char *cmd,
@@ -1389,6 +1410,7 @@ void _bt_hfp_vendor_cmd_request(const char *cmd,
        bt_hfp_agent_error_t error = BT_HFP_AGENT_ERROR_NONE;
 
        if (NULL != t_sender_list) {
+               /* LCOV_EXCL_START */
                for (l = t_sender_list; l != NULL; l = l->next) {
                        sender_info = l->data;
                        error = _bt_ag_agent_vendor_cmd(cmd,
@@ -1397,6 +1419,7 @@ void _bt_hfp_vendor_cmd_request(const char *cmd,
                        if (error != BT_HFP_AGENT_ERROR_NONE)
                                break;
                }
+               /* LCOV_EXCL_STOP */
        }
 
        if (error != BT_HFP_AGENT_ERROR_NONE)
@@ -1409,7 +1432,7 @@ void _bt_hfp_vendor_cmd_request(const char *cmd,
 void _bt_hfp_subscriber_number_request(void *t_device)
 {
        if (ag_subscriber_num != NULL) {
-
+               /* LCOV_EXCL_START */
                int  t_number =  AGENT_NUMBER_TYPE_TELEPHONY;
 
                if (ag_subscriber_num[0] == '+' || strncmp(
@@ -1418,11 +1441,13 @@ void _bt_hfp_subscriber_number_request(void *t_device)
 
                _bt_subscriber_number_indicator(ag_subscriber_num,
                        t_number, AGENT_SUBSCRIBER_SERVICE_VOICE);
+               /* LCOV_EXCL_STOP */
        }
 
        _bt_subscriber_number_response(t_device, HFP_STATE_MNGR_ERR_NONE);
 }
 
+/* LCOV_EXCL_START */
 static int __bt_hfp_get_call_status(struct telephony_call *t_call)
 {
        switch (t_call->call_status) {
@@ -1473,6 +1498,7 @@ static int __bt_hfp_get_call_status(struct telephony_call *t_call)
                return -1;
        }
 }
+/* LCOV_EXCL_STOP */
 
 void _bt_list_current_calls(void *t_device)
 {
@@ -1483,6 +1509,7 @@ void _bt_list_current_calls(void *t_device)
        int index;
 
        while (t_call_list != NULL) {
+               /* LCOV_EXCL_START */
                struct telephony_call *t_call  = t_call_list->data;
                t_status = __bt_hfp_get_call_status(t_call);
                if (t_status >= 0) {
@@ -1513,6 +1540,7 @@ void _bt_list_current_calls(void *t_device)
                                        t_number);
                }
                t_call_list = t_call_list->next;
+               /* LCOV_EXCL_STOP */
        }
        _bt_list_current_calls_response(t_device, HFP_STATE_MNGR_ERR_NONE);
 }
@@ -1522,12 +1550,13 @@ void _bt_hfp_release_all_calls_by_sender(const char *sender)
        GSList *temp_list = existing_call_list;
        GSList *next_list;
 
-       if(!sender)
+       if (!sender)
                return;
 
        DBG("sender [%s]", sender);
 
        while (temp_list != NULL) {
+               /* LCOV_EXCL_START */
                struct telephony_call *t_call = temp_list->data;
 
                if (g_strcmp0(t_call->call_sender, sender) == 0) {
@@ -1537,6 +1566,7 @@ void _bt_hfp_release_all_calls_by_sender(const char *sender)
                        temp_list = next_list;
                } else
                        temp_list = temp_list->next;
+               /* LCOV_EXCL_STOP */
        }
 }
 
@@ -1583,6 +1613,7 @@ void _bt_hfp_set_indicators(const char *t_command, void *t_device)
        while (hfp_ag_ind[i].indicator_desc != NULL && str != NULL) {
                str++;
 
+               /* LCOV_EXCL_START */
                if ((g_strcmp0(hfp_ag_ind[i].indicator_desc, "call") != 0) &&
                (g_strcmp0(hfp_ag_ind[i].indicator_desc, "callheld") != 0) &&
                (g_strcmp0(hfp_ag_ind[i].indicator_desc, "callsetup") != 0)) {
@@ -1598,6 +1629,7 @@ void _bt_hfp_set_indicators(const char *t_command, void *t_device)
                }
                str = strchr(str, delims);
                i++;
+               /* LCOV_EXCL_STOP */
        }
 
        _bt_indicators_activation_response(t_device, HFP_STATE_MNGR_ERR_NONE);
@@ -1612,7 +1644,7 @@ fail:
 static int __bt_hfp_get_phonebook_count(const char *path, uint32_t *max_size,
                                uint32_t *used)
 {
-#ifndef TIZEN_WEARABLE
+#ifndef TIZEN_PROFILE_WEARABLE
        GDBusConnection *g_conn;
        GDBusProxy *g_proxy;
        GError *err = NULL;
@@ -1643,6 +1675,7 @@ static int __bt_hfp_get_phonebook_count(const char *path, uint32_t *max_size,
                return -1;
        }
 
+       /* LCOV_EXCL_START */
        ret = g_dbus_proxy_call_sync(g_proxy, "GetPhonebookSizeAt",
                        g_variant_new("(s)",
                        path),
@@ -1685,6 +1718,7 @@ static int __bt_hfp_get_phonebook_count(const char *path, uint32_t *max_size,
                g_object_unref(g_conn);
        if (g_proxy)
                g_object_unref(g_proxy);
+       /* LCOV_EXCL_STOP */
 #endif
        return 0;
 }
@@ -1791,7 +1825,7 @@ void _bt_hfp_read_phonebook_entries_list(void *t_device)
 
 static int __bt_hfp_get_phonebook_entries(int start_index, int end_index)
 {
-#ifdef TIZEN_WEARABLE
+#ifdef TIZEN_PROFILE_WEARABLE
        int count = 0;
 #else
        GDBusConnection *g_conn;
@@ -1831,6 +1865,7 @@ static int __bt_hfp_get_phonebook_entries(int start_index, int end_index)
                return -1;
        }
 
+       /* LCOV_EXCL_START */
        ret = g_dbus_proxy_call_sync(g_proxy, "GetPhonebookEntriesAt",
                        g_variant_new("(sii)",
                        agent_pb_store_list[ag_pb_info.path_id],
@@ -1869,8 +1904,8 @@ static int __bt_hfp_get_phonebook_entries(int start_index, int end_index)
                                g_variant_unref(value);
                                g_free(uni_name);
                                g_free(uni_number);
-                               g_free(name);
-                               g_free(number);
+                               g_free((gpointer)name);
+                               g_free((gpointer)number);
                        }
                        g_variant_unref(tuple);
                }
@@ -1880,6 +1915,7 @@ static int __bt_hfp_get_phonebook_entries(int start_index, int end_index)
                g_object_unref(g_conn);
        if (g_proxy)
                g_object_unref(g_proxy);
+       /* LCOV_EXCL_STOP */
 #endif
        return count;
 }
@@ -2111,7 +2147,7 @@ void _bt_hfp_get_imsi_reply(char *mcc, char *mnc, char *msin, void *t_device)
                _bt_hfp_get_imsi_rsp(t_device, mcc, mnc, msin,
                                HFP_STATE_MNGR_ERR_NONE);
        else
-               _bt_hfp_get_imsi_rsp(t_device,NULL,NULL,NULL,
+               _bt_hfp_get_imsi_rsp(t_device, NULL, NULL, NULL,
                                HFP_STATE_MNGR_ERR_NOT_ALLOWED);
 }