Upgrading signal subscription logic.
[platform/core/api/wifi-direct.git] / src / wifi-direct-client-proxy.c
old mode 100755 (executable)
new mode 100644 (file)
index 026ecc4..5cefcec
 /*****************************************************************************
  *  Global Variables
  *****************************************************************************/
-wifi_direct_client_info_s g_client_info = {
-       .is_registered = FALSE,
-       .client_id = -1,
-       .sync_sockfd = -1,
-       .async_sockfd = -1,
-       .activation_cb = NULL,
-       .discover_cb = NULL,
-       .connection_cb = NULL,
-       .ip_assigned_cb = NULL,
-       .peer_found_cb = NULL,
-       .user_data_for_cb_activation = NULL,
-       .user_data_for_cb_discover = NULL,
-       .user_data_for_cb_connection = NULL,
-       .user_data_for_cb_ip_assigned = NULL,
-       .user_data_for_cb_peer_found = NULL,
-       .user_data_for_cb_device_name = NULL,
-#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
-       .service_cb = NULL,
-       .user_data_for_cb_service = NULL,
-#endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
-       .mutex = PTHREAD_MUTEX_INITIALIZER
-};
+static __thread wifi_direct_client_info_s g_client_info = {0, };
 
 /*****************************************************************************
  *  Local Functions Definition
@@ -100,9 +79,97 @@ static wifi_direct_client_info_s *__wfd_get_control()
        return &g_client_info;
 }
 
+static int __net_wifidirect_gerror_to_enum(GError* error)
+{
+       int ret = WIFI_DIRECT_ERROR_NONE;
+       if (error == NULL) {
+               WDC_LOGI("GError is NULL!!");
+               return ret;
+       }
+
+       WDC_LOGE("wifi_direct_dbus_method_call_sync() failed. error [%d: %s]",
+                       error->code, error->message);
+
+       if (NULL == strstr(error->message, "net.wifidirect.Error")) {
+//LCOV_EXCL_START
+               if (NULL != strstr(error->message, ".AccessDenied")) {
+                       WDC_LOGE("Client doesn't have wifidirect privilege");
+                       ret = WIFI_DIRECT_ERROR_PERMISSION_DENIED;
+               } else {
+                       WDC_LOGE("DBus failure");
+                       ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               }
+//LCOV_EXCL_STOP
+       } else {
+               if (NULL != strstr(error->message, "InvalidParameter"))
+                       ret = WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+               else if (NULL != strstr(error->message, "NotPermitted"))
+                       ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+               else if (NULL != strstr(error->message, "OperationFailed"))
+                       ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_START
+               else if (NULL != strstr(error->message, "TooManyClient"))
+                       ret = WIFI_DIRECT_ERROR_TOO_MANY_CLIENT;
+               else
+                       ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+//LCOV_EXCL_STOP
+       }
+       g_error_free(error);
+       return ret;
+}
+
+//LCOV_EXCL_START
+void __wfd_vconf_state_changed_cb(keynode_t *key, void *data)
+{
+       __WDC_LOG_FUNC_START__;
+       int state = 0;
+       int res = 0;
+
+       if (!g_client_info.state_cb) {
+               WDC_LOGI("g_state_cb is NULL!!");
+               __WDC_LOG_FUNC_END__;
+               return; //LCOV_EXCL_LINE
+       }
+
+       res = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &state);
+       if (res < 0) {
+               WDC_LOGE("Failed to get vconf value [%s]\n",
+                        VCONFKEY_WIFI_DIRECT_STATE);
+               __WDC_LOG_FUNC_END__;
+               return;
+       }
+
+       if (state == VCONFKEY_WIFI_DIRECT_ACTIVATED) {
+               state = WIFI_DIRECT_STATE_ACTIVATED;
+       } else if (state == VCONFKEY_WIFI_DIRECT_DEACTIVATED) {
+               state = WIFI_DIRECT_STATE_DEACTIVATED;
+       } else if (state == VCONFKEY_WIFI_DIRECT_CONNECTED) {
+               state = WIFI_DIRECT_STATE_CONNECTED;
+       } else if (state == VCONFKEY_WIFI_DIRECT_GROUP_OWNER) {
+               state = WIFI_DIRECT_STATE_CONNECTED;
+       } else if (state == VCONFKEY_WIFI_DIRECT_DISCOVERING) {
+               state = WIFI_DIRECT_STATE_DISCOVERING;
+       } else {
+               WDC_LOGE("This state cannot be set as wifi_direct vconf state[%d]", state);
+               __WDC_LOG_FUNC_END__;
+               return;
+       }
+
+       g_client_info.state_cb(state, g_client_info.user_data_for_cb_state);
+
+       __WDC_LOG_FUNC_END__;
+       return;
+}
+//LCOV_EXCL_STOP
+
 /* Manage */
 void wifi_direct_process_manage_activation(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                          const gchar *sender,
+                                          const gchar *object_path,
+                                          const gchar *interface,
+                                          const gchar *signal,
+                                          GVariant *parameters,
+                                          gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        int error_code;
@@ -110,7 +177,7 @@ void wifi_direct_process_manage_activation(GDBusConnection *connection,
 
        if (!client->activation_cb) {
                WDC_LOGI("activation_cb is NULL!!");
-               return;
+               return; //LCOV_EXCL_LINE
        }
 
        if (!parameters) {
@@ -128,7 +195,12 @@ void wifi_direct_process_manage_activation(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                            const gchar *sender,
+                                            const gchar *object_path,
+                                            const gchar *interface,
+                                            const gchar *signal,
+                                            GVariant *parameters,
+                                            gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        int error_code;
@@ -136,7 +208,7 @@ void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
 
        if (!parameters) {
                __WDC_LOG_FUNC_END__;
-               return;
+               return; //LCOV_EXCL_LINE
        }
 
        if (!client->activation_cb) {
@@ -154,8 +226,14 @@ void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
        __WDC_LOG_FUNC_END__;
 }
 
+//LCOV_EXCL_START
 void wifi_direct_process_manage_connection(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                          const gchar *sender,
+                                          const gchar *object_path,
+                                          const gchar *interface,
+                                          const gchar *signal,
+                                          GVariant *parameters,
+                                          gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        int error_code;
@@ -186,7 +264,12 @@ void wifi_direct_process_manage_connection(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_disconnection(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                             const gchar *sender,
+                                             const gchar *object_path,
+                                             const gchar *interface,
+                                             const gchar *signal,
+                                             GVariant *parameters,
+                                             gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        int error_code;
@@ -217,7 +300,12 @@ void wifi_direct_process_manage_disconnection(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_peer_ip_assigned(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                const gchar *sender,
+                                                const gchar *object_path,
+                                                const gchar *interface,
+                                                const gchar *signal,
+                                                GVariant *parameters,
+                                                gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        char *get_str = NULL;
@@ -254,7 +342,7 @@ void wifi_direct_process_manage_peer_ip_assigned(GDBusConnection *connection,
                return;
        }
 
-       g_variant_get(reply, "(i&s)", ret ,&get_str);
+       g_variant_get(reply, "(i&s)", ret&get_str);
        g_variant_unref(reply);
 
        WDC_LOGD("Interface Name = [%s]", get_str);
@@ -267,7 +355,12 @@ void wifi_direct_process_manage_peer_ip_assigned(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_listen_started(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                              const gchar *sender,
+                                              const gchar *object_path,
+                                              const gchar *interface,
+                                              const gchar *signal,
+                                              GVariant *parameters,
+                                              gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -286,7 +379,12 @@ void wifi_direct_process_manage_listen_started(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_discovery_started(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                 const gchar *sender,
+                                                 const gchar *object_path,
+                                                 const gchar *interface,
+                                                 const gchar *signal,
+                                                 GVariant *parameters,
+                                                 gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -305,7 +403,12 @@ void wifi_direct_process_manage_discovery_started(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_discovery_finished(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                  const gchar *sender,
+                                                  const gchar *object_path,
+                                                  const gchar *interface,
+                                                  const gchar *signal,
+                                                  GVariant *parameters,
+                                                  gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -324,7 +427,12 @@ void wifi_direct_process_manage_discovery_finished(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_peer_found(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                          const gchar *sender,
+                                          const gchar *object_path,
+                                          const gchar *interface,
+                                          const gchar *signal,
+                                          GVariant *parameters,
+                                          gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        const gchar *peer_mac_address = NULL;
@@ -360,7 +468,12 @@ void wifi_direct_process_manage_peer_found(GDBusConnection *connection,
 }
 
 void wifi_direct_process_manage_peer_lost(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                         const gchar *sender,
+                                         const gchar *object_path,
+                                         const gchar *interface,
+                                         const gchar *signal,
+                                         GVariant *parameters,
+                                         gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        const gchar *peer_mac_address = NULL;
@@ -397,7 +510,12 @@ void wifi_direct_process_manage_peer_lost(GDBusConnection *connection,
 
 /* Group */
 void wifi_direct_process_group_created(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                      const gchar *sender,
+                                      const gchar *object_path,
+                                      const gchar *interface,
+                                      const gchar *signal,
+                                      GVariant *parameters,
+                                      gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -417,7 +535,12 @@ void wifi_direct_process_group_created(GDBusConnection *connection,
 }
 
 void wifi_direct_process_group_destroyed(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                        const gchar *sender,
+                                        const gchar *object_path,
+                                        const gchar *interface,
+                                        const gchar *signal,
+                                        GVariant *parameters,
+                                        gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -439,7 +562,12 @@ void wifi_direct_process_group_destroyed(GDBusConnection *connection,
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
 /* Service */
 void wifi_direct_process_service_discovery_started(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                  const gchar *sender,
+                                                  const gchar *object_path,
+                                                  const gchar *interface,
+                                                  const gchar *signal,
+                                                  GVariant *parameters,
+                                                  gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -461,7 +589,12 @@ void wifi_direct_process_service_discovery_started(GDBusConnection *connection,
 }
 
 void wifi_direct_process_service_discovery_found(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                const gchar *sender,
+                                                const gchar *object_path,
+                                                const gchar *interface,
+                                                const gchar *signal,
+                                                GVariant *parameters,
+                                                gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_service_type_e service_type;
@@ -494,7 +627,12 @@ void wifi_direct_process_service_discovery_found(GDBusConnection *connection,
 }
 
 void wifi_direct_process_service_discovery_finished(GDBusConnection *connection,
-               const gchar *object_path, GVariant *parameters)
+                                                   const gchar *sender,
+                                                   const gchar *object_path,
+                                                   const gchar *interface,
+                                                   const gchar *signal,
+                                                   GVariant *parameters,
+                                                   gpointer user_data)
 {
        __WDC_LOG_FUNC_START__;
        wifi_direct_client_info_s *client = __wfd_get_control();
@@ -521,8 +659,7 @@ void __wfd_client_print_entry_list(wfd_discovery_entry_s *list, int num)
        int i = 0;
 
        WDC_LOGD("------------------------------------------");
-       for (i = 0; i < num; i++)
-       {
+       for (i = 0; i < num; i++)       {
                WDC_LOGD("== Peer index : %d ==", i);
                WDC_LOGD("is Group Owner ? %s", list[i].is_group_owner ? "YES" : "NO");
                WDC_LOGD("device_name : %s", list[i].device_name);
@@ -562,6 +699,7 @@ void __wfd_client_print_persistent_group_info(wfd_persistent_group_info_s *list,
        }
        WDC_LOGD("------------------------------------------\n");
 }
+//LCOV_EXCL_STOP
 
 int wifi_direct_initialize(void)
 {
@@ -569,7 +707,10 @@ int wifi_direct_initialize(void)
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
 
+       GError* error = NULL;
+       GVariant *reply = NULL;
        bool wifi_direct_enable;
+       bool val;
        int res = 0;
 
        if (g_client_info.is_registered == TRUE) {
@@ -582,39 +723,51 @@ int wifi_direct_initialize(void)
        if (res < 0) {
                WDC_LOGE("Failed to get sys info");
                __WDC_LOG_FUNC_END__;
-               return res;
+               return res; //LCOV_EXCL_LINE
        }
 
        if (!wifi_direct_enable) {
                WDC_LOGE("Wi-Fi Direct not supported");
-               return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
+               return WIFI_DIRECT_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
        }
 
        if (wifi_direct_dbus_init() == FALSE) {
                WDC_LOGW("Failed to initialize dbus");
                __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
+                                                 "IsGroupOwner", NULL, &error);
+
+       res = __net_wifidirect_gerror_to_enum(error);
+       if (res != WIFI_DIRECT_ERROR_NONE)
+               return res;
+
+       g_variant_get(reply, "(b)", &val);
+       WDC_LOGD("is group owner [%s]", val ? "YES" : "NO");
+
        g_client_info.is_registered = TRUE;
 
        /* Initialize callbacks */
        g_client_info.activation_cb = NULL;
+       g_client_info.user_data_for_cb_activation = NULL;
+
        g_client_info.discover_cb = NULL;
+       g_client_info.user_data_for_cb_discover = NULL;
+
        g_client_info.connection_cb = NULL;
+       g_client_info.user_data_for_cb_connection = NULL;
+
        g_client_info.ip_assigned_cb = NULL;
+       g_client_info.user_data_for_cb_ip_assigned = NULL;
 
        g_client_info.peer_found_cb = NULL;
-       g_client_info.user_data_for_cb_activation = NULL;
-       g_client_info.user_data_for_cb_discover = NULL;
-       g_client_info.user_data_for_cb_connection = NULL;
-       g_client_info.user_data_for_cb_ip_assigned = NULL;
        g_client_info.user_data_for_cb_peer_found = NULL;
-       g_client_info.user_data_for_cb_device_name = NULL;
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
        g_client_info.service_cb = NULL;
-       g_client_info.user_data_for_cb_service= NULL;
+       g_client_info.user_data_for_cb_service = NULL;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
 
        __WDC_LOG_FUNC_END__;
@@ -636,14 +789,18 @@ int wifi_direct_deinitialize(void)
        wifi_direct_dbus_deinit();
 
        g_client_info.activation_cb = NULL;
-       g_client_info.discover_cb = NULL;
-       g_client_info.connection_cb = NULL;
-       g_client_info.ip_assigned_cb = NULL;
-       g_client_info.peer_found_cb = NULL;
        g_client_info.user_data_for_cb_activation = NULL;
+
+       g_client_info.discover_cb = NULL;
        g_client_info.user_data_for_cb_discover = NULL;
+
+       g_client_info.connection_cb = NULL;
        g_client_info.user_data_for_cb_connection = NULL;
+
+       g_client_info.ip_assigned_cb = NULL;
        g_client_info.user_data_for_cb_ip_assigned = NULL;
+
+       g_client_info.peer_found_cb = NULL;
        g_client_info.user_data_for_cb_peer_found = NULL;
 
 #ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
@@ -806,6 +963,7 @@ int wifi_direct_set_service_state_changed_cb(wifi_direct_service_state_changed_c
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
 
+//LCOV_EXCL_START
        if (!cb) {
                WDC_LOGE("Callback is NULL.");
                __WDC_LOG_FUNC_END__;
@@ -823,6 +981,7 @@ int wifi_direct_set_service_state_changed_cb(wifi_direct_service_state_changed_c
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -836,6 +995,7 @@ int wifi_direct_unset_service_state_changed_cb(void)
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
 
+//LCOV_EXCL_START
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is not initialized.");
                __WDC_LOG_FUNC_END__;
@@ -847,6 +1007,7 @@ int wifi_direct_unset_service_state_changed_cb(void)
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -944,6 +1105,56 @@ int wifi_direct_unset_client_ip_address_assigned_cb(void)
        return WIFI_DIRECT_ERROR_NONE;
 }
 
+int wifi_direct_set_state_changed_cb(wifi_direct_state_changed_cb cb, void *user_data)
+{
+       __WDC_LOG_FUNC_START__;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       if (!cb) {
+               WDC_LOGE("Callback is NULL");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = vconf_notify_key_changed(VCONFKEY_WIFI_DIRECT_STATE,
+                       __wfd_vconf_state_changed_cb, NULL);
+       if (ret) {
+               WDC_LOGE("Failed to set vconf notification callback");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       }
+
+       g_client_info.state_cb = cb;
+       g_client_info.user_data_for_cb_state = user_data;
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_unset_state_changed_cb(void)
+{
+       __WDC_LOG_FUNC_START__;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       ret = vconf_ignore_key_changed(VCONFKEY_WIFI_DIRECT_STATE,
+                       __wfd_vconf_state_changed_cb);
+       if (ret) {
+               WDC_LOGE("Failed to ignore vconf notification callback");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       }
+
+       g_client_info.state_cb = NULL;
+       g_client_info.user_data_for_cb_state = NULL;
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+}
+
 int wifi_direct_activate(void)
 {
        __WDC_LOG_FUNC_START__;
@@ -961,16 +1172,12 @@ int wifi_direct_activate(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                    "Activate", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -994,16 +1201,12 @@ int wifi_direct_deactivate(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "Deactivate", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1033,7 +1236,7 @@ int wifi_direct_start_discovery(bool listen_only, int timeout)
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
        g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
        g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
        params = g_variant_new("(a{sv})", builder);
@@ -1042,16 +1245,12 @@ int wifi_direct_start_discovery(bool listen_only, int timeout)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "StartDiscovery", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1083,7 +1282,7 @@ int wifi_direct_start_discovery_specific_channel(bool listen_only,
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       builder = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
        g_variant_builder_add(builder, "{sv}", "Mode", g_variant_new("b", listen_only));
        g_variant_builder_add(builder, "{sv}", "Timeout", g_variant_new("i", timeout));
        g_variant_builder_add(builder, "{sv}", "Channel", g_variant_new("i", channel));
@@ -1093,16 +1292,12 @@ int wifi_direct_start_discovery_specific_channel(bool listen_only,
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "StartDiscovery", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1126,23 +1321,19 @@ int wifi_direct_cancel_discovery(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "StopDiscovery", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
 
-#ifdef TIZEN_FEATURE_SERVICE_DISCOVERY
+#if 0
 static char **get_service_list(char *services, unsigned int *count)
 {
        __WDC_LOG_FUNC_START__;
@@ -1152,6 +1343,7 @@ static char **get_service_list(char *services, unsigned int *count)
        unsigned int cnt = 0;
        unsigned int i = 0;
        unsigned int j = 0;
+       char *saveptr = NULL;
 
        if (!count || !services || (services && strlen(services) <= 0)) {
                WDC_LOGE("Invalid parameters.");
@@ -1162,10 +1354,10 @@ static char **get_service_list(char *services, unsigned int *count)
        pos1 = services;
        pos2 = g_strdup(services);
 
-       pos1 = strtok (pos1,",\n");
+       pos1 = strtok_r(pos1, ",\n", &saveptr);
        while (pos1) {
                cnt++;
-               pos1 = strtok (NULL, ",\n");
+               pos1 = strtok_r(NULL, ",\n", &saveptr);
        }
        WDC_LOGD("Total Service Count = %d", cnt);
 
@@ -1176,13 +1368,13 @@ static char **get_service_list(char *services, unsigned int *count)
                        g_free(pos2);
                        return NULL;
                }
-               pos2 = strtok (pos2,",\n");
+               pos2 = strtok_r(pos2, ",\n", &saveptr);
                while (pos2 != NULL) {
                        char *s = strchr(pos2, ' ');
                        if (s) {
                                *s = '\0';
                                result[i++] = strdup(pos2);
-                               pos2 = strtok (NULL, ",\n");
+                               pos2 = strtok_r(NULL, ",\n", &saveptr);
                        }
                }
        }
@@ -1196,7 +1388,7 @@ static char **get_service_list(char *services, unsigned int *count)
        } else {
                *count = 0;
                if (result) {
-                       for (j=0; j<i && result[j] != NULL; j++)
+                       for (j = 0; j < i && result[j] != NULL; j++)
                                free(result[j]);
                        free(result);
                }
@@ -1235,13 +1427,10 @@ int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb cb,
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "GetDiscoveredPeers", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
        if (ret != WIFI_DIRECT_ERROR_NONE) {
@@ -1250,8 +1439,8 @@ int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb cb,
        }
 
        WDC_LOGD("wifi_direct_foreach_discovered_peers() SUCCESS");
-
-       while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
+//LCOV_EXCL_START
+       while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
                wifi_direct_discovered_peer_info_s *peer_list = NULL;
 
                peer_list = (wifi_direct_discovered_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_discovered_peer_info_s));
@@ -1310,13 +1499,13 @@ int wifi_direct_foreach_discovered_peers(wifi_direct_discovered_peer_cb cb,
                        }
                }
 
-               //__wfd_client_print_entry_list(peer_list, 1);
+               /* __wfd_client_print_entry_list(peer_list, 1); */
                if (!cb(peer_list, user_data)) {
                        g_variant_iter_free(iter_peer);
                        break;
                }
        }
-
+//LCOV_EXCL_STOP
        g_variant_iter_free(iter_peers);
        g_variant_unref(reply);
        __WDC_LOG_FUNC_END__;
@@ -1349,22 +1538,19 @@ int wifi_direct_connect(char *mac_address)
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "Connect", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
 
+//LCOV_EXCL_START
 int wifi_direct_cancel_connection(char *mac_address)
 {
        __WDC_LOG_FUNC_START__;
@@ -1391,16 +1577,12 @@ int wifi_direct_cancel_connection(char *mac_address)
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "CancelConnection", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1434,22 +1616,18 @@ int wifi_direct_reject_connection(char *mac_address)
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "RejectConnection", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
-
+//LCOV_EXCL_STOP
 
 int wifi_direct_disconnect_all(void)
 {
@@ -1469,23 +1647,19 @@ int wifi_direct_disconnect_all(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "DisconnectAll", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
 
-
+//LCOV_EXCL_START
 int wifi_direct_disconnect(char *mac_address)
 {
        __WDC_LOG_FUNC_START__;
@@ -1512,16 +1686,12 @@ int wifi_direct_disconnect(char *mac_address)
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "Disconnect", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1554,22 +1724,18 @@ int wifi_direct_accept_connection(char *mac_address)
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "AcceptConnection", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
-
+//LCOV_EXCL_STOP
 
 int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
                                        void *user_data)
@@ -1599,15 +1765,13 @@ int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
+//LCOV_EXCL_START
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "GetConnectedPeers", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(iaa{sv})", &ret, &iter_peers);
        if (ret != WIFI_DIRECT_ERROR_NONE) {
@@ -1617,7 +1781,7 @@ int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
 
        WDC_LOGD("wifi_direct_foreach_connected_peers() SUCCESS");
 
-       while(g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
+       while (g_variant_iter_loop(iter_peers, "a{sv}", &iter_peer)) {
                wifi_direct_connected_peer_info_s *peer_list = NULL;
 
                peer_list = (wifi_direct_connected_peer_info_s *) g_try_malloc0(sizeof(wifi_direct_connected_peer_info_s));
@@ -1678,7 +1842,7 @@ int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
                        }
                }
 
-               //__wfd_client_print_connected_peer_info(peer_list, 1);
+               /* __wfd_client_print_connected_peer_info(peer_list, 1); */
                if (!cb(peer_list, user_data)) {
                        g_variant_iter_free(iter_peer);
                        break;
@@ -1687,6 +1851,7 @@ int wifi_direct_foreach_connected_peers(wifi_direct_connected_peer_cb cb,
 
        g_variant_iter_free(iter_peers);
        g_variant_unref(reply);
+//LCOV_EXCL_STOP
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
@@ -1710,16 +1875,12 @@ int wifi_direct_create_group(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
                                                  "CreateGroup", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1745,16 +1906,12 @@ int wifi_direct_destroy_group(void)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
                                                  "DestroyGroup", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1770,6 +1927,7 @@ int wifi_direct_is_group_owner(bool *owner)
 
        GError* error = NULL;
        GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
        bool val;
 
        if (g_client_info.is_registered == false) {
@@ -1788,13 +1946,11 @@ int wifi_direct_is_group_owner(bool *owner)
                                          "IsGroupOwner",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_get(reply, "(b)", &val);
        *owner = val;
@@ -1812,6 +1968,7 @@ int wifi_direct_is_autonomous_group(bool *autonomous_group)
 
        GError* error = NULL;
        GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
        bool val;
 
        if (g_client_info.is_registered == false) {
@@ -1830,13 +1987,11 @@ int wifi_direct_is_autonomous_group(bool *autonomous_group)
                                          "IsAutoGroup",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_get(reply, "(b)", &val);
        *autonomous_group = val;
@@ -1875,16 +2030,12 @@ int wifi_direct_set_group_owner_intent(int intent)
                                          "SetGoIntent",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -1918,13 +2069,10 @@ int wifi_direct_get_group_owner_intent(int *intent)
                                          "GetGoIntent",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *intent = val;
@@ -1959,16 +2107,12 @@ int wifi_direct_set_max_clients(int max)
                                          "SetMaxClient",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -2002,13 +2146,10 @@ int wifi_direct_get_max_clients(int *max)
                                          "GetMaxClient",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *max = val;
@@ -2047,13 +2188,10 @@ int wifi_direct_get_operating_channel(int *channel)
                                          "GetOperatingChannel",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *channel = val;
@@ -2085,17 +2223,12 @@ int wifi_direct_activate_pushbutton(void)
                                          "ActivatePushButton",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
-       WDC_LOGD("%s() SUCCESS", __func__);
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -2131,16 +2264,12 @@ int wifi_direct_set_wps_pin(char *pin)
                                          "SetWpsPin",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -2175,16 +2304,13 @@ int wifi_direct_get_wps_pin(char **pin)
                                          "GetWpsPin",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(i&s)", &ret, &str);
-       if(pin != NULL && str != NULL)
+       if (pin != NULL && str != NULL)
                *pin = g_strdup(str);
        g_variant_unref(reply);
 
@@ -2220,13 +2346,10 @@ int wifi_direct_get_supported_wps_mode(int *wps_mode)
                                          "GetSupportedWpsMode",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &mode);
        *wps_mode = mode;
@@ -2265,13 +2388,10 @@ int wifi_direct_foreach_supported_wps_types(wifi_direct_supported_wps_type_cb cb
                                          "GetSupportedWpsMode",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &wps_mode);
        g_variant_unref(reply);
@@ -2315,13 +2435,10 @@ int wifi_direct_get_local_wps_type(wifi_direct_wps_type_e *type)
                                          "GetLocalWpsMode",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &mode);
        *type = mode;
@@ -2364,16 +2481,12 @@ int wifi_direct_set_req_wps_type(wifi_direct_wps_type_e type)
                                          "SetReqWpsMode",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -2407,13 +2520,10 @@ int wifi_direct_get_req_wps_type(wifi_direct_wps_type_e *type)
                                          "GetReqWpsMode",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &mode);
        *type = mode;
@@ -2451,13 +2561,10 @@ int wifi_direct_get_ssid(char **ssid)
                                          "GetDeviceName",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(i&s)", &ret, &str);
        *ssid = g_strdup(str);
@@ -2495,13 +2602,10 @@ int wifi_direct_get_device_name(char **device_name)
                                          "GetDeviceName",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(i&s)", &ret, &str);
        *device_name = g_strdup(str);
@@ -2541,22 +2645,19 @@ int wifi_direct_set_device_name(const char *device_name)
                                          "SetDeviceName",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
 }
 
+//LCOV_EXCL_START
 int wifi_direct_get_network_interface_name(char **name)
 {
        __WDC_LOG_FUNC_START__;
@@ -2594,15 +2695,12 @@ int wifi_direct_get_network_interface_name(char **name)
                                                  "GetInterfaceName",
                                                  NULL,
                                                  &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i&s)", ret ,&get_str);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(i&s)", ret, &get_str);
        *name = g_strdup(get_str);
        g_variant_unref(reply);
 
@@ -2640,15 +2738,12 @@ int wifi_direct_get_ip_address(char **ip_address)
                                                  "GetIPAddress",
                                                  NULL,
                                                  &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i&s)", ret ,&str);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(i&s)", ret, &str);
        *ip_address = g_strdup(str);
        g_variant_unref(reply);
 
@@ -2684,7 +2779,7 @@ int wifi_direct_get_subnet_mask(char **subnet_mask)
 
        ret = wifi_direct_get_state(&status);
        WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
-       ifstatus < WIFI_DIRECT_STATE_CONNECTED) {
+       if (status < WIFI_DIRECT_STATE_CONNECTED) {
                WDC_LOGE("Device is not connected!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
@@ -2694,15 +2789,12 @@ int wifi_direct_get_subnet_mask(char **subnet_mask)
                                                  "GetSubnetMask",
                                                  NULL,
                                                  &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i&s)", ret ,&get_str);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(i&s)", ret, &get_str);
        *subnet_mask = g_strdup(get_str);
        g_variant_unref(reply);
 
@@ -2739,7 +2831,7 @@ int wifi_direct_get_gateway_address(char **gateway_address)
 
        ret = wifi_direct_get_state(&status);
        WDC_LOGD("wifi_direct_get_state() state=[%d], ret=[%d]", status, ret);
-       if(status < WIFI_DIRECT_STATE_CONNECTED) {
+       if (status < WIFI_DIRECT_STATE_CONNECTED) {
                WDC_LOGE("Device is not connected!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_PERMITTED;
@@ -2749,15 +2841,12 @@ int wifi_direct_get_gateway_address(char **gateway_address)
                                                  "GetGateway",
                                                  NULL,
                                                  &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i&s)", ret ,&get_str);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(i&s)", ret, &get_str);
        *gateway_address = g_strdup(get_str);
        g_variant_unref(reply);
 
@@ -2767,6 +2856,7 @@ int wifi_direct_get_gateway_address(char **gateway_address)
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 int wifi_direct_get_mac_address(char **mac_address)
 {
@@ -2795,13 +2885,10 @@ int wifi_direct_get_mac_address(char **mac_address)
                                          "GetMacAddress",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(i&s)", &ret, &str);
        *mac_address = g_strdup(str);
@@ -2813,47 +2900,42 @@ int wifi_direct_get_mac_address(char **mac_address)
        return ret;
 }
 
-
 int wifi_direct_get_state(wifi_direct_state_e *state)
 {
        __WDC_LOG_FUNC_START__;
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
 
-       GError* error = NULL;
-       GVariant *reply = NULL;
        int val = 0;
        int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if (g_client_info.is_registered == false) {
-               WDC_LOGE("Client is NOT registered");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
-       }
-
        if (!state) {
                WDC_LOGE("Invalid Parameter");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
-                                                 "GetState", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
+       ret = vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &val);
+       if (ret < 0) {
+               WDC_LOGE("Failed to get vconf value [%s]\n", VCONFKEY_WIFI_DIRECT_STATE);
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_OPERATION_FAILED;
        }
 
-       g_variant_get(reply, "(ii)", &ret, &val);
-       *state = (wifi_direct_state_e) val;
-       /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
-       if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
+       if (val == VCONFKEY_WIFI_DIRECT_ACTIVATED) {
+               *state = WIFI_DIRECT_STATE_ACTIVATED;
+       } else if (val == VCONFKEY_WIFI_DIRECT_DEACTIVATED) {
+               *state = WIFI_DIRECT_STATE_DEACTIVATED;
+       } else if (val == VCONFKEY_WIFI_DIRECT_CONNECTED) {
                *state = WIFI_DIRECT_STATE_CONNECTED;
-
-       g_variant_unref(reply);
+       } else if (val == VCONFKEY_WIFI_DIRECT_GROUP_OWNER) {
+               *state = WIFI_DIRECT_STATE_CONNECTED;
+       } else if (val == VCONFKEY_WIFI_DIRECT_DISCOVERING) {
+               *state = WIFI_DIRECT_STATE_DISCOVERING;
+       } else {
+               WDC_LOGE("This state cannot be set as wifi_direct vconf state[%d]", val);
+               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+       }
 
        WDC_LOGD("State = [%d]", *state);
        WDC_LOGD("%s() return : [%d]", __func__, ret);
@@ -2861,7 +2943,6 @@ int wifi_direct_get_state(wifi_direct_state_e *state)
        return ret;
 }
 
-
 int wifi_direct_is_discoverable(bool* discoverable)
 {
        __WDC_LOG_FUNC_START__;
@@ -2870,6 +2951,7 @@ int wifi_direct_is_discoverable(bool* discoverable)
 
        GError* error = NULL;
        GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
@@ -2885,16 +2967,13 @@ int wifi_direct_is_discoverable(bool* discoverable)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "IsDiscoverable", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(b)", discoverable);
-       WDC_LOGD("Discoverable = [%s]", *discoverable ? "Yes":"No");
+       WDC_LOGD("Discoverable = [%s]", *discoverable ? "Yes" : "No");
 
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_unref(reply);
@@ -2911,6 +2990,7 @@ int wifi_direct_is_listening_only(bool* listen_only)
 
        GError* error = NULL;
        GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
@@ -2926,17 +3006,14 @@ int wifi_direct_is_listening_only(bool* listen_only)
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "IsListeningOnly", NULL, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(b)", listen_only);
 
-       WDC_LOGD("Is listen only = [%s]", *listen_only ? "Yes":"No");
+       WDC_LOGD("Is listen only = [%s]", *listen_only ? "Yes" : "No");
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_unref(reply);
 
@@ -2951,11 +3028,10 @@ int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e* type)
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
 
-       if (!type) {
-               WDC_LOGE("NULL Param [type]!");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
-       }
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+       int primary_device_type = 0;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
@@ -2963,16 +3039,27 @@ int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e* type)
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-#ifdef TIZEN_TV
-       WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY);
-       *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY;
-#else /* TIZEN_TV */
-       WDC_LOGD("Current primary_dev_type [%d]", WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE);
-       *type = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE;
-#endif /* TIZEN_TV */
+       if (type == NULL) {
+               WDC_LOGE("NULL Param [type]!");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                                 "GetPrimaryDevType",
+                                                 NULL, &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       WDC_LOGD("%s() SUCCESS", __func__);
+       g_variant_get(reply, "(ii)", &ret, &primary_device_type);
+       g_variant_unref(reply);
+       *type = primary_device_type;
 
        __WDC_LOG_FUNC_END__;
-       return WIFI_DIRECT_ERROR_NONE;
+       return ret;
 }
 
 int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e* type)
@@ -2981,28 +3068,38 @@ int wifi_direct_get_secondary_device_type(wifi_direct_secondary_device_type_e* t
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
 
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+       int secondary_device_type = 0;
+
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if (NULL == type) {
+       if (type == NULL) {
                WDC_LOGE("NULL Param [type]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
 
-#ifdef TIZEN_TV
-       WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV);
-       *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV;
-#else /* TIZEN_TV */
-       WDC_LOGD("Current second_dev_type [%d]", WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL);
-       *type = WIFI_DIRECT_SECONDARY_DEVICE_TYPE_TELEPHONE_SMARTPHONE_DUAL;    /* smart phone dual mode (wifi and cellular) */
-#endif /* TIZEN_TV */
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                                 "GetSecondaryDevType",
+                                                 NULL, &error);
 
-       __WDC_LOG_FUNC_END__;
-       return WIFI_DIRECT_ERROR_NONE;
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       WDC_LOGD("%s() SUCCESS", __func__);
+       g_variant_get(reply, "(ii)", &ret, &secondary_device_type);
+       g_variant_unref(reply);
+       *type = secondary_device_type;
+
+       __WDC_LOG_FUNC_END__;
+       return ret;
 }
 
 int wifi_direct_set_autoconnection_mode(bool mode)
@@ -3027,16 +3124,12 @@ int wifi_direct_set_autoconnection_mode(bool mode)
                                          "SetAutoConnectionMode",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3070,13 +3163,10 @@ int wifi_direct_is_autoconnection_mode(bool *mode)
                                          "IsAutoConnectionMode",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ib)", &ret, &val);
        *mode = val;
@@ -3097,6 +3187,7 @@ int wifi_direct_set_persistent_group_enabled(bool enabled)
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
@@ -3109,16 +3200,14 @@ int wifi_direct_set_persistent_group_enabled(bool enabled)
                                          "SetPersistentGroupEnabled",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
        }
-       WDC_LOGD("%s() SUCCESS", __func__);
 
-       g_variant_unref(reply);
+       WDC_LOGD("%s() return : [%d]", __func__, ret);
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
@@ -3133,6 +3222,7 @@ int wifi_direct_is_persistent_group_enabled(bool *enabled)
 
        GError* error = NULL;
        GVariant *reply = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
        bool val;
 
        if (g_client_info.is_registered == false) {
@@ -3151,13 +3241,11 @@ int wifi_direct_is_persistent_group_enabled(bool *enabled)
                                          "IsPersistentGroupEnabled",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_get(reply, "(b)", &val);
        *enabled = val;
@@ -3197,13 +3285,10 @@ int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb cb,
 
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_GROUP_INTERFACE,
                                                  "GetPersistentGroups", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(iaa{sv})", &ret, &iter_groups);
        if (ret != WIFI_DIRECT_ERROR_NONE) {
@@ -3212,8 +3297,8 @@ int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb cb,
        }
 
        WDC_LOGD("wifi_direct_foreach_persistent_groups() SUCCESS");
-
-       while(g_variant_iter_loop(iter_groups, "a{sv}", &iter_group)) {
+//LCOV_EXCL_START
+       while (g_variant_iter_loop(iter_groups, "a{sv}", &iter_group)) {
                const char *ssid = NULL;
                char *go_mac_address = NULL;
 
@@ -3242,12 +3327,13 @@ int wifi_direct_foreach_persistent_groups(wifi_direct_persistent_group_cb cb,
                        break;
                }
        }
-
+//LCOV_EXCL_STOP
        g_variant_iter_free(iter_groups);
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
 
+//LCOV_EXCL_START
 int wifi_direct_remove_persistent_group(char *mac_address, const char *ssid)
 {
        __WDC_LOG_FUNC_START__;
@@ -3257,6 +3343,7 @@ int wifi_direct_remove_persistent_group(char *mac_address, const char *ssid)
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered");
@@ -3275,54 +3362,19 @@ int wifi_direct_remove_persistent_group(char *mac_address, const char *ssid)
                                          "RemovePersistentGroup",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
-       WDC_LOGD("%s() SUCCESS", __func__);
 
-       g_variant_unref(reply);
-
-       __WDC_LOG_FUNC_END__;
-       return WIFI_DIRECT_ERROR_NONE;
-}
-
-int wifi_direct_set_p2poem_loglevel(int increase_log_level)
-{
-       __WDC_LOG_FUNC_START__;
-/* TODO:
-       wifi_direct_client_request_s req;
-       wifi_direct_client_response_s rsp;
-       int res = WIFI_DIRECT_ERROR_NONE;
-
-       if (g_client_info.is_registered == false) {
-               WDC_LOGE("Client is NOT registered");
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
        }
 
-       memset(&req, 0, sizeof(wifi_direct_client_request_s));
-       memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
-
-       req.cmd = WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL;
-       req.client_id = g_client_info.client_id;
-       if (increase_log_level == 0)
-               req.data.int1 = false;
-       else
-               req.data.int1 = true;
+       WDC_LOGD("%s() return : [%d]", __func__, ret);
 
-       res = __wfd_client_send_request(g_client_info.sync_sockfd, &req, &rsp);
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-               __WDC_LOG_FUNC_END__;
-               return res;
-       }
-*/
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 int wifi_direct_start_service_discovery(char *mac_address,
                wifi_direct_service_type_e type)
@@ -3332,6 +3384,8 @@ int wifi_direct_start_service_discovery(char *mac_address,
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
 
+//LCOV_EXCL_START
+
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
@@ -3361,20 +3415,17 @@ int wifi_direct_start_service_discovery(char *mac_address,
                                                    "StartDiscovery",
                                                    params,
                                                    &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -3388,7 +3439,7 @@ int wifi_direct_cancel_service_discovery(char *mac_address,
        __WDC_LOG_FUNC_START__;
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
@@ -3418,20 +3469,17 @@ int wifi_direct_cancel_service_discovery(char *mac_address,
                                                    "StopDiscovery",
                                                    params,
                                                    &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -3443,7 +3491,7 @@ int wifi_direct_register_service(wifi_direct_service_type_e type, char *info1, c
        __WDC_LOG_FUNC_START__;
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
@@ -3494,20 +3542,21 @@ int wifi_direct_register_service(wifi_direct_service_type_e type, char *info1, c
                                                    "Register",
                                                    params,
                                                    &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               g_free(buf);
+               return ret;
        }
 
        g_variant_get(reply, "(ii)", &ret, service_id);
        g_variant_unref(reply);
+       g_free(buf);
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -3519,7 +3568,7 @@ int wifi_direct_deregister_service(unsigned int service_id)
        __WDC_LOG_FUNC_START__;
 
        CHECK_FEATURE_SUPPORTED(WIFIDIRECT_SERVICE_DISCOVERY_FEATURE);
-
+//LCOV_EXCL_START
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
@@ -3536,20 +3585,17 @@ int wifi_direct_deregister_service(unsigned int service_id)
                                                    "Deregister",
                                                    params,
                                                    &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
        return ret;
+//LCOV_EXCL_STOP
 #else /* TIZEN_FEATURE_SERVICE_DISCOVERY */
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_SERVICE_DISCOVERY */
@@ -3560,7 +3606,7 @@ int wifi_direct_init_miracast(bool enable)
        __WDC_LOG_FUNC_START__;
        int ret = WIFI_DIRECT_ERROR_NONE;
 
-       if(enable)
+       if (enable)
                ret = wifi_direct_init_display();
        else
                ret = wifi_direct_deinit_display();
@@ -3600,17 +3646,14 @@ int wifi_direct_get_peer_info(char* mac_address, wifi_direct_discovered_peer_inf
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
        }
-
+//LCOV_EXCL_START
        params = g_variant_new("(s)", mac_address);
        reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
                                                  "GetPeerInfo", params, &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ia{sv})", &ret, &iter_peer);
        if (ret != WIFI_DIRECT_ERROR_NONE) {
@@ -3637,12 +3680,12 @@ int wifi_direct_get_peer_info(char* mac_address, wifi_direct_discovered_peer_inf
                        peer->device_name = g_strndup(device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1);
 
                } else if (!g_strcmp0(key, "DeviceAddress")) {
-                       unsigned char mac_address[MACADDR_LEN] = {0, };
+                       unsigned char l_mac_address[MACADDR_LEN] = {0, };
 
-                       wifi_direct_dbus_unpack_ay(mac_address, var, MACADDR_LEN);
+                       wifi_direct_dbus_unpack_ay(l_mac_address, var, MACADDR_LEN);
                        peer->mac_address = (char*) g_try_malloc0(MACSTR_LEN);
                        if (peer->mac_address)
-                               g_snprintf(peer->mac_address, MACSTR_LEN, MACSTR, MAC2STR(mac_address));
+                               g_snprintf(peer->mac_address, MACSTR_LEN, MACSTR, MAC2STR(l_mac_address));
 
                } else if (!g_strcmp0(key, "InterfaceAddress")) {
                        unsigned char intf_address[MACADDR_LEN] = {0, };
@@ -3682,6 +3725,7 @@ int wifi_direct_get_peer_info(char* mac_address, wifi_direct_discovered_peer_inf
        *peer_info = peer;
 
        g_variant_unref(reply);
+//LCOV_EXCL_STOP
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
 }
@@ -3695,6 +3739,7 @@ int wifi_direct_set_passphrase(const char *passphrase)
        GError* error = NULL;
        GVariant *reply = NULL;
        GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
 
        if (g_client_info.is_registered == false) {
                WDC_LOGE("Client is NOT registered.");
@@ -3714,16 +3759,14 @@ int wifi_direct_set_passphrase(const char *passphrase)
                                          "SetPassphrase",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
        }
-       WDC_LOGD("%s() SUCCESS", __func__);
 
-       g_variant_unref(reply);
+       WDC_LOGD("%s() SUCCESS", __func__);
 
        __WDC_LOG_FUNC_END__;
        return WIFI_DIRECT_ERROR_NONE;
@@ -3746,7 +3789,7 @@ int wifi_direct_get_passphrase(char** passphrase)
                return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
        }
 
-       if(!passphrase){
+       if (!passphrase) {
                WDC_LOGE("NULL Param [passphrase]!");
                __WDC_LOG_FUNC_END__;
                return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
@@ -3756,13 +3799,11 @@ int wifi_direct_get_passphrase(char** passphrase)
                                          "GetPassphrase",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
        WDC_LOGD("%s() SUCCESS", __func__);
        g_variant_get(reply, "(i&s)", &ret, &val);
        *passphrase = g_strdup(val);
@@ -3801,16 +3842,12 @@ int wifi_direct_set_autoconnection_peer(char *mac_address)
                                          "SetAutoConnectionPeer",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3838,16 +3875,12 @@ int wifi_direct_init_display(void)
                                          "Init",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3878,16 +3911,12 @@ int wifi_direct_deinit_display(void)
                                          "Deinit",
                                          NULL,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3928,16 +3957,12 @@ int wifi_direct_set_display(wifi_direct_display_type_e type, int port, int hdcp)
                                          "SetConfig",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3971,16 +3996,12 @@ int wifi_direct_set_display_availability(bool availability)
                                          "SetAvailiability",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
 
-       g_variant_get(reply, "(i)", &ret);
-       g_variant_unref(reply);
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
 
        WDC_LOGD("%s() return : [%d]", __func__, ret);
        __WDC_LOG_FUNC_END__;
@@ -3990,6 +4011,7 @@ int wifi_direct_set_display_availability(bool availability)
 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
 }
 
+//LCOV_EXCL_START
 int wifi_direct_get_peer_display_type(char *mac_address, wifi_direct_display_type_e *type)
 {
        __WDC_LOG_FUNC_START__;
@@ -4020,13 +4042,10 @@ int wifi_direct_get_peer_display_type(char *mac_address, wifi_direct_display_typ
                                          "GetPeerType",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *type = val;
@@ -4070,13 +4089,10 @@ int wifi_direct_get_peer_display_availability(char *mac_address, bool *availabil
                                          "GetPeerAvailability",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *availability = val;
@@ -4120,13 +4136,10 @@ int wifi_direct_get_peer_display_hdcp(char *mac_address, int *hdcp)
                                          "GetPeerHdcp",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *hdcp = val;
@@ -4170,13 +4183,10 @@ int wifi_direct_get_peer_display_port(char *mac_address, int *port)
                                          "GetPeerPort",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *port = val;
@@ -4220,13 +4230,10 @@ int wifi_direct_get_peer_display_throughput(char *mac_address, int *throughput)
                                          "GetPeerThroughput",
                                          params,
                                          &error);
-       if (error != NULL) {
-               WDC_LOGE("wifi_direct_dbus_method_call_sync() failed."
-                               "error [%d: %s]", error->code, error->message);
-               g_error_free(error);
-               __WDC_LOG_FUNC_END__;
-               return WIFI_DIRECT_ERROR_OPERATION_FAILED;
-       }
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
 
        g_variant_get(reply, "(ii)", &ret, &val);
        *throughput = val;
@@ -4239,3 +4246,124 @@ int wifi_direct_get_peer_display_throughput(char *mac_address, int *throughput)
        return WIFI_DIRECT_ERROR_NOT_SUPPORTED;
 #endif /* TIZEN_FEATURE_WIFI_DISPLAY */
 }
+
+int wifi_direct_set_session_timer(int seconds)
+{
+       __WDC_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       if (g_client_info.is_registered == false) {
+               WDC_LOGE("Client is NOT registered.");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+       if (seconds < 0) {
+               WDC_LOGE("Negative Timer Value");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       WDC_LOGD("seconds = [%d]", seconds);
+
+       params = g_variant_new("(i)", seconds);
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                         "SetSessionTimer",
+                                         params,
+                                         &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
+
+       WDC_LOGD("%s() SUCCESS", __func__);
+
+       __WDC_LOG_FUNC_END__;
+       return WIFI_DIRECT_ERROR_NONE;
+
+}
+
+int wifi_direct_get_session_timer(int *seconds)
+{
+       __WDC_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       int val = 0;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       if (g_client_info.is_registered == false) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
+       if (!seconds) {
+               WDC_LOGE("Invalid Parameter");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+       }
+
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                         "GetSessionTimer",
+                                         NULL,
+                                         &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret != WIFI_DIRECT_ERROR_NONE)
+               return ret;
+
+       g_variant_get(reply, "(ii)", &ret, &val);
+       *seconds = val;
+       g_variant_unref(reply);
+
+       WDC_LOGD("Session Timer = [%d] Seconds", *seconds);
+       WDC_LOGD("%s() return : [%d]", __func__, ret);
+
+       __WDC_LOG_FUNC_END__;
+       return ret;
+}
+
+int wifi_direct_set_auto_group_removal(bool enable)
+{
+       __WDC_LOG_FUNC_START__;
+
+       CHECK_FEATURE_SUPPORTED(WIFIDIRECT_FEATURE);
+
+       GError* error = NULL;
+       GVariant *reply = NULL;
+       GVariant *params = NULL;
+       int ret = WIFI_DIRECT_ERROR_NONE;
+
+       if (g_client_info.is_registered == false) {
+               WDC_LOGE("Client is NOT registered");
+               __WDC_LOG_FUNC_END__;
+               return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+       }
+
+       params = g_variant_new("(b)", enable);
+       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_CONFIG_INTERFACE,
+                                         "SetAutoGroupRemoval",
+                                         params,
+                                         &error);
+
+       ret = __net_wifidirect_gerror_to_enum(error);
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               g_variant_get(reply, "(i)", &ret);
+               g_variant_unref(reply);
+       }
+
+       WDC_LOGD("%s() return : [%d]", __func__, ret);
+       __WDC_LOG_FUNC_END__;
+       return ret;
+}
+//LCOV_EXCL_STOP