Fixed: Coding rule issues.
[apps/native/ug-wifi-direct.git] / ug-wifidirect / src / wfd_client.c
index c073d08..4d0052b 100644 (file)
@@ -64,9 +64,8 @@ static void _wifi_state_cb(keynode_t *key, void *data)
        }
 
        res = net_deregister_client();
-       if (res != NET_ERR_NONE) {
+       if (res != NET_ERR_NONE)
                DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res);
-       }
 
        __FUNC_EXIT__;
 }
@@ -142,9 +141,8 @@ static void __enabled_cb(tethering_error_e error, tethering_type_e type, bool is
        bool is_wifi_enabled = false;
 
        if (error != TETHERING_ERROR_NONE) {
-               if (is_requested != TRUE) {
+               if (is_requested != TRUE)
                        return;
-               }
 
                DBG(LOG_ERROR, "error !!! TETHERING is not enabled.\n");
                return;
@@ -153,21 +151,18 @@ static void __enabled_cb(tethering_error_e error, tethering_type_e type, bool is
        th = ugd->hotspot_handle;
        if (th != NULL) {
                is_wifi_enabled = tethering_is_enabled(th, TETHERING_TYPE_WIFI);
-               if (is_wifi_enabled) {
+               if (is_wifi_enabled)
                        DBG(LOG_INFO, "Mobile hotspot is activated\n");
-               }
 
                /* Deregister cbs */
                ret = tethering_unset_enabled_cb(th, TETHERING_TYPE_WIFI);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_unset_enabled_cb is failed(%d)\n", ret);
-               }
 
                /* Destroy tethering handle */
                ret = tethering_destroy(th);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
-               }
 
                ugd->hotspot_handle = NULL;
        }
@@ -196,9 +191,8 @@ static void __disabled_cb(tethering_error_e error, tethering_type_e type, tether
        bool is_wifi_enabled = false;
 
        if (error != TETHERING_ERROR_NONE) {
-               if (code != TETHERING_DISABLED_BY_REQUEST) {
+               if (code != TETHERING_DISABLED_BY_REQUEST)
                        return;
-               }
 
                DBG(LOG_ERROR, "error !!! TETHERING is not disabled.\n");
                return;
@@ -216,15 +210,13 @@ static void __disabled_cb(tethering_error_e error, tethering_type_e type, tether
                wfd_client_swtch_force(ugd, TRUE);
 
                ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_WIFI);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret);
-               }
 
                /* Destroy tethering handle */
                ret = tethering_destroy(th);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
-               }
 
                ugd->hotspot_handle = NULL;
        }
@@ -345,15 +337,13 @@ static device_type_s *wfd_client_find_peer_by_mac(void *data, const char *mac_ad
 
        if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
                for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
-                       if (!strncmp(mac_addr, (const char *)ugd->raw_multi_selected_peers[i].mac_addr, MAC_LENGTH)) {
+                       if (!strncmp(mac_addr, (const char *)ugd->raw_multi_selected_peers[i].mac_addr, MAC_LENGTH))
                                return &ugd->raw_multi_selected_peers[i];
-                       }
                }
        } else {
                for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
-                       if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH)) {
+                       if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH))
                                return (device_type_s *)iterator->data;
-                       }
                }
        }
 
@@ -374,9 +364,8 @@ static device_type_s *wfd_client_find_peer_by_mac(void *data, const char *mac_ad
 
        /* Get the device from peer list */
        for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
-               if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH)) {
+               if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH))
                        return (device_type_s *)iterator->data;
-               }
        }
 
        __FUNC_EXIT__;
@@ -400,16 +389,15 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
        switch (device_state) {
        case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
                DBG(LOG_INFO, "WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
-               if(ugd->scan_toolbar == NULL) {
+               if (ugd->scan_toolbar == NULL)
                        scan_button_create(ugd);
-               }
+
                if (error_code != WIFI_DIRECT_ERROR_NONE) {
                        DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code);
-                       if (WIFI_DIRECT_ERROR_AUTH_FAILED == error_code) {
+                       if (WIFI_DIRECT_ERROR_AUTH_FAILED == error_code)
                                wfd_ug_warn_popup(ugd, D_("IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI"), POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS);
-                       } else {
+                       else
                                wfd_ug_warn_popup(ugd, D_("IDS_COM_POP_FAILED"), POPUP_TYPE_ACTIVATE_FAIL);
-                       }
 
 #ifdef WFD_ON_OFF_GENLIST
                        ugd->wfd_onoff = 0;
@@ -432,9 +420,8 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
 
 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
                res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb);
-               if (res == -1) {
+               if (res == -1)
                        DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n");
-               }
 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
 
                ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
@@ -460,9 +447,8 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
 
                WFD_IF_DEL_ITEM(ugd->multi_connect_toolbar_item);
 
-               if (ugd->ctxpopup) {
+               if (ugd->ctxpopup)
                        ctxpopup_dismissed_cb(ugd, NULL, NULL);
-               }
 
                /*
                 * When multi-connect is on ongoing and deactivte happened destroy
@@ -498,7 +484,7 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
 
                /* Delete warn popups for Airplane mode */
                if (NULL != ugd->warn_popup) {
-                       evas_object_del( ugd->warn_popup);
+                       evas_object_del(ugd->warn_popup);
                        ugd->warn_popup = NULL;
                }
 
@@ -511,9 +497,8 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
                *  discovered peers and connected peers
                */
                wfd_client_free_raw_discovered_peers(ugd);
-               if (ugd->raw_connected_peer_cnt > 0) {
+               if (ugd->raw_connected_peer_cnt > 0)
                        memset(ugd->raw_connected_peers, 0x00, ugd->raw_connected_peer_cnt*sizeof(device_type_s));
-               }
 
                ugd->raw_discovered_peer_cnt = 0;
                ugd->raw_connected_peer_cnt = 0;
@@ -521,17 +506,15 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
                wfd_free_nodivice_item(ugd);
                wfd_ug_view_init_genlist(ugd, true);
 
-               if (ugd->multi_navi_item != NULL) {
+               if (ugd->multi_navi_item != NULL)
                        elm_naviframe_item_pop(ugd->naviframe);
-               }
 
                if (TRUE == ugd->is_hotspot_off && TRUE == ugd->is_hotspot_locally_disabled) {
-                       if (0 == wfd_mobile_ap_on(ugd)) {
+                       if (0 == wfd_mobile_ap_on(ugd))
                                ugd->is_hotspot_locally_disabled = FALSE;
-                       }
                }
 
-               if(ugd->scan_toolbar) {
+               if (ugd->scan_toolbar) {
                        evas_object_del(ugd->scan_toolbar);
                        ugd->scan_toolbar = NULL;
                }
@@ -540,17 +523,15 @@ void _activation_cb(int error_code, wifi_direct_device_state_e device_state, voi
                break;
        }
 
-       /*if (ugd->scan_toolbar) {
+       /*if (ugd->scan_toolbar)
                wfd_ug_view_refresh_button(ugd->scan_toolbar, D_("IDS_WIFI_SK4_SCAN"), TRUE);
-       }*/
+       */
 
-       if (ugd->multiconn_scan_stop_btn) {
+       if (ugd->multiconn_scan_stop_btn)
                wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", TRUE);
-       }
 
-       if (ugd->back_btn) {
+       if (ugd->back_btn)
                elm_object_disabled_set(ugd->back_btn, FALSE);
-       }
 
        __FUNC_EXIT__;
        return;
@@ -589,11 +570,10 @@ bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user
                peer_tmp->is_connected = peer->is_connected;
                peer_tmp->dev_sel_state = FALSE;
 
-               if (TRUE == peer->is_connected) {
+               if (TRUE == peer->is_connected)
                        peer_tmp->conn_status = PEER_CONN_STATUS_CONNECTED;
-               } else {
+               else
                        peer_tmp->conn_status = PEER_CONN_STATUS_DISCONNECTED;
-               }
 
                ugd->raw_discovered_peer_list = g_list_append(ugd->raw_discovered_peer_list, peer_tmp);
                DBG(LOG_INFO, "\tSSID: [%s]\n", peer_tmp->ssid);
@@ -609,11 +589,10 @@ bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user
        WFD_IF_FREE_MEM(peer->mac_address);
        WFD_IF_FREE_MEM(peer->interface_address);
 
-       if (NULL != peer->service_list)
-       {
-               for (i=0; i<peer->service_count && peer->service_list[i] != NULL; i++) {
+       if (NULL != peer->service_list) {
+               for (i = 0; i < peer->service_count && peer->service_list[i] != NULL; i++)
                        free(peer->service_list[i]);
-               }
+
                WFD_IF_FREE_MEM(peer->service_list);
        }
 
@@ -648,9 +627,9 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_
 
        char services[256] = {0,};
        DBG(LOG_INFO, "\tservice_count: [%d]\n", peer->service_count);
-       if (peer->service_count>0) {
+       if (peer->service_count > 0) {
                unsigned int len = 0;
-               for (i=0; i<peer->service_count && peer->service_list != NULL; i++) {
+               for (i = 0; i < peer->service_count && peer->service_list != NULL; i++) {
                        snprintf(services + len, 256-len, "%s ", peer->service_list[i]);
                        len = len + strlen(peer->service_list[i]) + 1;
                }
@@ -688,7 +667,7 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_
                        return FALSE;
                }
 
-               if(peer->ip_address != NULL && strlen(services) != 0 ) {
+               if (peer->ip_address != NULL && strlen(services) != 0) {
                        app_control_add_extra_data(control, "ip_address", peer->ip_address);
                        app_control_add_extra_data(control, "wfds", services);
                        ug_send_result(ugd->ug, control);
@@ -700,11 +679,10 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_
        WFD_IF_FREE_MEM(peer->mac_address);
        WFD_IF_FREE_MEM(peer->interface_address);
 
-       if (NULL != peer->service_list)
-       {
-               for (i=0; i<peer->service_count && peer->service_list[i] != NULL; i++) {
+       if (NULL != peer->service_list) {
+               for (i = 0; i < peer->service_count && peer->service_list[i] != NULL; i++)
                        free(peer->service_list[i]);
-               }
+
                WFD_IF_FREE_MEM(peer->service_list);
        }
 
@@ -762,9 +740,8 @@ int wfd_ug_get_connecting_peer(struct ug_data *ugd)
        ugd->mac_addr_connecting = mac_addr;
 
        for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
-               if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH)) {
+               if (!strncmp(mac_addr, ((device_type_s *)iterator->data)->mac_addr, MAC_LENGTH))
                        ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_CONNECTING;
-               }
        }
 
 
@@ -845,9 +822,8 @@ gboolean wfd_delete_progressbar_cb(void *user_data)
        wfd_ug_view_refresh_glitem(ugd->mcview_title_item);
        wfd_ug_view_refresh_glitem(ugd->avlbl_wfd_item);
 
-       if (0 == ugd->gl_available_dev_cnt_at_multiconn_view) {
+       if (0 == ugd->gl_available_dev_cnt_at_multiconn_view)
                _create_no_device_multiconnect_genlist(ugd);
-       }
 
        wfd_refresh_wifi_direct_state(ugd);
        if (WIFI_DIRECT_STATE_CONNECTING != ugd->wfd_status &&
@@ -886,9 +862,8 @@ void discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state,
                return;
        }
 
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
+       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS)
                return;
-       }
 
        DBG(LOG_INFO, "Discovery event [%d], error_code [%d]\n", discovery_state, error_code);
 
@@ -903,9 +878,8 @@ void discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state,
                        ugd->raw_discovered_peer_cnt = 0;
                        wfd_ug_view_init_genlist(ugd, false);
 
-                       if (ugd->avlbl_wfd_item == NULL) {
+                       if (ugd->avlbl_wfd_item == NULL)
                                _create_available_dev_genlist(ugd);
-                       }
 
                        wfd_ug_view_refresh_glitem(ugd->mcview_title_item);
                        /* clear not alive peers after 5 secs */
@@ -936,13 +910,12 @@ void discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state,
        if (WIFI_DIRECT_DISCOVERY_STARTED == discovery_state &&
                ugd->wfd_discovery_status == WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START) {
                WFD_IF_DEL_ITEM(ugd->multi_connect_toolbar_item);
-               if (!ugd->conn_wfd_item) {
+               if (!ugd->conn_wfd_item)
                        elm_layout_content_set(ugd->button_layout, "button.big", ugd->scan_toolbar);
-               }
+
                wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK_STOP", TRUE);
-               if (ugd->multiconn_scan_stop_btn) {
+               if (ugd->multiconn_scan_stop_btn)
                        wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK_STOP", TRUE);
-               }
        }
 
        __FUNC_EXIT__;
@@ -996,7 +969,7 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                        } else {
                                peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
                                peer = find_peer_in_glist(ugd->gl_mul_conn_peers_start, peer->mac_addr);
-                               if ( peer != NULL) {
+                               if (peer != NULL) {
                                        peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
                                        wfd_ug_view_refresh_glitem(peer->gl_item);
                                }
@@ -1009,7 +982,7 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                        peer->conn_status = PEER_CONN_STATUS_CONNECTING;
                        peer = find_peer_in_glist(ugd->gl_mul_conn_peers_start, peer->mac_addr);
 
-                       if ( peer != NULL) {
+                       if (peer != NULL) {
                                peer->conn_status = PEER_CONN_STATUS_CONNECTING;
                                wfd_ug_view_refresh_glitem(peer->gl_item);
                        }
@@ -1045,9 +1018,8 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                                wfd_ug_get_connected_peers(ugd);
 
                                /* when auto_exit and not multi-connect*/
-                               if ((ugd->is_auto_exit)&&(ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_NONE)) {
+                               if ((ugd->is_auto_exit) && (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_NONE))
                                        _wfd_ug_auto_exit(ugd);
-                               }
 
                                wfd_ug_update_connected_peers(ugd);
                        } else {
@@ -1064,9 +1036,8 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                        wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", TRUE);
 
                        /* change the multi connection mode, it can be connected now */
-                       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
+                       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED)
                                ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE;
-                       }
 
                        /* if other peer disconnected, get connected peers and update */
                        peer->conn_status = PEER_CONN_STATUS_DISCONNECTED;
@@ -1085,9 +1056,8 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                        evas_object_hide(content);
 
                        /* when disconnection, clear all the connected peers */
-                       if (ugd->raw_connected_peer_cnt > 0) {
+                       if (ugd->raw_connected_peer_cnt > 0)
                                memset(ugd->raw_connected_peers, 0x00, ugd->raw_connected_peer_cnt*sizeof(device_type_s));
-                       }
 
                        ugd->raw_connected_peer_cnt = 0;
                        wfd_ug_view_init_genlist(ugd, true);
@@ -1114,9 +1084,8 @@ void _connection_cb(int error_code, wifi_direct_connection_state_e connection_st
                        wfd_cancel_progressbar_stop_timer(ugd);
                        wfd_delete_progressbar_cb(ugd);
 
-                       if (ugd->multi_navi_item) {
+                       if (ugd->multi_navi_item)
                                elm_naviframe_item_pop(ugd->naviframe);
-                       }
 
                        ugd->mac_addr_connecting = peer->mac_addr;
                        ugd->is_conn_incoming = FALSE;
@@ -1165,25 +1134,21 @@ refresh_button:
                res = wifi_direct_is_group_owner(&owner);
                if (res == WIFI_DIRECT_ERROR_NONE) {
                        if (!owner) {
-                               if (ugd->scan_toolbar) {
+                               if (ugd->scan_toolbar)
                                        evas_object_data_set(ugd->toolbar, "scan", "scan");
-                               }
 
-                               if (ugd->multiconn_scan_stop_btn) {
+                               if (ugd->multiconn_scan_stop_btn)
                                        wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
-                               }
                        }
                } else {
                    DBG(LOG_ERROR, "Failed to get whether client is group owner. [%d]\n", res);
                }
        } else {
-               if (ugd->scan_toolbar) {
+               if (ugd->scan_toolbar)
                        evas_object_data_set(ugd->toolbar, "scan", "scan");
-               }
 
-               if (ugd->multiconn_scan_stop_btn) {
+               if (ugd->multiconn_scan_stop_btn)
                        wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", TRUE);
-               }
        }
 
        __FUNC_EXIT__;
@@ -1210,7 +1175,7 @@ void _ip_assigned_cb(const char *mac_address, const char *ip_address, const char
        struct ug_data *ugd = (struct ug_data *)user_data;
 
        if (!ip_address || 0 == strncmp(ip_address, "0.0.0.0", 7)) {
-               DBG(LOG_ERROR,"ip address is invalid.\n");
+               DBG(LOG_ERROR, "ip address is invalid.\n");
                return;
        }
 
@@ -1231,9 +1196,8 @@ void _ip_assigned_cb(const char *mac_address, const char *ip_address, const char
        app_control_destroy(control);
 
        /* when auto_exit and not multi-connect*/
-       if ((ugd->is_auto_exit)&&(ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_NONE)) {
+       if ((ugd->is_auto_exit) && (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_NONE))
                _wfd_ug_auto_exit(ugd);
-       }
 
        __FUNC_EXIT__;
 }
@@ -1316,7 +1280,7 @@ void wfd_init_ug_by_status(void *user_data)
        struct ug_data *ugd = (struct ug_data *)user_data;
        int res = 0;
 
-       if(ugd == NULL) {
+       if (ugd == NULL) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return;
        }
@@ -1436,11 +1400,11 @@ void wfd_gdbus_callback(GObject *source_object, GAsyncResult *result, gpointer u
 
        g_object_unref(ugd->dbus_cancellable);
        ugd->dbus_cancellable = NULL;
-       ugd->conn = G_DBUS_CONNECTION (source_object);
+       ugd->conn = G_DBUS_CONNECTION(source_object);
        return_data = g_dbus_connection_call_finish(ugd->conn, result, &error);
 
        if (error != NULL) {
-               DBG(LOG_ERROR,"DBus action failed. Error Msg [%s]\n", error->message);
+               DBG(LOG_ERROR, "DBus action failed. Error Msg [%s]\n", error->message);
                g_clear_error(&error);
        } else {
                DBG(LOG_INFO, "error msg is NULL\n");
@@ -1482,14 +1446,14 @@ int launch_wifi_direct_manager(void *data)
        addr  = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
        WFD_RETV_IF(addr == NULL, -1, "Fail to get dbus addr.\n");
 
-       ugd->conn = g_dbus_connection_new_for_address_sync(addr,G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+       ugd->conn = g_dbus_connection_new_for_address_sync(addr, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
                        G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, NULL, NULL, NULL);
 
-       if(ugd->conn == NULL) {
-               DBG(LOG_ERROR,"g_dbus_conn is NULL\n");
+       if (ugd->conn == NULL) {
+               DBG(LOG_ERROR, "g_dbus_conn is NULL\n");
                return -1;
        } else {
-               g_dbus_connection_call(ugd->conn, "net.netconfig", "/net/netconfig/wifi","net.netconfig.wifi",
+               g_dbus_connection_call(ugd->conn, "net.netconfig", "/net/netconfig/wifi", "net.netconfig.wifi",
                "LaunchDirect", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, ugd->dbus_cancellable, wfd_gdbus_callback, data);
        }
 
@@ -1507,20 +1471,17 @@ void wfd_client_destroy_tethering(struct ug_data *ugd)
        if (ugd->hotspot_handle != NULL) {
                /* Deregister cbs */
                ret = tethering_unset_enabled_cb(ugd->hotspot_handle, TETHERING_TYPE_WIFI);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_unset_enabled_cb is failed(%d)\n", ret);
-               }
 
                ret = tethering_unset_disabled_cb(ugd->hotspot_handle, TETHERING_TYPE_WIFI);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret);
-               }
 
                /* Destroy tethering handle */
                ret = tethering_destroy(ugd->hotspot_handle);
-               if (ret != TETHERING_ERROR_NONE) {
+               if (ret != TETHERING_ERROR_NONE)
                        DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
-               }
 
                ugd->hotspot_handle = NULL;
        }
@@ -1549,71 +1510,63 @@ int deinit_wfd_client(void *data)
        wfd_cancel_progressbar_stop_timer(ugd);
        wfd_cancel_not_alive_delete_timer(ugd);
 
-       if(ugd->timer_multi_reset > 0) {
+       if (ugd->timer_multi_reset > 0)
                g_source_remove(ugd->timer_multi_reset);
-       }
+
        ugd->timer_multi_reset = 0;
 
-       if (ugd->g_source_multi_connect_next > 0) {
+       if (ugd->g_source_multi_connect_next > 0)
                g_source_remove(ugd->g_source_multi_connect_next);
-       }
+
        ugd->g_source_multi_connect_next = 0;
 
        res = wifi_direct_unset_discovery_state_changed_cb();
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-                       DBG(LOG_ERROR, "Failed to unset discovery state changed cb. [%d]\n", res);
-       }
+       if (res != WIFI_DIRECT_ERROR_NONE)
+               DBG(LOG_ERROR, "Failed to unset discovery state changed cb. [%d]\n", res);
 
        wifi_direct_unset_device_state_changed_cb();
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-                       DBG(LOG_ERROR, "Failed to unset device state changed cb. [%d]\n", res);
-       }
+       if (res != WIFI_DIRECT_ERROR_NONE)
+               DBG(LOG_ERROR, "Failed to unset device state changed cb. [%d]\n", res);
 
        wifi_direct_unset_connection_state_changed_cb();
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-                       DBG(LOG_ERROR, "Failed to unset connection state changed cb. [%d]\n", res);
-       }
+       if (res != WIFI_DIRECT_ERROR_NONE)
+               DBG(LOG_ERROR, "Failed to unset connection state changed cb. [%d]\n", res);
 
        wifi_direct_unset_client_ip_address_assigned_cb();
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-                       DBG(LOG_ERROR, "Failed to unset client ip address assigned cb. [%d]\n", res);
-       }
+       if (res != WIFI_DIRECT_ERROR_NONE)
+               DBG(LOG_ERROR, "Failed to unset client ip address assigned cb. [%d]\n", res);
 
        if (ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING &&
                NULL != ugd->mac_addr_connecting) {
                if (ugd->is_conn_incoming) {
                        DBG(LOG_INFO, "Reject the incoming connection before client deregister \n");
                        res = wifi_direct_reject_connection(ugd->mac_addr_connecting);
-                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                       if (res != WIFI_DIRECT_ERROR_NONE)
                                DBG(LOG_ERROR, "Failed to send reject request [%d]\n", res);
-                       }
                } else {
                        DBG(LOG_INFO, "Cancel the outgoing connection before client deregister \n");
                        res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
-                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                       if (res != WIFI_DIRECT_ERROR_NONE)
                                DBG(LOG_ERROR, "Failed to send cancel request [%d]\n", res);
-                       }
                }
                ugd->mac_addr_connecting = NULL;
        }
 
 
        res = wifi_direct_deinitialize();
-       if (res != WIFI_DIRECT_ERROR_NONE) {
+       if (res != WIFI_DIRECT_ERROR_NONE)
                DBG(LOG_ERROR, "Failed to deregister client. [%d]\n", res);
-       }
 
        /* release vconf, hotspot..  */
 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
        res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb);
-       if (res == -1) {
+       if (res == -1)
                DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n");
-       }
 
        res = net_deregister_client();
-       if (res != NET_ERR_NONE) {
+       if (res != NET_ERR_NONE)
                DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res);
-       }
+
 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
 
 
@@ -1636,7 +1589,7 @@ int wfd_client_switch_on(void *data)
 
        bool is_wifi_enabled = false;
 
-       if(!ugd->is_init_ok) {
+       if (!ugd->is_init_ok) {
                DBG(LOG_ERROR, "device is initializing, please wait\n");
                return -1;
        }
@@ -1676,9 +1629,7 @@ int wfd_client_switch_on(void *data)
                if (is_wifi_enabled) {
                        DBG(LOG_INFO, "WiFi is connected, so have to turn off WiFi");
                        wfd_ug_act_popup(ugd, D_("IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q"), POPUP_TYPE_HOTSPOT_OFF);
-               } else
-
-               {
+               } else {
                        res = wifi_direct_activate();
                        if (res != WIFI_DIRECT_ERROR_NONE) {
                                DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res);
@@ -1696,21 +1647,17 @@ int wfd_client_switch_on(void *data)
                        }
 #endif
                        /* while activating, disable the buttons */
-                       if (ugd->scan_toolbar == NULL) {
+                       if (ugd->scan_toolbar == NULL)
                                scan_button_create(ugd);
-                       }
 
-                       if (ugd->scan_toolbar) {
+                       if (ugd->scan_toolbar)
                                wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
-                       }
 
-                       if (ugd->multiconn_scan_stop_btn) {
+                       if (ugd->multiconn_scan_stop_btn)
                                wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
-                       }
 
-                       if (ugd->back_btn) {
+                       if (ugd->back_btn)
                                elm_object_disabled_set(ugd->back_btn, TRUE);
-                       }
                }
        } else {
                DBG(LOG_INFO, "Wi-Fi Direct is already activated\n");
@@ -1746,14 +1693,14 @@ int wfd_client_switch_off(void *data)
                wfd_cancel_progressbar_stop_timer(ugd);
                wfd_cancel_not_alive_delete_timer(ugd);
 
-               if(ugd->timer_multi_reset > 0) {
+               if (ugd->timer_multi_reset > 0)
                        g_source_remove(ugd->timer_multi_reset);
-               }
+
                ugd->timer_multi_reset = 0;
 
-               if (ugd->g_source_multi_connect_next > 0) {
+               if (ugd->g_source_multi_connect_next > 0)
                        g_source_remove(ugd->g_source_multi_connect_next);
-               }
+
                ugd->g_source_multi_connect_next = 0;
 
                /*if connected, disconnect all devices*/
@@ -1782,17 +1729,14 @@ int wfd_client_switch_off(void *data)
                        ugd->scan_toolbar = NULL;
                }
 
-               if (ugd->multiconn_scan_stop_btn) {
+               if (ugd->multiconn_scan_stop_btn)
                        wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
-               }
 
-               if (ugd->multi_connect_toolbar_item) {
+               if (ugd->multi_connect_toolbar_item)
                        elm_object_item_disabled_set(ugd->multi_connect_toolbar_item, TRUE);
-               }
 
-               if (ugd->back_btn) {
+               if (ugd->back_btn)
                        elm_object_disabled_set(ugd->back_btn, TRUE);
-               }
        }
 
        __FUNC_EXIT__;