Add the exception handling logic for TC
[platform/core/connectivity/bluetooth-agent.git] / ag-agent / bluetooth-ag-agent.c
index 00cb6c2..609da2e 100644 (file)
@@ -1244,7 +1244,8 @@ gboolean _bt_hfp_agent_nrec_status(gboolean status,
        else
                hs->nrec_status = TRUE;
 
-       _bt_ag_agent_emit_signal(ag_dbus_conn, hs->path,
+       if (ag_dbus_conn)
+               _bt_ag_agent_emit_signal(ag_dbus_conn, hs->path,
                                        BT_AG_SERVICE_NAME, "NrecStatusChanged",
                                        g_variant_new("(b)", status));
        FN_END;
@@ -4041,9 +4042,7 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
        GVariant *optional_param = NULL;
 
        if (strcasecmp(signal_name, "InterfacesAdded") == 0) {
-
-               g_variant_get(parameters, "(&o@a{sa{sv}})",
-                                                       &path, &optional_param);
+               g_variant_get(parameters, "(&o@a{sa{sv}})", &path, &optional_param);
                if (!path) {
                        if (optional_param)
                                g_variant_unref(optional_param);
@@ -4053,12 +4052,12 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
 
                INFO("Adapter Path = [%s]", path);
                if (strcasecmp(path, DEFAULT_ADAPTER_OBJECT_PATH) == 0) {
-                       gchar *path = g_strdup(BT_AG_AGENT_OBJECT_PATH);
-                       __bt_ag_agent_register(path, hfp_ver,
+                       gchar *obj_path = g_strdup(BT_AG_AGENT_OBJECT_PATH);
+                       __bt_ag_agent_register(obj_path, hfp_ver,
                                 HFP_AG_UUID, "Hands-Free Audio Gateway");
 
-                       path =  g_strdup(BT_HS_AG_AGENT_OBJECT_PATH);
-                       __bt_ag_agent_register(path, hsp_ver,
+                       obj_path =  g_strdup(BT_HS_AG_AGENT_OBJECT_PATH);
+                       __bt_ag_agent_register(obj_path, hsp_ver,
                                HSP_AG_UUID, "Headset Audio Gateway");
                }
        } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
@@ -4072,11 +4071,11 @@ static void __bt_ag_agent_filter_cb(GDBusConnection *connection,
 
                INFO("Adapter Path = [%s]", path);
                if (strcasecmp(path, DEFAULT_ADAPTER_OBJECT_PATH) == 0) {
-                       gchar *path = g_strdup(BT_AG_AGENT_OBJECT_PATH);
-                       __bt_ag_agent_unregister(path);
+                       gchar *obj_path = g_strdup(BT_AG_AGENT_OBJECT_PATH);
+                       __bt_ag_agent_unregister(obj_path);
 
-                       path =  g_strdup(BT_HS_AG_AGENT_OBJECT_PATH);
-                       __bt_ag_agent_unregister(path);
+                       obj_path =  g_strdup(BT_HS_AG_AGENT_OBJECT_PATH);
+                       __bt_ag_agent_unregister(obj_path);
                }
        }