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 4caf727..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
@@ -139,9 +118,58 @@ static int __net_wifidirect_gerror_to_enum(GError* 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;
@@ -167,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;
@@ -195,7 +228,12 @@ void wifi_direct_process_manage_deactivation(GDBusConnection *connection,
 
 //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;
@@ -226,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;
@@ -257,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;
@@ -307,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();
@@ -326,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();
@@ -345,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();
@@ -364,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;
@@ -400,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;
@@ -437,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();
@@ -457,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();
@@ -479,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();
@@ -501,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;
@@ -534,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();
@@ -612,7 +710,7 @@ int wifi_direct_initialize(void)
        GError* error = NULL;
        GVariant *reply = NULL;
        bool wifi_direct_enable;
-       int state = 0;
+       bool val;
        int res = 0;
 
        if (g_client_info.is_registered == TRUE) {
@@ -639,31 +737,33 @@ int wifi_direct_initialize(void)
                return WIFI_DIRECT_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
-       reply = wifi_direct_dbus_method_call_sync(WFD_MANAGER_MANAGE_INTERFACE,
-                                                 "GetState", NULL, &error);
+       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, "(ii)", &res, &state);
-       WDC_LOGD("State = [%d]", state);
+       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;
@@ -689,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
@@ -1001,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__;
@@ -2746,44 +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);
-
-       ret = __net_wifidirect_gerror_to_enum(error);
-       if (ret != WIFI_DIRECT_ERROR_NONE)
-               return ret;
+       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);
@@ -2791,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__;
@@ -2877,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");
@@ -2889,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)
@@ -2907,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);
+
+       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 WIFI_DIRECT_ERROR_NONE;
+       return ret;
 }
 
 int wifi_direct_set_autoconnection_mode(bool mode)
@@ -3509,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, };
@@ -4107,7 +4278,7 @@ int wifi_direct_set_session_timer(int seconds)
                                          &error);
 
        ret = __net_wifidirect_gerror_to_enum(error);
-       if(ret == WIFI_DIRECT_ERROR_NONE) {
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
                g_variant_get(reply, "(i)", &ret);
                g_variant_unref(reply);
        }
@@ -4157,8 +4328,42 @@ int wifi_direct_get_session_timer(int *seconds)
 
        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