Fix dlog format error
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-hdp-dbus-handler.c
index 143e36f..9bf3321 100644 (file)
@@ -47,14 +47,14 @@ typedef struct {
        int channel_id;
        char *obj_path;
        int fd;
-}hdp_conn_info_t;
+} hdp_conn_info_t;
 
 typedef struct {
        int id;
        char *path;
        int channel_type;
        GSList *conn_list;
-}hdp_app_data_t;
+} hdp_app_data_t;
 
 static handle_stack_msg event_cb = NULL;
 static int latest_id = -1;
@@ -76,9 +76,7 @@ static void __hdp_send_conn_event(hdp_conn_info_t *conn_info, int state)
        ev.channel_state = state;
        if (!event_cb) {
                ERR("HDP dbus handler callback not registered");
-               g_free(conn_info);
-       }
-       else
+       } else
                event_cb(HAL_EV_HDP_CONN_STATE, (void *)&ev, sizeof(ev));
 
        DBG("-");
@@ -219,7 +217,7 @@ static hdp_conn_info_t *__hdp_app_create_incomming_conn_info(const char *path)
        DBG("+");
 
        conn = _bt_hal_get_system_gconn();
-       if(!conn) {
+       if (!conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return NULL;
        }
@@ -340,7 +338,7 @@ static int __hdp_acquire_fd(const char *path)
        DBG("+");
 
        conn = _bt_hal_get_system_gconn();
-       if(!conn) {
+       if (!conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return  -1;
        }
@@ -427,7 +425,9 @@ err:
 
                ERR("Outgoing connection failed for app_id:%d, send event", conn_info->app_id);
                /* Send channel_connect callback with status: disconnected and fd = -1 */
-               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+               if (event_cb)
+                       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+
                app->conn_list = g_slist_remove(app->conn_list, conn_info);
                __hdp_free_conn_info(conn_info);
        }
@@ -453,7 +453,8 @@ static void __hdp_handle_disconnect(GVariant *parameters,
        }
 
        /* Send channel_connect callback with status: success */
-       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DESTROYED);
+       if (event_cb)
+               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DESTROYED);
 
        app = __get_hdp_app_by_id(conn_info->app_id);
        app->conn_list = g_slist_remove(app->conn_list, conn_info);
@@ -517,16 +518,13 @@ static void __hdp_event_filter(GDBusConnection *connection,
 }
 
 static int __hdp_filter_subscribe_signal(GDBusConnection *conn,
-                               gboolean subscribe)
+               gboolean subscribe)
 {
        static guint subs_add_filter_id = 0;
 
        if (conn == NULL)
                return BT_HAL_ERROR_INVALID_PARAM;
 
-       if (subscribe && subs_add_filter_id) {
-       }
-
        if (subscribe) {
                if (subs_add_filter_id == 0) {
                        subs_add_filter_id = g_dbus_connection_signal_subscribe(
@@ -554,7 +552,7 @@ static int __hdp_add_filter(void)
        DBG("+");
 
        hdp_conn = _bt_hal_get_system_gconn();
-       if(!hdp_conn) {
+       if (!hdp_conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return BT_HAL_ERROR_INTERNAL;
        }
@@ -571,7 +569,7 @@ static int __hdp_remove_filter(void)
        DBG("+");
 
        hdp_conn = _bt_hal_get_system_gconn();
-       if(!hdp_conn) {
+       if (!hdp_conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return BT_HAL_ERROR_INTERNAL;
        }
@@ -674,7 +672,7 @@ static GDBusProxy *__get_health_device_proxy(char *address)
        DBG("dev_path: %s", dev_path);
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-       if(!conn) {
+       if (!conn) {
                ERR("ERROR: Can't get on system bus [%s]", err->message);
                g_clear_error(&err);
                g_free(dev_path);
@@ -713,7 +711,8 @@ static void __hdp_connect_request_cb(GDBusProxy *hdp_proxy,
                        g_clear_error(&err);
                }
                /* Send channel_connect callback with status: disconnected and fd = -1 */
-               __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
+               if (event_cb)
+                       __hdp_send_conn_event(conn_info, BTHL_CONN_STATE_DISCONNECTED);
                __hdp_free_conn_info(conn_info);
                return;
        }
@@ -724,7 +723,7 @@ static void __hdp_connect_request_cb(GDBusProxy *hdp_proxy,
 
        app = __get_hdp_app_by_id(conn_info->app_id);
        if (!app) {
-               ERR("No app with app_id: %d exists");
+               ERR("No app with app_id: %d exists", conn_info->app_id);
                __hdp_free_conn_info(conn_info);
                return;
        }
@@ -775,7 +774,7 @@ bt_status_t _bt_hal_dbus_handler_hdp_register_application(int role,
        DBG("+");
 
        conn = _bt_hal_get_system_gconn();
-       if(!conn) {
+       if (!conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return BT_STATUS_FAIL;
        }
@@ -868,12 +867,12 @@ bt_status_t _bt_hal_dbus_handler_hdp_unregister_application(int app_id)
        DBG("app_id: %d", app_id);
        app = __get_hdp_app_by_id(app_id);
        if (!app) {
-               ERR("No app with app_id: %d exists");
+               ERR("No app with app_id: %d exists", app_id);
                return BT_STATUS_PARM_INVALID;
        }
 
        conn = _bt_hal_get_system_gconn();
-       if(!conn) {
+       if (!conn) {
                ERR("_bt_hal_get_system_gconn returned NULL, return");
                return BT_STATUS_FAIL;
        }