Applied changes from EFL and wifi-direct APIS
authorKim Gibyoung <lastkgb.kim@samsung.com>
Tue, 11 Dec 2012 09:27:09 +0000 (18:27 +0900)
committerKim Gibyoung <lastkgb.kim@samsung.com>
Tue, 11 Dec 2012 09:27:09 +0000 (18:27 +0900)
Change-Id: Ic6d2886aeee3f2ad05a8fba95fd7e01aad94b493

77 files changed:
debian/changelog
packaging/libug-setting-wifidirect-efl.spec
popup-wifidirect/include/wfd-app-strings.h
popup-wifidirect/include/wfd-app-util.h
popup-wifidirect/include/wfd-app.h
popup-wifidirect/org.tizen.wifi-direct-popup.xml
popup-wifidirect/po/ar.po
popup-wifidirect/po/az.po
popup-wifidirect/po/bg.po
popup-wifidirect/po/ca.po
popup-wifidirect/po/cs.po
popup-wifidirect/po/da.po
popup-wifidirect/po/de_DE.po
popup-wifidirect/po/el_GR.po
popup-wifidirect/po/en.po
popup-wifidirect/po/en_PH.po
popup-wifidirect/po/en_US.po
popup-wifidirect/po/es_ES.po
popup-wifidirect/po/es_US.po
popup-wifidirect/po/et.po
popup-wifidirect/po/eu.po
popup-wifidirect/po/fi.po
popup-wifidirect/po/fr_CA.po
popup-wifidirect/po/fr_FR.po
popup-wifidirect/po/ga.po
popup-wifidirect/po/gl.po
popup-wifidirect/po/hi.po
popup-wifidirect/po/hr.po
popup-wifidirect/po/hu.po
popup-wifidirect/po/hy.po
popup-wifidirect/po/is.po
popup-wifidirect/po/it_IT.po
popup-wifidirect/po/ja_JP.po
popup-wifidirect/po/ka.po
popup-wifidirect/po/kk.po
popup-wifidirect/po/ko_KR.po
popup-wifidirect/po/lt.po
popup-wifidirect/po/lv.po
popup-wifidirect/po/mk.po
popup-wifidirect/po/nb.po
popup-wifidirect/po/nl_NL.po
popup-wifidirect/po/pl.po
popup-wifidirect/po/pt_BR.po
popup-wifidirect/po/pt_PT.po
popup-wifidirect/po/ro.po
popup-wifidirect/po/ru_RU.po
popup-wifidirect/po/sk.po
popup-wifidirect/po/sl.po
popup-wifidirect/po/sr.po
popup-wifidirect/po/sv.po
popup-wifidirect/po/tr_TR.po
popup-wifidirect/po/uk.po
popup-wifidirect/po/uz.po
popup-wifidirect/po/zh_CN.po
popup-wifidirect/po/zh_HK.po
popup-wifidirect/po/zh_SG.po
popup-wifidirect/po/zh_TW.po
popup-wifidirect/src/wfd-app-client.c
popup-wifidirect/src/wfd-app-main.c
popup-wifidirect/src/wfd-app-popup-view.c
popup-wifidirect/src/wfd-app-util.c
ug-wifidirect/include/wfd_client.h
ug-wifidirect/include/wfd_ug.h
ug-wifidirect/include/wfd_ug_view.h
ug-wifidirect/po/en.po [changed mode: 0644->0755]
ug-wifidirect/src/wfd_client.c
ug-wifidirect/src/wfd_ug.c
ug-wifidirect/src/wfd_ug_about_view.c
ug-wifidirect/src/wfd_ug_genlist.c
ug-wifidirect/src/wfd_ug_main_view.c
ug-wifidirect/src/wfd_ug_multiconnect_view.c
ug-wifidirect/src/wfd_ug_popup.c
ugapp-wifidirect/include/wfd-ugapp-util.h
ugapp-wifidirect/include/wfd-ugapp.h
ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml
ugapp-wifidirect/src/wfd-ugapp-main.c
ugapp-wifidirect/src/wfd-ugapp-util.c

index 0210470..818dbf3 100755 (executable)
@@ -1,3 +1,20 @@
+ug-setting-wifidirect-efl (1.0.1) precise; urgency=low
+
+  * Applied EFL code and winset changes
+  * SSID is deprecated, use device name
+  * Git: rsa/apps/home/ug-wifi-direct
+  * Tag: libug-setting-wifidirect-efl_1.0.1
+
+ -- Gibyoung Kim <laskgb.kim@samsung.com>  Tue, 11 Dec 2012 17:37:28 +0900
+
+ug-setting-wifidirect-efl (1.0.0) precise; urgency=low
+
+  * Update from private
+  * Git: rsa/apps/home/ug-wifi-direct
+  * Tag: libug-setting-wifidirect-efl_1.0.0
+
+ -- Gibyoung Kim <laskgb.kim@samsung.com>  Fri, 23 Nov 2012 17:32:15 +0900
+
 ug-setting-wifidirect-efl (0.7.9) precise; urgency=low
 
   * applied the new partition rule.
index 1c19e7b..200dc20 100755 (executable)
@@ -3,7 +3,7 @@
 
 Name:       libug-setting-wifidirect-efl
 Summary:    Wi-Fi Direct setting UI gadget 
-Version:    0.7.9
+Version:    1.0.1
 Release:    1
 Group:      TO_BE_FILLED
 License:    Samsung Proprietary License
@@ -96,7 +96,7 @@ ln -sf /usr/bin/ug-client /usr/ug/bin/ug-setting-wifidirect-efl
 /usr/ug/res/locale/*/*/*
 
 %files -n org.tizen.wifi-direct-popup
-%manifest com.samsung.wifi-direct-popup.manifest
+%manifest org.tizen.wifi-direct-popup.manifest
 %defattr(-,root,root,-)
 /usr/apps/org.tizen.wifi-direct-popup/bin/*
 /usr/apps/org.tizen.wifi-direct-popup/res/images/*
@@ -106,7 +106,7 @@ ln -sf /usr/bin/ug-client /usr/ug/bin/ug-setting-wifidirect-efl
 /usr/share/packages/org.tizen.wifi-direct-popup.xml
 
 %files -n org.tizen.wifi-direct-ugapp
-%manifest com.samsung.wifi-direct-ugapp.manifest
+%manifest org.tizen.wifi-direct-ugapp.manifest
 %defattr(-,root,root,-)
 /usr/apps/org.tizen.wifi-direct-ugapp/bin/*
 #/usr/share/applications/org.tizen.wifi-direct-ugapp.desktop
index d315389..8748253 100755 (executable)
 extern "C" {
 #endif
 
-#if 1 //Text should be translated.
-
-#define WFD_STR_HEADER                                 
+#if 1
+/* Text should be translated. */
+#define IDS_WFD_POP_CONNECTED "Connected to %s"
+#define IDS_WFD_POP_CONNECT_FAILED "Connect to %s failed"
+#define IDS_WFD_POP_DISCONNECTED "Disconnected to %s"
 
 #define IDS_WFD_POP_CONNECT_Q "Connect with %s?"
-#define IDS_WFD_POP_ENTER_PIN "Connect with %s in %d secs. Enter PIN to connect %s."
-#define IDS_WFD_POP_CONNECTING_WITH_PIN "Connecting...PIN:"
-#define IDS_WFD_POP_AUTOMATIC_TURN_OFF "There has been no activity for 5 minutes since Wi-Fi Direct was enabled. To extend battery life, Wi-Fi Direct has been disabled."
+#define IDS_WFD_POP_CONNECTING_WITH_KEYPAD "Connect with %s in %d secs. Enter PIN to connect to %s"
+#define IDS_WFD_POP_ENTER_PIN "Connect with %s in %d secs"
+#define IDS_WFD_POP_ENTER_PIN_WITH_KEYPAD "%s is requesting a Wi-Fi Direct connection. Allow?"
+#define IDS_WFD_POP_CONNECTING_WITH_PIN "Connect with %s in %d secs. PIN: %s"
 
 #endif
 
index 890e374..bff8201 100755 (executable)
 
 #define WIFI_DIRECT_APP_MID            "wfd-app"
 
-#define WFD_APP_LOG_LOW        LOG_VERBOSE
-#define WFD_APP_LOG_HIGH       LOG_INFO
-#define WFD_APP_LOG_ERROR      LOG_ERROR
-#define WFD_APP_LOG_WARN       LOG_WARN
-#define WFD_APP_LOG_ASSERT     LOG_FATAL
-#define WFD_APP_LOG_EXCEPTION  LOG_FATAL
+#define WFD_APP_LOG_LOW                LOG_VERBOSE
+#define WFD_APP_LOG_HIGH               LOG_INFO
+#define WFD_APP_LOG_ERROR              LOG_ERROR
+#define WFD_APP_LOG_WARN               LOG_WARN
+#define WFD_APP_LOG_ASSERT             LOG_FATAL
+#define WFD_APP_LOG_EXCEPTION  LOG_FATAL
 #define WFD_MAX_SIZE            128
 #define WFD_MAC_ADDRESS_SIZE    18
 
-char * wfd_app_trim_path(const char* filewithpath);
+char *wfd_app_trim_path(const char *filewithpath);
 int wfd_app_gettid();
 
 #define WFD_APP_LOG(log_level, format, args...) \
-       LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),##args)
-#define __WFD_APP_FUNC_ENTER__ LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
-#define __WFD_APP_FUNC_EXIT__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
+       LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__),  __LINE__, wfd_app_gettid(), ##args)
+#define __WFD_APP_FUNC_ENTER__ LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
+#define __WFD_APP_FUNC_EXIT__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
 
 #else /** _DLOG_UTIL */
 
-#define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(), ##args)
-#define __WFD_APP_FUNC_ENTER__ printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
-#define __WFD_APP_FUNC_EXIT__  printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
+#define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), ##args)
+#define __WFD_APP_FUNC_ENTER__ printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
+#define __WFD_APP_FUNC_EXIT__  printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
 
 #endif /** _USE_DLOG_UTIL */
 
 
 
 #define assertm_if(expr, fmt, arg...) do { \
-   if(expr) { \
+       if (expr) { \
          WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
                 exit(1); \
-   } \
-} while (0)                    // retvm if
+       } \
+} while (0)
 
 
 
index 0bf527e..59d808c 100755 (executable)
@@ -36,6 +36,7 @@
 #include <aul.h>
 #include <notification.h>
 #include <syspopup_caller.h>
+#include "wifi-direct.h"
 
 #define PACKAGE "org.tizen.wifi-direct-popup"
 #define EDJ_NAME RESDIR"/edje/wifi-direct-popup.edj"
 
 
 
-enum
-{
-    WFD_POP_TIMER_3 = 3,
-    WFD_POP_TIMER_10 = 10,
-    WFD_POP_TIMER_30 = 30,
-    WFD_POP_TIMER_120 = 120,
+enum {
+       WFD_POP_TIMER_3 = 3,
+       WFD_POP_TIMER_10 = 10,
+       WFD_POP_TIMER_30 = 30,
+       WFD_POP_TIMER_120 = 120,
 };
 
-enum
-{
-    WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ,
-    WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ,
-    WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ,
+enum {
+       WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ,
+       WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ,
+       WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ,
 
-    WFD_POP_PROG_CONNECT,
-    WFD_POP_PROG_DISCONNECT,
-    WFD_POP_PROG_CONNECT_CANCEL,
-    WFD_POP_PROG_CONNECT_WITH_PIN,
-    WFD_POP_PROG_CONNECT_WITH_KEYPAD,
-    WFD_POP_NOTI_CONNECTED,
-    WFD_POP_NOTI_DISCONNECTED,
-
-    WFD_POP_FAIL_INIT,
-    WFD_POP_FAIL_CONNECT,
-    WFD_POP_INCORRECT_PIN,
-
-    //Automatic turn off wfd
-    WFD_POP_AUTOMATIC_TURN_OFF,
+       WFD_POP_PROG_CONNECT,
+       WFD_POP_PROG_DISCONNECT,
+       WFD_POP_PROG_CONNECT_CANCEL,
+       WFD_POP_PROG_CONNECT_WITH_PIN,
+       WFD_POP_PROG_CONNECT_WITH_KEYPAD,
+       WFD_POP_NOTI_DISCONNECTED,
 
+       WFD_POP_FAIL_INIT,
 };
 
-enum
-{
-    WFD_POP_RESP_OK,
-    WFD_POP_RESP_CANCEL,
-    WFD_POP_RESP_APRV_CONNECT_PBC_YES = 1,
-    WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES,
-    WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES,
-    WFD_POP_RESP_APRV_CONNECT_NO,
-    WFD_POP_RESP_PROG_CONNECT_CANCEL,
-    WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK,
-    WFD_POP_RESP_APRV_ENTER_PIN_YES,
-    WFD_POP_RESP_APRV_ENTER_PIN_NO,
-    WFD_POP_RESP_AUTOMATIC_TURNOFF_OK,
+enum {
+       WFD_POP_RESP_OK,
+       WFD_POP_RESP_CANCEL,
+       WFD_POP_RESP_APRV_CONNECT_PBC_YES = 1,
+       WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK,
+       WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES,
+       WFD_POP_RESP_APRV_CONNECT_NO,
+       WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK,
+       WFD_POP_RESP_APRV_ENTER_PIN_YES,
+       WFD_POP_RESP_APRV_ENTER_PIN_NO,
 };
 
-typedef struct
-{
-    int type;
-    char text[WFD_POP_STR_MAX_LEN];
-    char label1[WFD_POP_STR_MAX_LEN];
-    char label2[WFD_POP_STR_MAX_LEN];
-    int timeout;
-    int resp_data1;
-    int resp_data2;
-    int data;
+typedef struct {
+       int type;
+       char text[WFD_POP_STR_MAX_LEN];
+       char label1[WFD_POP_STR_MAX_LEN];
+       char label2[WFD_POP_STR_MAX_LEN];
+       int timeout;
+       int resp_data1;
+       int resp_data2;
+       int data;
 } wfd_popup_t;
 
-typedef struct
-{
-    char ssid[32];
-    char mac_address[18];
+typedef struct {
+       char ssid[32];
+       char mac_address[18];
 } wfd_device_info_t;
 
-typedef struct
-{
-    Evas_Object *win;
-    Evas_Object *popup;
-    Evas_Object *pin_entry;
-    wfd_popup_t *popup_data;
-    uint popup_timeout_handle;
-    char pin_number[32];
-    char peer_mac[18];
-    char peer_name[32];
-    wfd_device_info_t *discovered_peers;
-    int discovered_peer_count;
-
-    /* notification */
-    notification_h noti;
-    wfd_device_info_t raw_connected_peers[WFD_MAX_PEER_NUM];
-    int raw_connected_peer_cnt;
-
-    /* used for automatic turn off */
-    int wfd_status;
-    int last_wfd_status;
-    int last_wfd_time;
-    int last_wfd_transmit_time;
-    Ecore_Timer *monitor_timer;
-    Ecore_Timer *transmit_timer;
+typedef struct {
+       Evas_Object *win;
+       Evas_Object *popup;
+       Evas_Object *pin_entry;
+       wfd_popup_t *popup_data;
+       uint popup_timeout_handle;
+       char pin_number[64];
+       char peer_mac[18];
+       char peer_name[32];
+       wfd_device_info_t *discovered_peers;
+       int discovered_peer_count;
+
+       /* notification */
+       notification_h noti;
+       wfd_device_info_t raw_connected_peers[WFD_MAX_PEER_NUM];
+       int raw_connected_peer_cnt;
+
+       /* Transmit timer */
+       wifi_direct_state_e wfd_status;
+       int last_wfd_transmit_time;
+       Ecore_Timer *transmit_timer;
 } wfd_appdata_t;
 
-typedef struct
-{
-    int step;
-    Evas_Object *progressbar;
-    Evas_Object *time;
+typedef struct {
+       int step;
+       Evas_Object *progressbar;
+       Evas_Object *time;
 } wfd_wps_display_popup_t;
 
 extern wfd_appdata_t *wfd_get_appdata();
+
+/**
+ *     This function let the app do initialization
+ *     @return   If success, return TRUE, else return FALSE
+ *     @param[in] ad the pointer to the main data structure
+ */
+int init_wfd_popup_client(wfd_appdata_t *ad);
+
+/**
+ *     This function let the app do de-initialization
+ *     @return   If success, return TRUE, else return FALSE
+ *     @param[in] ad the pointer to the main data structure
+ */
+int deinit_wfd_popup_client(wfd_appdata_t *ad);
+
+
+/**
+ *     This function let the app destroy the popup
+ *     @return   void
+ *     @param[in] null
+ */
 extern void wfd_destroy_popup();
+
+/**
+ *     This function let the app create a popup
+ *     @return   void
+ *     @param[in] type the type of popup
+ *     @param[in] userdata the pointer to the data which will be used
+ */
 extern void wfd_prepare_popup(int type, void *userdata);
+
+/**
+ *     This function let the app create a tickernoti syspopup
+ *     @return   void
+ *     @param[in] msg the pointer to message of tickernoti
+ */
 extern void wfd_tickernoti_popup(char *msg);
 
 #endif                          /* __WFD_SYS_POPAPP_MAIN_H__ */
index 0f82b8d..0295e9d 100755 (executable)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.wifi-direct-popup" version="0.6.2" install-location="internal-only">
        <label>WifiDirectPopup</label>
-       <author email="sungsik.jang@samsung.com" href="www.samsung.com">Sungsik Jang</author>
-       <author email="dwmax.lee@samsung.com" href="www.samsung.com">Dongwook Lee</author>
+       <author email="lastkgb.kim@samsung.com" href="www.samsung.com">Sungsik Jang</author>
+       <author email="jinmin@samsung.com" href="www.samsung.com">Dongwook Lee</author>
        <description>WiFi Direct Popup Application</description>
        <ui-application appid="org.tizen.wifi-direct-popup" exec="/usr/apps/org.tizen.wifi-direct-popup/bin/wifi-direct-popup" nodisplay="true" multiple="false" type="capp" taskmanage="false">
                <label>WifiDirectPopup</label>
index 37876a1..910015d 100644 (file)
@@ -115,7 +115,7 @@ msgstr "لا شيء محدد"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "تم الفصل"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index dd77e08..dc72fa8 100644 (file)
@@ -115,7 +115,7 @@ msgstr "He nə seçilməmişdir"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "əlaqəsi pozuldu"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index d45bb65..5f39888 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Нищо не е избрано"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Изключен"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index b65f3e7..e76d9f9 100644 (file)
@@ -115,7 +115,7 @@ msgstr "No s'ha seleccionat res"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desconnectat"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 6f8245f..f0ac73f 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Není nic vybráno"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Odpojeno"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 0452b6d..1b91571 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Intet er valgt"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Afbrudt"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 0506d8f..cb77b4b 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nichts ausgewählt"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Getrennt"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index e7b765a..1c9c0cc 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Δεν έχει γίνει καμία επιλογή"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Αποσυνδέθηκε"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index ab22b95..9590bb8 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nothing selected"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Disconnected"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 26772b0..2fffd5d 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nothing selected"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Disconnected"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index c172503..8b8b99d 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nothing selected"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Disconnected"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 4dac140..ce96cba 100644 (file)
@@ -115,7 +115,7 @@ msgstr "No se ha seleccionado nada"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desconectado"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 90ab68d..788cd8b 100644 (file)
@@ -115,7 +115,7 @@ msgstr "No se ha seleccionado nada"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Directo"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desconectado"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index ea7749b..33236ed 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Valik tegemata"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Ühendus katkestatud"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index bfa3ed8..60671dc 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ez da ezer aukeratu"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Deskonketatuta"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index b03a036..d717ec0 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Mitään ei valittu"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Yhteys katkaistu"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index e81c1d8..10a8a77 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Aucune sélection"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wifi direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Déconnecté"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index bfdcc83..12a86e5 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Aucune sélection"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Déconnecté"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 6371f10..51d5a13 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Dada roghnaithe"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Dínasctha"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index a40cd49..f3e26f1 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Non se seleccionou nada"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desconectado"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index b89f320..306d60c 100644 (file)
@@ -115,7 +115,7 @@ msgstr "कुछ चयनित नहीं"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi डायरेक्ट"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "डिस्कनेक्ट हुआ"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 21a56d9..3eebf83 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ništa odabrano"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Odspojeno"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 1916b13..81f49cb 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Semmi nincs kiválasztva"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Szétkapcsolva"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 10b82a0..ee7a3e5 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ոչինչ ընտրված չէ"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Անջատված է"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 1335c81..c7df9b0 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ekkert er valið"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Aftengt"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 87933f6..b24d362 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nessun elemento selezionato"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Disconnesso"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 84a1858..509259d 100644 (file)
@@ -115,7 +115,7 @@ msgstr "何も​選択​されて​いません。"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "切断しました。"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 03d2b0f..e6e7ad0 100644 (file)
@@ -115,7 +115,7 @@ msgstr "არაფერია არჩეული"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "გათიშულია"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 9cae0b2..169415b 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ештенке таңдалмады"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Ажыратылды"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 663b3c8..86ce129 100644 (file)
@@ -115,7 +115,7 @@ msgstr "선택된 것이 없습니다"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "연결 끊김"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index e209284..829d268 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Niekas nepasirinkta"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "„Wi-Fi Direct“"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Atjungta"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index d357d00..17379ee 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nekas nav izvēlēts"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Atvienots"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 5f47fbb..9c0a756 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Не е избрано ништо"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Врската е прекината"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 536e8a8..21f04d5 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ingenting valgt"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Frakoblet"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index feb7640..418d965 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Niets geselecteerd"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Verbinding verbroken"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 68ef448..087aba1 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Niczego nie zaznaczono"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Rozłączono"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 53ad5be..6b3a912 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nada selecionado"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desconectado"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index af1d611..e4661f8 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nada seleccionado"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Desligado"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index af6dbe0..8342e17 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nimic selectat"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Deconectat"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 10f8d46..b483157 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ничего не выбрано"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Отключено"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index b2985ee..c542382 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nič nie je vybrané"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Odpojené"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 541ed4b..c385410 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Nič ni izbrano"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Prekinjeno"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index f01694b..c8a134c 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Ništa nije izabrano"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Prekinuta veza"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index fddf794..551c6f1 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Inget markerat"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Frånkopplad"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index d00fa4f..6f7d777 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Bir şey seçilmedi"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Bağlantı kesildi"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 2d3f7c8..49445e9 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Нічого не вибрано"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Роз'єднано"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 1459683..c50e272 100644 (file)
@@ -115,7 +115,7 @@ msgstr "Hech narsa tanlanmagan"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "Uzilgan"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 3ac9839..52d4d48 100644 (file)
@@ -115,7 +115,7 @@ msgstr "未选择"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi直连"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "已断开"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index f47c05b..989a60f 100644 (file)
@@ -115,7 +115,7 @@ msgstr "無已選擇項目"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "已中斷連接"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 64b9a03..d1e06a3 100644 (file)
@@ -115,7 +115,7 @@ msgstr "未选择"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "直接Wi-Fi"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "已中断连接"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index c5ef35f..f430b94 100644 (file)
@@ -115,7 +115,7 @@ msgstr "未選擇任何項目"
 msgid "IDS_COM_OPT1_WI_FI_DIRECT"
 msgstr "Wi-Fi Direct"
 
-msgid "IDS_WFD_POP_DISCONNECTED"
+msgid "IDS_COM_POP_DISCONNECTED"
 msgstr "已中斷連線"
 
 msgid "IDS_WIFI_MBODY_MOBILE_HOTSPOT_VZW"
index 3fbbbdb..c198110 100755 (executable)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "wifi-direct.h"
 #include "wfd-app.h"
 #include "wfd-app-util.h"
-#include "vconf.h"
-
+#include "wfd-app-strings.h"
+#include <vconf.h>
 
+/**
+ *     This function let the app make a callback for connected peer
+ *     @return   TRUE
+ *     @param[in] peer the pointer to the connected peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
 bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
 
        wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
-       if (NULL == ad || NULL == peer || NULL == peer->ssid || NULL == peer->mac_address) {
+       if (NULL == ad || NULL == peer || NULL == peer->device_name || NULL == peer->mac_address) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
                return FALSE;
        }
 
        int peer_cnt = ad->raw_connected_peer_cnt;
-       WFD_APP_LOG(WFD_APP_LOG_LOW, "%dth connected peer. [%s]\n", peer_cnt, peer->ssid);
+       WFD_APP_LOG(WFD_APP_LOG_LOW, "%dth connected peer. [%s]\n", peer_cnt, peer->device_name);
 
-       strncpy(ad->raw_connected_peers[peer_cnt].ssid, peer->ssid, sizeof(ad->raw_connected_peers[peer_cnt].ssid));
+       strncpy(ad->raw_connected_peers[peer_cnt].ssid, peer->device_name, sizeof(ad->raw_connected_peers[peer_cnt].ssid));
        strncpy(ad->raw_connected_peers[peer_cnt].mac_address, peer->mac_address, WFD_MAC_ADDRESS_SIZE);
        WFD_APP_LOG(WFD_APP_LOG_LOW, "\tSSID: [%s]\n", ad->raw_connected_peers[peer_cnt].ssid);
        ad->raw_connected_peer_cnt++;
 
-       free(peer->ssid);
+       free(peer->device_name);
        free(peer->mac_address);
        free(peer);
 
@@ -60,6 +65,11 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_
        return TRUE;
 }
 
+/**
+ *     This function let the app get the connected peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ */
 int _wfd_app_get_connected_peers(void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
@@ -83,6 +93,10 @@ int _wfd_app_get_connected_peers(void *user_data)
        return 0;
 }
 
+/**
+ *     This function let the app delete the notification
+ *     @return   void
+ */
 void _del_wfd_notification()
 {
        __WFD_APP_FUNC_ENTER__;
@@ -90,91 +104,19 @@ void _del_wfd_notification()
        /* delete the notification */
        notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
        noti_err  = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
-       if(noti_err != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_delete_all_by_type.(%d)\n", noti_err);
-               return;
-       }
-
-       __WFD_APP_FUNC_EXIT__;
-}
-
-#if 0
-void _add_wfd_actived_notification(void *user_data)
-{
-       __WFD_APP_FUNC_ENTER__;
-
-       wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
-       if (NULL == ad || NULL == ad->noti) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
-               return;
-       }
-
-       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-
-       /* set the icon */
-       noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON,  RESDIR"/images/A09_notification_icon.png");
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_image. (%d)\n", noti_err);
-               return;
-       }
-
-       /* set the title and content */
-       noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE,
-               "Wi-Fi Direct activated", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       if (noti_err != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err);
-               return;
-       }
-
-       noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-               "Tap to change settings", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err);
-               return;
-       }
-
-       bundle *b = NULL;
-       b = bundle_create();
-       appsvc_set_pkgname(b, PACKAGE);
-       appsvc_add_data(b, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE);
-
-       int res = NOTIFICATION_ERROR_NONE;
-       res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
-       if (res != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res);
-               return;
-       }
-
-       bundle_free(b);
-
-       /* set display application list */
-       noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
-       if(noti_err != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_delete_all_by_type.(%d)\n", noti_err);
                return;
        }
 
-       /* notify the quick panel */
-       if (0 == ad->is_insert) {
-               noti_err = notification_insert(ad->noti, NULL);
-               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_insert.(%d)\n", noti_err);
-                       return;
-               }
-
-               ad->is_insert= 1;
-       } else {
-               noti_err  = notification_update(ad->noti);
-               if (noti_err != NOTIFICATION_ERROR_NONE) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_update. (%d)\n", noti_err);
-                       return;
-               }
-       }
-
        __WFD_APP_FUNC_EXIT__;
 }
-#endif
 
+/**
+ *     This function let the app add the notification when it is connected
+ *     @return   void
+ *     @param[in] user_data the pointer to the main data structure
+ */
 void _add_wfd_peers_connected_notification(void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
@@ -222,7 +164,7 @@ void _add_wfd_peers_connected_notification(void *user_data)
        int res = NOTIFICATION_ERROR_NONE;
        res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
        if (res != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to notification_set_execute_option. [%d]", res);
                return;
        }
 
@@ -230,7 +172,7 @@ void _add_wfd_peers_connected_notification(void *user_data)
 
        /* set display application list */
        noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
-       if(noti_err != NOTIFICATION_ERROR_NONE) {
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err);
                return;
        }
@@ -245,6 +187,11 @@ void _add_wfd_peers_connected_notification(void *user_data)
        __WFD_APP_FUNC_EXIT__;
 }
 
+/**
+ *     This function let the app add the notification when it shoule be turned off
+ *     @return   void
+ *     @param[in] user_data the pointer to the main data structure
+ */
 void _add_wfd_turn_off_notification(void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
@@ -269,14 +216,14 @@ void _add_wfd_turn_off_notification(void *user_data)
 
        /* set the title and content */
        noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE,
-               "Turn off Wi-Fi direct after using", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               "Disable Wi-Fi Direct after use", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err);
                return;
        }
 
        noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT,
-               "To save battery turn off Wi-Fi direct after using", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+               "Disable Wi-Fi Direct after use to save battery", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err);
                return;
@@ -290,7 +237,7 @@ void _add_wfd_turn_off_notification(void *user_data)
        int res = NOTIFICATION_ERROR_NONE;
        res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b);
        if (res != NOTIFICATION_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to notification_set_execute_option. [%d]", res);
                return;
        }
 
@@ -298,7 +245,7 @@ void _add_wfd_turn_off_notification(void *user_data)
 
        /* set display application list */
        noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
-       if(noti_err != NOTIFICATION_ERROR_NONE) {
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err);
                return;
        }
@@ -313,12 +260,16 @@ void _add_wfd_turn_off_notification(void *user_data)
        __WFD_APP_FUNC_EXIT__;
 }
 
+/**
+ *     This function let the app make a callback for deactivating wfd automatically when connected
+ *     @return   if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
+ *     @param[in] user_data the pointer to the main data structure
+ */
 static Eina_Bool _wfd_automatic_deactivated_for_connection_cb(void *user_data)
 {
        int interval = 0;
-       unsigned int transmit_packet = 0;
        int wfd_transfer_state = 0;
-       wfd_appdata_t *ad = (wfd_appdata_t*) user_data;
+       wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
 
        if (NULL == ad) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
@@ -351,223 +302,171 @@ static Eina_Bool _wfd_automatic_deactivated_for_connection_cb(void *user_data)
        return ECORE_CALLBACK_CANCEL;
 }
 
-/* automatic deactivated wfd callback*/
-static Eina_Bool _wfd_automatic_deactivated_for_no_connection_cb(void *user_data)
-{
-       int res = -1;
-       int interval = 0;
-       wfd_appdata_t *ad = (wfd_appdata_t*) user_data;
-
-       if (NULL == ad) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       /* check the action, if action is exist, keep the cb */
-       res = wifi_direct_get_state(&ad->wfd_status);
-       if (res != WIFI_DIRECT_ERROR_NONE) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to get link status. [%d]\n", res);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (ad->last_wfd_status != ad->wfd_status) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Action is exist, last status: %d\n",
-                       ad->last_wfd_status);
-               ad->last_wfd_status = ad->wfd_status;
-               ad->last_wfd_time = time(NULL);
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       /* check the timeout, if not timeout, keep the cb */
-       interval = time(NULL) - ad->last_wfd_time;
-       if (interval < NO_ACTION_TIME_OUT) {
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       /* turn off the Wi-Fi Direct */
-       wifi_direct_get_state(&ad->wfd_status);
-       if (ad->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is already deactivated\n");
-       } else {
-               wfd_prepare_popup(WFD_POP_AUTOMATIC_TURN_OFF, NULL);
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-void _cb_activation(int error_code, wifi_direct_device_state_e device_state,
-                    void *user_data)
+/**
+ *     This function let the app make a callback for registering activation event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] device_state the state of device
+ *     @param[in] user_data the pointer to the main data structure
+ */
+void _cb_activation(int error_code, wifi_direct_device_state_e device_state, void *user_data)
 {
-    __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
 
-    wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+       switch (device_state) {
+       case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
+               break;
 
-    switch (device_state)
-    {
-    case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
-        WFD_APP_LOG(WFD_APP_LOG_LOW,
-                    "event ------------------ WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
-        break;
+       case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Termination process of wifi-direct popup begins...\n");
 
-    case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
-        WFD_APP_LOG(WFD_APP_LOG_LOW,
-                    "event ------------------ WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
-        WFD_APP_LOG(WFD_APP_LOG_LOW,
-                    "Termination process of wifi-direct popup begins...\n");
+               /* when deactivated, stop the timer */
+               if (ad->transmit_timer) {
+                       ecore_timer_del(ad->transmit_timer);
+                       ad->transmit_timer = NULL;
+               }
 
-       /* when deactivated, stop the timer */
-       if (ad->transmit_timer) {
-           ecore_timer_del(ad->transmit_timer);
-           ad->transmit_timer = NULL;
-       }
+               elm_exit();
+               break;
 
-       if (ad->monitor_timer) {
-           ecore_timer_del(ad->monitor_timer);
-           ad->monitor_timer = NULL;
+       default:
+               break;
        }
 
-        elm_exit();
-        break;
-
-    default:
-        break;
-    }
-
-    __WFD_APP_FUNC_EXIT__;
-
+       __WFD_APP_FUNC_EXIT__;
 }
 
-
-static wfd_device_info_t *_wfd_app_find_peer_by_mac_address(void *data,
-                                                         const char *mac_address)
+/**
+ *     This function let the app find the peer by mac address
+ *     @return   the found peer
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] mac_address the pointer to mac address
+ */
+static wfd_device_info_t *_wfd_app_find_peer_by_mac_address(void *data, const char *mac_address)
 {
        __WFD_APP_FUNC_ENTER__;
-
        wfd_appdata_t *ad = (wfd_appdata_t *) data;
-       
        int i;
 
-       if (ad == NULL)
-       {
+       if (ad == NULL) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter(NULL)\n");
                return NULL;
        }
 
        WFD_APP_LOG(WFD_APP_LOG_LOW, "find peer by MAC [%s] \n", mac_address);
 
-       for (i = 0; i < ad->discovered_peer_count; i++)
-       {
+       for (i = 0; i < ad->discovered_peer_count; i++) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "check %dth peer\n", i);
-               
-               if (!strncmp(mac_address, (const char *) ad->discovered_peers[i].mac_address, 18))
-               {
+
+               if (!strncmp(mac_address, (const char *) ad->discovered_peers[i].mac_address, 18)) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "found peer. [%d]\n", i);
                        __WFD_APP_FUNC_EXIT__;
                        return &ad->discovered_peers[i];
                }
        }
-    
-       __WFD_APP_FUNC_EXIT__;
 
-    return NULL;
+       __WFD_APP_FUNC_EXIT__;
+       return NULL;
 }
 
-
-bool _wfd_app_discoverd_peer_cb(wifi_direct_discovered_peer_info_s * peer,
-                            void *user_data)
+/**
+ *     This function let the app make a callback for discovering peer
+ *     @return   TRUE
+ *     @param[in] peer the pointer to the discovered peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
+bool _wfd_app_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
-
        wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
 
-       if (NULL != peer->ssid)
-       {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "discovered peer ssid[%s]\n", peer->ssid);
-               strncpy(ad->discovered_peers[ad->discovered_peer_count].ssid, peer->ssid, 32);
-       }
-       else
-       {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "peer's ssid is NULL\n");
+       if (NULL != peer->device_name) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "discovered peer ssid[%s]\n", peer->device_name);
+               strncpy(ad->discovered_peers[ad->discovered_peer_count].ssid, peer->device_name, 32);
+       } else {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "peer's device name is NULL\n");
        }
 
-       if (NULL != peer->mac_address)
-       {
+       if (NULL != peer->mac_address) {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "discovered peer mac[%s]\n", peer->mac_address);
                strncpy(ad->discovered_peers[ad->discovered_peer_count].mac_address, peer->mac_address, 18);
-       }
-       else
-       {
+       } else {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "peer's mac is NULL\n");
        }
-       
+
        ad->discovered_peer_count++;
 
        __WFD_APP_FUNC_EXIT__;
-       
        return TRUE;
 
 }
 
-
-void _cb_discover(int error_code, wifi_direct_discovery_state_e discovery_state,
-                  void *user_data)
+/**
+ *     This function let the app make a callback for registering discover event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] discovery_state the state of discover
+ *     @param[in] user_data the pointer to the main data structure
+ */
+void _cb_discover(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
-    int ret;
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+       int ret;
 
-    switch (discovery_state)
-    {
+       switch (discovery_state) {
        case WIFI_DIRECT_DISCOVERY_STARTED:
-               {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_STARTED\n");
-               }
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_STARTED\n");
                break;
 
        case WIFI_DIRECT_ONLY_LISTEN_STARTED:
-               {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_ONLY_LISTEN_STARTED\n");
-               }
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_ONLY_LISTEN_STARTED\n");
                break;
 
        case WIFI_DIRECT_DISCOVERY_FINISHED:
-               {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_FINISHED\n");
-               }
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_FINISHED\n");
                break;
 
        case WIFI_DIRECT_DISCOVERY_FOUND:
-               {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_FOUND\n");
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCOVERY_FOUND\n");
 
-                       if (NULL != ad->discovered_peers)
-                               free(ad->discovered_peers);
+               if (NULL != ad->discovered_peers) {
+                       free(ad->discovered_peers);
+                       ad->discovered_peers = NULL;
+               }
 
-                       ad->discovered_peers = calloc(10, sizeof(wfd_device_info_t));
-                       ad->discovered_peer_count = 0;
+               ad->discovered_peers = calloc(10, sizeof(wfd_device_info_t));
+               ad->discovered_peer_count = 0;
 
-                       ret = wifi_direct_foreach_discovered_peers(_wfd_app_discoverd_peer_cb, (void *) ad);
-                       if (ret != WIFI_DIRECT_ERROR_NONE)
-                               WFD_APP_LOG(WFD_APP_LOG_LOW, "get discovery result failed: %d\n", ret);
-               }
+               ret = wifi_direct_foreach_discovered_peers(_wfd_app_discoverd_peer_cb, (void *) ad);
+               if (ret != WIFI_DIRECT_ERROR_NONE) {
+                       WFD_APP_LOG(WFD_APP_LOG_LOW, "get discovery result failed: %d\n", ret);
+               }
                break;
 
        default:
                break;
-    }
-
-    __WFD_APP_FUNC_EXIT__;
+       }
 
+       __WFD_APP_FUNC_EXIT__;
 }
 
-void _cb_connection(int error_code,
-                    wifi_direct_connection_state_e connection_state,
-                    const char *mac_address, void *user_data)
+/**
+ *     This function let the app make a callback for registering connection event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] connection_state the state of connection
+ *     @param[in] mac_address the mac address of peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
+void _cb_connection(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data)
 {
        __WFD_APP_FUNC_ENTER__;
 
-       wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
+       wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
        int result = -1;
        char msg[WFD_POP_STR_MAX_LEN] = {0};
        wfd_device_info_t *peer_info = NULL;
@@ -578,121 +477,104 @@ void _cb_connection(int error_code,
                return;
        }
 
-       strncpy(ad->peer_mac, mac_address, strlen(mac_address));
-
-       peer_info = _wfd_app_find_peer_by_mac_address(ad, mac_address);
-
-       if (NULL == peer_info)
-       {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "peer_info is NULL !!\n");
-       }
-       else if (NULL == peer_info->ssid)
-       {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is NULL !!\n");
-       }
-       else
-       {
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is %s.\n", peer_info->ssid);
-               strncpy(ad->peer_name, peer_info->ssid, strlen(peer_info->ssid));
-       }
+       /* when disconnection, mac_address is empty */
+       if (connection_state <= WIFI_DIRECT_CONNECTION_RSP) {
+               memset(ad->peer_mac, 0, sizeof(ad->peer_mac));
+               memset(ad->peer_name, 0, sizeof(ad->peer_name));
+               strncpy(ad->peer_mac, mac_address, strlen(mac_address));
+               peer_info = _wfd_app_find_peer_by_mac_address(ad, mac_address);
+
+               if (NULL == peer_info) {
+                       WFD_APP_LOG(WFD_APP_LOG_LOW, "peer_info is NULL !!\n");
+               } else if (0 == strlen(peer_info->ssid)) {
+                       WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is invalid !!\n");
+               } else {
+                       WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is %s.\n", peer_info->ssid);
+                       strncpy(ad->peer_name, peer_info->ssid, strlen(peer_info->ssid));
+               }
 
-       if (ad->peer_name == NULL || strlen(ad->peer_name) == 0) {
-               strncpy(ad->peer_name, ad->peer_mac, strlen(ad->peer_mac));
+               if (0 == strlen(ad->peer_name)) {
+                       strncpy(ad->peer_name, ad->peer_mac, strlen(ad->peer_mac));
+               }
        }
 
-       switch (connection_state)
-       {
+       switch (connection_state) {
        case WIFI_DIRECT_CONNECTION_RSP:
        {
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "event ------------------ WIFI_DIRECT_CONNECTION_RSP\n");
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_RSP\n");
                wfd_destroy_popup();
 
-               if (error_code == WIFI_DIRECT_ERROR_NONE)
-               {
+               if (error_code == WIFI_DIRECT_ERROR_NONE) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "Link Complete!\n");
 
                        /* add connected notification */
                        _add_wfd_peers_connected_notification(ad);
 
                        /* tickernoti popup */
-                       snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECTED"), ad->peer_name);
+                       snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECTED, ad->peer_name);
                        wfd_tickernoti_popup(msg);
-               }
-               else
-               {
-                       if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT)
+               } else {
+                       if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                                "Error Code - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT\n");
-                       else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED)
+                       } else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                                "Error Code - WIFI_DIRECT_ERROR_AUTH_FAILED\n");
-                       else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED)
+                       } else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                                "Error Code - WIFI_DIRECT_ERROR_CONNECTION_FAILED\n");
+                       }
 
-                       result = wifi_direct_start_discovery(FALSE, 0);
-                       WFD_APP_LOG(WFD_APP_LOG_LOW,
-                                       "wifi_direct_start_discovery() result=[%d]\n",
-                                       result);
+                       /* tickernoti popup */
+                       snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
+                       wfd_tickernoti_popup(msg);
                }
        }
        break;
 
        case WIFI_DIRECT_CONNECTION_WPS_REQ:
        {
-               wifi_direct_config_data_s *config = NULL;
+               wifi_direct_wps_type_e wps_mode;
 
                memcpy(ad->peer_mac, mac_address, sizeof(ad->peer_mac));
 
                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                "event ------------------ WIFI_DIRECT_CONNECTION_WPS_REQ\n");
-               result = wifi_direct_get_config_data(&config);
+               result = wifi_direct_get_wps_type(&wps_mode);
                WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "wifi_direct_client_get_config_data() result=[%d]\n",
-                               result);
+                               "wifi_direct_get_wps_type() result=[%d]\n", result);
 
-               if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PBC)
-               {
+               if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW,
                                        "wps_config is WIFI_DIRECT_WPS_TYPE_PBC. Ignore it..\n");
-               }
-               else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
-               {
+               } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
                        char *pin;
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n");
 
-                       if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE)
-                       {
+                       if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n");
                                return;
                        }
 
-                       if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE)
-                       {
+                       if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n");
                                return;
                        }
-                       strncpy(ad->pin_number, pin, 32);
+
+                       strncpy(ad->pin_number, pin, 64);
                        free(pin);
-                       pin=NULL;
+                       pin = NULL;
 
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "pin=[%s]\n", ad->pin_number);
 
                        wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
-               }
-               else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
-               {
+               } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n");
                        wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
-               }
-               else
-               {
+               } else {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is unkown!\n");
 
                }
-               if (config != NULL)
-                       free(config);
        }
        break;
 
@@ -700,45 +582,31 @@ void _cb_connection(int error_code,
        {
                WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_REQ\n");
 
-               wifi_direct_config_data_s *config = NULL;
+               wifi_direct_wps_type_e wps_mode;
+               bool auto_connection_mode;
+
+               result = wifi_direct_get_wps_type(&wps_mode);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_get_wps_type() result=[%d]\n", result);
 
-               result = wifi_direct_get_config_data(&config);
-               WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_client_get_config_data() result=[%d]\n", result);
+               result = wifi_direct_is_autoconnection_mode(&auto_connection_mode);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_is_autoconnection_mode() result=[%d]\n", result);
 
-               if(config->auto_connection == TRUE)
-               {
+               if (auto_connection_mode == TRUE) {
                        result = wifi_direct_accept_connection(ad->peer_mac);
                        printf("wifi_direct_accept_connection() result=[%d]\n", result);
-               }
-               else
-               {
-
-                       if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PBC)
-                       {
-                               char pushbutton;
+               } else {
+                       if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PBC\n");
-
                                wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ, NULL);
-                       }
-                       else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
-                       {
+                       } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n");
-
                                wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ, NULL);
-                       }
-                       else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
-                       {
+                       } else if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n");
                                wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, (void *) NULL);
-                       }
-                       else
-                       {
+                       } else {
                                WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is unkown!\n");
                        }
-
-                       if (config != NULL)
-                               free(config);
-
                }
        }
        break;
@@ -746,14 +614,13 @@ void _cb_connection(int error_code,
        case WIFI_DIRECT_DISCONNECTION_IND:
        {
                _del_wfd_notification();
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n");
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n");
 
                result = wifi_direct_set_autoconnection_mode(false);
-               WFD_APP_LOG(WFD_APP_LOG_LOW,"wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
 
                /* tickernoti popup */
-               snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name);
+               snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_DISCONNECTED, ad->peer_name);
                wfd_tickernoti_popup(msg);
        }
        break;
@@ -764,21 +631,16 @@ void _cb_connection(int error_code,
                wfd_destroy_popup();
 
                result = wifi_direct_set_autoconnection_mode(false);
-               WFD_APP_LOG(WFD_APP_LOG_LOW,"wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
-
-               result = wifi_direct_start_discovery(FALSE, 0);
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "wifi_direct_start_discovery() result=[%d]\n", result);
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_set_autoconnection_mode() result=[%d]\n", result);
 
                /* tickernoti popup */
-               snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name);
+               snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_DISCONNECTED, ad->peer_name);
                wfd_tickernoti_popup(msg);
        }
        break;
        case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
        {
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "event ------------------ WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
                /* tickernoti popup */
                wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECTING"));
        }
@@ -787,118 +649,188 @@ void _cb_connection(int error_code,
 
        }
 
-       /* if connected, switch to the transmit timer; Otherwise, switch to monitor timer */
+       /* if connected, start the transmit timer */
        wifi_direct_get_state(&ad->wfd_status);
-       WFD_APP_LOG(WFD_APP_LOG_LOW,"status: %d", ad->wfd_status);
-
-       if (ad->wfd_status > WIFI_DIRECT_STATE_CONNECTING) {
-               if (ad->monitor_timer) {
-                       ecore_timer_del(ad->monitor_timer);
-                       ad->monitor_timer = NULL;
-               }
+       WFD_APP_LOG(WFD_APP_LOG_LOW, "status: %d", ad->wfd_status);
 
+       if (ad->wfd_status < WIFI_DIRECT_STATE_CONNECTED) {
+           if (ad->transmit_timer) {
+                   ecore_timer_del(ad->transmit_timer);
+                   ad->transmit_timer = NULL;
+           }
+       } else {
                if (NULL == ad->transmit_timer) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "switch to the transmit timer\n");
+                       WFD_APP_LOG(WFD_APP_LOG_LOW, "start the transmit timer\n");
                        ad->last_wfd_transmit_time = time(NULL);
                        ad->transmit_timer = ecore_timer_add(5.0,
-                                       (Ecore_Task_Cb)_wfd_automatic_deactivated_for_connection_cb, ad);
-               }
-       } else {
-               if (ad->transmit_timer) {
-                       ecore_timer_del(ad->transmit_timer);
-                       ad->transmit_timer = NULL;
+                               (Ecore_Task_Cb)_wfd_automatic_deactivated_for_connection_cb, ad);
                }
+       }
 
-               if (NULL == ad->monitor_timer) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "switch to the monitor timer\n");
-                       ad->last_wfd_time = time(NULL);
-                       ad->monitor_timer = ecore_timer_add(5.0,
-                                       (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad);
+       __WFD_APP_FUNC_EXIT__;
+}
+
+/**
+ *     This function let the app make a change callback for flight mode
+ *     @return   void
+ *     @param[in] key the pointer to the key
+ *     @param[in] user_data the pointer to the main data structure
+ */
+static void _wfd_flight_mode_changed(keynode_t *node, void *user_data)
+{
+       __WFD_APP_FUNC_ENTER__;
+       int res = -1;
+       int flight_mode = 0;
+       wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
+
+       if (NULL == ad) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "NULL parameters.\n");
+               return;
+       }
+
+       res = vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &flight_mode);
+       if (res != 0) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to get flight state from vconf. [%d]\n", res);
+               return;
+       }
+
+       if (flight_mode == FALSE) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Flight mode is off\n");
+               return;
+       }
+
+       /* If flight mode is on, turn off WFD */
+       wifi_direct_get_state(&ad->wfd_status);
+       if (WIFI_DIRECT_STATE_DEACTIVATED == ad->wfd_status) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is deactivated.\n");
+               return;
+       }
+
+       /*if connected, disconnect all devices*/
+       if (WIFI_DIRECT_STATE_CONNECTED == ad->wfd_status) {
+               res = wifi_direct_disconnect_all();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
+                       return;
                }
        }
 
+       res = wifi_direct_deactivate();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
+               return;
+       }
+
        __WFD_APP_FUNC_EXIT__;
 }
 
-
-int init_wfd_popup_client(wfd_appdata_t * ad)
+/**
+ *     This function let the app do initialization
+ *     @return   If success, return TRUE, else return FALSE
+ *     @param[in] ad the pointer to the main data structure
+ */
+int init_wfd_popup_client(wfd_appdata_t *ad)
 {
-    __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_ENTER__;
 
-    if (NULL == ad) {
-       WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
-       return FALSE;
-    }
+       if (NULL == ad) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
+               return FALSE;
+       }
 
-    int ret = -1;
+       int ret = -1;
 
-    ret = wifi_direct_initialize();
+       ret = wifi_direct_initialize();
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to initialize Wi-Fi Direct. error code = [%d]\n", ret);
+               return FALSE;
+       }
 
-    ret = wifi_direct_set_device_state_changed_cb(_cb_activation, (void *) ad);
-    ret = wifi_direct_set_discovery_state_changed_cb(_cb_discover, (void *) ad);
-    ret =
-        wifi_direct_set_connection_state_changed_cb(_cb_connection,
-                                                    (void *) ad);
+       ret = wifi_direct_set_device_state_changed_cb(_cb_activation, (void *)ad);
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register _cb_activation. error code = [%d]\n", ret);
+               return FALSE;
+       }
 
-    /* initialize notification */
-    ad->noti = NULL;
-    ad->raw_connected_peer_cnt = 0;
+       ret = wifi_direct_set_discovery_state_changed_cb(_cb_discover, (void *)ad);
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register _cb_discover. error code = [%d]\n", ret);
+               return FALSE;
+       }
 
-    ad->noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
-    if (NULL == ad->noti) {
-       WFD_APP_LOG(WFD_APP_LOG_LOW, "notification_new failed.\n");
-       return FALSE;
-    }
+       ret = wifi_direct_set_connection_state_changed_cb(_cb_connection, (void *)ad);
+       if (ret != WIFI_DIRECT_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register _cb_connection. error code = [%d]\n", ret);
+               return FALSE;
+       }
 
-    /* start the monitor timer */
-    ad->last_wfd_time = time(NULL);
-    ad->last_wfd_status = WIFI_DIRECT_STATE_DEACTIVATED;
-    ad->monitor_timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad);
+       /* initialize notification */
+       ad->noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
+       if (NULL == ad->noti) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "notification_new failed.\n");
+               return FALSE;
+       }
 
-    __WFD_APP_FUNC_EXIT__;
+       /* register flight mode */
+       int result = -1;
+       result = vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, _wfd_flight_mode_changed, ad);
+       if (result == -1) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to register vconf callback for flight mode\n");
+               return FALSE;
+       }
+
+       __WFD_APP_FUNC_EXIT__;
 
-    if (ret == WIFI_DIRECT_ERROR_NONE)
-        return TRUE;
-    else
-        return FALSE;
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               return TRUE;
+       } else {
+               return FALSE;
+       }
 }
 
-int deinit_wfd_popup_client(wfd_appdata_t * ad)
+/**
+ *     This function let the app do de-initialization
+ *     @return   If success, return TRUE, else return FALSE
+ *     @param[in] ad the pointer to the main data structure
+ */
+int deinit_wfd_popup_client(wfd_appdata_t *ad)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    if (NULL == ad || NULL == ad->noti) {
-       WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
-       return FALSE;
-    }
+       __WFD_APP_FUNC_ENTER__;
 
-    int ret = -1;
+       if (NULL == ad || NULL == ad->noti) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n");
+               return FALSE;
+       }
 
-    ret = wifi_direct_deinitialize();
+       int ret = -1;
 
-    _del_wfd_notification(ad);
+       ret = wifi_direct_deinitialize();
 
-    notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
-    noti_err = notification_free(ad->noti);
-    if (noti_err != NOTIFICATION_ERROR_NONE) {
-       WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_free.(%d)\n", noti_err);
-       ret = WIFI_DIRECT_ERROR_RESOURCE_BUSY;
-    }
+       _del_wfd_notification(ad);
+       notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+       noti_err = notification_free(ad->noti);
+       if (noti_err != NOTIFICATION_ERROR_NONE) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_free.(%d)\n", noti_err);
+               ret = WIFI_DIRECT_ERROR_RESOURCE_BUSY;
+       }
 
-    if (ad->transmit_timer) {
-       ecore_timer_del(ad->transmit_timer);
-       ad->transmit_timer = NULL;
-    }
+       /* remove callback for flight mode */
+       int result = -1;
+       result = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wfd_flight_mode_changed);
+       if (result == -1) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to ignore vconf key callback for flight mode\n");
+       }
 
-    if (ad->monitor_timer) {
-       ecore_timer_del(ad->monitor_timer);
-       ad->monitor_timer = NULL;
-    }
+       if (ad->transmit_timer) {
+               ecore_timer_del(ad->transmit_timer);
+               ad->transmit_timer = NULL;
+       }
 
-    __WFD_APP_FUNC_EXIT__;
+       __WFD_APP_FUNC_EXIT__;
 
-    if (ret == WIFI_DIRECT_ERROR_NONE)
-        return TRUE;
-    else
-        return FALSE;
+       if (ret == WIFI_DIRECT_ERROR_NONE) {
+               return TRUE;
+       } else {
+               return FALSE;
+       }
 }
index 16dd365..d14fa1c 100755 (executable)
@@ -38,188 +38,170 @@ wfd_appdata_t *g_wfd_ad;
 
 wfd_appdata_t *wfd_get_appdata()
 {
-    return g_wfd_ad;
+       return g_wfd_ad;
 }
 
-static void _win_del(void *data, Evas_Object * obj, void *event)
+static void _win_del(void *data, Evas_Object *obj, void *event)
 {
-    elm_exit();
+       elm_exit();
 }
 
-static Evas_Object *_create_win(Evas_Object * parent, const char *name)
+static Evas_Object *_create_win(Evas_Object *parent, const char *name)
 {
-    Evas_Object *eo;
-    int w, h;
-
-    /* eo = elm_win_add(parent, name, ELM_WIN_BASIC); */
-    eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION);
-    if (eo)
-    {
-        elm_win_title_set(eo, name);
-        elm_win_borderless_set(eo, EINA_TRUE);
-        elm_win_alpha_set(eo, EINA_TRUE);
-        evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
-        ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
-        evas_object_resize(eo, w, h);
-        evas_object_raise(eo);
-    }
-
-    return eo;
-}
+       Evas_Object *eo;
+       int w, h;
+
+       /* eo = elm_win_add(parent, name, ELM_WIN_BASIC); */
+       eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION);
+       if (eo) {
+               elm_win_title_set(eo, name);
+               elm_win_borderless_set(eo, EINA_TRUE);
+               elm_win_alpha_set(eo, EINA_TRUE);
+               evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
+               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+               evas_object_resize(eo, w, h);
+               evas_object_raise(eo);
+       }
 
+       return eo;
+}
 
 static int _app_create(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = wfd_get_appdata();
-
-    if (data == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
-        return -1;
-    }
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = wfd_get_appdata();
 
-    bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR);
+       if (data == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
+               return -1;
+       }
 
-    ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
-    if (!ad->popup_data)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "malloc failed\n");
-        return -1;
-    }
-    memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
+       bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR);
 
-    ad->win = _create_win(NULL, PACKAGE);
-    elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t));
+       if (!ad->popup_data) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "malloc failed\n");
+               return -1;
+       }
 
-    int r;
+       memset(ad->popup_data, 0x0, sizeof(wfd_popup_t));
+       ad->win = _create_win(NULL, PACKAGE);
+       elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
 
-    if (!ecore_x_display_get())
-        return -1;
+       int r;
 
-    r = appcore_set_i18n(PACKAGE, NULL);
-    if (r != 0)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
-        return -1;
-    }
+       if (!ecore_x_display_get()) {
+               return -1;
+       }
 
-    if (init_wfd_popup_client(ad) == FALSE)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "init_wfd_popup_client error\n");
-        wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
-    }
+       r = appcore_set_i18n(PACKAGE, NULL);
+       if (r != 0) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
+               return -1;
+       }
 
-    __WFD_APP_FUNC_EXIT__;
+       if (init_wfd_popup_client(ad) == FALSE) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "init_wfd_popup_client error\n");
+               wfd_prepare_popup(WFD_POP_FAIL_INIT, NULL);
+       }
 
-    return 0;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 static int _app_terminate(void *data)
 {
        __WFD_APP_FUNC_ENTER__;
 
-       if (data == NULL)
-       {
+       if (data == NULL) {
                WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
                return -1;
        }
 
        wfd_appdata_t *ad = (wfd_appdata_t *) data;
 
-       if (deinit_wfd_popup_client(ad) == FALSE)
-       {
+       if (deinit_wfd_popup_client(ad) == FALSE) {
                WFD_APP_LOG(WFD_APP_LOG_ERROR, "deinit_wfd_popup_client error\n");
-       }
-       else
-       {
-               if (ad->popup)
-               {
+       } else {
+               if (ad->popup) {
                        evas_object_del(ad->popup);
                        ad->popup = NULL;
                }
-               if (ad->win)
-               {
+               if (ad->win) {
                        evas_object_del(ad->win);
                        ad->win = NULL;
                }
-               if (ad->discovered_peers)
-               {
+               if (ad->discovered_peers) {
                        free(ad->discovered_peers);
                        ad->discovered_peers = NULL;
                }
        }
 
        __WFD_APP_FUNC_EXIT__;
-
        return 0;
 }
 
 static int _app_pause(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 static int _app_resume(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
-static int _app_reset(bundle * b, void *data)
+static int _app_reset(bundle *b, void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = (wfd_appdata_t*) data;
-
-    if(b == NULL)
-    {
-       WFD_APP_LOG(WFD_APP_LOG_LOW,"Bundle is NULL");
-        return -1;
-    }
-    // From Notification
-    char *noti_type = NULL;
-    noti_type = (char*) appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM);
-    if (noti_type == NULL)
-    {
-       WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is wrong.");
-       return -1;
-    }
-    WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is [%s]", noti_type);
-    if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM))==0)
-    {
-       WFD_APP_LOG(WFD_APP_LOG_LOW,"Launch wifidirect-ugapp");
-       service_h service;
-       service_create(&service);
-       service_set_operation(service, SERVICE_OPERATION_DEFAULT);
-       service_set_package(service, "org.tizen.wifi-direct-ugapp");
-       service_send_launch_request(service, NULL, NULL);
-       service_destroy(service);
-    }
-
-
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_ENTER__;
+
+       if (b == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Bundle is NULL");
+               return -1;
+       }
+
+       // From Notification
+       char *noti_type = NULL;
+       noti_type = (char *)appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM);
+
+       if (noti_type == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Notification type is wrong.");
+               return -1;
+       }
+
+       WFD_APP_LOG(WFD_APP_LOG_LOW, "Notification type is [%s]", noti_type);
+       if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM)) == 0) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Launch wifidirect-ugapp");
+               service_h service;
+               service_create(&service);
+               service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+               service_set_package(service, "org.tizen.wifi-direct-ugapp");
+               service_send_launch_request(service, NULL, NULL);
+               service_destroy(service);
+       }
+
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 int main(int argc, char *argv[])
 {
-    wfd_appdata_t ad;
-    struct appcore_ops ops = {
-        .create = _app_create,
-        .terminate = _app_terminate,
-        .pause = _app_pause,
-        .resume = _app_resume,
-        .reset = _app_reset,
-    };
-
-    memset(&ad, 0x0, sizeof(wfd_appdata_t));
-    ops.data = &ad;
-    g_wfd_ad = &ad;
-
-    return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+       wfd_appdata_t ad;
+       struct appcore_ops ops = {
+               .create = _app_create,
+               .terminate = _app_terminate,
+               .pause = _app_pause,
+               .resume = _app_resume,
+               .reset = _app_reset,
+       };
+
+       memset(&ad, 0x0, sizeof(wfd_appdata_t));
+       ops.data = &ad;
+       g_wfd_ad = &ad;
+
+       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 }
index b3bde5a..624c806 100755 (executable)
@@ -41,20 +41,24 @@ static Ecore_Timer *pb_timer = NULL;
 
 void wfd_tickernoti_popup(char *msg);
 
+/**
+ *     This function let the ug make a callback for click the button in popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
 {
        __WFD_APP_FUNC_ENTER__;
-
        wfd_appdata_t *ad = wfd_get_appdata();
        int result = -1;
        int resp = (int) data;
-       Evas_Object *btn = obj;
        char msg[WFD_POP_STR_MAX_LEN] = {0};
 
        WFD_APP_LOG(WFD_APP_LOG_HIGH, "popup resp : %d\n", resp);
 
-       switch (resp)
-       {
+       switch (resp) {
        case /* MT */ WFD_POP_RESP_APRV_CONNECT_PBC_YES:
        {
                WFD_APP_LOG(WFD_APP_LOG_HIGH,
@@ -65,91 +69,74 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                "wifi_direct_accept_connection() result=[%d]\n",
                                result);
-               if (result == WIFI_DIRECT_ERROR_NONE)
-               {
+               if (result == WIFI_DIRECT_ERROR_NONE) {
                        /* tickernoti popup */
                        wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECTING"));
-               }
-               else
-               {
+               } else {
                        WFD_APP_LOG(WFD_APP_LOG_ERROR,
                                        "wifi_direct_accept_connection() FAILED!!\n");
                        evas_object_hide(ad->win);
 
                        /* tickernoti popup */
-                       snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name);
+                       snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
                        wfd_tickernoti_popup(msg);
                }
        }
        break;
 
-       case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES:
+       case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK:
        {
                char *pin = NULL;
 
                WFD_APP_LOG(WFD_APP_LOG_HIGH,
-                               "WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES\n");
+                               "WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK\n");
                wfd_destroy_popup();
-               if (pb_timer) {
-                       ecore_timer_del(pb_timer);
-                       pb_timer = NULL;
-               }
 
-               if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE)
-               {
+               if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n");
                        return;
                }
 
-               if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE)
-               {
+               if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n");
                        return;
                }
-               strncpy(ad->pin_number, pin, 32);
+
+               strncpy(ad->pin_number, pin, 64);
                free(pin);
                pin = NULL;
-
                WFD_APP_LOG(WFD_APP_LOG_LOW, "button ok: pin [%s]", ad->pin_number);
 
                result = wifi_direct_accept_connection(ad->peer_mac);
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "wifi_direct_accept_connection() failed. result=[%d]\n",
-                               result);
-               if (result == WIFI_DIRECT_ERROR_NONE)
-               {
-                       evas_object_hide(ad->win);
+               if (result == WIFI_DIRECT_ERROR_NONE) {
                        wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
-               }
-               else
-               {
+               } else {
+                       WFD_APP_LOG(WFD_APP_LOG_LOW,
+                               "wifi_direct_accept_connection() failed. result=[%d]\n", result);
                        /* tickernoti popup */
-                       wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECT_FAILED"));
+                       wfd_tickernoti_popup(IDS_WFD_POP_CONNECT_FAILED);
                }
        }
        break;
 
        case /* MO */ WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK:
-       case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES:
        {
                WFD_APP_LOG(WFD_APP_LOG_HIGH,
-                               "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n");
+                               "WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK\n");
+
                wfd_destroy_popup();
 
                int len = strlen(ad->pin_number);
                WFD_APP_LOG(WFD_APP_LOG_LOW, "button ok: pin [%s]", ad->pin_number);
 
-               if (len > 7 && len < 64)
-               {
+               if (len > 7 && len < 64) {
                        int result = 0;
                        WFD_APP_LOG(WFD_APP_LOG_LOW, "pin=[%s]\n", ad->pin_number);
 
                        result = wifi_direct_set_wps_pin(ad->pin_number);
-
-                       if (result != WIFI_DIRECT_ERROR_NONE)
-                       {
+                       if (result != WIFI_DIRECT_ERROR_NONE) {
                                /* tickernoti popup */
-                               snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name);
+                               snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
                                wfd_tickernoti_popup(msg);
                                return;
                        }
@@ -159,19 +146,16 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
                        WFD_APP_LOG(WFD_APP_LOG_LOW,
                                        "wifi_direct_accept_connection(%s) result=[%d]\n",
                                        ad->peer_mac, result);
-                       if (result != WIFI_DIRECT_ERROR_NONE)
-                       {
+                       if (result != WIFI_DIRECT_ERROR_NONE) {
                                WFD_APP_LOG(WFD_APP_LOG_ERROR,
                                                "wifi_direct_accept_connection() FAILED!!\n");
                                evas_object_hide(ad->win);
 
                                /* tickernoti popup */
-                               snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name);
+                               snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
                                wfd_tickernoti_popup(msg);
                        }
-               }
-               else
-               {
+               } else {
                        WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error, Incorrect PIN!!\n");
 
                        /* tickernoti popup */
@@ -189,71 +173,35 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
        }
        break;
 
-       case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO:
+       case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES:
        {
                WFD_APP_LOG(WFD_APP_LOG_HIGH,
-                               "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n");
-
+                               "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n");
                wfd_destroy_popup();
                if (pb_timer) {
                        ecore_timer_del(pb_timer);
                        pb_timer = NULL;
                }
 
-               result = wifi_direct_disconnect(ad->peer_mac);
-               WFD_APP_LOG(WFD_APP_LOG_LOW,
-                               "wifi_direct_disconnect[%s] result=[%d]\n",
-                               ad->peer_mac, result);
+               wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
        }
        break;
 
-       case WFD_POP_RESP_PROG_CONNECT_CANCEL:
+       case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO:
        {
-               WFD_APP_LOG(WFD_APP_LOG_HIGH, "WFD_POP_RESP_PROG_CONNECT_CANCEL\n");
+               WFD_APP_LOG(WFD_APP_LOG_HIGH,
+                               "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n");
+
                wfd_destroy_popup();
+               if (pb_timer) {
+                       ecore_timer_del(pb_timer);
+                       pb_timer = NULL;
+               }
 
                result = wifi_direct_disconnect(ad->peer_mac);
                WFD_APP_LOG(WFD_APP_LOG_LOW,
                                "wifi_direct_disconnect[%s] result=[%d]\n",
                                ad->peer_mac, result);
-
-               if (result == WIFI_DIRECT_ERROR_NONE)
-               {
-                       /* tickernoti popup */
-                       snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name);
-                       wfd_tickernoti_popup(msg);
-               }
-               else
-               {
-                       WFD_APP_LOG(WFD_APP_LOG_ERROR,
-                                       "wifi_direct_disconnect() FAILED!!\n");
-
-                       /* tickernoti popup */
-                       snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECT_FAILED"), ad->peer_name);
-                       wfd_tickernoti_popup(msg);
-               }
-       }
-       break;
-
-       case WFD_POP_RESP_AUTOMATIC_TURNOFF_OK:
-       {
-               WFD_APP_LOG(WFD_APP_LOG_HIGH, "WFD_POP_RESP_AUTOMATIC_TURNOFF_OK\n");
-
-               /* turn off the Wi-Fi Direct */
-               result = wifi_direct_get_state(&ad->wfd_status);
-               if (result != WIFI_DIRECT_ERROR_NONE) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to get link status. [%d]\n", result);
-                       return;
-               }
-
-               if (ad->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
-                       WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is already deactivated\n");
-               } else {
-                       ad->wfd_status = WIFI_DIRECT_STATE_DEACTIVATING;
-                       wifi_direct_deactivate();
-               }
-
-               wfd_destroy_popup();
        }
        break;
 
@@ -268,310 +216,186 @@ static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
        __WFD_APP_FUNC_EXIT__;
 }
 
-static Evas_Object *__create_progress_layout(Evas_Object * parent,
-                                             const char *text)
-{
-    __WFD_APP_FUNC_ENTER__;
-
-    if (parent == NULL || text == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "param is NULL\n");
-        return NULL;
-    }
-
-    Evas_Object *progressbar = NULL, *layout = NULL;
-    Evas_Object *label = NULL;
-    int w = 0, h = 0;
-
-    layout = elm_layout_add(parent);
-    if (layout == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "layout is NULL\n");
-        return NULL;
-    }
-
-    elm_layout_file_set(layout, EDJ_NAME, "progress_popup");
-    evas_object_size_hint_weight_set(layout,
-                                     EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-    progressbar = elm_progressbar_add(layout);
-    if (progressbar == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "progressbar is NULL\n");
-        evas_object_del(layout);
-        return NULL;
-    }
-    elm_object_style_set(progressbar, "list_process");
-    evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
-    evas_object_size_hint_weight_set(progressbar,
-                                     EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_part_content_set(layout, "popup_pb", progressbar);
-    elm_progressbar_pulse(progressbar, EINA_TRUE);
-
-    label = elm_label_add(layout);
-    if (label == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "label is NULL\n");
-        evas_object_del(layout);
-        evas_object_del(progressbar);
-        return NULL;
-    }
-    elm_object_style_set(label, "popup_description/default");
-    elm_object_part_content_set(layout, "popup_progress_text", label);
-    edje_object_part_geometry_get(layout, "popup_progress_text", NULL, NULL, &w,
-                                  &h);
-    elm_label_line_wrap_set(label, ELM_WRAP_WORD);
-    elm_label_wrap_width_set(label, w);
-    elm_object_text_set(label, text);
-
-    evas_object_show(layout);
-
-    __WFD_APP_FUNC_EXIT__;
-
-    return layout;
-}
-
-
+/**
+ *     This function let the app destroy the popup
+ *     @return   void
+ *     @param[in] null
+ */
 void wfd_destroy_popup()
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = wfd_get_appdata();
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = wfd_get_appdata();
 
-    if (ad == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "ad is NULL\n");
-        return;
-    }
+       if (ad == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "ad is NULL\n");
+               return;
+       }
 
-    if (ad->popup)
-    {
-        evas_object_del(ad->popup);
-        ad->popup = NULL;
-    }
+       if (ad->popup) {
+               evas_object_del(ad->popup);
+               ad->popup = NULL;
+       }
 
-    if (ad->popup_timeout_handle > 0)
-    {
-        g_source_remove(ad->popup_timeout_handle);
-        ad->popup_timeout_handle = 0;
-    }
+       if (ad->popup_timeout_handle > 0) {
+               g_source_remove(ad->popup_timeout_handle);
+               ad->popup_timeout_handle = 0;
+       }
 
-    evas_object_hide(ad->win);
+       evas_object_hide(ad->win);
 
-    __WFD_APP_FUNC_EXIT__;
-    return;
+       __WFD_APP_FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the app create a popup which includes no button
+ *     @return   popup
+ *     @param[in] win the window object
+ *     @param[in] pop the pointer to the prepared popup
+ */
 static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop)
-{                               //no button with spin
-    __WFD_APP_FUNC_ENTER__;
-
-    Evas_Object *popup;
+{
+       __WFD_APP_FUNC_ENTER__;
+       Evas_Object *popup;
 
-    popup = elm_popup_add(win);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_text_set(popup, pop->text);
-    elm_popup_timeout_set(popup, pop->timeout);
-    evas_object_show(popup);
-    evas_object_show(win);
+       popup = elm_popup_add(win);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_text_set(popup, pop->text);
+       elm_popup_timeout_set(popup, pop->timeout);
+       evas_object_show(popup);
+       evas_object_show(win);
 
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
+       __WFD_APP_FUNC_EXIT__;
+       return popup;
 }
 
+/**
+ *     This function let the app create a popup which includes one button
+ *     @return   popup
+ *     @param[in] win the window object
+ *     @param[in] pop the pointer to the prepared popup
+ */
 static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop)
-{                               //one button with spin
-    __WFD_APP_FUNC_ENTER__;
-
-    Evas_Object *popup = NULL;
-    Evas_Object *btn = NULL;
+{
+       __WFD_APP_FUNC_ENTER__;
+       Evas_Object *popup = NULL;
+       Evas_Object *btn = NULL;
 
-    popup = elm_popup_add(win);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_text_set(popup, pop->text);
+       popup = elm_popup_add(win);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_text_set(popup, pop->text);
 
-    btn = elm_button_add(popup);
-    elm_object_style_set(btn, "popup_button/default");
-    elm_object_text_set(btn, pop->label1);
-    elm_object_part_content_set(popup, "button1", btn);
-    evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data1);
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup_button/default");
+       elm_object_text_set(btn, pop->label1);
+       elm_object_part_content_set(popup, "button1", btn);
+       evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb, (void *) pop->resp_data1);
 
-    evas_object_show(popup);
-    evas_object_show(win);
+       evas_object_show(popup);
+       evas_object_show(win);
 
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
+       __WFD_APP_FUNC_EXIT__;
+       return popup;
 }
 
+/**
+ *     This function let the app create a popup which includes two buttons
+ *     @return   popup
+ *     @param[in] win the window object
+ *     @param[in] pop the pointer to the prepared popup
+ */
 static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop)
-{                               //two button
-    __WFD_APP_FUNC_ENTER__;
-
-    Evas_Object *popup = NULL;
-    Evas_Object *btn1 = NULL, *btn2 = NULL;
-
-    popup = elm_popup_add(win);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_text_set(popup, pop->text);
-
-    btn1 = elm_button_add(popup);
-    elm_object_style_set(btn1, "popup_button/default");
-    elm_object_text_set(btn1, pop->label1);
-    elm_object_part_content_set(popup, "button1", btn1);
-    evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data1);
-
-    btn2 = elm_button_add(popup);
-    elm_object_style_set(btn2, "popup_button/default");
-    elm_object_text_set(btn2, pop->label2);
-    elm_object_part_content_set(popup, "button2", btn2);
-    evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data2);
-
-    evas_object_show(popup);
-    evas_object_show(win);
-
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
-}
-
-static Evas_Object *wfd_draw_pop_type_d(Evas_Object * win, wfd_popup_t * pop)
-{                               //text with spin
-    __WFD_APP_FUNC_ENTER__;
-
-    Evas_Object *popup;
-    Evas_Object *layout;
-
-    popup = elm_popup_add(win);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_style_set(popup, "customstyle");
-    layout = __create_progress_layout(popup, pop->text);
-    elm_popup_timeout_set(popup, pop->timeout);
-    elm_object_content_set(popup, layout);
-    evas_object_show(popup);
-    evas_object_show(win);
-
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
-}
-
-static void __popup_block_clicked_cb(void *data, Evas_Object * obj,
-                                     void *event_info)
 {
-    wfd_appdata_t *ad = wfd_get_appdata();
-    wfd_popup_t *pop = NULL;
-
-    if (ad != NULL)
-        pop = ad->popup;
-
-    if (ad->win != NULL)
-        evas_object_hide(ad->win);
+       __WFD_APP_FUNC_ENTER__;
+       Evas_Object *popup = NULL;
+       Evas_Object *btn1 = NULL, *btn2 = NULL;
+
+       popup = elm_popup_add(win);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_text_set(popup, pop->text);
+
+       btn1 = elm_button_add(popup);
+       elm_object_style_set(btn1, "popup_button/default");
+       elm_object_text_set(btn1, pop->label1);
+       elm_object_part_content_set(popup, "button1", btn1);
+       evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
+               (void *) pop->resp_data1);
+
+       btn2 = elm_button_add(popup);
+       elm_object_style_set(btn2, "popup_button/default");
+       elm_object_text_set(btn2, pop->label2);
+       elm_object_part_content_set(popup, "button2", btn2);
+       evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
+               (void *) pop->resp_data2);
+
+       evas_object_show(popup);
+       evas_object_show(win);
 
-    if (ad->popup_timeout_handle > 0)
-    {
-        g_source_remove(ad->popup_timeout_handle);
-        ad->popup_timeout_handle = 0;
-    }
+       __WFD_APP_FUNC_EXIT__;
+       return popup;
 }
 
-gboolean __popup_remove_timeout_cb(gpointer user_data)
+/**
+ *     This function let the ug make a change callback for password input
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    wfd_appdata_t *ad = wfd_get_appdata();
-    wfd_popup_t *pop = NULL;
-
-    if (ad != NULL)
-        pop = ad->popup;
-    else
-        return false;
-
-    if (pop != user_data)
-        return false;
-
-    if (ad->win != NULL)
-        evas_object_hide(ad->win);
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = wfd_get_appdata();
 
-    ad->popup_timeout_handle = 0;
-    return false;
-}
+       Ecore_IMF_Context *imf_context = NULL;
+       imf_context = (Ecore_IMF_Context *) ad->pin_entry;
 
-static Evas_Object *wfd_draw_pop_type_e(Evas_Object * win, wfd_popup_t * pop)
-{
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = wfd_get_appdata();
-    Evas_Object *popup;
-
-    if (ad == NULL)
-        return NULL;
-
-    popup = elm_popup_add(win);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_text_set(popup, pop->text);
-    evas_object_smart_callback_add(popup, "block,clicked",
-                                   __popup_block_clicked_cb, NULL);
-    ad->popup_timeout_handle =
-        g_timeout_add(3000, __popup_remove_timeout_cb, popup);
-    evas_object_show(popup);
-    evas_object_show(win);
-
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
-}
+       if (NULL == imf_context) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error!!! Ecore_IMF_Context is NULL!!");
+               return;
+       }
 
+       const char *txt = elm_entry_markup_to_utf8(elm_entry_entry_get((const Evas_Object *) imf_context));
+       if (NULL != txt) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "* text [%s], len=[%d]", txt, strlen(txt));
+               strncpy(ad->pin_number, txt, sizeof(ad->pin_number));
+       } else {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Err!");
+       }
 
-static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
-{
-    __WFD_APP_FUNC_ENTER__;
-    wfd_appdata_t *ad = wfd_get_appdata();
-
-    Ecore_IMF_Context *imf_context = NULL;
-    imf_context = (Ecore_IMF_Context *) ad->pin_entry;
-
-    if (NULL == imf_context)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error!!! Ecore_IMF_Context is NULL!!");
-        return;
-    }
-
-    const char *txt =
-        elm_entry_markup_to_utf8(elm_entry_entry_get
-                                 ((const Evas_Object *) imf_context));
-
-    if (NULL != txt)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "* text [%s], len=[%d]", txt, strlen(txt));
-        strncpy(ad->pin_number, txt, sizeof(ad->pin_number));
-    }
-    else
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "Err!");
-    }
-
-    __WFD_APP_FUNC_EXIT__;
+       __WFD_APP_FUNC_EXIT__;
 }
 
-
-//#ifdef HIDE_PIN_NUMBER
-#if 1
+/**
+ *     This function let the app make a change callback for password checkbox
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _check_changed_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    wfd_appdata_t *ad = wfd_get_appdata();
+       wfd_appdata_t *ad = wfd_get_appdata();
 
-    if (obj == NULL)
-        return;
+       if (obj == NULL) {
+               return;
+       }
 
-    Eina_Bool state = elm_check_state_get(obj);
-    elm_entry_password_set(ad->pin_entry, !state);
+       Eina_Bool state = elm_check_state_get(obj);
+       elm_entry_password_set(ad->pin_entry, !state);
 }
-#endif
 
+/**
+ *     This function let the app make a callback for progressbar timer
+ *     @return   if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
+ *     @param[in] data the pointer to the wps structure
+ */
 static Eina_Bool _fn_pb_timer(void *data)
 {
        int step = 0;
        double value = 0.0;
        char time_label[32] = {0};
-       wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t*) data;
+       wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t *) data;
 
        if (NULL == wps_display_popup) {
                WFD_APP_LOG(WFD_APP_LOG_ERROR, "Param is NULL.\n");
@@ -587,6 +411,11 @@ static Eina_Bool _fn_pb_timer(void *data)
 
        if (value >= 1.0) {
                WFD_APP_LOG(WFD_APP_LOG_ERROR, "Progress end.\n");
+               if (pb_timer) {
+                       ecore_timer_del(pb_timer);
+                       pb_timer = NULL;
+               }
+               wfd_destroy_popup();
                return ECORE_CALLBACK_CANCEL;
        }
 
@@ -616,7 +445,16 @@ static Eina_Bool _fn_pb_timer(void *data)
        return ECORE_CALLBACK_RENEW;
 }
 
-static Evas_Object * _add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
+/**
+ *     This function let the app create a edit filed
+ *     @return   edit filed
+ *     @param[in] parent the parent object
+ *     @param[in] title the pointer to the title of edit field
+ *     @param[in] guide the pointer to the text of guide
+ *     @param[in] single_line whether it can support single line
+ *     @param[in] is_editable whether it is avaliable to edit
+ */
+static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
 {
        assertm_if(NULL == parent, "parent is NULL!!");
 
@@ -626,8 +464,7 @@ static Evas_Object * _add_edit_field(Evas_Object *parent, const char *title, con
        if (title && title[0] != '\0') {
                elm_layout_theme_set(layout, "layout", "editfield", "title");
                elm_object_part_text_set(layout, "elm.text", title);
-       }
-       else {
+       } else {
                elm_layout_theme_set(layout, "layout", "editfield", "default");
        }
 
@@ -650,202 +487,216 @@ static Evas_Object * _add_edit_field(Evas_Object *parent, const char *title, con
        return layout;
 }
 
+/**
+ *     This function let the app create a display popup
+ *     @return   display popup
+ *     @param[in] win the window object
+ *     @param[in] pop the pointer to the prepared popup
+ */
 Evas_Object *wfd_draw_pop_type_display(Evas_Object * win, wfd_popup_t * pop)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    Evas_Object *popup = NULL;
-    Evas_Object *label = NULL;
-    Evas_Object *layout = NULL;
-    Evas_Object *progressbar = NULL;
-    Evas_Object *time = NULL;
-    Evas_Object *btn1 = NULL;
-    Evas_Object *btn2 = NULL;
-    static wfd_wps_display_popup_t wps_display_popup;
-
-    popup = elm_popup_add(win);
-    elm_object_style_set(popup, "customstyle");
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0);
-
-    Evas_Object *box = elm_box_add(popup);
-    if (!box) {
-       evas_object_del(popup);
-       popup = NULL;
-       return NULL;
-    }
-
-    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
-    elm_object_part_content_set(popup, NULL, box);
-    evas_object_show(box);
-
-    /* add label */
-    label = elm_label_add(box);
-    elm_object_style_set(label, "popup/default");
-    elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
-    elm_object_text_set(label, pop->text);
-    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0);
-    elm_box_pack_end(box, label);
-    evas_object_show(label);
-
-    /* add progressbar */
-    progressbar = elm_progressbar_add(box);
-    elm_object_style_set(progressbar, "list_progress");
-    elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
-    evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.0);
-    evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, 0.0);
-    elm_progressbar_value_set(progressbar, 0.0);
-    elm_box_pack_end(box, progressbar);
-    evas_object_show(progressbar);
-
-    /* add time */
-    time = elm_label_add(box);
-    elm_object_style_set(time, "popup/default");
-    elm_object_text_set(time, "00:00");
-    evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(time, EVAS_HINT_FILL, 0.0);
-    elm_box_pack_end(box, time);
-    evas_object_show(time);
-
-    /* start progressbar timer */
-    wps_display_popup.step = 0;
-    wps_display_popup.progressbar= progressbar;
-    wps_display_popup.time = time;
-    pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup);
-
-    /* add cancel buttons */
-    btn1 = elm_button_add(popup);
-    elm_object_style_set(btn1, "popup_button/default");
-    elm_object_text_set(btn1, pop->label1);
-    elm_object_part_content_set(popup, "button1", btn1);
-    evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data1);
-
-    btn2 = elm_button_add(popup);
-    elm_object_style_set(btn2, "popup_button/default");
-    elm_object_text_set(btn2, pop->label2);
-    elm_object_part_content_set(popup, "button2", btn2);
-    evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data2);
-
-    elm_object_content_set(popup, box);
-    evas_object_show(popup);
-    evas_object_show(win);
-
-    __WFD_APP_FUNC_EXIT__;
-    return popup;
+       __WFD_APP_FUNC_ENTER__;
+
+       Evas_Object *popup = NULL;
+       Evas_Object *label = NULL;
+       Evas_Object *progressbar = NULL;
+       Evas_Object *time = NULL;
+       static wfd_wps_display_popup_t wps_display_popup;
+
+       popup = elm_popup_add(win);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0);
+
+       Evas_Object *box = elm_box_add(popup);
+       if (!box) {
+               evas_object_del(popup);
+               popup = NULL;
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
+       elm_object_part_content_set(popup, NULL, box);
+       evas_object_show(box);
+
+       /* add label */
+       label = elm_label_add(box);
+       elm_object_style_set(label, "popup/default");
+       elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+       elm_object_text_set(label, pop->text);
+       evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0);
+       elm_box_pack_end(box, label);
+       evas_object_show(label);
+
+       /* add progressbar */
+       progressbar = elm_progressbar_add(box);
+       elm_object_style_set(progressbar, "list_progress");
+       elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
+       evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.0);
+       evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, 0.0);
+       elm_progressbar_value_set(progressbar, 0.0);
+       elm_box_pack_end(box, progressbar);
+       evas_object_show(progressbar);
+
+       /* add time */
+       time = elm_label_add(box);
+       elm_object_style_set(time, "popup/default");
+       elm_object_text_set(time, "00:00");
+       evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(time, EVAS_HINT_FILL, 0.0);
+       elm_box_pack_end(box, time);
+       evas_object_show(time);
+
+       /* start progressbar timer */
+       wps_display_popup.step = 0;
+       wps_display_popup.progressbar = progressbar;
+       wps_display_popup.time = time;
+       pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup);
+
+       /* add buttons */
+       if (pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES ||
+               pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_NO) {
+               Evas_Object *btn1 = NULL;
+               btn1 = elm_button_add(popup);
+               elm_object_style_set(btn1, "popup_button/default");
+               elm_object_text_set(btn1, pop->label1);
+               elm_object_part_content_set(popup, "button1", btn1);
+               evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
+                       (void *) pop->resp_data1);
+       }
+
+       if (pop->resp_data2 == WFD_POP_RESP_APRV_CONNECT_NO) {
+               Evas_Object *btn2 = NULL;
+               btn2 = elm_button_add(popup);
+               elm_object_style_set(btn2, "popup_button/default");
+               elm_object_text_set(btn2, pop->label2);
+               elm_object_part_content_set(popup, "button2", btn2);
+               evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
+                       (void *) pop->resp_data2);
+       }
+
+       elm_object_content_set(popup, box);
+       evas_object_show(popup);
+       evas_object_show(win);
+
+       __WFD_APP_FUNC_EXIT__;
+       return popup;
 }
 
+/**
+ *     This function let the app create a keypad popup
+ *     @return   keypad popup
+ *     @param[in] win the window object
+ *     @param[in] pop the pointer to the prepared popup
+ */
 Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop)
 {
-    __WFD_APP_FUNC_ENTER__;
-    wfd_appdata_t *ad = wfd_get_appdata();
-
-    Evas_Object *conformant = NULL;
-    Evas_Object *layout = NULL;
-    Evas_Object *pinpopup = NULL;
-    Evas_Object *label = NULL;
-    Evas_Object *btn1 = NULL, *btn2 = NULL;
-
-    conformant = elm_conformant_add(win);
-    assertm_if(NULL == conformant, "conformant is NULL!!");
-    elm_win_conformant_set(win, EINA_TRUE);
-    elm_win_resize_object_add(win, conformant);
-    evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, 0.0);
-    evas_object_show(conformant);
-
-    layout = elm_layout_add(conformant);
-    elm_object_content_set(conformant, layout);
-
-    pinpopup = elm_popup_add(layout);
-    assertm_if(NULL == pinpopup, "pinpopup is NULL!!");
-    elm_object_style_set(pinpopup, "customstyle");
-    evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, 0.0);
-    elm_object_part_text_set(pinpopup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION"));
-
-    Evas_Object *box = elm_box_add(pinpopup);
-    if (!box) {
-       evas_object_del(pinpopup);
-       pinpopup = NULL;
-       return NULL;
-    }
-
-    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
-    elm_object_part_content_set(pinpopup, NULL, box);
-    evas_object_show(box);
-
-    /* add label */
-    label = elm_label_add(box);
-    elm_object_style_set(label, "popup/default");
-    elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
-    elm_object_text_set(label, pop->text);
-    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_box_pack_end(box, label);
-    evas_object_show(label);
-
-    /* add password */
-    Evas_Object *body = elm_layout_add(box);
-    if (!body) {
-       evas_object_del(pinpopup);
-       pinpopup = NULL;
-       return NULL;
-    }
-
-    elm_layout_theme_set(body, "layout", "dialogue", "1icon");
-    evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(body, EVAS_HINT_FILL, 0.0);
-
-    Evas_Object *editfield_pin = _add_edit_field(body, NULL, NULL, EINA_TRUE, EINA_TRUE);
-    Evas_Object *entry_pin = elm_object_part_content_get(editfield_pin, "elm.swallow.content");
-    ad->pin_entry = entry_pin;
-    evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, NULL);
-    elm_object_part_content_set(body, "elm.icon", editfield_pin);
-    elm_box_pack_end(box, body);
-    evas_object_show(body);
-
-//#ifdef HIDE_PIN_NUMBER
-#if 1
-    elm_entry_password_set(ad->pin_entry, TRUE);
-
-    Evas_Object *check = elm_check_add(box);
-    elm_object_text_set(check, _("Show password"));
-    elm_object_focus_allow_set(check, EINA_FALSE);
-    evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0.0);
-    evas_object_smart_callback_add(check, "changed", _check_changed_cb, NULL);
-    evas_object_show(check);
-    elm_box_pack_end(box, check);
-#endif
-
-    /* add buttons */
-    btn1 = elm_button_add(pinpopup);
-    elm_object_style_set(btn1, "popup_button/default");
-    elm_object_text_set(btn1, pop->label1);
-    elm_object_part_content_set(pinpopup, "button1", btn1);
-    evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data1);
-
-    btn2 = elm_button_add(pinpopup);
-    elm_object_style_set(btn2, "popup_button/default");
-    elm_object_text_set(btn2, pop->label2);
-    elm_object_part_content_set(pinpopup, "button2", btn2);
-    evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
-                                   (void *) pop->resp_data2);
-
-    elm_object_content_set(pinpopup, box);
-    evas_object_show(pinpopup);
-    evas_object_show(win);
-    elm_object_focus_set(ad->pin_entry, EINA_TRUE);
-
-    __WFD_APP_FUNC_EXIT__;
-
-    return pinpopup;
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = wfd_get_appdata();
+
+       Evas_Object *conformant = NULL;
+       Evas_Object *layout = NULL;
+       Evas_Object *pinpopup = NULL;
+       Evas_Object *label = NULL;
+       Evas_Object *btn1 = NULL, *btn2 = NULL;
+
+       conformant = elm_conformant_add(win);
+       assertm_if(NULL == conformant, "conformant is NULL!!");
+       elm_win_conformant_set(win, EINA_TRUE);
+       elm_win_resize_object_add(win, conformant);
+       evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, 0.0);
+       evas_object_show(conformant);
+
+       layout = elm_layout_add(conformant);
+       elm_object_content_set(conformant, layout);
+
+       pinpopup = elm_popup_add(layout);
+       assertm_if(NULL == pinpopup, "pinpopup is NULL!!");
+       evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, 0.0);
+       elm_object_part_text_set(pinpopup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION"));
+
+       Evas_Object *box = elm_box_add(pinpopup);
+       if (!box) {
+               evas_object_del(pinpopup);
+               pinpopup = NULL;
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
+       elm_object_part_content_set(pinpopup, NULL, box);
+       evas_object_show(box);
+
+       /* add label */
+       label = elm_label_add(box);
+       elm_object_style_set(label, "popup/default");
+       elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+       elm_object_text_set(label, pop->text);
+       evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_box_pack_end(box, label);
+       evas_object_show(label);
+
+       /* add password */
+       Evas_Object *body = elm_layout_add(box);
+       if (!body) {
+               evas_object_del(pinpopup);
+               pinpopup = NULL;
+               return NULL;
+       }
+
+       elm_layout_theme_set(body, "layout", "dialogue", "1icon");
+       evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(body, EVAS_HINT_FILL, 0.0);
+
+       Evas_Object *editfield_pin = _add_edit_field(body, NULL, NULL, EINA_TRUE, EINA_TRUE);
+       Evas_Object *entry_pin = elm_object_part_content_get(editfield_pin, "elm.swallow.content");
+       ad->pin_entry = entry_pin;
+       evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, NULL);
+       elm_object_part_content_set(body, "elm.icon", editfield_pin);
+       elm_box_pack_end(box, body);
+       evas_object_show(body);
+
+       elm_entry_password_set(ad->pin_entry, TRUE);
+
+       Evas_Object *check = elm_check_add(box);
+       elm_object_text_set(check, _("Show password"));
+       elm_object_focus_allow_set(check, EINA_FALSE);
+       evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
+       evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0.0);
+       evas_object_smart_callback_add(check, "changed", _check_changed_cb, NULL);
+       evas_object_show(check);
+       elm_box_pack_end(box, check);
+
+       /* add buttons */
+       btn1 = elm_button_add(pinpopup);
+       elm_object_style_set(btn1, "popup_button/default");
+       elm_object_text_set(btn1, pop->label1);
+       elm_object_part_content_set(pinpopup, "button1", btn1);
+       evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, (void *)pop->resp_data1);
+
+       btn2 = elm_button_add(pinpopup);
+       elm_object_style_set(btn2, "popup_button/default");
+       elm_object_text_set(btn2, pop->label2);
+       elm_object_part_content_set(pinpopup, "button2", btn2);
+       evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, (void *)pop->resp_data2);
+
+       elm_object_content_set(pinpopup, box);
+       evas_object_show(pinpopup);
+       evas_object_show(win);
+       elm_object_focus_set(ad->pin_entry, EINA_TRUE);
+
+       __WFD_APP_FUNC_EXIT__;
+       return pinpopup;
 }
 
+/**
+ *     This function let the app create a popup
+ *     @return   void
+ *     @param[in] type the type of popup
+ *     @param[in] userdata the pointer to the data which will be used
+ */
 void wfd_prepare_popup(int type, void *userdata)
 {
        __WFD_APP_FUNC_ENTER__;
@@ -858,123 +709,79 @@ void wfd_prepare_popup(int type, void *userdata)
 
        pop->type = type;
 
-       switch (pop->type)
-       {
-
+       switch (pop->type) {
        case /* MT */ WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ:
-       {
-               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q, // WFD_STR_POP_APRV_CONNECT4
+               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q,
                                ad->peer_name);
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // IDS_WFD_BUTN_YES
-               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES"));
+               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO"));
                pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES;
                pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
 
                ad->popup = wfd_draw_pop_type_c(ad->win, pop);
-       }
-       break;
+               break;
 
        case /* MT */ WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ:
-       {
-               char *pin = (char *) userdata;
-               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q, //WFD_STR_POP_APRV_CONNECT4"<br>PIN:%s"
-                               ad->peer_name, WFD_POP_TIMER_120, ad->pin_number);
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // IDS_WFD_BUTN_YES
-               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO
+               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN_WITH_KEYPAD,
+                               ad->peer_name);
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
-               pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES;
+               pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK;
                pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
 
-               ad->popup = wfd_draw_pop_type_display(ad->win, pop);
-       }
-       break;
+               ad->popup = wfd_draw_pop_type_c(ad->win, pop);
+               break;
 
-       case /*MO/MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ:
-       {
-               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN, // WFD_STR_POP_APRV_CONNECT4
-                               ad->peer_name, WFD_POP_TIMER_120, ad->peer_name);
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // IDS_WFD_BUTN_YES
-               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO
+       case /* MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ:
+               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN,
+                               ad->peer_name, WFD_POP_TIMER_120);
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
                pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES;
                pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
 
-               ad->popup = wfd_draw_pop_type_keypad(ad->win, pop);
-       }
-       break;
+               ad->popup = wfd_draw_pop_type_display(ad->win, pop);
+               break;
 
        case /* MT */ WFD_POP_PROG_CONNECT:
-       {
-               snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTING")); // WFD_STR_POP_PROG_CONNECT
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL
+               snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTING"));
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
-               pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL;
+               pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
 
                ad->popup = wfd_draw_pop_type_b(ad->win, pop);
-       }
-       break;
+               break;
 
        case /* MO */ WFD_POP_PROG_CONNECT_WITH_KEYPAD:
-       {
-               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN, // WFD_STR_POP_ENTER_PIN
+               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_KEYPAD,
                                ad->peer_name, WFD_POP_TIMER_120, ad->peer_name);
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK")); // WFD_STR_BTN_OK
-               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
+               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
                pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK;
                pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
 
                ad->popup = wfd_draw_pop_type_keypad(ad->win, pop);
-       }
-       break;
+               break;
 
        case /* MO/MT */ WFD_POP_PROG_CONNECT_WITH_PIN:
-               snprintf(pop->text, sizeof(pop->text), "%s %s", IDS_WFD_POP_CONNECTING_WITH_PIN, ad->pin_number); // WFD_STR_POP_PROG_CONNECT_WITH_PIN
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL
+               snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_PIN,
+                       ad->peer_name, WFD_POP_TIMER_120, ad->pin_number);
+               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
-               pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL;
+               pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
 
-               ad->popup = wfd_draw_pop_type_b(ad->win, pop);
-               break;
+               ad->popup = wfd_draw_pop_type_display(ad->win, pop);
+               break;
 
        case WFD_POP_PROG_CONNECT_CANCEL:
-       {
-               snprintf(pop->text, sizeof(pop->text), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_POP_PROG_CANCEL
+               snprintf(pop->text, sizeof(pop->text), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
                pop->timeout = WFD_POP_TIMER_120;
                ad->popup = wfd_draw_pop_type_a(ad->win, pop);
-       }
-       break;
-
-       case WFD_POP_INCORRECT_PIN:
-               snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_PIN_INVALID")); // WFD_STR_POP_INVALID_PIN
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK")); // WFD_STR_BTN_OK
-               pop->timeout = WFD_POP_TIMER_3;
-               pop->resp_data1 = WFD_POP_RESP_OK;
-               break;
-
-       case WFD_POP_NOTI_CONNECTED:
-               snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTED")); // WFD_STR_POP_NOTI_CONNECTED
-               pop->timeout = WFD_POP_TIMER_3;
+               break;
 
-               ad->popup = wfd_draw_pop_type_e(ad->win, pop);
-               break;
-
-       case WFD_POP_FAIL_CONNECT:
-               snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_DISCONNECT_FAILED")); // IDS_WFD_POP_DISCONNECT_FAILED
-               pop->timeout = WFD_POP_TIMER_3;
-
-               ad->popup = wfd_draw_pop_type_e(ad->win, pop);
-               break;
-       case WFD_POP_AUTOMATIC_TURN_OFF:
-               snprintf(pop->text, sizeof(pop->text), "%s", IDS_WFD_POP_AUTOMATIC_TURN_OFF);
-               snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
-               snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
-               pop->timeout = WFD_POP_TIMER_120;
-               pop->resp_data1 = WFD_POP_RESP_AUTOMATIC_TURNOFF_OK;
-
-               ad->popup = wfd_draw_pop_type_b(ad->win, pop);
-
-               break;
        default:
                break;
        }
@@ -983,6 +790,11 @@ void wfd_prepare_popup(int type, void *userdata)
        return;
 }
 
+/**
+ *     This function let the app create a tickernoti syspopup
+ *     @return   void
+ *     @param[in] msg the pointer to message of tickernoti
+ */
 void wfd_tickernoti_popup(char *msg)
 {
        __WFD_APP_FUNC_ENTER__;
index d584917..8efb237 100644 (file)
 char *wfd_app_trim_path(const char *filewithpath)
 {
 #if 0
-    char *filename = NULL;
-    if ((filename = strrchr(filewithpath, '/')) == NULL)
-        return (char *) filewithpath;
-    else
-        return (filename + 1);
+       char *filename = NULL;
+       if ((filename = strrchr(filewithpath, '/')) == NULL)
+           return (char *) filewithpath;
+       else
+           return (filename + 1);
 #else
-    static char *filename[100];
-    char *strptr = NULL;
-    int start = 0;
-    const char *space = "                                        ";
-    int len = strlen(filewithpath);
+       static char *filename[100];
+       char *strptr = NULL;
+       int start = 0;
+       const char *space = "                                        ";
+       int len = strlen(filewithpath);
 
-    if (len > 20)
-    {
-        strptr = (char *) filewithpath + (len - 20);
-        start = 0;
-    }
-    else if (len < 20)
-    {
-        strptr = (char *) filewithpath;
-        start = 20 - len;
-    }
-    strncpy((char *) filename, space, strlen(space));
-    strncpy((char *) filename + start, strptr, 50);
+       if (len > 20) {
+               strptr = (char *) filewithpath + (len - 20);
+               start = 0;
+       } else if (len < 20) {
+               strptr = (char *) filewithpath;
+               start = 20 - len;
+       }
 
-    return (char *) filename;
+       strncpy((char *) filename, space, strlen(space));
+       strncpy((char *) filename + start, strptr, 50);
+
+       return (char *) filename;
 #endif
 }
 
@@ -67,10 +65,9 @@ char *wfd_app_trim_path(const char *filewithpath)
 int wfd_app_gettid()
 {
 #ifdef __NR_gettid
-    return syscall(__NR_gettid);
+       return syscall(__NR_gettid);
 #else
-    fprintf(stderr,
-            "__NR_gettid is not defined, please include linux/unistd.h ");
-    return -1;
+       fprintf(stderr, "__NR_gettid is not defined, please include linux/unistd.h ");
+       return -1;
 #endif
 }
index 2e65b2e..067fb08 100644 (file)
 #define __WFD_CLIENT_H__
 
 
-typedef enum
-{
-    WFD_DEVICE_TYPE_COMPUTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER, // 1
-    WFD_DEVICE_TYPE_INPUT_DEVICE= WIFI_DIRECT_PRIMARY_DEVICE_TYPE_INPUT_DEVICE,
-    WFD_DEVICE_TYPE_PRINTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_PRINTER,
-    WFD_DEVICE_TYPE_CAMERA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_CAMERA,
-    WFD_DEVICE_TYPE_STORAGE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE, // 5
-    WFD_DEVICE_TYPE_NW_INFRA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_NETWORK_INFRA,
-    WFD_DEVICE_TYPE_DISPLAYS = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY,
-    WFD_DEVICE_TYPE_MM_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_MULTIMEDIA_DEVICE,
-    WFD_DEVICE_TYPE_GAME_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_GAME_DEVICE,
-    WFD_DEVICE_TYPE_TELEPHONE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE, // 10
-    WFD_DEVICE_TYPE_AUDIO = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_AUDIO,
-    WFD_DEVICE_TYPE_OTHER =  WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER, // 255
+typedef enum {
+       WFD_DEVICE_TYPE_COMPUTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER,
+       WFD_DEVICE_TYPE_INPUT_DEVICE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_INPUT_DEVICE,
+       WFD_DEVICE_TYPE_PRINTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_PRINTER,
+       WFD_DEVICE_TYPE_CAMERA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_CAMERA,
+       WFD_DEVICE_TYPE_STORAGE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE,
+       WFD_DEVICE_TYPE_NW_INFRA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_NETWORK_INFRA,
+       WFD_DEVICE_TYPE_DISPLAYS = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY,
+       WFD_DEVICE_TYPE_MM_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_MULTIMEDIA_DEVICE,
+       WFD_DEVICE_TYPE_GAME_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_GAME_DEVICE,
+       WFD_DEVICE_TYPE_TELEPHONE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE,
+       WFD_DEVICE_TYPE_AUDIO = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_AUDIO,
+       WFD_DEVICE_TYPE_OTHER =  WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER,
 } device_type_e;
 
 typedef enum {
-    WFD_LINK_STATUS_DEACTIVATED = WIFI_DIRECT_STATE_DEACTIVATED, // 0
-    WFD_LINK_STATUS_DEACTIVATING = WIFI_DIRECT_STATE_DEACTIVATING,
-    WFD_LINK_STATUS_ACTIVATING = WIFI_DIRECT_STATE_ACTIVATING,
-    WFD_LINK_STATUS_ACTIVATED = WIFI_DIRECT_STATE_ACTIVATED,
-    WFD_LINK_STATUS_DISCOVERING = WIFI_DIRECT_STATE_DISCOVERING,
-    WFD_LINK_STATUS_CONNECTING = WIFI_DIRECT_STATE_CONNECTING, // 5
-    WFD_LINK_STATUS_DISCONNECTING = WIFI_DIRECT_STATE_DISCONNECTING,
-    WFD_LINK_STATUS_CONNECTED = WIFI_DIRECT_STATE_CONNECTED,
-    WFD_LINK_STATUS_GROUP_OWNER = WIFI_DIRECT_STATE_GROUP_OWNER,
+       WFD_LINK_STATUS_DEACTIVATED = WIFI_DIRECT_STATE_DEACTIVATED,
+       WFD_LINK_STATUS_DEACTIVATING = WIFI_DIRECT_STATE_DEACTIVATING,
+       WFD_LINK_STATUS_ACTIVATING = WIFI_DIRECT_STATE_ACTIVATING,
+       WFD_LINK_STATUS_ACTIVATED = WIFI_DIRECT_STATE_ACTIVATED,
+       WFD_LINK_STATUS_DISCOVERING = WIFI_DIRECT_STATE_DISCOVERING,
+       WFD_LINK_STATUS_CONNECTING = WIFI_DIRECT_STATE_CONNECTING,
+       WFD_LINK_STATUS_DISCONNECTING = WIFI_DIRECT_STATE_DISCONNECTING,
+       WFD_LINK_STATUS_CONNECTED = WIFI_DIRECT_STATE_CONNECTED,
+       WFD_LINK_STATUS_GROUP_OWNER = WIFI_DIRECT_STATE_GROUP_OWNER,
 } link_status_e;
 
+/**
+ *     This function let the ug get wi-fi direct status from vconf
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_get_vconf_status(void *data);
+
+/**
+ *     This function let the ug turn wifi off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_wifi_off(void *data);
+
+/**
+ *     This function let the ug turn AP on
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_mobile_ap_on(void *data);
+
+/**
+ *     This function let the ug turn AP off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_mobile_ap_off(void *data);
+
+/**
+ *     This function let the ug do initialization
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int init_wfd_client(void *data);
+
+/**
+ *     This function let the ug do de-initialization
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int deinit_wfd_client(void *data);
-int wfd_client_start_discovery(void *data);
+
+/**
+ *     This function let the ug turn wi-fi direct on
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_client_switch_on(void *data);
+
+/**
+ *     This function let the ug turn wi-fi direct off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_client_switch_off(void *data);
+
+/**
+ *     This function let the ug turn wi-fi direct on/off forcely
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+  *    @param[in] onoff whether to turn on/off wi-fi direct
+ */
 int wfd_client_swtch_force(void *data, int onoff);
+
+/**
+ *     This function let the ug create a group
+ *     @return   If success, return 0, else return -1
+ */
+int wfd_client_group_add();
+
+/**
+ *     This function let the ug connect to the device by mac address
+ *     @return   If success, return 0, else return -1
+ *     @param[in] mac_addr the pointer to the mac address of device
+ */
 int wfd_client_connect(const char *mac_addr);
+
+/**
+ *     This function let the ug disconnect to the device by mac address
+ *     @return   If success, return 0, else return -1
+ *     @param[in] mac_addr the pointer to the mac address of device
+ */
 int wfd_client_disconnect(const char *mac_addr);
+
+/**
+ *     This function let the ug set the intent of a group owner
+ *     @return   If success, return 0, else return -1
+ *     @param[in] go_intent the intent parameter
+ */
 int wfd_client_set_p2p_group_owner_intent(int go_intent);
 
 #endif /* __WFD_CLIENT_H__ */
index be905df..bf6d3f0 100755 (executable)
 #include <dlog.h>
 #include <ui-gadget-module.h>
 #include <tethering.h>
+#include <wifi-direct.h>
 
 #define PACKAGE "ug-setting-wifidirect-efl"
 #define LOCALEDIR "/usr/ug/res/locale"
 
 #define DIRECT_TAG  "wfd_ug"
 #define DBG(log_level, format, args...) \
-       LOG(log_level, DIRECT_TAG, "[%s()][%d] " format, __FUNCTION__, __LINE__, ##args)
+       LOG(log_level, DIRECT_TAG, "[%s()][%d] " format, __FUNCTION__, __LINE__, ##args)
 
 #define __FUNC_ENTER__  DBG(LOG_VERBOSE, "+\n")
 #define __FUNC_EXIT__   DBG(LOG_VERBOSE, "-\n")
 
-#define VCONF_WFD_APNAME                       "db/setting/device_name"
+#define VCONF_WFD_APNAME                       "db/setting/device_name"
 
 #define assertm_if(expr, fmt, arg...) do { \
-   if(expr) { \
+       if (expr) { \
          DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
                 assert(1); \
-   } \
-} while (0)                    // retvm if
+       } \
+} while (0)
 
 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
 
-#define AP_NAME_LENGTH_MAX             32      //allowed lenght is 31 + '\0'
-#define AP_PASSWORD_LENGTH_MAX 64      //allowed lenght is 63 + '\0'
-#define AP_PASSWORD_LENGTH_MIN 8       //min limit
+#define AP_NAME_LENGTH_MAX             32
+#define AP_PASSWORD_LENGTH_MAX 64
+#define AP_PASSWORD_LENGTH_MIN 8
 #define AP_REJECT_CHAR_LIST            "=,"
 
-#define DEFAULT_DEV_NAME        "GT_I9500"
+#define DEFAULT_DEV_NAME        "Tizen"
 #define MAC_LENGTH  18
 #define SSID_LENGTH 32
 #define MAX_PEER_NUM 10
 #define MAX_POPUP_PEER_NUM 7
 #define MAX_POPUP_TEXT_SIZE 256
 #define MAX_DISPLAY_TIME_OUT   30
+#define MAX_NO_ACTION_TIME_OUT 300            /*5min*/
+#define MAX_SCAN_TIME_OUT 30
 
 #define _(s)        dgettext(PACKAGE, s)
 #define N_(s)      dgettext_noop(s)
 #define S_(s)      dgettext("sys_string", s)
 
-
-#if 1  //To-Do : Text should be translated.
-
-#define IDS_WFD_POP_SCAN_AGAIN "To start new scanning,<br>current connection will be<br>ended.Continue?"
+#if 1
+/* To-Do : Text should be translated. */
+#define IDS_WFD_POP_SCAN_AGAIN "Current connection will be disconnected so that scanning can start.Continue?"
 #define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
+#define IDS_WFD_POP_AUTOMATIC_TURN_OFF "There has been no activity for 5 minutes since Wi-Fi Direct was enabled. To extend battery life, Wi-Fi Direct has been disabled."
 #define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
+#define IDS_WFD_TITLE_ABOUT_WIFI_DIRECT "About Wi-Fi Direct"
 #endif
 
 
@@ -82,145 +85,142 @@ typedef enum {
        WFD_MULTI_CONNECT_MODE_COMPLETED,
 } wfd_multi_connect_mode_e;
 
-typedef enum
-{
-    PEER_CONN_STATUS_DISCONNECTED,
-    PEER_CONN_STATUS_DISCONNECTING,
-    PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
-    PEER_CONN_STATUS_CONNECTED,
-    PEER_CONN_STATUS_FAILED_TO_CONNECT,
-    PEER_CONN_STATUS_WAIT_FOR_CONNECT,
+typedef enum {
+       PEER_CONN_STATUS_DISCONNECTED,
+       PEER_CONN_STATUS_DISCONNECTING,
+       PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
+       PEER_CONN_STATUS_CONNECTED,
+       PEER_CONN_STATUS_FAILED_TO_CONNECT,
+       PEER_CONN_STATUS_WAIT_FOR_CONNECT,
 } conn_status_e;
 
 
-typedef struct
-{
-    char ssid[SSID_LENGTH];    // 31 + 1('\0')
-    unsigned int category;
-    char mac_addr[MAC_LENGTH];
-    char if_addr[MAC_LENGTH];
-    conn_status_e conn_status;
-    bool is_group_owner;  /** Is an active P2P Group Owner */
-    bool is_persistent_group_owner;  /** Is a stored Persistent GO */
-    bool is_connected;  /** Is peer connected*/
-    Elm_Object_Item *gl_item;
+typedef struct {
+       char ssid[SSID_LENGTH];
+       unsigned int category;
+       char mac_addr[MAC_LENGTH];
+       char if_addr[MAC_LENGTH];
+       conn_status_e conn_status;
+       bool is_group_owner;  /** Is an active P2P Group Owner */
+       bool is_persistent_group_owner;  /** Is a stored Persistent GO */
+       bool is_connected;  /** Is peer connected*/
+       Elm_Object_Item *gl_item;
 } device_type_s;
 
-typedef struct
-{
-    bool dev_sel_state;
-    device_type_s peer;
+typedef struct {
+       bool dev_sel_state;
+       device_type_s peer;
 } wfd_multi_sel_data_s;
 
-struct ug_data
-{
-    Evas_Object *base;
-    ui_gadget_h ug;
-
-    Evas_Object *win;
-    Evas_Object *bg;
-    Evas_Object *naviframe;
-    Evas_Object *genlist;
-    Evas_Object *multiconn_view_genlist;
-    Evas_Object *popup;
-    Evas_Object *act_popup;
-    Evas_Object *warn_popup;
-
-    Elm_Object_Item *head;
-    Elm_Object_Item *scan_btn;
-    Elm_Object_Item *multi_scan_btn;
-    Elm_Object_Item *multi_connect_btn;
-
-    Elm_Object_Item *nodevice_title_item;
-    Elm_Object_Item *nodevice_item;
-    Elm_Object_Item *nodevice_sep_low_item;
+struct ug_data {
+       Evas_Object *base;
+       ui_gadget_h ug;
 
-    Elm_Object_Item *about_wfd_item;
-    Elm_Object_Item *about_wfdsp_sep_end_item;
+       Evas_Object *win;
+       Evas_Object *bg;
+       Evas_Object *naviframe;
+       Evas_Object *genlist;
+       Evas_Object *multiconn_view_genlist;
+       Evas_Object *popup;
+       Evas_Object *act_popup;
+       Evas_Object *warn_popup;
 
-    Elm_Object_Item *conn_wfd_item;
+       Elm_Object_Item *head;
+       Evas_Object *scan_btn;
+       Evas_Object *multi_scan_btn;
+       Evas_Object *multi_connect_btn;
 
-    Elm_Object_Item *conn_failed_wfd_item;
-    Elm_Object_Item *conn_failed_wfd_sep_item;
+       Elm_Object_Item *nodevice_title_item;
+       Elm_Object_Item *nodevice_item;
 
-    Elm_Object_Item *avlbl_wfd_item;
+       Elm_Object_Item *about_wfd_item;
+       Elm_Object_Item *about_wfd_sep_high_item;
+       Elm_Object_Item *about_wfd_sep_low_item;
 
-    Elm_Object_Item *busy_wfd_item;
-    Elm_Object_Item *busy_wfd_sep_item;
+       Elm_Object_Item *conn_wfd_item;
+       Elm_Object_Item *conn_failed_wfd_item;
+       Elm_Object_Item *avlbl_wfd_item;
+       Elm_Object_Item *busy_wfd_item;
+       Elm_Object_Item *multi_connect_wfd_item;
 
-    Elm_Object_Item *multi_connect_wfd_item;
+       Elm_Object_Item *multi_button_item;
+       Elm_Object_Item *multi_button_sep_item;
 
-    Elm_Object_Item *multi_button_item;
-    Elm_Object_Item *multi_button_sep_high_item;
-    Elm_Object_Item *multi_button_sep_low_item;
+       Elm_Object_Item *mcview_select_all_item;
+       Elm_Object_Item *mcview_title_item;
+       Elm_Object_Item *mcview_nodevice_item;
 
+       Evas_Object *back_btn;
+       Evas_Object *multi_btn;
 
-    Elm_Object_Item *mcview_select_all_item;
-    Elm_Object_Item *mcview_title_item;
-    Elm_Object_Item *mcview_nodevice_item;
+       // Notify
+       Evas_Object *notify;
+       Evas_Object *notify_layout;
 
+       int head_text_mode;
 
-    Evas_Object *multi_btn;
+       // Raw peer data
+       device_type_s raw_connected_peers[MAX_PEER_NUM];
+       int raw_connected_peer_cnt;
+       device_type_s raw_discovered_peers[MAX_PEER_NUM];
+       int raw_discovered_peer_cnt;
 
-    int head_text_mode;
+       // Peer data in the Genlist
+       device_type_s gl_connected_peers[MAX_PEER_NUM];
+       int gl_connected_peer_cnt;
 
-    // Raw peer data
-    device_type_s raw_connected_peers[MAX_PEER_NUM];
-    int raw_connected_peer_cnt;
-    device_type_s raw_discovered_peers[MAX_PEER_NUM];
-    int raw_discovered_peer_cnt;
+       device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
+       int gl_connected_failed_peer_cnt;
 
-    // Peer data in the Genlist
-    device_type_s gl_connected_peers[MAX_PEER_NUM];
-    int gl_connected_peer_cnt;
+       device_type_s gl_available_peers[MAX_PEER_NUM];
+       int gl_available_peer_cnt;
 
-    device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
-    int gl_connected_failed_peer_cnt;
+       device_type_s gl_busy_peers[MAX_PEER_NUM];
+       int gl_busy_peer_cnt;
 
-    device_type_s gl_available_peers[MAX_PEER_NUM];
-    int gl_available_peer_cnt;
+       device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
+       int raw_multi_selected_peer_cnt;
 
-    device_type_s gl_busy_peers[MAX_PEER_NUM];
-    int gl_busy_peer_cnt;
+       device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
+       int gl_multi_connect_peer_cnt;
 
-    device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
-    int raw_multi_selected_peer_cnt;
+       // My status
+       bool I_am_group_owner;
+       bool I_am_connected;
 
-    device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
-    int gl_multi_connect_peer_cnt;
+       // Following variables are used at the Multi connect view.
+       wfd_multi_connect_mode_e multi_connect_mode;
+       wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
+       int gl_available_dev_cnt_at_multiconn_view;
+       int g_source_multi_connect_next;
 
-    // My status
-    bool I_am_group_owner;
-    bool I_am_connected;
+       int wfd_onoff;
+       wifi_direct_state_e wfd_status;
+       char *dev_name;
+       char *dev_pass;
 
-    // Following variables are used at the Multi connect view.
-    wfd_multi_connect_mode_e multi_connect_mode;
-    wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
-    int gl_available_dev_cnt_at_multiconn_view;
-    int g_source_multi_connect_next;
+       // For connect failed peers
+       int last_display_time;
+       Ecore_Timer *display_timer;
 
-    int wfd_onoff;
-    int wfd_status;
-    char *dev_name;
-    char *dev_pass;
+       // Tethering
+       bool is_hotspot_off;
+       tethering_h hotspot_handle;
 
-    // For connect failed peers
-    int last_display_time;
-    Ecore_Timer *display_timer;
+       // Used for automatic turn off
+       int last_wfd_status;
+       int last_wfd_time;
+       Ecore_Timer *monitor_timer;
 
-    //tethering
-    tethering_h hotspot_handle;
-    
+       // Re-discover or not
+       bool is_re_discover;
 };
 
-extern Elm_Gen_Item_Class sep_itc;
-extern Elm_Gen_Item_Class sep_itc_end;
 extern Elm_Gen_Item_Class head_itc;
 extern Elm_Gen_Item_Class name_itc;
 extern Elm_Gen_Item_Class title_itc;
 extern Elm_Gen_Item_Class peer_itc;
 extern Elm_Gen_Item_Class noitem_itc;
-extern Elm_Gen_Item_Class help_itc;
 extern Elm_Gen_Item_Class button_itc;
 
 extern Elm_Gen_Item_Class title_conn_itc;
index f22a391..7a6359b 100755 (executable)
 
 /* Define icons */
 
-#define WFD_ICON_DEVICE_COMPUTER                       WFD_IMG_DIR"/A09_device_computer.png"
+#define WFD_ICON_DEVICE_COMPUTER                       WFD_IMG_DIR"/A09_device_computer.png"
 #define WFD_ICON_DEVICE_INPUT_DEVICE                   WFD_IMG_DIR"/A09_device_input_device.png"
-#define WFD_ICON_DEVICE_PRINTER                        WFD_IMG_DIR"/A09_device_printer.png"
-#define WFD_ICON_DEVICE_CAMERA                                 WFD_IMG_DIR"/A09_device_camera.png"
+#define WFD_ICON_DEVICE_PRINTER                                WFD_IMG_DIR"/A09_device_printer.png"
+#define WFD_ICON_DEVICE_CAMERA                         WFD_IMG_DIR"/A09_device_camera.png"
 #define WFD_ICON_DEVICE_STORAGE                                WFD_IMG_DIR"/A09_device_storage.png"
 #define WFD_ICON_DEVICE_NETWORK_INFRA                  WFD_IMG_DIR"/A09_device_network_infrastructure.png"
 #define WFD_ICON_DEVICE_DISPLAY                                WFD_IMG_DIR"/A09_device_display.png"
-#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE              WFD_IMG_DIR"/A09_device_multimedia_devices.png"
+#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE              WFD_IMG_DIR"/A09_device_multimedia_devices.png"
 #define WFD_ICON_DEVICE_GAMING_DEVICE                  WFD_IMG_DIR"/A09_device_gaming_devices.png"
-#define WFD_ICON_DEVICE_TELEPHONE                      WFD_IMG_DIR"/A09_device_telephone.png"
+#define WFD_ICON_DEVICE_TELEPHONE                      WFD_IMG_DIR"/A09_device_telephone.png"
 #define WFD_ICON_DEVICE_AUDIO_DEVICE                   WFD_IMG_DIR"/A09_device_audio_devices.png"
 
-#define WFD_ICON_DEVICE_COMPUTER_CONNECT               WFD_IMG_DIR"/A09_device_computer_connect.png"
+#define WFD_ICON_DEVICE_COMPUTER_CONNECT               WFD_IMG_DIR"/A09_device_computer_connect.png"
 #define WFD_ICON_DEVICE_INPUT_DEVICE_CONNECT           WFD_IMG_DIR"/A09_device_input_device_connect.png"
-#define WFD_ICON_DEVICE_PRINTER_CONNECT                WFD_IMG_DIR"/A09_device_printer_connect.png"
-#define WFD_ICON_DEVICE_CAMERA_CONNECT                         WFD_IMG_DIR"/A09_device_camera_connect.png"
+#define WFD_ICON_DEVICE_PRINTER_CONNECT                        WFD_IMG_DIR"/A09_device_printer_connect.png"
+#define WFD_ICON_DEVICE_CAMERA_CONNECT                 WFD_IMG_DIR"/A09_device_camera_connect.png"
 #define WFD_ICON_DEVICE_STORAGE_CONNECT                        WFD_IMG_DIR"/A09_device_storage_connect.png"
 #define WFD_ICON_DEVICE_NETWORK_INFRA_CONNECT          WFD_IMG_DIR"/A09_device_network_infrastructure_connect.png"
 #define WFD_ICON_DEVICE_DISPLAY_CONNECT                        WFD_IMG_DIR"/A09_device_display_connect.png"
-#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT      WFD_IMG_DIR"/A09_device_multimedia_devices_connect.png"
+#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT      WFD_IMG_DIR"/A09_device_multimedia_devices_connect.png"
 #define WFD_ICON_DEVICE_GAMING_DEVICE_CONNECT          WFD_IMG_DIR"/A09_device_gaming_devices_connect.png"
-#define WFD_ICON_DEVICE_TELEPHONE_CONNECT              WFD_IMG_DIR"/A09_device_telephone_connect.png"
+#define WFD_ICON_DEVICE_TELEPHONE_CONNECT              WFD_IMG_DIR"/A09_device_telephone_connect.png"
 #define WFD_ICON_DEVICE_AUDIO_DEVICE_CONNECT           WFD_IMG_DIR"/A09_device_audio_devices_connect.png"
 
 #define WFD_ICON_CONNECTED                             WFD_IMG_DIR"/A09_Connect.png"
 
 
-enum
-{
-    HEAD_TEXT_TYPE_DIRECT,
-    HEAD_TEXT_TYPE_DEACTIVATING,
-    HEAD_TEXT_TYPE_ACTIVATING,
-    HEAD_TEXT_TYPE_ACTIVATED,
-    HEAD_TEXT_TYPE_SCANING,
+enum {
+       HEAD_TEXT_TYPE_DIRECT,
+       HEAD_TEXT_TYPE_DEACTIVATING,
+       HEAD_TEXT_TYPE_ACTIVATING,
+       HEAD_TEXT_TYPE_ACTIVATED,
+       HEAD_TEXT_TYPE_SCANING,
 };
 
-enum
-{
-    /* User confirm */
-    POPUP_TYPE_WIFI_OFF,
-    POPUP_TYPE_HOTSPOT_OFF,
+enum {
+       /* User confirm */
+       POPUP_TYPE_WIFI_OFF,
+       POPUP_TYPE_HOTSPOT_OFF,
 
-    /* Activation */
-    POPUP_TYPE_ACTIVATE_FAIL,
-    POPUP_TYPE_DEACTIVATE_FAIL,
+       /* Activation */
+       POPUP_TYPE_ACTIVATE_FAIL,
+       POPUP_TYPE_DEACTIVATE_FAIL,
 
-    /* Connection */
-    POPUP_TYPE_LINK_TIMEOUT,
-    POPUP_TYPE_AUTH_FAIL,
-    POPUP_TYPE_LINK_FAIL,
-    POPUP_TYPE_UNKNOWN_ERROR,
+       /* Connection */
+       POPUP_TYPE_LINK_TIMEOUT,
+       POPUP_TYPE_AUTH_FAIL,
+       POPUP_TYPE_LINK_FAIL,
+       POPUP_TYPE_UNKNOWN_ERROR,
 
-    POPUP_TYPE_TERMINATE,
+       POPUP_TYPE_TERMINATE,
 
-    /* Disconnect */
-    POP_TYPE_DISCONNECT,
+       /* Disconnect */
+       POP_TYPE_DISCONNECT,
 
-    /* Disconnect All*/
-    POP_TYPE_DISCONNECT_ALL,
+       /* Disconnect All*/
+       POP_TYPE_DISCONNECT_ALL,
 
-    /* Scan again */
-    POP_TYPE_SCAN_AGAIN,
+       /* Scan again */
+       POP_TYPE_SCAN_AGAIN,
 
-    /* multi connect */
-    POP_TYPE_MULTI_CONNECT_POPUP,
+       /* multi connect */
+       POP_TYPE_MULTI_CONNECT_POPUP,
 
-    /* Busy device */
-    POP_TYPE_BUSY_DEVICE_POPUP,
+       /* Busy device */
+       POP_TYPE_BUSY_DEVICE_POPUP,
+
+       /* Automaticlly turn off */
+       POP_TYPE_AUTOMATIC_TURN_OFF,
 };
 
 struct ug_data *wfd_get_ug_data();
+
+/**
+ *     This function let the ug create the main view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void create_wfd_ug_view(void *data);
+
+/**
+ *     This function let the ug destroy the main view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void destroy_wfd_ug_view(void *data);
+
+/**
+ *     This function let the ug update the genlist item
+ *     @return   void
+ *     @param[in] obj the pointer to genlist item
+ */
 void wfd_ug_view_refresh_glitem(void *obj);
+
+/**
+ *     This function let the ug refresh the attributes of button
+ *     @return   void
+ *     @param[in] obj the pointer to the button
+ *     @param[in] text the pointer to the text of button
+ *     @param[in] enable whether the button is disabled
+ */
 void wfd_ug_view_refresh_button(void *obj, const char *text, int enable);
+
+/**
+ *     This function let the ug update the peers
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfd_ug_view_update_peers(void *data);
+
+/**
+ *     This function let the ug free the peers
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfd_ug_view_free_peers(void *data);
+
+/**
+ *     This function let the ug create a action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] message the pointer to the text of popup
+ *     @param[in] popup_type the message type
+ */
 void wfd_ug_act_popup(void *data, const char *message, int popup_type);
+
+/**
+ *     This function let the ug remove the action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfg_ug_act_popup_remove(void *data);
+
+/**
+ *     This function let the ug create a warning popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] message the pointer to the text of popup
+ *     @param[in] popup_type the message type
+ */
 void wfd_ug_warn_popup(void *data, const char *message, int popup_type);
-void wfg_ug_warn_popup_remove(void *data);
-int _create_connected_dev_list(void *data);
+
+/**
+ *     This function let the ug change the text of multi button
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int _change_multi_button_title(void *data);
 
+/**
+ *     This function let the ug create about view
+ *     @return   void
+ *     @param[in] ugd the pointer to the main data structure
+ */
 void _wifid_create_about_view(struct ug_data *ugd);
+
+/**
+ *     This function let the ug create the view for multi connection
+ *     @return   void
+ *     @param[in] ugd the pointer to the main data structure
+ */
 void _wifid_create_multiconnect_view(struct ug_data *ugd);
 
-void _sub_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info);
+/**
+ *     This function let the ug call it when click 'back' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _back_btn_cb(void *data, Evas_Object * obj, void *event_info);
+
+/**
+ *     This function let the ug call it when click 'scan' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info);
 
-void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info);
-void _wifid_create_multibutton_cb(void *data, Evas_Object * obj, void *event_info);
+/**
+ *     This function let the ug call it when click 'multi connect' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+void _wifid_create_multibutton_cb(void *data, Evas_Object *obj, void *event_info);
 
+/**
+ *     This function let the ug get the found peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ */
 int wfd_ug_get_discovered_peers(struct ug_data *ugd);
+
+/**
+ *     This function let the ug get the connected peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ */
 int wfd_ug_get_connected_peers(struct ug_data *ugd);
-int wfd_refresh_wifi_direct_state(void* data);
 
-int wfd_multi_connect_next(void* data);
+/**
+ *     This function let the ug get the device status
+ *     @return  If success, return 0-3(available: 0, connected: 1, busy: 2, connected failed: 3), else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] device the pointer to the number of connected failed devices
+ */
+int wfd_get_device_status(void *data, device_type_s *device);
+
+/**
+ *     This function let the ug refresh current status of wi-fi direct
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_refresh_wifi_direct_state(void *data);
+
+/**
+ *     This function let the ug free the selected peers in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
+void wfd_free_multi_selected_peers(void *data);
+
+/**
+ *     This function let the ug stop to connect to selected peer
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_stop_multi_connect(void *data);
 
-gboolean wfd_multi_connect_next_cb(void* data);
+/**
+ *     This function let the ug connect to the next selected peer automatically
+ *     @return   If stop the timer, return false, else return true
+ *     @param[in] data the pointer to the main data structure
+ */
+gboolean wfd_multi_connect_next_cb(void *data);
+
+/**
+ *     This function let the ug add a dialogue separator
+ *     @return   the separator item
+ *     @param[in] genlist the pointer to the genlist
+ *     @param[in] separator_style the style of separator
+ */
+Elm_Object_Item *wfd_add_dialogue_separator(Evas_Object *genlist, const char *separator_style);
+
+/**
+ *     This function let the ug fee the multi connect devices
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_free_multiconnect_device(struct ug_data *ugd);
+
+/**
+ *     This function let the ug update the multi connect devices
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_update_multiconnect_device(struct ug_data *ugd);
+
+/**
+ *     This function let the ug create the view for multi connection
+ *     @return   void
+ *     @param[in] ugd the pointer to the main data structure
+ */
+void wfd_create_multiconnect_view(struct ug_data *ugd);
 
-void wfd_ug_tickernoti_popup(char *msg);
 
 #endif  /* __WFD_UG_VIEW_H__ */
old mode 100644 (file)
new mode 100755 (executable)
index d3a8223..3cc4ea8
@@ -46,6 +46,9 @@ msgstr "Connect"
 msgid "IDS_WFD_BUTTON_CANCEL"
 msgstr "Cancel connection"
 
+msgid "IDS_WFD_TITLE_ABOUT_WIFI_DIRECT"
+msgstr "About Wi-Fi Direct"
+
 msgid "IDS_WFD_BODY_ABOUT_WIFI"
 msgstr "Wi-Fi Direct enables Wi-Fi devices to connect directly, making printing, file sharing, synchronising, and screen sharing much simpler and more convenient. Connecting to devices that support Wi-Fi Direct makes it possible to share your content, synchronise your data, socialise with friends, play games, audio, videos, and more, using various applications"
 
index d0c3ae9..3176804 100755 (executable)
 #include <tethering.h>
 #include <network-cm-intf.h>
 #include <network-wifi-intf.h>
-#include <wifi-direct.h>
 
 #include "wfd_ug.h"
 #include "wfd_ug_view.h"
 #include "wfd_client.h"
 
+/**
+ *     This function let the ug make a change callback for wifi state
+ *     @return   void
+ *     @param[in] key the pointer to the key
+ *     @param[in] data the pointer to the main data structure
+ */
 static void _wifi_state_cb(keynode_t *key, void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res;
-    int wifi_state;
-
-    res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
-    if (res != 0)
-    {
-        DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res);
-        // TODO: set genlist head item as "WiFi Direct"
-        return;
-    }
-
-    if(wifi_state == VCONFKEY_WIFI_OFF)
-    {
-        DBG(LOG_VERBOSE, "WiFi is turned off\n");
-        wfd_client_swtch_force(ugd, TRUE);
-    }
-    else
-    {
-        DBG(LOG_VERBOSE, "WiFi is turned on\n");
-    }
-
-    res = net_deregister_client();
-    if(res != NET_ERR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res);
-    }
-
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+       int wifi_state;
+
+       res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+       if (res != 0) {
+               DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res);
+               return;
+       }
+
+       if (wifi_state == VCONFKEY_WIFI_OFF) {
+               DBG(LOG_VERBOSE, "WiFi is turned off\n");
+               wfd_client_swtch_force(ugd, TRUE);
+       } else {
+               DBG(LOG_VERBOSE, "WiFi is turned on\n");
+       }
+
+       res = net_deregister_client();
+       if (res != NET_ERR_NONE) {
+               DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res);
+       }
+
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug make a event callback for network registering
+ *     @return   void
+ *     @param[in] event_info the pointer to the information of network event
+ *     @param[in] user_data the pointer to the user data
+ */
 static void _network_event_cb(net_event_info_t *event_info, void *user_data)
 {
-    __FUNC_ENTER__;
-    DBG(LOG_VERBOSE, "Event from network. [%d]\n", event_info->Event);
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       DBG(LOG_VERBOSE, "Event from network. [%d]\n", event_info->Event);
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug turn wifi off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_wifi_off(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res;
-
-    res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb, ugd);
-    if (res == -1)
-    {
-        DBG(LOG_ERROR, "Failed to register vconf callback\n");
-        return -1;
-    }
-    DBG(LOG_VERBOSE, "Vconf key callback is registered\n");
-    res = net_register_client((net_event_cb_t) _network_event_cb, NULL);
-    if(res != NET_ERR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to register network client. [%d]\n", res);
-        return -1;
-    }
-    DBG(LOG_VERBOSE, "Network client is registered\n");
-    res = net_wifi_power_off();
-    if(res != NET_ERR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to turn off wifi. [%d]\n", res);
-        return -1;
-    }
-    DBG(LOG_VERBOSE, "WiFi power off\n");
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+
+       res = vconf_notify_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb, ugd);
+       if (res == -1) {
+               DBG(LOG_ERROR, "Failed to register vconf callback\n");
+               return -1;
+       }
+
+       DBG(LOG_VERBOSE, "Vconf key callback is registered\n");
+
+       res = net_register_client((net_event_cb_t) _network_event_cb, NULL);
+       if (res != NET_ERR_NONE) {
+               DBG(LOG_ERROR, "Failed to register network client. [%d]\n", res);
+               return -1;
+       }
+
+       DBG(LOG_VERBOSE, "Network client is registered\n");
+
+       res = net_wifi_power_off();
+       if (res != NET_ERR_NONE) {
+               DBG(LOG_ERROR, "Failed to turn off wifi. [%d]\n", res);
+               return -1;
+       }
+
+       DBG(LOG_VERBOSE, "WiFi power off\n");
+
+       __FUNC_EXIT__;
+       return 0;
+}
+
+/**
+ *     This function let the ug make a change callback for enabling hotspot state
+ *     @return   void
+ *     @param[in] key the pointer to the key
+ *     @param[in] data the pointer to the main data structure
+ */
+static void _enable_hotspot_state_cb(keynode_t *key, void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+       int hotspot_mode;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+       tethering_h th = NULL;
+
+       res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode);
+       if (res != 0) {
+               DBG(LOG_ERROR, "Failed to get mobile hotspot state from vconf. [%d]\n", res);
+               return;
+       }
+
+       if (hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+               DBG(LOG_VERBOSE, " Mobile hotspot is activated\n");
+       }
+
+       th = ugd->hotspot_handle;
+
+       if (th != NULL) {
+               /* Deregister cbs */
+               ret = tethering_unset_enabled_cb(th, TETHERING_TYPE_WIFI);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_unset_enabled_cb is failed(%d)\n", ret);
+               }
+
+               /* Destroy tethering handle */
+               ret = tethering_destroy(th);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
+               }
+
+               ugd->hotspot_handle = NULL;
+       }
+
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug make a change callback for disabling hotspot state
+ *     @return   void
+ *     @param[in] key the pointer to the key
+ *     @param[in] data the pointer to the main data structure
+ */
+static void _disable_hotspot_state_cb(keynode_t *key, void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+       int hotspot_mode;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+       tethering_h th = NULL;
+
+       res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode);
+       if (res != 0) {
+               DBG(LOG_ERROR, "Failed to get mobile hotspot state from vconf. [%d]\n", res);
+               return;
+       }
+
+       if (!(hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)) {
+               DBG(LOG_VERBOSE, " Mobile hotspot is deactivated\n");
+               wfd_client_swtch_force(ugd, TRUE);
+       }
+
+       th = ugd->hotspot_handle;
+
+       if (th != NULL) {
+               /* Deregister cbs */
+               ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_WIFI);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret);
+               }
+
+               /* Destroy tethering handle */
+               ret = tethering_destroy(th);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
+               }
+
+               ugd->hotspot_handle = NULL;
+       }
+
+       __FUNC_EXIT__;
+}
+
+/**
+ *     This function let the ug make a callback for setting tethering mode enabled
+ *     @return   void
+ *     @param[in] error the returned error code
+ *     @param[in] type the type of tethering
+ *     @param[in] is_requested whether tethering mode is enabled
+ *     @param[in] data the pointer to the user data
+ */
+static void __enabled_cb(tethering_error_e error, tethering_type_e type, bool is_requested, void *data)
+{
+       __FUNC_ENTER__;
+
+       if (error != TETHERING_ERROR_NONE) {
+               if (is_requested != TRUE) {
+                       return;
+               }
+
+               DBG(LOG_ERROR, "error !!! TETHERING is not enabled.\n");
+               return;
+       }
+
+       DBG(LOG_VERBOSE, "TETHERING is enabled.\n");
+
+       __FUNC_EXIT__;
+       return;
+}
+
+/**
+ *     This function let the ug make a callback for setting tethering mode disabled
+ *     @return   void
+ *     @param[in] error the returned error code
+ *     @param[in] type the type of tethering
+ *     @param[in] code whether tethering mode is enabled
+ *     @param[in] data the pointer to the user data
+ */
 static void __disabled_cb(tethering_error_e error, tethering_type_e type, tethering_disabled_cause_e code, void *data)
 {
        __FUNC_ENTER__;
 
        if (error != TETHERING_ERROR_NONE) {
-       
                if (code != TETHERING_DISABLED_BY_REQUEST) {
                        return;
                }
+
                DBG(LOG_ERROR, "error !!! TETHERING is not disabled.\n");
                return;
        }
@@ -122,836 +263,1167 @@ static void __disabled_cb(tethering_error_e error, tethering_type_e type, tether
        DBG(LOG_VERBOSE, "TETHERING is disabled.\n");
 
        __FUNC_EXIT__;
-
        return;
 }
 
+/**
+ *     This function let the ug turn AP on
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_mobile_ap_on(void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+       tethering_h th = NULL;
 
-#if 0
-static device_type_s *wfd_client_find_peer_by_ssid(void *data, const char *ssid)
+       res = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _enable_hotspot_state_cb, ugd);
+       if (res == -1) {
+               DBG(LOG_ERROR, "Failed to register vconf callback\n");
+               return -1;
+       }
+
+       /* Create tethering handle */
+       ret = tethering_create(&th);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to tethering_create() [%d]\n", ret);
+               return -1;
+       } else {
+               DBG(LOG_VERBOSE, "Succeeded to tethering_create()\n");
+       }
+
+       /* Register cbs */
+       ret = tethering_set_enabled_cb(th, TETHERING_TYPE_WIFI, __enabled_cb, NULL);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "tethering_set_enabled_cb is failed\n", ret);
+               return -1;
+       }
+
+       /* Enable tethering */
+       ret = tethering_enable(th, TETHERING_TYPE_WIFI);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to turn on mobile hotspot. [%d]\n", ret);
+               return -1;
+       } else {
+               DBG(LOG_VERBOSE, "Succeeded to turn on mobile hotspot\n");
+       }
+
+       ugd->hotspot_handle = th;
+       ugd->is_hotspot_off = FALSE;
+
+       __FUNC_EXIT__;
+       return 0;
+}
+
+/**
+ *     This function let the ug turn AP off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_mobile_ap_off(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int i;
-
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    for(i=0; i<ugd->gl_available_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "check %dth peer\n", i);
-        if(!strcmp(ugd->gl_available_peers[i].ssid, ssid))
-        {
-            DBG(LOG_VERBOSE, "found peer. [%d]\n", i);
-            __FUNC_EXIT__;
-            return &ugd->gl_available_peers[i];
-        }
-    }
-    __FUNC_EXIT__;
-
-    return NULL;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+       tethering_error_e ret = TETHERING_ERROR_NONE;
+       tethering_h th = NULL;
+
+       res = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _disable_hotspot_state_cb, ugd);
+       if (res == -1) {
+               DBG(LOG_ERROR, "Failed to register vconf callback\n");
+               return -1;
+       }
+
+       /* Create tethering handle */
+       ret = tethering_create(&th);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to tethering_create() [%d]\n", ret);
+               return -1;
+       } else {
+               DBG(LOG_VERBOSE, "Succeeded to tethering_create()\n");
+       }
+
+       /* Register cbs */
+       ret = tethering_set_disabled_cb(th, TETHERING_TYPE_WIFI, __disabled_cb, NULL);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "tethering_set_disabled_cb is failed\n", ret);
+               return -1;
+       }
+
+       /* Disable tethering */
+       ret = tethering_disable(th, TETHERING_TYPE_WIFI);
+       if (ret != TETHERING_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to turn off mobile hotspot. [%d]\n", ret);
+               return -1;
+       } else {
+               DBG(LOG_VERBOSE, "Succeeded to turn off mobile hotspot\n");
+       }
+
+       ugd->hotspot_handle = th;
+       ugd->is_hotspot_off = TRUE;
+
+       __FUNC_EXIT__;
+       return 0;
 }
-#endif
 
+/**
+ *     This function let the ug find the peer by mac address
+ *     @return   the found peer
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] mac_addr the pointer to mac address
+ */
 static device_type_s *wfd_client_find_peer_by_mac(void *data, const char *mac_addr)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int i;
-
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE)
-    {
-               for(i=0; i<ugd->raw_multi_selected_peer_cnt; i++)
-               {
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int i;
+
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
+               for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
                        DBG(LOG_VERBOSE, "[Multi Connect] check %dth peer\n", i);
-                       if(!strncmp(mac_addr, (const char*) ugd->raw_multi_selected_peers[i].mac_addr, MAC_LENGTH))
-                       {
+                       if (!strncmp(mac_addr, (const char *)ugd->raw_multi_selected_peers[i].mac_addr, MAC_LENGTH)) {
                                DBG(LOG_VERBOSE, "selected found peer. [%d]\n", i);
                                __FUNC_EXIT__;
                                return &ugd->raw_multi_selected_peers[i];
                        }
                }
-    }
-    else
-    {
-               for(i=0; i<ugd->raw_discovered_peer_cnt; i++)
-               {
+       } else {
+               for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
                        DBG(LOG_VERBOSE, "check %dth peer\n", i);
-                       if(!strncmp(mac_addr, (const char*) ugd->raw_discovered_peers[i].mac_addr, MAC_LENGTH))
-                       {
+                       if (!strncmp(mac_addr, (const char *)ugd->raw_discovered_peers[i].mac_addr, MAC_LENGTH)) {
                                DBG(LOG_VERBOSE, "found peer. [%d]\n", i);
                                __FUNC_EXIT__;
                                return &ugd->raw_discovered_peers[i];
                        }
                }
+       }
 
-    }
-    __FUNC_EXIT__;
-
-    return NULL;
-}
-
-int _wfd_ug_view_clean_on_off(struct ug_data *ugd)
-{
-       wfd_ug_view_update_peers(ugd);
-       return 0;
+       __FUNC_EXIT__;
+       return NULL;
 }
 
+/**
+ *     This function let the ug make a callback for registering activation event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] device_state the state of device
+ *     @param[in] user_data the pointer to the main data structure
+ */
 void _activation_cb(int error_code, wifi_direct_device_state_e device_state, void *user_data)
 {
-    __FUNC_ENTER__;
-    int res;
-    struct ug_data *ugd = (struct ug_data*) user_data;
-
-    wfd_refresh_wifi_direct_state(ugd);
-
-    switch(device_state)
-    {
-        case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
-            if(error_code != WIFI_DIRECT_ERROR_NONE)
-            {
-                DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code);
-                wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_ACTIVATE_FAIL);
-
-                ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-                ugd->wfd_onoff = 0;
-                wfd_ug_view_refresh_glitem(ugd->head);
-                return;
-            }
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATED;
-            ugd->wfd_onoff = 1;
-            wfd_ug_view_refresh_glitem(ugd->head);
-
-            wfg_ug_act_popup_remove(ugd);
-
-            res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb);
-            if(res == -1)
-            {
-                DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n");
-            }
-
-            res = wifi_direct_start_discovery(FALSE, 0);
-            if(res != WIFI_DIRECT_ERROR_NONE)
-            {
-                DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
-            }
-            DBG(LOG_VERBOSE, "Discovery is started\n");
-            break;
-
-        case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
-            if(error_code != WIFI_DIRECT_ERROR_NONE)
-            {
-                DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code);
-                wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_DEACTIVATE_FAIL);
-                ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-                ugd->wfd_onoff = 1;
-                wfd_ug_view_refresh_glitem(ugd->head);
-                return;
-            }
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            ugd->wfd_onoff = 0;
-
-            wfd_ug_view_update_peers(ugd);
-
-            break;
-        default:
-            break;
-    }
-
-    wfd_ug_view_refresh_glitem(ugd->head);
-
-    if (ugd->scan_btn) {
-       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
-    }
-
-    if (ugd->multi_connect_btn) {
-       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
-    }
-
-    __FUNC_EXIT__;
-    return;
+       __FUNC_ENTER__;
+       int res = -1;
+       struct ug_data *ugd = (struct ug_data *)user_data;
+
+       wfd_refresh_wifi_direct_state(ugd);
+
+       switch (device_state) {
+       case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
+               DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
+               if (error_code != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code);
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_ACTIVATE_FAIL);
+
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                       ugd->wfd_onoff = 0;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+                       return;
+               }
+
+               ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATED;
+               ugd->wfd_onoff = 1;
+               wfd_ug_view_refresh_glitem(ugd->head);
+
+               wfg_ug_act_popup_remove(ugd);
+
+               res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb);
+               if (res == -1) {
+                       DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n");
+               }
+
+               res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _disable_hotspot_state_cb);
+               if (res == -1) {
+                       DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n");
+               }
+
+               res = wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
+                       ugd->is_re_discover = TRUE;
+                       wifi_direct_cancel_discovery();
+               } else {
+                       DBG(LOG_VERBOSE, "Discovery is started\n");
+                       ugd->is_re_discover = FALSE;
+               }
+
+               break;
+       case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED:
+               DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n");
+               if (error_code != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code);
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_DEACTIVATE_FAIL);
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                       ugd->wfd_onoff = 1;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+                       return;
+               }
+
+               ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+               ugd->wfd_onoff = 0;
+
+               /*
+               * when deactivated, clear all the
+               *  discovered peers and connected peers
+               */
+               if (ugd->raw_discovered_peer_cnt > 0) {
+                       memset(ugd->raw_discovered_peers, 0x00, ugd->raw_discovered_peer_cnt*sizeof(device_type_s));
+               }
+
+               if (ugd->raw_connected_peer_cnt > 0) {
+                       memset(ugd->raw_connected_peers, 0x00, ugd->raw_connected_peer_cnt*sizeof(device_type_s));
+               }
+
+               ugd->raw_discovered_peer_cnt = 0;
+               ugd->raw_connected_peer_cnt = 0;
+
+               wfd_ug_view_update_peers(ugd);
+
+               /* remove the callback for hotspot */
+               res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _enable_hotspot_state_cb);
+               if (res == -1) {
+                       DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n");
+               }
+
+               /* when deactivated, stop the timer */
+               if (ugd->monitor_timer) {
+                       ecore_timer_del(ugd->monitor_timer);
+                       ugd->monitor_timer = NULL;
+               }
+               break;
+       default:
+               break;
+       }
+
+       wfd_ug_view_refresh_glitem(ugd->head);
+
+       if (ugd->scan_btn) {
+               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+       }
+
+       if (ugd->multi_connect_btn) {
+               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+       }
+
+       if (ugd->back_btn) {
+               elm_object_disabled_set(ugd->back_btn, FALSE);
+       }
+
+       __FUNC_EXIT__;
+       return;
 }
 
-bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data)
+/**
+ *     This function let the ug make a callback for discovering peer
+ *     @return   TRUE
+ *     @param[in] peer the pointer to the discovered peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
+bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
+       if (NULL == peer || NULL == user_data) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               __FUNC_EXIT__;
+               return FALSE;
+       }
 
-    struct ug_data *ugd = (struct ug_data*) user_data;
-    int peer_cnt = ugd->raw_discovered_peer_cnt;
+       struct ug_data *ugd = (struct ug_data *)user_data;
+       int peer_cnt = ugd->raw_discovered_peer_cnt;
 
-    DBG(LOG_VERBOSE, "%dth discovered peer. [%s] [%s]\n", peer_cnt, peer->ssid, peer->mac_address);
+       DBG(LOG_VERBOSE, "%dth discovered peer. [%s] [%s]\n", peer_cnt, peer->device_name, peer->mac_address);
 
-    strncpy(ugd->raw_discovered_peers[peer_cnt].ssid, peer->ssid, sizeof(ugd->raw_discovered_peers[peer_cnt].ssid));
-    ugd->raw_discovered_peers[peer_cnt].category = peer->primary_device_type;
-    strncpy(ugd->raw_discovered_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH);
-    strncpy(ugd->raw_discovered_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH);
-    ugd->raw_discovered_peers[peer_cnt].is_group_owner = peer->is_group_owner;
-    ugd->raw_discovered_peers[peer_cnt].is_persistent_group_owner = peer->is_persistent_group_owner;
-    ugd->raw_discovered_peers[peer_cnt].is_connected = peer->is_connected;
+       strncpy(ugd->raw_discovered_peers[peer_cnt].ssid, peer->device_name, sizeof(ugd->raw_discovered_peers[peer_cnt].ssid));
+       ugd->raw_discovered_peers[peer_cnt].category = peer->primary_device_type;
+       strncpy(ugd->raw_discovered_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH);
+       strncpy(ugd->raw_discovered_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH);
+       ugd->raw_discovered_peers[peer_cnt].is_group_owner = peer->is_group_owner;
+       ugd->raw_discovered_peers[peer_cnt].is_persistent_group_owner = peer->is_persistent_group_owner;
+       ugd->raw_discovered_peers[peer_cnt].is_connected = peer->is_connected;
 
-    if (TRUE == peer->is_connected) {
-       ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED;
-    } else {
-       ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_DISCONNECTED;
-    }
+       if (TRUE == peer->is_connected) {
+               ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED;
+       } else {
+               ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_DISCONNECTED;
+       }
 
-    DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_discovered_peers[peer_cnt].ssid);
-    DBG(LOG_VERBOSE, "\tPeer category [%d] -> [%d]\n", peer->primary_device_type, ugd->raw_discovered_peers[peer_cnt].category);
-    DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_discovered_peers[peer_cnt].conn_status);
+       DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_discovered_peers[peer_cnt].ssid);
+       DBG(LOG_VERBOSE, "\tPeer category [%d] -> [%d]\n", peer->primary_device_type, ugd->raw_discovered_peers[peer_cnt].category);
+       DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_discovered_peers[peer_cnt].conn_status);
 
-    ugd->raw_discovered_peer_cnt ++;
+       ugd->raw_discovered_peer_cnt++;
 
-    free(peer->ssid);
-    free(peer->mac_address);
-    free(peer->interface_address);
-    free(peer);
+       free(peer->device_name);
+       free(peer->mac_address);
+       free(peer->interface_address);
+       free(peer);
 
-    __FUNC_EXIT__;
-    return TRUE;
+       __FUNC_EXIT__;
+       return TRUE;
 }
 
-bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s* peer, void *user_data)
+/**
+ *     This function let the ug make a callback for connected peer
+ *     @return   TRUE
+ *     @param[in] peer the pointer to the connected peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
+bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) user_data;
-    int peer_cnt = ugd->raw_connected_peer_cnt;
-
-    DBG(LOG_VERBOSE, "%dth connected peer. [%s] [%s]\n", peer_cnt, peer->ssid, peer->mac_address);
-
-    strncpy(ugd->raw_connected_peers[peer_cnt].ssid, peer->ssid, sizeof(ugd->raw_connected_peers[peer_cnt].ssid));
-    ugd->raw_connected_peers[peer_cnt].category = peer->primary_device_type;
-    strncpy(ugd->raw_connected_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH);
-    strncpy(ugd->raw_connected_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH);
-    ugd->raw_connected_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED;
-
-    DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_connected_peers[peer_cnt].conn_status);
-    DBG(LOG_VERBOSE, "\tCategory: [%d]\n", ugd->raw_connected_peers[peer_cnt].category);
-    DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_connected_peers[peer_cnt].ssid);
-
-    ugd->raw_connected_peer_cnt++;
-
-    free(peer->ssid);
-    free(peer->mac_address);
-    free(peer->interface_address);
-    free(peer);
-    __FUNC_EXIT__;
-    return TRUE;
+       __FUNC_ENTER__;
+       if (NULL == peer || NULL == user_data) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               __FUNC_EXIT__;
+               return FALSE;
+       }
+
+       struct ug_data *ugd = (struct ug_data *)user_data;
+       int peer_cnt = ugd->raw_connected_peer_cnt;
+
+       DBG(LOG_VERBOSE, "%dth connected peer. [%s] [%s]\n", peer_cnt, peer->device_name, peer->mac_address);
+
+       strncpy(ugd->raw_connected_peers[peer_cnt].ssid, peer->device_name, sizeof(ugd->raw_connected_peers[peer_cnt].ssid));
+       ugd->raw_connected_peers[peer_cnt].category = peer->primary_device_type;
+       strncpy(ugd->raw_connected_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH);
+       strncpy(ugd->raw_connected_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH);
+       ugd->raw_connected_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED;
+
+       DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_connected_peers[peer_cnt].conn_status);
+       DBG(LOG_VERBOSE, "\tCategory: [%d]\n", ugd->raw_connected_peers[peer_cnt].category);
+       DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_connected_peers[peer_cnt].ssid);
+
+       ugd->raw_connected_peer_cnt++;
+
+       free(peer->device_name);
+       free(peer->mac_address);
+       free(peer->interface_address);
+       free(peer);
+
+       __FUNC_EXIT__;
+       return TRUE;
 }
 
+/**
+ *     This function let the ug get the found peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ */
 int wfd_ug_get_discovered_peers(struct ug_data *ugd)
 {
+       __FUNC_ENTER__;
        int res = 0;
 
-       if (ugd==NULL)
+       if (ugd == NULL) {
                return -1;
+       }
 
        ugd->raw_discovered_peer_cnt = 0;
-    res = wifi_direct_foreach_discovered_peers(_wfd_discoverd_peer_cb, (void*) ugd);
-    if (res != WIFI_DIRECT_ERROR_NONE)
-    {
-       ugd->raw_discovered_peer_cnt = 0;
-        DBG(LOG_ERROR, "Get discovery result failed: %d\n", res);
-    }
+       res = wifi_direct_foreach_discovered_peers(_wfd_discoverd_peer_cb, (void *)ugd);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               ugd->raw_discovered_peer_cnt = 0;
+               DBG(LOG_ERROR, "Get discovery result failed: %d\n", res);
+       }
 
+       __FUNC_EXIT__;
        return 0;
 }
 
-
+/**
+ *     This function let the ug get the connected peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ */
 int wfd_ug_get_connected_peers(struct ug_data *ugd)
 {
+       __FUNC_ENTER__;
        int res = 0;
 
-       if (ugd==NULL)
+       if (ugd == NULL) {
                return -1;
+       }
 
        ugd->raw_connected_peer_cnt = 0;
-       res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void*) ugd);
-       if(res != WIFI_DIRECT_ERROR_NONE)
-       {
+       res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void *)ugd);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
                ugd->raw_connected_peer_cnt = 0;
                DBG(LOG_ERROR, "Get connected peer failed: %d\n", res);
        }
+
+       __FUNC_EXIT__;
        return 0;
 }
 
-void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
+/**
+ *     This function let the ug make a callback for deactivating wfd automatically
+ *     @return   if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
+ *     @param[in] user_data the pointer to the main data structure
+ */
+static Eina_Bool _wfd_automatic_deactivated_for_no_connection_cb(void *user_data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) user_data;
-
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return;
-    }
-
-    if(discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED)
-    {
-        ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-    }
-    else if(discovery_state == WIFI_DIRECT_DISCOVERY_STARTED)
-    {
-        ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING;
-    }
-    else if(discovery_state == WIFI_DIRECT_DISCOVERY_FOUND)
-    {
-        ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-    }
-
-    wfd_ug_view_refresh_glitem(ugd->head);
-
-    if (WIFI_DIRECT_DISCOVERY_STARTED == discovery_state) {
-       if (ugd->scan_btn) {
-               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+       int res = -1;
+       int interval = 0;
+       struct ug_data *ugd = (struct ug_data *)user_data;
+
+       if (NULL == ugd) {
+               DBG(LOG_ERROR, "NULL parameters.\n");
+               return ECORE_CALLBACK_CANCEL;
        }
 
-       if (ugd->multi_connect_btn) {
-               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+       /* check the action, if action is exist, keep the cb */
+       res = wifi_direct_get_state(&ugd->wfd_status);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to get link status. [%d]\n", res);
+               return ECORE_CALLBACK_CANCEL;
        }
-    } else {
-       if (ugd->scan_btn) {
-               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+
+       if (ugd->last_wfd_status != ugd->wfd_status) {
+               DBG(LOG_ERROR, "Action is exist, last status: %d\n",
+                       ugd->last_wfd_status);
+               ugd->last_wfd_status = ugd->wfd_status;
+               ugd->last_wfd_time = time(NULL);
+               return ECORE_CALLBACK_RENEW;
        }
 
-       if (ugd->multi_connect_btn) {
-               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+       /* check the timeout, if not timeout, keep the cb */
+       interval = time(NULL) - ugd->last_wfd_time;
+       if (interval < MAX_NO_ACTION_TIME_OUT) {
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       /* turn off the Wi-Fi Direct */
+       wifi_direct_get_state(&ugd->wfd_status);
+       if (ugd->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
+               DBG(LOG_ERROR, "Wi-Fi Direct is already deactivated\n");
+       } else {
+               wfd_ug_warn_popup(ugd, IDS_WFD_POP_AUTOMATIC_TURN_OFF, POP_TYPE_AUTOMATIC_TURN_OFF);
+       }
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+/**
+ *     This function let the ug make a callback for registering discover event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] discovery_state the state of discover
+ *     @param[in] user_data the pointer to the main data structure
+ */
+void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)user_data;
+
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return;
+       }
+
+       DBG(LOG_VERBOSE, "Discovery event [%d], error_code [%d]\n", discovery_state, error_code);
+
+       if (discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED) {
+               __FUNC_EXIT__;
+               return;
+       } else if (discovery_state == WIFI_DIRECT_DISCOVERY_STARTED) {
+               ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING;
+
+               /* clear all the previous discovered peers */
+               if (ugd->raw_discovered_peer_cnt > 0) {
+                       memset(ugd->raw_discovered_peers, 0x00, ugd->raw_discovered_peer_cnt*sizeof(device_type_s));
+               }
+
+               ugd->raw_discovered_peer_cnt = 0;
+       } else if (discovery_state == WIFI_DIRECT_DISCOVERY_FOUND) {
+               ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+               wfd_ug_get_discovered_peers(ugd);
+       } else {
+               ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+
+               if (TRUE == ugd->is_re_discover) {
+                       ugd->is_re_discover = FALSE;
+                       wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+               } else {
+                       /* start LISTEN ONLY mode */
+                       wifi_direct_start_discovery(TRUE, 0);
+               }
        }
-    }
 
-    wfd_ug_get_discovered_peers(ugd);
-    wfd_ug_get_connected_peers(ugd);
+       wfd_ug_view_refresh_glitem(ugd->head);
+       wfd_ug_view_update_peers(ugd);
+       wfd_update_multiconnect_device(ugd);
 
-    wfd_ug_view_update_peers(ugd);
+       if (WIFI_DIRECT_DISCOVERY_STARTED == discovery_state) {
+               if (ugd->scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+               }
 
-    _wfd_free_multiconnect_device(ugd);
-    _wfd_update_multiconnect_device(ugd);
-    //_change_multi_button_title(ugd);
+               if (ugd->multi_connect_btn) {
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+               }
+       } else {
+               if (ugd->scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+               }
 
-    __FUNC_EXIT__;
-    return;
+               if (ugd->multi_connect_btn) {
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+               }
+       }
+
+       __FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the ug make a callback for registering connection event
+ *     @return   void
+ *     @param[in] error_code the returned error code
+ *     @param[in] connection_state the state of connection
+ *     @param[in] mac_address the mac address of peer
+ *     @param[in] user_data the pointer to the main data structure
+ */
 void _connection_cb(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data)
 {
-    __FUNC_ENTER__;
-
-    struct ug_data *ugd = (struct ug_data*) user_data;
-    device_type_s *peer = NULL;
-    bool owner = FALSE;
-    int res = 0;
-
-    DBG(LOG_VERBOSE, "Connection event [%d], error_code [%d]\n", connection_state, error_code);
-
-    if(mac_address == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(peer mac is NULL)\n");
-        return;
-    }
-    DBG(LOG_VERBOSE, "Connection event from %s", mac_address);
-
-    if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS)
-    {
-       peer = wfd_client_find_peer_by_mac(ugd, mac_address);
-       if (peer != NULL)
-       {
-                       switch(connection_state)
-                       {
-                       case WIFI_DIRECT_CONNECTION_RSP:
-                               if(error_code == WIFI_DIRECT_ERROR_NONE)
-                               {
-                                       ugd->wfd_status = WFD_LINK_STATUS_CONNECTED;
-                                       peer->conn_status = PEER_CONN_STATUS_CONNECTED;
-                               }
-                               else
-                               {
-                                       peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
-                               }
-                               ugd->g_source_multi_connect_next = g_timeout_add(1000, wfd_multi_connect_next_cb, ugd);
-                               break;
-                       default:
-                               break;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)user_data;
+       device_type_s *peer = NULL;
+       bool owner = FALSE;
+       int res = 0;
+
+       DBG(LOG_VERBOSE, "Connection event [%d], error_code [%d], multi_connect_mode [%d]\n",
+               connection_state, error_code, ugd->multi_connect_mode);
+
+       if (mac_address == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(peer mac is NULL)\n");
+               return;
+       }
+
+       /* when not in connection, mac_address is empty */
+       if (connection_state <= WIFI_DIRECT_DISASSOCIATION_IND) {
+               peer = wfd_client_find_peer_by_mac(ugd, mac_address);
+
+               if (NULL == peer || '\0' == peer->ssid[0]) {
+                       DBG(LOG_ERROR, "invalid peer from connection !!\n");
+                       goto refresh_button;
+               }
+       }
+
+       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
+               switch (connection_state) {
+               case WIFI_DIRECT_CONNECTION_RSP:
+                       DBG(LOG_VERBOSE, "MULTI: WIFI_DIRECT_CONNECTION_RSP\n");
+
+                       if (error_code == WIFI_DIRECT_ERROR_NONE) {
+                               peer->conn_status = PEER_CONN_STATUS_CONNECTED;
+                               wfd_ug_get_connected_peers(ugd);
+                       } else {
+                               peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
+                       }
+
+                       wfd_ug_view_update_peers(ugd);
+
+                       /* connect the next peer */
+                       ugd->g_source_multi_connect_next = g_timeout_add(1000, wfd_multi_connect_next_cb, ugd);
+                       break;
+               case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
+                       DBG(LOG_VERBOSE, "MULTI: WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
+                       peer->conn_status = PEER_CONN_STATUS_CONNECTING;
+                       wfd_ug_view_update_peers(ugd);
+                       break;
+               case WIFI_DIRECT_GROUP_CREATED:
+                       DBG(LOG_VERBOSE, "MULTI: WIFI_DIRECT_GROUP_CREATED\n");
+                       wfd_multi_connect_next_cb(ugd);
+                       break;
+               default:
+                       break;
+               }
+       } else {
+               switch (connection_state) {
+               case WIFI_DIRECT_CONNECTION_RSP:
+                       DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_RSP\n");
+
+                       if (error_code == WIFI_DIRECT_ERROR_NONE) {
+                               peer->conn_status = PEER_CONN_STATUS_CONNECTED;
+                               wfd_ug_get_connected_peers(ugd);
+                       } else {
+                               peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
+                       }
+
+                       wfd_ug_view_update_peers(ugd);
+                       break;
+               case WIFI_DIRECT_DISASSOCIATION_IND:
+                       DBG(LOG_VERBOSE, "WIFI_DIRECT_DISASSOCIATION_IND\n");
+                       /* change the multi connection mode, it can be connected now */
+                       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
+                               ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_IN_PROGRESS;
                        }
+
+                       /* if other peer disconnected, get connected peers and update */
+                       peer->conn_status = PEER_CONN_STATUS_WAIT_FOR_CONNECT;
                        wfd_ug_get_connected_peers(ugd);
                        wfd_ug_view_update_peers(ugd);
-       }
-       else
-       {
-           DBG(LOG_VERBOSE, "peer is not found [%s]", mac_address);
-       }
-       goto refresh_button;
-    }
-
-
-    peer = wfd_client_find_peer_by_mac(ugd, mac_address);
-
-    if (NULL == peer || NULL == peer->ssid) {
-           DBG(LOG_ERROR, "SSID from connection is NULL !!\n");
-           goto refresh_button;
-    }
-
-    switch(connection_state)
-    {
-        case WIFI_DIRECT_CONNECTION_RSP:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_RSP\n");
-
-            if(error_code == WIFI_DIRECT_ERROR_NONE)
-            {
-                ugd->wfd_status = WFD_LINK_STATUS_CONNECTED;
-                peer->conn_status = PEER_CONN_STATUS_CONNECTED;
-            }
-            else
-            {
-               peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
-            }
-
-            wfd_ug_get_connected_peers(ugd);
-            wfd_ug_view_update_peers(ugd);
-            break;
-        case WIFI_DIRECT_DISCONNECTION_RSP:
-        case WIFI_DIRECT_DISCONNECTION_IND:
-        case WIFI_DIRECT_DISASSOCIATION_IND:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_DISCONNECTION_X\n");
-            if(error_code != WIFI_DIRECT_ERROR_NONE)
-            {
-                // TODO: show disconnection error popup
-                return;
-            }
-
-            if (peer!=NULL)
-               peer->conn_status = PEER_CONN_STATUS_DISCONNECTED;
-            else
-            {
-               // In case of disconnect_all(), no specific peer is found.
-            }
-
-            wifi_direct_start_discovery(FALSE, 0);
-            ugd->wfd_status = WFD_LINK_STATUS_DISCOVERING;
-            ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING;
-
-            wfd_ug_view_refresh_glitem(ugd->head);
-
-            wfd_ug_get_discovered_peers(ugd);
-            wfd_ug_get_connected_peers(ugd);
-            wfd_ug_view_update_peers(ugd);
-            break;
-
-        case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
-            peer->conn_status = PEER_CONN_STATUS_CONNECTING;
-            break;
-        case WIFI_DIRECT_CONNECTION_REQ:
-        case WIFI_DIRECT_CONNECTION_WPS_REQ:
-            DBG(LOG_VERBOSE, "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ\n");
-            break;
-        default:
-            break;
-    }
-
-    if(peer != NULL)
-        wfd_ug_view_refresh_glitem(peer->gl_item);
-
-    _change_multi_button_title(ugd);
+                       break;
+               case WIFI_DIRECT_DISCONNECTION_RSP:
+               case WIFI_DIRECT_DISCONNECTION_IND:
+                       DBG(LOG_VERBOSE, "WIFI_DIRECT_DISCONNECTION_X\n");
+
+                       /* when disconnection, clear all the connected peers */
+                       if (ugd->raw_connected_peer_cnt > 0) {
+                               memset(ugd->raw_connected_peers, 0x00, ugd->raw_connected_peer_cnt*sizeof(device_type_s));
+                       }
+
+                       ugd->raw_connected_peer_cnt = 0;
+
+                       /* start discovery again */
+                       res = wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                               DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
+                               ugd->is_re_discover = TRUE;
+                               wifi_direct_cancel_discovery();
+                       } else {
+                               DBG(LOG_VERBOSE, "Discovery is started\n");
+                               ugd->is_re_discover = FALSE;
+                       }
+
+                       break;
+               case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
+                       DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
+                       peer->conn_status = PEER_CONN_STATUS_CONNECTING;
+                       wfd_ug_view_update_peers(ugd);
+                       break;
+               case WIFI_DIRECT_CONNECTION_REQ:
+               case WIFI_DIRECT_CONNECTION_WPS_REQ:
+                       DBG(LOG_VERBOSE, "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ\n");
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       if (peer != NULL) {
+               wfd_ug_view_refresh_glitem(peer->gl_item);
+       }
+
+       _change_multi_button_title(ugd);
 
 refresh_button:
-    /* refresh the scan button */
-    wfd_refresh_wifi_direct_state(ugd);
-    if (WIFI_DIRECT_STATE_CONNECTING == ugd->wfd_status ||
-           WIFI_DIRECT_STATE_DISCONNECTING == ugd->wfd_status) {
-
-       res = wifi_direct_is_group_owner(&owner);
-       if (res == WIFI_DIRECT_ERROR_NONE) {
-           if (!owner) {
+       /* refresh the scan button */
+       wfd_refresh_wifi_direct_state(ugd);
+       if (WIFI_DIRECT_STATE_CONNECTING == ugd->wfd_status ||
+               WIFI_DIRECT_STATE_DISCONNECTING == ugd->wfd_status) {
+               res = wifi_direct_is_group_owner(&owner);
+               if (res == WIFI_DIRECT_ERROR_NONE) {
+                       if (!owner) {
+                               if (ugd->scan_btn) {
+                                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                               }
+
+                               if (ugd->multi_connect_btn) {
+                                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                               }
+                       }
+               } else {
+                   DBG(LOG_ERROR, "Failed to get whether client is group owner. [%d]\n", res);
+               }
+       } else {
                if (ugd->scan_btn) {
-                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
                }
 
                if (ugd->multi_connect_btn) {
-                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
                }
-           }
-       } else {
-           DBG(LOG_ERROR, "Failed to get whether client is group owner. [%d]\n", res);
-       }
-    } else {
-       if (ugd->scan_btn) {
-               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
        }
 
-       if (ugd->multi_connect_btn) {
-               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
+       /* if no connection, start the monitor timer */
+       wifi_direct_get_state(&ugd->wfd_status);
+       DBG(LOG_VERBOSE, "status: %d", ugd->wfd_status);
+
+       if (ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) {
+               if (ugd->monitor_timer) {
+                       ecore_timer_del(ugd->monitor_timer);
+                       ugd->monitor_timer = NULL;
+               }
+       } else {
+               if (NULL == ugd->monitor_timer) {
+                       DBG(LOG_VERBOSE, "start the monitor timer\n");
+                       ugd->last_wfd_time = time(NULL);
+                       ugd->monitor_timer = ecore_timer_add(5.0,
+                               (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ugd);
+               }
        }
-    }
 
-    __FUNC_EXIT__;
-    return;
+       __FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the ug get wi-fi direct status from vconf
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_get_vconf_status(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    char *dev_name;
-
-    // TODO: get wifi direct status from vconf
-    // db/mobile_hotspot/wifi_key (string)
-
-    dev_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);  // "db/setting/device_name" (VCONF_WFD_APNAME)
-    if (dev_name == NULL)
-    {
-        ugd->dev_name = strdup(DEFAULT_DEV_NAME);
-        DBG(LOG_ERROR, "The AP name is NULL(setting default value)\n");
-    }
-    else
-    {
-        ugd->dev_name = strdup(dev_name);
-        free(dev_name);
-    }
-
-    __FUNC_EXIT__;
-
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       char *dev_name;
+       int wifi_direct_state = 0;
+
+       /* get wifi direct status from vconf */
+       if (vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state) < 0) {
+               DBG(LOG_ERROR, "Error reading vconf (%s)\n", VCONFKEY_WIFI_DIRECT_STATE);
+               return -1;
+       }
+
+       ugd->wfd_status = wifi_direct_state;
+
+       /* get device name from vconf */
+       dev_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
+       if (dev_name == NULL) {
+               ugd->dev_name = strdup(DEFAULT_DEV_NAME);
+               DBG(LOG_ERROR, "The AP name is NULL(setting default value)\n");
+       } else {
+               ugd->dev_name = strdup(dev_name);
+               free(dev_name);
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug refresh current status of wi-fi direct
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_refresh_wifi_direct_state(void *data)
 {
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
        int res;
        wifi_direct_state_e wfd_status;
-    res = wifi_direct_get_state(&wfd_status);
-    if(res != WIFI_DIRECT_ERROR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to get link status. [%d]\n", res);
-        return -1;
-    }
-    DBG(LOG_VERBOSE, "WFD status [%d]", wfd_status);
-    ugd->wfd_status = wfd_status;
-    return 0;
+
+       res = wifi_direct_get_state(&wfd_status);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to get link status. [%d]\n", res);
+               return -1;
+       }
+
+       DBG(LOG_VERBOSE, "WFD status [%d]", wfd_status);
+       ugd->wfd_status = wfd_status;
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug do initialization
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int init_wfd_client(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res = 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res = 0;
+
+       res = wifi_direct_initialize();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to initialize wifi direct. [%d]\n", res);
+               return -1;
+       }
+
+       res = wifi_direct_initialize();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to initialize Wi-Fi Direct. error code = [%d]\n", res);
+               return -1;
+       }
 
-    res = wifi_direct_initialize();
-    if(res != WIFI_DIRECT_ERROR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to initialize wifi direct. [%d]\n", res);
-        return -1;
-    }
+       res = wifi_direct_set_device_state_changed_cb(_activation_cb, (void *)ugd);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to register _cb_activation. error code = [%d]\n", res);
+               return -1;
+       }
+
+       res = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void *)ugd);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to register _cb_discover. error code = [%d]\n", res);
+               return -1;
+       }
+
+       res = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void *)ugd);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to register _cb_connection. error code = [%d]\n", res);
+               return -1;
+       }
 
-    res = wifi_direct_set_device_state_changed_cb(_activation_cb, (void*) ugd);
-    res = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void*) ugd);
-    res = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void*) ugd);
+       /* update WFD status */
+       wfd_refresh_wifi_direct_state(ugd);
+       if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) {
+               ugd->wfd_onoff = 1;
+       } else {
+               ugd->wfd_onoff = 0;
+       }
 
-    /* update WFD status */
-    wfd_refresh_wifi_direct_state(ugd);
-    if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING)
-       ugd->wfd_onoff = 1;
-    else
-       ugd->wfd_onoff = 0;
+       DBG(LOG_VERBOSE, "WFD link status. [%d]\n", ugd->wfd_status);
 
-    DBG(LOG_VERBOSE, "WFD link status. [%d]\n", ugd->wfd_status);
+       /* start the monitor timer */
+       ugd->last_wfd_time = time(NULL);
+       ugd->last_wfd_status = WIFI_DIRECT_STATE_DEACTIVATED;
+       ugd->monitor_timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ugd);
 
-    __FUNC_EXIT__;
+       ugd->is_re_discover = FALSE;
 
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug do de-initialization
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int deinit_wfd_client(void *data)
 {
        __FUNC_ENTER__;
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *)data;
        int res = 0;
        tethering_error_e ret = TETHERING_ERROR_NONE;
        tethering_h th = NULL;
 
        wfd_refresh_wifi_direct_state(ugd);
 
-       if(ugd->wfd_status == WIFI_DIRECT_STATE_DISCOVERING)
-       {
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_DISCOVERING) {
                DBG(LOG_VERBOSE, "Stop discovery before deregister client\n");
                wifi_direct_cancel_discovery();
        }
 
        res = wifi_direct_deinitialize();
-       if(res != WIFI_DIRECT_ERROR_NONE)
-       {
+       if (res != WIFI_DIRECT_ERROR_NONE) {
                DBG(LOG_ERROR, "Failed to deregister client. [%d]\n", res);
        }
 
+       /* release monitor timer */
+       if (ugd->monitor_timer) {
+               ecore_timer_del(ugd->monitor_timer);
+               ugd->monitor_timer = NULL;
+       }
+
+       /* release vconf, hotspot..  */
        res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb);
-       if(res == -1)
-       {
+       if (res == -1) {
                DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n");
        }
 
        res = net_deregister_client();
-       if(res != NET_ERR_NONE)
-       {
+       if (res != NET_ERR_NONE) {
                DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res);
        }
 
-       __FUNC_EXIT__;
+       res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _enable_hotspot_state_cb);
+       if (res == -1) {
+               DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n");
+       }
+
+       res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _disable_hotspot_state_cb);
+       if (res == -1) {
+               DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n");
+       }
+
+       th = ugd->hotspot_handle;
+
+       if (th != NULL) {
+               /* Deregister cbs */
+               ret = tethering_unset_enabled_cb(th, TETHERING_TYPE_WIFI);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_unset_enabled_cb is failed(%d)\n", ret);
+               }
 
+               ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_WIFI);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret);
+               }
+
+               /* Destroy tethering handle */
+               ret = tethering_destroy(th);
+               if (ret != TETHERING_ERROR_NONE) {
+                       DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret);
+               }
+
+               ugd->hotspot_handle = NULL;
+       }
+
+       __FUNC_EXIT__;
        return 0;
 }
 
+/**
+ *     This function let the ug turn wi-fi direct on
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_client_switch_on(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res;
-
-    DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status);
-
-    if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING)
-    {
-        ugd->wfd_status = WFD_LINK_STATUS_ACTIVATING;
-
-        int wifi_state;
-        res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
-        if (res != 0)
-        {
-            DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res);
-            // TODO: set genlist head item as "WiFi Direct"
-            return -1;
-        }
-
-        if(wifi_state > VCONFKEY_WIFI_OFF)
-        {
-            DBG(LOG_VERBOSE, "WiFi is connected, so have to turn off WiFi");
-            wfd_ug_act_popup(ugd, _("IDS_WFD_POP_WIFI_OFF"), POPUP_TYPE_WIFI_OFF); // "This will turn off Wi-Fi client operation.<br>Continue?"
-        }
-        else    // (wifi_state < VCONFKEY_WIFI_CONNECTED && !(hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI))
-        {
-            res = wifi_direct_activate();
-            if(res != WIFI_DIRECT_ERROR_NONE)
-            {
-                DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res);
-                wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-                ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-                wfd_ug_view_refresh_glitem(ugd->head);
-                return -1;
-            }
-        }
-    }
-    else
-    {
-        DBG(LOG_VERBOSE, "Wi-Fi Direct is already activated\n");
-    }
-
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+
+       wfd_refresh_wifi_direct_state(ugd);
+       DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status);
+
+       if (ugd->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
+               int wifi_state;
+               res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res);
+                       return -1;
+               }
+
+               int hotspot_mode;
+               res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to get mobile hotspot state from vconf. [%d]\n", res);
+                       return -1;
+               }
+
+               if (wifi_state > VCONFKEY_WIFI_OFF) {
+                       DBG(LOG_VERBOSE, "WiFi is connected, so have to turn off WiFi");
+                       wfd_ug_act_popup(ugd, _("IDS_WFD_POP_WIFI_OFF"), POPUP_TYPE_WIFI_OFF);
+               } else if (hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+                       DBG(LOG_VERBOSE, "WiFi is connected, so have to turn off WiFi");
+                       wfd_ug_act_popup(ugd, _("IDS_WFD_POP_HOTSPOT_OFF"), POPUP_TYPE_HOTSPOT_OFF);
+               } else {
+                       res = wifi_direct_activate();
+                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                               DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res);
+                               wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
+
+                               ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                               wfd_ug_view_refresh_glitem(ugd->head);
+                               return -1;
+                       }
+
+                       /* refresh the header */
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+
+                       /* while activating, disable the buttons */
+                       if (ugd->scan_btn) {
+                               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                       }
+
+                       if (ugd->multi_scan_btn) {
+                               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+                       }
+
+                       if (ugd->back_btn) {
+                               elm_object_disabled_set(ugd->back_btn, TRUE);
+                       }
+               }
+       } else {
+               DBG(LOG_VERBOSE, "Wi-Fi Direct is already activated\n");
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug turn wi-fi direct off
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_client_switch_off(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res;
-
-    DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status);
-
-    if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING)
-    {
-        DBG(LOG_VERBOSE, "Wi-Fi Direct is already deactivated\n");
-    }
-    else
-    {
-        ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATING;
-
-        res = wifi_direct_deactivate();
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            wfd_ug_view_refresh_glitem(ugd->head);
-            return -1;
-        }
-    }
-
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+
+       wfd_refresh_wifi_direct_state(ugd);
+       DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status);
+
+       if (ugd->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) {
+               DBG(LOG_VERBOSE, "Wi-Fi Direct is already deactivated\n");
+       } else {
+               /*if connected, disconnect all devices*/
+               if (WIFI_DIRECT_STATE_CONNECTED == ugd->wfd_status) {
+                       res = wifi_direct_disconnect_all();
+                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                               DBG(LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
+                               return -1;
+                       }
+               }
+
+               res = wifi_direct_deactivate();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
+
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+                       return -1;
+               }
+
+               /* refresh the header */
+               ugd->head_text_mode = HEAD_TEXT_TYPE_DEACTIVATING;
+               wfd_ug_view_refresh_glitem(ugd->head);
+
+               /* while deactivating, disable the buttons */
+               if (ugd->scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->multi_scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->back_btn) {
+                       elm_object_disabled_set(ugd->back_btn, TRUE);
+               }
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug turn wi-fi direct on/off forcely
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+  *    @param[in] onoff whether to turn on/off wi-fi direct
+ */
 int wfd_client_swtch_force(void *data, int onoff)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res;
-
-    if(onoff)
-    {
-        res = wifi_direct_activate();
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res);
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            wfd_ug_view_refresh_glitem(ugd->head);
-            return -1;
-        }
-    }
-    else
-    {
-        res = wifi_direct_deactivate();
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            wfd_ug_view_refresh_glitem(ugd->head);
-            return -1;
-        }
-    }
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int res;
+
+       if (onoff) {
+               res = wifi_direct_activate();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res);
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
+
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+                       return -1;
+               }
+       } else {
+               res = wifi_direct_deactivate();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res);
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
+
+                       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+                       wfd_ug_view_refresh_glitem(ugd->head);
+                       return -1;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
-int wfd_client_start_discovery(void *data)
+/**
+ *     This function let the ug create a group
+ *     @return   If success, return 0, else return -1
+ */
+int wfd_client_group_add()
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int res = -1;
-
-#if 0
-    ret = wifi_direct_cancel_discovery();
-//    ret = wifi_direct_cancel_discovery();
-    if (ret != WIFI_DIRECT_ERROR_NONE) {
-       DBG(LOG_ERROR, "Failed wfd discover() : %d", ret);
-       return FALSE;
-    }
-
-
-    if(ugd->wfd_status >= WIFI_DIRECT_STATE_ACTIVATED)
-    {
-        res = wifi_direct_start_discovery(FALSE, 30);
-        if (res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to start wfd discovery. [%d]", res);
-            return -1;
-        }
-    }
-#endif
-
-    ugd->wfd_status = WIFI_DIRECT_DISCOVERY_STARTED;
-    wfd_refresh_wifi_direct_state(ugd);
-    ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING;
-    wfd_ug_view_refresh_glitem(ugd->head);
-    wifi_direct_cancel_discovery();
-
-    res = wifi_direct_start_discovery(FALSE, 0);
-    if (res != WIFI_DIRECT_ERROR_NONE) {
-       DBG(LOG_ERROR, "Fail to restart scanning. %d\n", res);
-       return -1;
-    }
-
-    ugd->wfd_status = WIFI_DIRECT_DISCOVERY_FOUND;
-    wfd_refresh_wifi_direct_state(ugd);
-
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       int res;
+
+       res = wifi_direct_create_group();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to add group");
+               __FUNC_EXIT__;
+               return -1;
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug connect to the device by mac address
+ *     @return   If success, return 0, else return -1
+ *     @param[in] mac_addr the pointer to the mac address of device
+ */
 int wfd_client_connect(const char *mac_addr)
 {
-    __FUNC_ENTER__;
-    int res;
-
-    DBG(LOG_ERROR, "connect to peer=[%s]\n", mac_addr);
-    res = wifi_direct_connect(mac_addr);
-    if(res != WIFI_DIRECT_ERROR_NONE)
-    {
-        DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res);
-        return -1;
-    }
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       int res;
+
+       DBG(LOG_ERROR, "connect to peer=[%s]\n", mac_addr);
+       res = wifi_direct_connect(mac_addr);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res);
+               return -1;
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug disconnect to the device by mac address
+ *     @return   If success, return 0, else return -1
+ *     @param[in] mac_addr the pointer to the mac address of device
+ */
 int wfd_client_disconnect(const char *mac_addr)
 {
-    __FUNC_ENTER__;
-    int res;
-
-    if(mac_addr == NULL)
-    {
-        res = wifi_direct_disconnect_all();
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
-            return -1;
-        }
-    }
-    else
-    {
-        res = wifi_direct_disconnect(mac_addr);
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res);
-            return -1;
-        }
-    }
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       int res;
+
+       if (mac_addr == NULL) {
+               res = wifi_direct_disconnect_all();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
+                       return -1;
+               }
+       } else {
+               res = wifi_direct_disconnect(mac_addr);
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res);
+                       return -1;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug set the intent of a group owner
+ *     @return   If success, return 0, else return -1
+ *     @param[in] go_intent the intent parameter
+ */
 int wfd_client_set_p2p_group_owner_intent(int go_intent)
 {
-    __FUNC_ENTER__;
-    int res;
+       __FUNC_ENTER__;
+       int res;
 
        res = wifi_direct_set_group_owner_intent(go_intent);
-       if(res != WIFI_DIRECT_ERROR_NONE)
-       {
+       if (res != WIFI_DIRECT_ERROR_NONE) {
                DBG(LOG_ERROR, "Failed to wifi_direct_set_go_intent(%d). [%d]\n", go_intent, res);
                return -1;
        }
-    __FUNC_EXIT__;
-    return 0;
-}
-
-int wfd_client_get_peers(struct ug_data *ugd)
-{
-
-       if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATED)
-       {
-               ugd->raw_discovered_peer_cnt = 0;
-               ugd->raw_connected_peer_cnt = 0;
-               return 0;
-       }
-
-    if(ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING)
-    {
-        wfd_ug_get_discovered_peers(ugd);
-    }
 
-    if(ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED)
-    {
-        wfd_ug_get_connected_peers(ugd);
-    }
-
-    wfd_ug_view_update_peers(ugd);
-    _change_multi_button_title(ugd);
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
index 9c43fca..0105f0a 100755 (executable)
@@ -27,6 +27,7 @@
 #include <libintl.h>
 #include <sys/utsname.h>
 
+#include <vconf.h>
 #include <Elementary.h>
 #include <ui-gadget-module.h>
 #include <wifi-direct.h>
@@ -44,386 +45,480 @@ struct ug_data *wfd_get_ug_data()
        return global_ugd;
 }
 
-
+/**
+ *     This function let the ug create backgroud
+ *     @return  backgroud
+ *     @param[in] ugd the pointer to the parent object
+ *     @param[in] ugd the pointer to the main data structure
+ */
 static Evas_Object *_create_bg(Evas_Object *parent, char *style)
 {
-    __FUNC_ENTER__;
-    Evas_Object *bg;
+       __FUNC_ENTER__;
+       Evas_Object *bg;
 
-    bg = elm_bg_add(parent);
-    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_style_set(bg, style);
-    elm_win_resize_object_add(parent, bg);
-    evas_object_show(bg);
+       bg = elm_bg_add(parent);
+       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_style_set(bg, style);
+       elm_win_resize_object_add(parent, bg);
+       evas_object_show(bg);
 
-    __FUNC_EXIT__;
-    return bg;
+       __FUNC_EXIT__;
+       return bg;
 }
 
+/**
+ *     This function let the ug create full view
+ *     @return  full view
+ *     @param[in] ugd the pointer to the parent object
+ *     @param[in] ugd the pointer to the main data structure
+ */
 static Evas_Object *_create_fullview(Evas_Object *parent, struct ug_data *ugd)
 {
-    __FUNC_ENTER__;
-    Evas_Object *base;
-
-    if(parent == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrenct parameter");
-        return NULL;
-    }
-
-    /* Create Full view */
-    base = elm_layout_add(parent);
-    if(!base)
-    {
-        DBG(LOG_ERROR, "Failed to add layout");
-        return NULL;
-    }
-
-    elm_layout_theme_set(base, "layout", "application", "default");
-    evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
-    __FUNC_EXIT__;
-    return base;
+       __FUNC_ENTER__;
+       Evas_Object *base;
+
+       if (parent == NULL) {
+               DBG(LOG_ERROR, "Incorrenct parameter");
+               return NULL;
+       }
+
+       /* Create Full view */
+       base = elm_layout_add(parent);
+       if (!base) {
+               DBG(LOG_ERROR, "Failed to add layout");
+               return NULL;
+       }
+
+       elm_layout_theme_set(base, "layout", "application", "default");
+       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       __FUNC_EXIT__;
+       return base;
 }
 
+/**
+ *     This function let the ug create frame view
+ *     @return  frame view
+ *     @param[in] ugd the pointer to the parent object
+ *     @param[in] ugd the pointer to the main data structure
+ */
 static Evas_Object *_create_frameview(Evas_Object *parent, struct ug_data *ugd)
 {
-    __FUNC_ENTER__;
-    Evas_Object *base;
-
-    if(parent == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrenct parameter");
-        return NULL;
-    }
-
-    /* Create Frame view */
-    base = elm_layout_add(parent);
-    if(!base)
-    {
-        DBG(LOG_ERROR, "Failed to add layout");
-        return NULL;
-    }
-
-    elm_layout_theme_set(base, "layout", "application", "default");
-    evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
-    __FUNC_EXIT__;
-    return base;
+       __FUNC_ENTER__;
+       Evas_Object *base;
+
+       if (parent == NULL) {
+               DBG(LOG_ERROR, "Incorrenct parameter");
+               return NULL;
+       }
+
+       /* Create Frame view */
+       base = elm_layout_add(parent);
+       if (!base) {
+               DBG(LOG_ERROR, "Failed to add layout");
+               return NULL;
+       }
+
+       elm_layout_theme_set(base, "layout", "application", "default");
+       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       __FUNC_EXIT__;
+       return base;
 }
 
-
+/**
+ *     This function let the ug destroy the main view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void destroy_wfd_ug_view(void *data)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    struct ug_data *ugd = (struct ug_data*) data;
+       if (ugd->genlist) {
+               evas_object_del(ugd->genlist);
+               ugd->genlist = NULL;
+       }
 
-    if(ugd->genlist)
-    {
-        evas_object_del(ugd->genlist);
-        ugd->genlist = NULL;
-    }
+       if (ugd->naviframe) {
+               evas_object_del(ugd->naviframe);
+               ugd->naviframe = NULL;
+       }
 
-    if(ugd->naviframe)
-    {
-        evas_object_del(ugd->naviframe);
-        ugd->naviframe = NULL;
-    }
+       __FUNC_EXIT__;
+}
 
-    __FUNC_EXIT__;
+/**
+ *     This function let the ug initialize wfd when timeout
+ *     @return   if stop the timer, return false, else return true
+ *     @param[in] data the pointer to the main data structure
+ */
+gboolean _wfd_init_cb(void *data)
+{
+       __FUNC_ENTER__;
+       int res = -1;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_DEACTIVATED) {
+               res = init_wfd_client(ugd);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to initialize WFD client library\n");
+                       return true;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return false;
 }
 
-static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service,
-                      void *priv)
+static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd;
-    int res = 0;
-
-    if (!ug || !priv)
-        return NULL;
-
-    ugd = priv;
-    ugd->ug = ug;
-
-    bindtextdomain(PACKAGE, LOCALEDIR);
-
-    ugd->win = ug_get_window();
-    if (!ugd->win)
-        return NULL;
-
-    if (mode == UG_MODE_FULLVIEW)
-        ugd->base = _create_fullview(ugd->win, ugd);
-    else
-        ugd->base = _create_frameview(ugd->win, ugd);
-
-    if(ugd->base)
-    {
-        ugd->bg = _create_bg(ugd->win, "group_list");
-        elm_object_part_content_set(ugd->base, "elm.swallow.bg", ugd->bg);
-    }
-    else
-    {
-        DBG(LOG_ERROR, "Failed to create base layout\n");
-        return NULL;
-    }
-
-    wfd_get_vconf_status(ugd);
-
-    initialize_gen_item_class();
-
-    res = init_wfd_client(ugd);
-    if(res != 0)
-    {
-        DBG(LOG_ERROR, "Failed to initialize WFD client library\n");
-        wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_PROBLEM_WITH_WFD"), POPUP_TYPE_TERMINATE);
-    }
-
-    create_wfd_ug_view(ugd);
-
-    wfd_ug_view_refresh_glitem(ugd->head);
-    if (ugd->scan_btn) {
-       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE);
-    }
-
-    if(ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING)
-    {
-        wfd_ug_get_discovered_peers(ugd);
-    }
-
-    if(ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED)
-    {
-        wfd_ug_get_connected_peers(ugd);
-    }
-
-    wfd_ug_view_update_peers(ugd);
-
-    if (ugd->wfd_status == WIFI_DIRECT_STATE_ACTIVATED)
-    {
-        res = wifi_direct_start_discovery(FALSE, 0);
-        if(res != WIFI_DIRECT_ERROR_NONE)
-        {
-            DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
-        }
-        DBG(LOG_VERBOSE, "Discovery is started\n");
-    }
-
-    evas_object_show(ugd->base);
-
-    __FUNC_EXIT__;
-    return ugd->base;
+       __FUNC_ENTER__;
+       struct ug_data *ugd;
+       int res = 0;
+
+       if (!ug || !priv) {
+               return NULL;
+       }
+
+       ugd = priv;
+       ugd->ug = ug;
+
+       bindtextdomain(PACKAGE, LOCALEDIR);
+
+       ugd->win = ug_get_window();
+       if (!ugd->win) {
+               return NULL;
+       }
+
+       if (mode == UG_MODE_FULLVIEW) {
+               ugd->base = _create_fullview(ugd->win, ugd);
+       } else {
+               ugd->base = _create_frameview(ugd->win, ugd);
+       }
+
+       if (ugd->base) {
+               ugd->bg = _create_bg(ugd->win, "group_list");
+               elm_object_part_content_set(ugd->base, "elm.swallow.bg", ugd->bg);
+       } else {
+               DBG(LOG_ERROR, "Failed to create base layout\n");
+               return NULL;
+       }
+
+       /* check status of wifi-direct from vconf */
+       wfd_get_vconf_status(ugd);
+
+       /*
+       * if not deactivated, do initialization at once;
+       * otherwise, do initialization later
+       */
+       if (ugd->wfd_status > WIFI_DIRECT_STATE_DEACTIVATED || service) {
+               res = init_wfd_client(ugd);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to initialize WFD client library\n");
+               }
+
+               if (service) {
+                       int status = 0;
+                       char *data = NULL;
+
+                       /* get the status from appsvc */
+                       service_get_extra_data(service, "status", &data);
+                       if (data) {
+                               status = atoi(data);
+                       }
+
+                       /*
+                       * status -
+                       * 0 : No operation,
+                       * 1 : Activate ,
+                       * 2 : Deactivate
+                       */
+                       if (status == 0x01) {
+                               wfd_client_switch_on(ugd);
+                       } else if (status == 0x02) {
+                               wfd_client_switch_off(ugd);
+                       }
+               }
+       } else {
+               g_timeout_add(100, _wfd_init_cb, ugd);
+       }
+
+       if (ugd->wfd_status >= WIFI_DIRECT_STATE_ACTIVATED) {
+               wfd_ug_get_discovered_peers(ugd);
+       }
+
+       if (ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) {
+               wfd_ug_get_connected_peers(ugd);
+       }
+
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_ACTIVATED) {
+               /* start discovery */
+               res = wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
+                       ugd->is_re_discover = TRUE;
+                       wifi_direct_cancel_discovery();
+               } else {
+                       DBG(LOG_VERBOSE, "Discovery is started\n");
+                       ugd->is_re_discover = FALSE;
+               }
+       }
+
+       /* draw UI */
+       initialize_gen_item_class();
+       create_wfd_ug_view(ugd);
+       wfd_ug_view_update_peers(ugd);
+
+       evas_object_show(ugd->base);
+
+       __FUNC_EXIT__;
+       return ugd->base;
 }
 
 static void on_start(ui_gadget_h ug, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd;
-    int res;
-
-    if (!ug || !priv)
-        return;
-
-    ugd = priv;
-
-    struct utsname kernel_info;
-    res = uname(&kernel_info);
-    if(res != 0)
-    {
-        DBG(LOG_ERROR, "Failed to detect target type\n");
-    }
-    else
-    {
-        DBG(LOG_VERBOSE, "HW ID of this device [%s]\n", kernel_info.machine);
-        if(strncmp(kernel_info.machine, "arm", 3) != 0)
-        {
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_NOT_SUPPORTED_DEVICE"), POPUP_TYPE_TERMINATE);
-            return;
-        }
-    }
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       struct ug_data *ugd;
+       int res;
+
+       if (!ug || !priv) {
+               return;
+       }
+
+       ugd = priv;
+
+       struct utsname kernel_info;
+       res = uname(&kernel_info);
+       if (res != 0) {
+               DBG(LOG_ERROR, "Failed to detect target type\n");
+       } else {
+               DBG(LOG_VERBOSE, "HW ID of this device [%s]\n", kernel_info.machine);
+               if (strncmp(kernel_info.machine, "arm", 3) != 0) {
+                       wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_NOT_SUPPORTED_DEVICE"), POPUP_TYPE_TERMINATE);
+                       return;
+               }
+       }
+
+       __FUNC_EXIT__;
 }
 
 static void on_pause(ui_gadget_h ug, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       __FUNC_EXIT__;
 }
 
 static void on_resume(ui_gadget_h ug, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       __FUNC_EXIT__;
 }
 
 static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-
-    if (!ug || !priv)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
-
-    struct ug_data *ugd = priv;
-    if (ugd == NULL || ugd->base == NULL)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
-
-    deinit_wfd_client(ugd);
-    DBG(LOG_VERBOSE, "WFD client deregistered");
-
-    destroy_wfd_ug_view(ugd);
-    DBG(LOG_VERBOSE, "Destroying About item");
-
-    wfd_ug_view_free_peers(ugd);
-
-    DBG(LOG_VERBOSE, "WFD client deregistered");
-    if(ugd->bg)
-    {
-        evas_object_del(ugd->bg);
-        ugd->bg = NULL;
-    }
-    DBG(LOG_VERBOSE, "WFD client deregistered");
-
-    if(ugd->base)
-    {
-        evas_object_del(ugd->base);
-        ugd->base = NULL;
-    }
-
-    __FUNC_EXIT__;
-    return;
+       __FUNC_ENTER__;
+
+       if (!ug || !priv) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       struct ug_data *ugd = priv;
+       if (ugd == NULL || ugd->base == NULL) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       deinit_wfd_client(ugd);
+       DBG(LOG_VERBOSE, "WFD client deregistered");
+
+       destroy_wfd_ug_view(ugd);
+       DBG(LOG_VERBOSE, "Destroying About item");
+
+       wfd_ug_view_free_peers(ugd);
+
+       DBG(LOG_VERBOSE, "WFD client deregistered");
+       if (ugd->bg) {
+               evas_object_del(ugd->bg);
+               ugd->bg = NULL;
+       }
+       DBG(LOG_VERBOSE, "WFD client deregistered");
+
+       if (ugd->base) {
+               evas_object_del(ugd->base);
+               ugd->base = NULL;
+       }
+
+       __FUNC_EXIT__;
+       return;
 }
 
-static void on_message(ui_gadget_h ug, service_h msg, service_h service,
-                      void *priv)
+static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       __FUNC_EXIT__;
 }
 
-static void on_event(ui_gadget_h ug, enum ug_event event, service_h service,
-                    void *priv)
+static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-
-    if (!ug || !priv)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
-
-    switch (event)
-    {
-        case UG_EVENT_LOW_MEMORY:
-            DBG(LOG_VERBOSE, "UG_EVENT_LOW_MEMORY\n");
-            break;
-        case UG_EVENT_LOW_BATTERY:
-            DBG(LOG_VERBOSE, "UG_EVENT_LOW_BATTERY\n");
-            break;
-        case UG_EVENT_LANG_CHANGE:
-            DBG(LOG_VERBOSE, "UG_EVENT_LANG_CHANGE\n");
-            break;
-        case UG_EVENT_ROTATE_PORTRAIT:
-            DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT\n");
-            break;
-        case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
-            DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN\n");
-            break;
-        case UG_EVENT_ROTATE_LANDSCAPE:
-            DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE\n");
-            break;
-        case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
-            DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN\n");
-            break;
-        default:
-            DBG(LOG_VERBOSE, "default\n");
-            break;
-    }
-
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+
+       if (!ug || !priv) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       switch (event) {
+       case UG_EVENT_LOW_MEMORY:
+               DBG(LOG_VERBOSE, "UG_EVENT_LOW_MEMORY\n");
+               break;
+       case UG_EVENT_LOW_BATTERY:
+               DBG(LOG_VERBOSE, "UG_EVENT_LOW_BATTERY\n");
+               break;
+       case UG_EVENT_LANG_CHANGE:
+               DBG(LOG_VERBOSE, "UG_EVENT_LANG_CHANGE\n");
+               break;
+       case UG_EVENT_ROTATE_PORTRAIT:
+               DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT\n");
+               break;
+       case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
+               DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN\n");
+               break;
+       case UG_EVENT_ROTATE_LANDSCAPE:
+               DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE\n");
+               break;
+       case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
+               DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN\n");
+               break;
+       default:
+               DBG(LOG_VERBOSE, "default\n");
+               break;
+       }
+
+       __FUNC_EXIT__;
 }
 
-static void on_key_event(ui_gadget_h ug, enum ug_key_event event,
-                        service_h service, void *priv)
+static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
 {
-    __FUNC_ENTER__;
-
-    if (!ug || !priv)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
-
-    switch (event)
-    {
-        case UG_KEY_EVENT_END:
-            DBG(LOG_VERBOSE, "UG_KEY_EVENT_END\n");
-            break;
-        default:
-            break;
-    }
-
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+
+       if (!ug || !priv) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       switch (event) {
+       case UG_KEY_EVENT_END:
+               DBG(LOG_VERBOSE, "UG_KEY_EVENT_END\n");
+               break;
+       default:
+               break;
+       }
+
+       __FUNC_EXIT__;
 }
 
 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd;
-
-    if (!ops)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return -1;
-    }
-
-    ugd = calloc(1, sizeof(struct ug_data));
-    if (ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Failed to allocate memory for UG data\n");
-        return -1;
-    }
-
-    global_ugd = ugd;
-
-    ops->create = on_create;
-    ops->start = on_start;
-    ops->pause = on_pause;
-    ops->resume = on_resume;
-    ops->destroy = on_destroy;
-    ops->message = on_message;
-    ops->event = on_event;
-    ops->key_event = on_key_event;
-    ops->priv = ugd;
-    ops->opt = UG_OPT_INDICATOR_ENABLE;
-
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_ENTER__;
+       struct ug_data *ugd;
+
+       if (!ops) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return -1;
+       }
+
+       ugd = calloc(1, sizeof(struct ug_data));
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Failed to allocate memory for UG data\n");
+               return -1;
+       }
+
+       global_ugd = ugd;
+
+       ops->create = on_create;
+       ops->start = on_start;
+       ops->pause = on_pause;
+       ops->resume = on_resume;
+       ops->destroy = on_destroy;
+       ops->message = on_message;
+       ops->event = on_event;
+       ops->key_event = on_key_event;
+       ops->priv = ugd;
+       ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
 
-    struct ug_data *ugd;
+       struct ug_data *ugd;
 
-    if (!ops)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
+       if (!ops) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
 
-    ugd = ops->priv;
+       ugd = ops->priv;
 
-    if (ugd)
-        free(ugd);
+       if (ugd) {
+               free(ugd);
+       }
 
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
 }
+
+UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
+{
+       __FUNC_ENTER__;
+       int res = -1;
+       wifi_direct_state_e state;
+
+       res = wifi_direct_initialize();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to initialize wifi direct. [%d]\n", res);
+               return -1;
+       }
+
+       res = wifi_direct_get_state(&state);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to get link status. [%d]\n", res);
+               return -1;
+       }
+
+       if (state < WIFI_DIRECT_STATE_ACTIVATING) {
+               DBG(LOG_VERBOSE, "No need to reset Wi-Fi Direct.\n");
+       } else {
+               /*if connected, disconnect all devices*/
+               if (WIFI_DIRECT_STATE_CONNECTED == state) {
+                       res = wifi_direct_disconnect_all();
+                       if (res != WIFI_DIRECT_ERROR_NONE) {
+                               DBG(LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res);
+                               return -1;
+                       }
+               }
+
+               res = wifi_direct_deactivate();
+               if (res != WIFI_DIRECT_ERROR_NONE) {
+                       DBG(LOG_ERROR, "Failed to reset Wi-Fi Direct. [%d]\n", res);
+                       return -1;
+               }
+       }
+
+       res = wifi_direct_deinitialize();
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to deinitialize wifi direct. [%d]\n", res);
+               return -1;
+       }
+
+       __FUNC_EXIT__;
+       return 0;
+}
+
index 5c1f7d2..e290e15 100644 (file)
 
 static Elm_Genlist_Item_Class itc;
 
+/**
+ *     This function let the ug get the label of about
+ *     @return   the label of about
+ *     @param[in] parent the pointer to the label's parent
+  *    @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_wfd_gl_label_help_dialogue_get(void *data, Evas_Object *obj, const char *part)
 {
-       DBG(LOG_VERBOSE, "Adding text");
-
-       if (!strcmp(part, "elm.text.2")) {
-               return strdup(_("IDS_WFD_BODY_ABOUT_WIFI"));
-       }
-       return NULL;
-}
-
-static Evas_Object *_wfd_gl_help_icon_get(void *data, Evas_Object * obj, const char *part)
-{
-    __FUNC_ENTER__;
-
-    DBG(LOG_VERBOSE, "Current part: %s\n", part);
-    Evas_Object *label = NULL;
-    char content[1024] = {0};
-
-    label = elm_label_add(obj);
-    snprintf(content, 1024, "<color=#7C7C7CFF><font_size=32>%s</font_size></color>", _("IDS_WFD_BODY_ABOUT_WIFI"));
-    elm_label_line_wrap_set(label, ELM_WRAP_WORD);
-    elm_object_text_set(label, content);
-    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0);
-    evas_object_show(label);
-
-    __FUNC_EXIT__;
-    return label;
+       return strdup(_("IDS_WFD_BODY_ABOUT_WIFI"));
 }
 
+/**
+ *     This function let the ug call it when click 'back' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _about_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    if(!ugd)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
+       if (!ugd) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
 
-   elm_naviframe_item_pop(ugd->naviframe);
+       elm_naviframe_item_pop(ugd->naviframe);
 
-    __FUNC_EXIT__;
-    return;
+       __FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the ug create about view
+ *     @return   void
+ *     @param[in] ugd the pointer to the main data structure
+ */
 void _wifid_create_about_view(struct ug_data *ugd)
 {
+       __FUNC_ENTER__;
+
+       Evas_Object *back_btn = NULL;
+       Elm_Object_Item *navi_item = NULL;
+       Evas_Object *genlist = NULL;
+       Elm_Object_Item *item = NULL;
+
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)");
+               return;
+       }
+
+       genlist = elm_genlist_add(ugd->naviframe);
+       if (NULL == genlist) {
+               DBG(LOG_ERROR, "Create genlist failed\n");
+               return;
+       }
+
+       elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+
+       /* Set multiline item class */
+       itc.item_style = "multiline/1text";
+       itc.func.text_get = _wfd_gl_label_help_dialogue_get;
+       itc.func.content_get = NULL;
+       itc.func.state_get = NULL;
+       itc.func.del = NULL;
+
+       item = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+       back_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(back_btn, "naviframe/back_btn/default");
+       evas_object_smart_callback_add(back_btn, "clicked", _about_view_back_btn_cb, (void *)ugd);
+       elm_object_focus_allow_set(back_btn, EINA_FALSE);
 
-    Evas_Object *back_btn = NULL;
-    Elm_Object_Item *navi_item = NULL;
-    Evas_Object *control_bar = NULL;
-    Elm_Object_Item *item = NULL;
-    Evas_Object *genlist = NULL;
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)");
-        return;
-    }
-
-    genlist = elm_genlist_add(ugd->naviframe);
-    elm_object_style_set(genlist, "dialogue");
-
-    DBG(LOG_VERBOSE, "creating about view");
-    elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
-#if 0
-    itc.item_style = "multiline/1text";
-    itc.func.text_get = _wfd_gl_label_help_dialogue_get;
-    itc.func.content_get = NULL;
-#else
-    itc.item_style = "1icon";
-    itc.func.text_get = NULL;
-    itc.func.content_get = _wfd_gl_help_icon_get;
-#endif
-    itc.func.state_get = NULL;
-    itc.func.del = NULL;
-    back_btn = elm_button_add(ugd->naviframe);
-    elm_object_style_set(back_btn, "naviframe/back_btn/default");
-    evas_object_smart_callback_add(back_btn, "clicked", _about_view_back_btn_cb, (void*) ugd);
-    elm_object_focus_allow_set(back_btn, EINA_FALSE);
-
-    item = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-    elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-    evas_object_show(genlist);
-    navi_item = elm_naviframe_item_push(ugd->naviframe, _("IDS_WFD_TITLE_ABOUT_WIFI"), back_btn, NULL, genlist, NULL);
-
-    control_bar = elm_toolbar_add(ugd->naviframe);
-    elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
-    evas_object_show(control_bar);
-    elm_object_item_part_content_set(navi_item, "controlbar", control_bar);
+       navi_item = elm_naviframe_item_push(ugd->naviframe, IDS_WFD_TITLE_ABOUT_WIFI_DIRECT, back_btn, NULL, genlist, NULL);
 
+       __FUNC_EXIT__;
 }
index 836c5b3..dae010d 100755 (executable)
 #include "wfd_ug_view.h"
 #include "wfd_client.h"
 
-Elm_Gen_Item_Class sep_itc;
-Elm_Gen_Item_Class sep_itc_end;
 Elm_Gen_Item_Class head_itc;
 Elm_Gen_Item_Class name_itc;
 Elm_Gen_Item_Class title_itc;
 Elm_Gen_Item_Class peer_itc;
 Elm_Gen_Item_Class noitem_itc;
-Elm_Gen_Item_Class help_itc;
 Elm_Gen_Item_Class button_itc;
 
 Elm_Gen_Item_Class title_conn_itc;
@@ -53,149 +50,164 @@ Elm_Gen_Item_Class peer_multi_connect_itc;
 Elm_Gen_Item_Class title_conn_failed_itc;
 Elm_Gen_Item_Class peer_conn_failed_itc;
 
-
-static char *_gl_header_label_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the label of header
+ *     @return   the label of header
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_header_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    DBG(LOG_VERBOSE, "%s", part);
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if(!strcmp(part, "elm.text.1"))
-    {
-        DBG(LOG_VERBOSE, "Current text mode [%d]\n", ugd->head_text_mode);
-        switch(ugd->head_text_mode)
-        {
-            case HEAD_TEXT_TYPE_DIRECT:
-           case HEAD_TEXT_TYPE_ACTIVATED:
-           case HEAD_TEXT_TYPE_SCANING:
-                return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
-                break;
-            case HEAD_TEXT_TYPE_DEACTIVATING:
-                return strdup(_("IDS_WFD_BODY_DEACTIVATING")); // "Deactivating Wi-Fi Direct..."
-                break;
-            case HEAD_TEXT_TYPE_ACTIVATING:
-                return strdup(_("IDS_WFD_BODY_ACTIVATING")); //"Activating Wi-Fi Direct..."
-                break;
-            default:
-                break;
-        }
-    }
-    else if(!strcmp(part, "elm.text.1"))
-    {
-       return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
-    } else if(!strcmp(part, "elm.text.2"))
-    {
-        return strdup(ugd->dev_name);
-    }
-
-    __FUNC_EXIT__;
-    return NULL;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       DBG(LOG_VERBOSE, "%s", part);
+
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.text.1")) {
+               DBG(LOG_VERBOSE, "Current text mode [%d]\n", ugd->head_text_mode);
+               switch (ugd->head_text_mode) {
+               case HEAD_TEXT_TYPE_DIRECT:
+               case HEAD_TEXT_TYPE_ACTIVATED:
+               case HEAD_TEXT_TYPE_SCANING:
+                       return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
+                       break;
+               case HEAD_TEXT_TYPE_DEACTIVATING:
+                       return strdup(_("IDS_WFD_BODY_DEACTIVATING"));
+                       break;
+               case HEAD_TEXT_TYPE_ACTIVATING:
+                       return strdup(_("IDS_WFD_BODY_ACTIVATING"));
+                       break;
+               default:
+                       break;
+               }
+       } else if (!strcmp(part, "elm.text.1")) {
+               return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
+       } else if (!strcmp(part, "elm.text.2")) {
+               return strdup(ugd->dev_name);
+       }
+
+       __FUNC_EXIT__;
+       return NULL;
 }
 
-static Evas_Object *_gl_header_icon_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the icon of header
+ *     @return   the icon of header
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static Evas_Object *_gl_header_icon_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    Evas_Object *onoff = NULL;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if(ugd->head_text_mode == HEAD_TEXT_TYPE_ACTIVATING ||
-        ugd->head_text_mode == HEAD_TEXT_TYPE_DEACTIVATING)
-        return NULL;
-
-    DBG(LOG_VERBOSE, "%s", part);
-    onoff = elm_check_add(obj);
-    elm_object_style_set(onoff, "on&off");
-    elm_check_state_set(onoff, ugd->wfd_onoff);
-    evas_object_smart_callback_add(onoff, "changed", _wfd_onoff_btn_cb, ugd);
-    evas_object_show(onoff);
-
-    __FUNC_EXIT__;
-
-    return onoff;
-}
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       Evas_Object *onoff = NULL;
 
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
 
+       if (ugd->head_text_mode == HEAD_TEXT_TYPE_ACTIVATING ||
+               ugd->head_text_mode == HEAD_TEXT_TYPE_DEACTIVATING) {
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.icon")) {
+               onoff = elm_check_add(obj);
+               elm_object_style_set(onoff, "on&off");
+               elm_check_state_set(onoff, ugd->wfd_onoff);
+               evas_object_show(onoff);
+       }
+
+       __FUNC_EXIT__;
+       return onoff;
+}
+
+/**
+ *     This function let the ug get the label of about item
+ *     @return   the label of about item
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_gl_name_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    DBG(LOG_VERBOSE, "%s", part);
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
 
-    if(!strcmp(part, "elm.text"))
-    {
-        return strdup(_("IDS_WFD_TITLE_ABOUT_WIFI")); // "Device name"
-    }
-    else if(!strcmp(part, "elm.text.2"))
-    {
-        return strdup(ugd->dev_name);
-    }
+       DBG(LOG_VERBOSE, "%s", part);
 
-    __FUNC_EXIT__;
+       if (!strcmp(part, "elm.text")) {
+               return strdup(IDS_WFD_TITLE_ABOUT_WIFI_DIRECT);
+       } else if (!strcmp(part, "elm.text.2")) {
+               return strdup(ugd->dev_name);
+       }
 
-    return NULL;
+       __FUNC_EXIT__;
+       return NULL;
 }
 
-
-static char *_gl_title_label_get(void *data, Evas_Object *obj,
-               const char *part)
+/**
+ *     This function let the ug get the label of titile
+ *     @return   the label of titile
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_title_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if (!strcmp(part, "elm.text"))
-    {
-       if (ugd->multiconn_view_genlist != NULL)
-       {
-               // It's called at Multi connect view...
-                       if(ugd->gl_available_dev_cnt_at_multiconn_view > 0)
-                               return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices"
-                       else
-                               return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES")); // "Wi-Fi Direct devices"
-       }
-       else
-       {
-               // It's called at Main View
-                       if(ugd->gl_available_peer_cnt > 0)
-                               return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices"
-                       else
-                               return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES")); // "Wi-Fi Direct devices"
-       }
-    }
-
-    __FUNC_EXIT__;
-
-    return NULL;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.text")) {
+               if (ugd->multiconn_view_genlist != NULL) {
+                       // It's called at Multi connect view...
+                       if (ugd->gl_available_dev_cnt_at_multiconn_view > 0) {
+                               return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
+                       } else {
+                               return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES"));
+                       }
+               } else {
+                       // It's called at Main View
+                       if (ugd->gl_available_peer_cnt > 0) {
+                               return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
+                       } else {
+                               return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES"));
+                       }
+               }
+       }
+
+       __FUNC_EXIT__;
+       return NULL;
 }
 
+/**
+ *     This function let the ug get the content of titile
+ *     @return   the content of titile
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static Evas_Object *_gl_title_content_get(void *data, Evas_Object *obj, const char *part)
 {
        Evas_Object *progressbar = NULL;
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *) data;
 
        if (data == NULL) {
            DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
@@ -217,225 +229,223 @@ static Evas_Object *_gl_title_content_get(void *data, Evas_Object *obj, const ch
        return progressbar;
 }
 
-static char *_gl_peer_label_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the label of peer item
+ *     @return   the label of peer item
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_peer_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    assertm_if(NULL == obj, "NULL!!");
-    assertm_if(NULL == part, "NULL!!");
-
-   device_type_s *peer = (device_type_s*) data;
-   char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
-   DBG(LOG_VERBOSE, "%s", part);
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if (!strcmp(part, "elm.text.1"))
-    {
-       __FUNC_EXIT__;
-        return strdup(peer->ssid);
-    }
-    else if (!strcmp(part, "elm.text.2"))
-    {
-        switch (peer->conn_status) {
-        case PEER_CONN_STATUS_DISCONNECTED:
-            g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"),
-                            WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-
-        case PEER_CONN_STATUS_CONNECTING:
-            g_strlcpy(buf, _("IDS_WFD_CONNECTING"),
-                    WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-
-        case PEER_CONN_STATUS_CONNECTED:
-            g_strlcpy(buf, _("IDS_WFD_CONNECTED"),
-                WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-
-        case PEER_CONN_STATUS_FAILED_TO_CONNECT:
-            g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"),
-                WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-
-        case PEER_CONN_STATUS_WAIT_FOR_CONNECT:
-            g_strlcpy(buf, _("IDS_WFD_WAITING_FOR_CONNECT"),
-                WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-
-        default:
-            g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"),
-                WFD_GLOBALIZATION_STR_LENGTH);
-        break;
-        }
-    }
-    else
-    {
-       __FUNC_EXIT__;
-       return NULL;
-    }
-
-    __FUNC_EXIT__;
-    return strdup(buf);
+       __FUNC_ENTER__;
+       assertm_if(NULL == obj, "NULL!!");
+       assertm_if(NULL == part, "NULL!!");
+       device_type_s *peer = (device_type_s *) data;
+       char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
+       DBG(LOG_VERBOSE, "%s", part);
+
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.text.1")) {
+               __FUNC_EXIT__;
+               return strdup(peer->ssid);
+       } else if (!strcmp(part, "elm.text.2")) {
+               switch (peer->conn_status) {
+               case PEER_CONN_STATUS_DISCONNECTED:
+                       g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
+                       break;
+               case PEER_CONN_STATUS_CONNECTING:
+                       g_strlcpy(buf, _("IDS_WFD_CONNECTING"), WFD_GLOBALIZATION_STR_LENGTH);
+                       break;
+               case PEER_CONN_STATUS_CONNECTED:
+                       if (peer->is_group_owner == FALSE) {
+                               g_strlcpy(buf, _("IDS_WFD_CONNECTED"), WFD_GLOBALIZATION_STR_LENGTH);
+                       } else {
+                               g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
+                       }
+                       break;
+               case PEER_CONN_STATUS_FAILED_TO_CONNECT:
+                       g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
+                       break;
+               case PEER_CONN_STATUS_WAIT_FOR_CONNECT:
+                       g_strlcpy(buf, _("IDS_WFD_WAITING_FOR_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
+                       break;
+               default:
+                       g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
+                       break;
+               }
+       } else {
+               __FUNC_EXIT__;
+               return NULL;
+       }
+
+       __FUNC_EXIT__;
+       return strdup(buf);
 }
 
-static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the icon of peer item
+ *     @return   the icon of peer item
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    assertm_if(NULL == obj, "NULL!!");
-    assertm_if(NULL == part, "NULL!!");
-
-    device_type_s *peer = (device_type_s*) data;
-    Evas_Object *icon = NULL;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if(!strcmp(part, "elm.icon.2"))
-    {
-        DBG(LOG_VERBOSE, "elm.icon.2 - connection status [%d]\n", peer->conn_status);
-        if(peer->conn_status == PEER_CONN_STATUS_CONNECTING)
-        {
-            icon = elm_progressbar_add(obj);
-            elm_object_style_set(icon, "list_process");
-            elm_progressbar_pulse(icon, EINA_TRUE);
-        }
-        else if(peer->conn_status == PEER_CONN_STATUS_CONNECTED)
-        {
-#if 0
-            icon = elm_icon_add(obj);
-            elm_icon_file_set(icon, WFD_ICON_CONNECTED, NULL);
-#endif
-               return NULL;
-        }
-
-        evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
-        elm_icon_resizable_set(icon, 1, 1);
-        evas_object_show(icon);
-    }
-    else if(!strcmp(part, "elm.icon.1"))
-    {
-        DBG(LOG_VERBOSE, "elm.icon.1 - category [%d]\n", peer->category);
-        char *img_path = NULL;
-        switch(peer->category)
-        {
+       __FUNC_ENTER__;
+       assertm_if(NULL == obj, "NULL!!");
+       assertm_if(NULL == part, "NULL!!");
+       device_type_s *peer = (device_type_s *) data;
+       Evas_Object *icon = NULL;
+       struct ug_data *ugd = wfd_get_ug_data();
+
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.icon.2")) {
+               DBG(LOG_VERBOSE, "elm.icon.2 - connection status [%d]\n", peer->conn_status);
+               if (peer->conn_status == PEER_CONN_STATUS_CONNECTING) {
+                       icon = elm_progressbar_add(obj);
+                       elm_object_style_set(icon, "list_process");
+                       elm_progressbar_pulse(icon, EINA_TRUE);
+               } else if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       return NULL;
+               }
+
+               evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+               elm_icon_resizable_set(icon, 1, 1);
+               evas_object_show(icon);
+       } else if (!strcmp(part, "elm.icon.1")) {
+               DBG(LOG_VERBOSE, "elm.icon.1 - category [%d]\n", peer->category);
+               char *img_path = NULL;
+               int status = -1;
+
+               status = wfd_get_device_status(ugd, peer);
+
+               /*
+               * the icon of connected device is
+               * different from available and busy device
+               */
+               switch (peer->category) {
                case WFD_DEVICE_TYPE_COMPUTER:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_COMPUTER;
                        }
                        break;
                case WFD_DEVICE_TYPE_INPUT_DEVICE:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_INPUT_DEVICE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_INPUT_DEVICE;
                        }
                        break;
                case WFD_DEVICE_TYPE_PRINTER:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_PRINTER_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_PRINTER;
                        }
                        break;
                case WFD_DEVICE_TYPE_CAMERA:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_CAMERA_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_CAMERA;
                        }
                        break;
                case WFD_DEVICE_TYPE_STORAGE:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_STORAGE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_STORAGE;
                        }
                        break;
                case WFD_DEVICE_TYPE_NW_INFRA:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_NETWORK_INFRA_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_NETWORK_INFRA;
                        }
                        break;
                case WFD_DEVICE_TYPE_DISPLAYS:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_DISPLAY_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_DISPLAY;
                        }
                        break;
                case WFD_DEVICE_TYPE_MM_DEVICES:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE;
                        }
                        break;
                case WFD_DEVICE_TYPE_GAME_DEVICES:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_GAMING_DEVICE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_GAMING_DEVICE;
                        }
                        break;
                case WFD_DEVICE_TYPE_TELEPHONE:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_TELEPHONE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_TELEPHONE;
                        }
                        break;
                case WFD_DEVICE_TYPE_AUDIO:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_AUDIO_DEVICE_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_AUDIO_DEVICE;
                        }
                        break;
                default:
-                       if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
+                       if (1 == status) {
                                img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT;
                        } else {
                                img_path = WFD_ICON_DEVICE_COMPUTER;
                        }
                        break;
-        }
-
-        if(img_path != NULL)
-        {
-            icon = elm_icon_add(obj);
-            elm_icon_file_set(icon, img_path, NULL);
-            evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
-            elm_icon_resizable_set(icon, 1, 1);
-            evas_object_show(icon);
-        }
-        else
-        {
-               return NULL;
-        }
-    }
-
-    __FUNC_EXIT__;
-    return icon;
-}
+               }
 
+               if (img_path != NULL) {
+                       icon = elm_icon_add(obj);
+                       elm_icon_file_set(icon, img_path, NULL);
+                       evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+                       elm_icon_resizable_set(icon, 1, 1);
+                       evas_object_show(icon);
+               } else {
+                       return NULL;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return icon;
+}
 
-static char *_gl_noitem_text_get(void *data, Evas_Object * obj,
-                                         const char *part)
+/**
+ *     This function let the ug get the text of no device item
+ *     @return   the text of no device item
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_noitem_text_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
 
-       if(data == NULL)
-       {
+       if (data == NULL) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return NULL;
        }
@@ -444,359 +454,340 @@ static char *_gl_noitem_text_get(void *data, Evas_Object * obj,
        return strdup(_("IDS_WFD_NOCONTENT"));
 }
 
-
-static char *_gl_help_label_get(void *data, Evas_Object * obj, const char *part)
-{
-    __FUNC_ENTER__;
-    DBG(LOG_VERBOSE, "%s", part);
-    __FUNC_EXIT__;
-    return strdup("Help");
-}
-
-
-static Evas_Object *_gl_button_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the multi connect button
+ *     @return   the multi connect button
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static Evas_Object *_gl_button_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-
-    DBG(LOG_VERBOSE, "%s", part);
-
-    ugd->multi_btn = elm_button_add(obj);
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
+       DBG(LOG_VERBOSE, "%s", part);
+       ugd->multi_btn = elm_button_add(obj);
        wfd_refresh_wifi_direct_state(ugd);
 
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED)
-       {
-               elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT"));
-               DBG(LOG_VERBOSE, "button: Disconnect\n");
-
-               // Don't connect "clicked" callback.
-               return ugd->multi_btn;
-       }
-
-       if (ugd->wfd_status == WFD_LINK_STATUS_CONNECTING)
-       {
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING) {
                elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_CANCEL"));
                DBG(LOG_VERBOSE, "button: Cancel connect\n");
-       }
-       else if (ugd->wfd_status >= WFD_LINK_STATUS_CONNECTED)
-       {
-               if (ugd->gl_connected_peer_cnt > 1)
-               {
+       } else {
+               if (ugd->gl_connected_peer_cnt > 1) {
                        elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT_ALL"));
                        DBG(LOG_VERBOSE, "button: Disconnect All\n");
-               }
-               else
-               {
+               } else if (ugd->gl_connected_peer_cnt == 1) {
                        elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT"));
                        DBG(LOG_VERBOSE, "button: Disconnect\n");
+               } else {
+                       elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_MULTI"));
+                       DBG(LOG_VERBOSE, "button: Multi connect\n");
                }
        }
-       else
-       {
-               elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_MULTI"));
-               DBG(LOG_VERBOSE, "button: Multi connect\n");
-       }
 
-    evas_object_smart_callback_add(ugd->multi_btn, "clicked", _wifid_create_multibutton_cb, ugd);
-    evas_object_show(ugd->multi_btn);
+       evas_object_smart_callback_add(ugd->multi_btn, "clicked", _wifid_create_multibutton_cb, ugd);
+       evas_object_show(ugd->multi_btn);
 
-    __FUNC_EXIT__;
-
-    return ugd->multi_btn;
+       __FUNC_EXIT__;
+       return ugd->multi_btn;
 }
 
-
-static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj,
-               const char *part)
+/**
+ *     This function let the ug get the title label of connected device list
+ *     @return   the title label of connected device list
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
+       __FUNC_ENTER__;
 
-    if (!strcmp(part, "elm.text"))
-    {
-            return strdup(_("IDS_WFD_BODY_CONNECTED_DEVICES"));
-    }
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
 
-    __FUNC_EXIT__;
+       if (!strcmp(part, "elm.text")) {
+               return strdup(_("IDS_WFD_BODY_CONNECTED_DEVICES"));
+       }
 
-    return NULL;
+       __FUNC_EXIT__;
+       return NULL;
 }
 
-
-static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the label of connected device
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object *obj, const char *part)
 {
        __FUNC_ENTER__;
        assertm_if(NULL == obj, "NULL!!");
        assertm_if(NULL == part, "NULL!!");
-
-       device_type_s *peer = (device_type_s*) data;
-
+       device_type_s *peer = (device_type_s *) data;
        char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
        DBG(LOG_VERBOSE, "%s", part);
-       if(data == NULL)
-       {
+
+       if (data == NULL) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return NULL;
        }
 
-       if (!strcmp(part, "elm.text.1"))
-       {
+       if (!strcmp(part, "elm.text.1")) {
                return strdup(peer->ssid);
-       }
-       else
-       {
-               g_strlcpy(buf, _("IDS_WFD_CONNECTED"),
-                                               WFD_GLOBALIZATION_STR_LENGTH);
+       } else {
+               g_strlcpy(buf, _("IDS_WFD_CONNECTED"), WFD_GLOBALIZATION_STR_LENGTH);
                __FUNC_EXIT__;
                return strdup(buf);
        }
 }
 
+/**
+ *     This function let the ug get the title label of connected failed device list
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj,
                const char *part)
 {
-    __FUNC_ENTER__;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
+       __FUNC_ENTER__;
 
-    if (!strcmp(part, "elm.text"))
-    {
-            return strdup(IDS_WFD_BODY_FAILED_DEVICES);
-    }
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
 
-    __FUNC_EXIT__;
+       if (!strcmp(part, "elm.text")) {
+               return strdup(IDS_WFD_BODY_FAILED_DEVICES);
+       }
 
-    return NULL;
+       __FUNC_EXIT__;
+       return NULL;
 }
 
-
-static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the label of connected failed device
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object *obj, const char *part)
 {
        __FUNC_ENTER__;
        assertm_if(NULL == obj, "NULL!!");
        assertm_if(NULL == part, "NULL!!");
-
-       device_type_s *peer = (device_type_s*) data;
-
+       device_type_s *peer = (device_type_s *) data;
        char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
        DBG(LOG_VERBOSE, "%s", part);
-       if(data == NULL)
-       {
+
+       if (data == NULL) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return NULL;
        }
 
-       if (!strcmp(part, "elm.text.1"))
-       {
+       if (!strcmp(part, "elm.text.1")) {
                return strdup(peer->ssid);
-       }
-       else
-       {
-               g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"),
-                                               WFD_GLOBALIZATION_STR_LENGTH);
+       } else {
+               g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
                __FUNC_EXIT__;
                return strdup(buf);
        }
 }
 
-static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj,
-               const char *part)
+/**
+ *     This function let the ug get the title label of multi connect list
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = wfd_get_ug_data();
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-    if (!strcmp(part, "elm.text"))
-    {
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS)
-               return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices"
-       else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED)
-               return strdup(IDS_WFD_BODY_FAILED_DEVICES); // "Available devices"
-    }
-
-    __FUNC_EXIT__;
-
-    return NULL;
-}
+       __FUNC_ENTER__;
+       struct ug_data *ugd = wfd_get_ug_data();
+
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
+
+       if (!strcmp(part, "elm.text")) {
+               if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
+                       return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
+               } else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
+                       return strdup(IDS_WFD_BODY_FAILED_DEVICES);
+               }
+       }
 
+       __FUNC_EXIT__;
+       return NULL;
+}
 
+/**
+ *     This function let the ug get the title label of busy device list
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj,
                const char *part)
 {
-    __FUNC_ENTER__;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
+       __FUNC_ENTER__;
 
-    if (!strcmp(part, "elm.text"))
-    {
-            return strdup(_("IDS_WFD_BODY_BUSY_DEVICES"));
-    }
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return NULL;
+       }
 
-    __FUNC_EXIT__;
+       if (!strcmp(part, "elm.text")) {
+               return strdup(_("IDS_WFD_BODY_BUSY_DEVICES"));
+       }
 
-    return NULL;
+       __FUNC_EXIT__;
+       return NULL;
 }
 
-
-static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object * obj, const char *part)
+/**
+ *     This function let the ug get the label of busy device
+ *     @return   the label of connected device
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
+static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object *obj, const char *part)
 {
        __FUNC_ENTER__;
        assertm_if(NULL == obj, "NULL!!");
        assertm_if(NULL == part, "NULL!!");
-       device_type_s *peer = (device_type_s*) data;
+       device_type_s *peer = (device_type_s *) data;
        char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
        DBG(LOG_VERBOSE, "%s", part);
-       if(data == NULL)
-       {
+
+       if (data == NULL) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return NULL;
        }
+
        DBG(LOG_VERBOSE, "peer->ssid = %s", peer->ssid);
-       if (!strcmp(part, "elm.text.1"))
-       {
+
+       if (!strcmp(part, "elm.text.1")) {
                return strdup(peer->ssid);
-       }
-       else
-       {
-               g_strlcpy(buf, _("IDS_WFD_CONNECTED_WITH_OTHER_DEVICE"),
-                                               WFD_GLOBALIZATION_STR_LENGTH);
+       } else {
+               g_strlcpy(buf, _("IDS_WFD_CONNECTED_WITH_OTHER_DEVICE"), WFD_GLOBALIZATION_STR_LENGTH);
                __FUNC_EXIT__;
                return strdup(buf);
        }
 }
 
-static void _gl_peer_del(void *data, Evas_Object * obj)
+/**
+ *     This function let the ug delete the peer item
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ */
+static void _gl_peer_del(void *data, Evas_Object *obj)
 {
-    __FUNC_ENTER__;
-    assertm_if(NULL == obj, "NULL!!");
-    assertm_if(NULL == data, "NULL!!");
+       __FUNC_ENTER__;
+       assertm_if(NULL == obj, "NULL!!");
+       assertm_if(NULL == data, "NULL!!");
 
-    __FUNC_EXIT__;
-    return;
+       __FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the ug initialize the items of genlist
+ *     @return   void
+ */
 void initialize_gen_item_class()
 {
-    sep_itc.item_style = "dialogue/separator";
-    sep_itc.func.text_get = NULL;
-    sep_itc.func.content_get = NULL;
-    sep_itc.func.state_get = NULL;
-    sep_itc.func.del = NULL;
-
-    sep_itc_end.item_style = "dialogue/separator/end";
-    sep_itc_end.func.text_get = NULL;
-    sep_itc_end.func.content_get = NULL;
-    sep_itc_end.func.state_get = NULL;
-    sep_itc_end.func.del = NULL;
-
-    head_itc.item_style = "dialogue/2text.1icon.6";
-    head_itc.func.text_get = _gl_header_label_get;
-    head_itc.func.content_get = _gl_header_icon_get;
-    head_itc.func.state_get = NULL;
-
-    name_itc.item_style = "dialogue/1text";
-    name_itc.func.text_get = _gl_name_label_get;
-    name_itc.func.content_get = NULL;
-    name_itc.func.state_get = NULL;
-    name_itc.func.del = NULL;
-
-    title_itc.item_style = "dialogue/title";
-    title_itc.func.text_get = _gl_title_label_get;
-    title_itc.func.content_get = _gl_title_content_get;
-    title_itc.func.state_get = NULL;
-    title_itc.func.del = NULL;
-
-    peer_itc.item_style = "dialogue/2text.2icon.3";
-    peer_itc.func.text_get = _gl_peer_label_get;
-    peer_itc.func.content_get = _gl_peer_icon_get;
-    peer_itc.func.state_get = NULL;
-    peer_itc.func.del = _gl_peer_del;
-
-    noitem_itc.item_style ="dialogue/1text";
-    noitem_itc.func.text_get = _gl_noitem_text_get;
-    noitem_itc.func.content_get = NULL;
-    noitem_itc.func.state_get = NULL;
-    noitem_itc.func.del = NULL;
-
-    help_itc.item_style = "dialogue/1text";
-    help_itc.func.text_get = _gl_help_label_get;
-    help_itc.func.content_get = NULL;
-    help_itc.func.state_get = NULL;
-    help_itc.func.del = NULL;
-
-    button_itc.item_style = "1icon";
-    button_itc.func.text_get = NULL;
-    button_itc.func.content_get = _gl_button_get;
-    button_itc.func.state_get = NULL;
-    button_itc.func.del = NULL;
-
-    title_conn_itc.item_style = "dialogue/title";
-    title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
-    title_conn_itc.func.content_get = NULL;
-    title_conn_itc.func.state_get = NULL;
-    title_conn_itc.func.del = NULL;
-
-    peer_conn_itc.item_style = "dialogue/2text.2icon.3";
-    peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
-    peer_conn_itc.func.content_get = _gl_peer_icon_get;
-    peer_conn_itc.func.state_get = NULL;
-    peer_conn_itc.func.del = _gl_peer_del;
-
-    title_conn_failed_itc.item_style = "dialogue/title";
-    title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
-    title_conn_failed_itc.func.content_get = NULL;
-    title_conn_failed_itc.func.state_get = NULL;
-    title_conn_failed_itc.func.del = NULL;
-
-    peer_conn_failed_itc.item_style = "dialogue/2text.2icon.3";
-    peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
-    peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
-    peer_conn_failed_itc.func.state_get = NULL;
-    peer_conn_failed_itc.func.del = _gl_peer_del;
-
-    title_busy_itc.item_style = "dialogue/title";
-    title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
-    title_busy_itc.func.content_get = NULL;
-    title_busy_itc.func.state_get = NULL;
-    title_busy_itc.func.del = NULL;
-
-    peer_busy_itc.item_style = "dialogue/2text.2icon.3";
-    peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
-    peer_busy_itc.func.content_get = _gl_peer_icon_get;
-    peer_busy_itc.func.state_get = NULL;
-    peer_busy_itc.func.del = _gl_peer_del;
-
-    title_multi_connect_itc.item_style = "dialogue/title";
-    title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
-    title_multi_connect_itc.func.content_get = NULL;
-    title_multi_connect_itc.func.state_get = NULL;
-    title_multi_connect_itc.func.del = NULL;
-
-#if 0
-    peer_multi_connect_itc.item_style = "dialogue/2text.2icon.3";
-    peer_multi_connect_itc.func.text_get = _gl_peer_label_get;
-    peer_multi_connect_itc.func.content_get = _gl_peer_icon_get;
-    peer_multi_connect_itc.func.state_get = NULL;
-    peer_multi_connect_itc.func.del = _gl_peer_del;
-#endif
+       __FUNC_ENTER__;
+       head_itc.item_style = "dialogue/2text.1icon.10";
+       head_itc.func.text_get = _gl_header_label_get;
+       head_itc.func.content_get = _gl_header_icon_get;
+       head_itc.func.state_get = NULL;
+
+       name_itc.item_style = "dialogue/1text";
+       name_itc.func.text_get = _gl_name_label_get;
+       name_itc.func.content_get = NULL;
+       name_itc.func.state_get = NULL;
+       name_itc.func.del = NULL;
+
+       title_itc.item_style = "dialogue/title";
+       title_itc.func.text_get = _gl_title_label_get;
+       title_itc.func.content_get = _gl_title_content_get;
+       title_itc.func.state_get = NULL;
+       title_itc.func.del = NULL;
+
+       peer_itc.item_style = "dialogue/2text.2icon.3";
+       peer_itc.func.text_get = _gl_peer_label_get;
+       peer_itc.func.content_get = _gl_peer_icon_get;
+       peer_itc.func.state_get = NULL;
+       peer_itc.func.del = _gl_peer_del;
+
+       noitem_itc.item_style = "dialogue/1text";
+       noitem_itc.func.text_get = _gl_noitem_text_get;
+       noitem_itc.func.content_get = NULL;
+       noitem_itc.func.state_get = NULL;
+       noitem_itc.func.del = NULL;
+
+       button_itc.item_style = "1icon";
+       button_itc.func.text_get = NULL;
+       button_itc.func.content_get = _gl_button_get;
+       button_itc.func.state_get = NULL;
+       button_itc.func.del = NULL;
+
+       title_conn_itc.item_style = "dialogue/title";
+       title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
+       title_conn_itc.func.content_get = NULL;
+       title_conn_itc.func.state_get = NULL;
+       title_conn_itc.func.del = NULL;
+
+       peer_conn_itc.item_style = "dialogue/2text.2icon.3";
+       peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
+       peer_conn_itc.func.content_get = _gl_peer_icon_get;
+       peer_conn_itc.func.state_get = NULL;
+       peer_conn_itc.func.del = _gl_peer_del;
+
+       title_conn_failed_itc.item_style = "dialogue/title";
+       title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
+       title_conn_failed_itc.func.content_get = NULL;
+       title_conn_failed_itc.func.state_get = NULL;
+       title_conn_failed_itc.func.del = NULL;
+
+       peer_conn_failed_itc.item_style = "dialogue/2text.2icon.3";
+       peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
+       peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
+       peer_conn_failed_itc.func.state_get = NULL;
+       peer_conn_failed_itc.func.del = _gl_peer_del;
+
+       title_busy_itc.item_style = "dialogue/title";
+       title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
+       title_busy_itc.func.content_get = NULL;
+       title_busy_itc.func.state_get = NULL;
+       title_busy_itc.func.del = NULL;
+
+       peer_busy_itc.item_style = "dialogue/2text.2icon.3";
+       peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
+       peer_busy_itc.func.content_get = _gl_peer_icon_get;
+       peer_busy_itc.func.state_get = NULL;
+       peer_busy_itc.func.del = _gl_peer_del;
+
+       title_multi_connect_itc.item_style = "dialogue/title";
+       title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
+       title_multi_connect_itc.func.content_get = NULL;
+       title_multi_connect_itc.func.state_get = NULL;
+       title_multi_connect_itc.func.del = NULL;
+
+       __FUNC_EXIT__;
+
 }
index f0e800f..b4089ec 100755 (executable)
 #include "wfd_ug_view.h"
 #include "wfd_client.h"
 
-void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info);
-
-
+/**
+ *     This function let the ug call it when click 'back' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _back_btn_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(!ugd)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
-
-    wfd_ug_view_free_peers(ugd);
-#if 0
-    bundle *b;
-    b = bundle_create();
-    if(!b)
-    {
-        DBG(LOG_ERROR, "Failed to create bundle");
-        return;
-    }
-
-    wfd_refresh_wifi_direct_state(ugd);
-    if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING)
-        bundle_add(b, "Connection", "TRUE");
-    else
-        bundle_add(b, "Connection", "FALSE");
-
-    ug_send_result(ugd->ug, b);
-
-    bundle_free(b);
-#else
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       if (!ugd) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       wfd_ug_view_free_peers(ugd);
+
        int ret = -1;
        service_h service = NULL;
        ret = service_create(&service);
-       if(ret)
-       {
+       if (ret) {
                DBG(LOG_ERROR, "Failed to create service");
                return;
        }
 
        wfd_refresh_wifi_direct_state(ugd);
-       if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING)
+       if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING) {
                service_add_extra_data(service, "Connection", "TRUE");
-       else
+       } else {
                service_add_extra_data(service, "Connection", "FALSE");
+       }
 
        ug_send_result(ugd->ug, service);
        service_destroy(service);
-#endif
-    ug_destroy_me(ugd->ug);
+       ug_destroy_me(ugd->ug);
 
-    __FUNC_EXIT__;
-    return;
+       __FUNC_EXIT__;
+       return;
 }
 
-void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'scan' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+void _scan_btn_cb(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-
-    struct ug_data *ugd = (struct ug_data*) data;
-    Elm_Object_Item *btn = event_info;
-    char *btn_text = NULL;
+       __FUNC_ENTER__;
 
-    if (NULL == ugd || NULL == btn) {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return;
-    }
+       struct ug_data *ugd = (struct ug_data *) data;
+       int ret = -1;
+       char *btn_text = NULL;
 
-    btn_text = elm_object_item_text_get(btn);
-    if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_SCAN"))) {
-       wfd_refresh_wifi_direct_state(ugd);
-       DBG(LOG_VERBOSE, "Start discovery again, status: %d\n", ugd->wfd_status);
-
-       /* if connected, show the popup*/
-       if (ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) {
-               wfd_ug_act_popup(ugd, IDS_WFD_POP_SCAN_AGAIN, POP_TYPE_SCAN_AGAIN);
-       } else if (WIFI_DIRECT_STATE_ACTIVATED == ugd->wfd_status) {
-               wfd_client_start_discovery(ugd);
-       } else if (WIFI_DIRECT_STATE_DEACTIVATED == ugd->wfd_status) {
-               _wfd_onoff_btn_cb(ugd, NULL, NULL);
-               __FUNC_EXIT__;
+       if (NULL == ugd) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return;
        }
 
-       if (ugd->scan_btn) {
-               wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+       btn_text = (char *)elm_object_text_get(obj);
+       if (NULL == btn_text) {
+               DBG(LOG_ERROR, "Incorrect button text(NULL)\n");
+               return;
        }
 
-       if (ugd->multi_scan_btn) {
-               wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE);
+       if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_SCAN"))) {
+               wfd_refresh_wifi_direct_state(ugd);
+               DBG(LOG_VERBOSE, "Start discovery again, status: %d\n", ugd->wfd_status);
+
+               /* if connected, show the popup*/
+               if (ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) {
+                       wfd_ug_act_popup(ugd, IDS_WFD_POP_SCAN_AGAIN, POP_TYPE_SCAN_AGAIN);
+               } else if (WIFI_DIRECT_STATE_DEACTIVATED == ugd->wfd_status) {
+                       wfd_client_switch_on(ugd);
+                       __FUNC_EXIT__;
+                       return;
+               } else {
+                       ret = wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+                       if (ret != WIFI_DIRECT_ERROR_NONE) {
+                               DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", ret);
+                               ugd->is_re_discover = TRUE;
+                               wifi_direct_cancel_discovery();
+                       } else {
+                               DBG(LOG_VERBOSE, "Discovery is started\n");
+                               ugd->is_re_discover = FALSE;
+                       }
+               }
+       } else if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_STOPSCAN"))) {
+               DBG(LOG_VERBOSE, "Stop discoverying.\n");
+               ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+               wfd_ug_view_refresh_glitem(ugd->head);
+
+               /* stop scaning */
+               ugd->is_re_discover = FALSE;
+               wifi_direct_cancel_discovery();
        }
-    } else if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_STOPSCAN"))) {
-       DBG(LOG_VERBOSE, "Stop discoverying.\n");
-       ugd->wfd_status = WIFI_DIRECT_STATE_ACTIVATED;
-       wfd_refresh_wifi_direct_state(ugd);
-       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-       wfd_ug_view_refresh_glitem(ugd->head);
-       wifi_direct_cancel_discovery();
-    }
 
-    __FUNC_EXIT__;
-    return;
-}
-
-Eina_Bool _is_wifi_on()
-{
-    __FUNC_ENTER__;
-    int wifi_state;
-
-    vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
-
-    if (wifi_state >= VCONFKEY_WIFI_CONNECTED)
-    {
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
-    __FUNC_EXIT__;
-}
-
-void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    wfd_refresh_wifi_direct_state(ugd);
-
-    if(!ugd->wfd_onoff)
-    {
-        if(ugd->wfd_status < 0)
-        {
-            DBG(LOG_VERBOSE, "bad wfd status\n");
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            wfd_ug_view_refresh_glitem(ugd->head);
-            return;
-        }
-        DBG(LOG_VERBOSE, "wifi-direct switch on\n");
-        ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING;
-        wfd_client_switch_on(ugd);
-    }
-    else
-    {
-        if(ugd->wfd_status < 0)
-        {
-            DBG(LOG_VERBOSE, "bad wfd status\n");
-            wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE);
-
-            ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-            wfd_ug_view_refresh_glitem(ugd->head);
-            return;
-        }
-        DBG(LOG_VERBOSE, "wifi-direct switch off\n");
-        ugd->head_text_mode = HEAD_TEXT_TYPE_DEACTIVATING;
-        wfd_client_switch_off(ugd);
-    }
-
-    wfd_ug_view_refresh_glitem(ugd->head);
-
-    if (ugd->scan_btn) {
-       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
-    }
-
-    if (ugd->multi_scan_btn) {
-       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
-    }
-
-
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
+       return;
 }
 
-
+/**
+ *     This function let the ug call it when click header
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _gl_header_sel(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    Elm_Object_Item *item = (Elm_Object_Item *)event_info;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return;
-    }
+       __FUNC_ENTER__;
+       if (NULL == data) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               __FUNC_EXIT__;
+               return;
+       }
 
-    if(item != NULL)
-        elm_genlist_item_selected_set(item, EINA_FALSE);
+       struct ug_data *ugd = (struct ug_data *) data;
+       Elm_Object_Item *item = (Elm_Object_Item *)event_info;
 
-    _wfd_onoff_btn_cb(ugd, NULL, NULL);
+       if (item != NULL) {
+               elm_genlist_item_selected_set(item, EINA_FALSE);
+       }
 
-    __FUNC_EXIT__;
-}
+       /* turn on/off wfd */
+       if (!ugd->wfd_onoff) {
+               DBG(LOG_VERBOSE, "wifi-direct switch on\n");
+               wfd_client_switch_on(ugd);
+       } else {
+               DBG(LOG_VERBOSE, "wifi-direct switch off\n");
+               wfd_client_switch_off(ugd);
+       }
 
-#if 0
-static Evas_Object *_gl_noitem_icon_get(void *data, Evas_Object * obj,
-                                         const char *part)
-{
-    __FUNC_ENTER__;
-    Evas_Object *nocontent;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return NULL;
-    }
-
-#if 1   // use nocontent
-    nocontent = elm_layout_add(obj);
-    if(nocontent == NULL)
-    {
-        DBG(LOG_ERROR, "Failed to add nocontent");
-        return NULL;
-    }
-    elm_layout_theme_set(nocontent, "layout", "nocontents", "unnamed");
-    elm_object_part_text_set(nocontent, "elm.text", _("IDS_WFD_BODY_NO_DEVICES"));
-    evas_object_size_hint_min_set(nocontent, 400, 200);
-    evas_object_size_hint_max_set(nocontent, 400, 200);
-    evas_object_resize(nocontent, 400, 200);
-
-    __FUNC_EXIT__;
-
-    return nocontent;
-#else   // use image
-    Evas_Object *icon;
-    icon = elm_icon_add(obj);
-    elm_icon_file_set(icon, "/usr/ug/res/images/ug-wifi-direct/A09_NoDevice.png", NULL);
-    evas_object_size_hint_min_set(icon, 400, 200);
-    evas_object_size_hint_max_set(icon, 400, 200);
-    evas_object_resize(icon, 400, 200);
-
-    return icon;
-#endif
+       __FUNC_EXIT__;
 }
-#endif
 
+/**
+ *     This function let the ug call it when click avaliable peer to connect
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _gl_peer_sel(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    assertm_if(NULL == obj, "NULL!!");
-    assertm_if(NULL == data, "NULL!!");
-    device_type_s *peer = (device_type_s*) data;
-    Elm_Object_Item *item = (Elm_Object_Item *)event_info;
-    struct ug_data* ugd = wfd_get_ug_data();
-    int res;
-
-    if(data == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-        return;
-    }
-
-    if(item != NULL)
-        elm_genlist_item_selected_set(item, EINA_FALSE);
-
-    if(peer->conn_status == PEER_CONN_STATUS_DISCONNECTED)
-    {
-#if 0   // for new connection during link_status is CONNECTING
-       wfd_refresh_wifi_direct_state(ugd);
-        if(ugd->wfd_status == WFD_LINK_STATUS_CONNECTING)
-        {
-            res = wfd_client_disconnect(NULL);
-            if(res != 0)
-            {
-                DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res);
-                return;
-            }
-        }
-#endif
-        DBG(LOG_VERBOSE, "Connect with peer [%s]\n", peer->mac_addr);
-        res = wfd_client_connect((const char*) peer->mac_addr);
-        if(res != 0)
-        {
-            DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res);
-            return;
-        }
-        peer->conn_status = PEER_CONN_STATUS_CONNECTING;
-    }
-    else    // PEER_CONN_STATUS_CONNECTED or PEER_CONN_STATUS_CONNECTING)
-    {
-        res = wfd_client_disconnect((const char*) peer->mac_addr);
-        if(res != 0)
-        {
-            DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res);
-            return;
-        }
-        peer->conn_status = PEER_CONN_STATUS_DISCONNECTED;
-    }
-
-    wfd_ug_view_refresh_glitem(peer->gl_item);
-    wfd_ug_view_refresh_glitem(ugd->multi_button_item);
-
-    __FUNC_EXIT__;
-    return;
-}
+       __FUNC_ENTER__;
+       assertm_if(NULL == obj, "NULL!!");
+       assertm_if(NULL == data, "NULL!!");
+       device_type_s *peer = (device_type_s *) data;
+       Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+       int res;
 
-static void _gl_busy_peer_sel(void *data, Evas_Object *obj, void *event_info)
-{
-    __FUNC_ENTER__;
+       if (data == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return;
+       }
 
-    struct ug_data *ugd = (struct ug_data*) data;
+       if (item != NULL) {
+               elm_genlist_item_selected_set(item, EINA_FALSE);
+       }
 
-    elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
+       if (peer->conn_status == PEER_CONN_STATUS_DISCONNECTED || peer->is_group_owner == TRUE) {
+               DBG(LOG_VERBOSE, "Connect with peer [%s]\n", peer->mac_addr);
+               res = wfd_client_connect((const char *) peer->mac_addr);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res);
+                       return;
+               }
+       } else {
+               res = wfd_client_disconnect((const char *)peer->mac_addr);
+               if (res != 0) {
+                       DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res);
+                       return;
+               }
+       }
 
-    DBG(LOG_VERBOSE, "Busy device is clicked");
+       __FUNC_EXIT__;
+       return;
+}
 
-    wfd_ug_warn_popup(ugd, IDS_WFD_POP_WARN_BUSY_DEVICE, POP_TYPE_BUSY_DEVICE_POPUP);
+/**
+ *     This function let the ug call it when click busy peer
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _gl_busy_peer_sel(void *data, Evas_Object *obj, void *event_info)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    __FUNC_EXIT__;
+       elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
+       DBG(LOG_VERBOSE, "Busy device is clicked");
+       wfd_ug_warn_popup(ugd, IDS_WFD_POP_WARN_BUSY_DEVICE, POP_TYPE_BUSY_DEVICE_POPUP);
+
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug call it when click about item
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _gl_about_wifi_sel(void *data, Evas_Object *obj, void *event_info)
 {
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    DBG(LOG_VERBOSE, "About wifi clicked");
+       DBG(LOG_VERBOSE, "About wifi clicked");
+       _wifid_create_about_view(ugd);
+       elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
 
-    _wifid_create_about_view(ugd);
-    elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug call it when click 'multi connect' button
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _wifid_create_multibutton_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    struct ug_data *ugd = (struct ug_data*) data;
-    const char *text_lbl = NULL;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       const char *text_lbl = NULL;
 
-    text_lbl = elm_object_text_get(ugd->multi_btn);
-    DBG(LOG_VERBOSE, "text_lbl = %s", text_lbl);
+       text_lbl = elm_object_text_get(ugd->multi_btn);
+       DBG(LOG_VERBOSE, "text_lbl = %s", text_lbl);
 
-    if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS)
-    {
-       ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE;
-               if (0 == strcmp(_("IDS_WFD_BUTTON_CANCEL"), text_lbl))
-               {
+       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
+               ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE;
+               if (0 == strcmp(_("IDS_WFD_BUTTON_CANCEL"), text_lbl)) {
                        wfd_ug_act_popup(ugd, _("IDS_WFD_POP_CANCEL_CONNECT"), POP_TYPE_DISCONNECT_ALL);
-               }
-               else
-               {
+               } else {
                        DBG(LOG_VERBOSE, "Invalid Case\n");
                }
-    }
-    else
-    {
-               if (0 == strcmp(_("IDS_WFD_BUTTON_MULTI"), text_lbl))
-               {
-                       _wifid_create_multiconnect_view(ugd);
-               }
-               else if (0 == strcmp(_("IDS_WFD_BUTTON_CANCEL"), text_lbl))
-               {
+       } else {
+               if (0 == strcmp(_("IDS_WFD_BUTTON_MULTI"), text_lbl)) {
+                       wfd_create_multiconnect_view(ugd);
+               } else if (0 == strcmp(_("IDS_WFD_BUTTON_CANCEL"), text_lbl)) {
                        wfd_ug_act_popup(ugd, _("IDS_WFD_POP_CANCEL_CONNECT"), POP_TYPE_DISCONNECT_ALL);
-               }
-               else if (0 == strcmp(_("IDS_WFD_BUTTON_DISCONNECT_ALL"), text_lbl))
-               {
+               } else if (0 == strcmp(_("IDS_WFD_BUTTON_DISCONNECT_ALL"), text_lbl)) {
                        wfd_ug_act_popup(ugd, _("IDS_WFD_POP_DISCONNECT"), POP_TYPE_DISCONNECT_ALL);
-               }
-               else if (0 == strcmp(_("IDS_WFD_BUTTON_DISCONNECT"), text_lbl))
-               {
+               } else if (0 == strcmp(_("IDS_WFD_BUTTON_DISCONNECT"), text_lbl)) {
                        wfd_ug_act_popup(ugd, _("IDS_WFD_POP_DISCONNECT"), POP_TYPE_DISCONNECT);
-               }
-               else
-               {
+               } else {
                        DBG(LOG_VERBOSE, "Invalid Case\n");
                }
-    }
-}
+       }
 
+       __FUNC_EXIT__;
+}
 
+/**
+ *     This function let the ug change the text of multi button
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int _change_multi_button_title(void *data)
 {
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    if(ugd->multi_button_item == NULL) /*Needs to be check as the peer count is not getting updated*/
-    {
-       return -1;
-    }
+       if (ugd->multi_button_item == NULL) {
+               return -1;
+       }
 
        wfd_refresh_wifi_direct_state(ugd);
-       if (ugd->wfd_status == WFD_LINK_STATUS_CONNECTING)
-       {
-               //if (conn_prog_count > 0)
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING) {
                elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_CANCEL"));
-       }
-       else if (ugd->wfd_status > WFD_LINK_STATUS_CONNECTING)
-       {
-               if (ugd->gl_connected_peer_cnt > 1)
+       } else if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING) {
+               if (ugd->gl_connected_peer_cnt > 1) {
                        elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT_ALL"));
-               else
+               } else {
                        elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT"));
-       }
-       else
-       {
+               }
+       } else {
                elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_MULTI"));
        }
 
-    evas_object_show(ugd->multi_btn);
+       evas_object_show(ugd->multi_btn);
+       __FUNC_EXIT__;
 
-    return 0;
+       return 0;
 }
 
-
+/**
+ *     This function let the ug update the genlist item
+ *     @return   void
+ *     @param[in] obj the pointer to genlist item
+ */
 void wfd_ug_view_refresh_glitem(void *obj)
 {
-    __FUNC_ENTER__;
-    elm_genlist_item_update(obj);
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       elm_genlist_item_update(obj);
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug refresh the attributes of button
+ *     @return   void
+ *     @param[in] obj the pointer to the button
+ *     @param[in] text the pointer to the text of button
+ *     @param[in] enable whether the button is disabled
+ */
 void wfd_ug_view_refresh_button(void *obj, const char *text, int enable)
 {
        __FUNC_ENTER__;
@@ -453,244 +355,435 @@ void wfd_ug_view_refresh_button(void *obj, const char *text, int enable)
        }
 
        DBG(LOG_VERBOSE, "Set the attributes of button: text[%s], enabled[%d]\n", text, enable);
-       elm_object_item_text_set(obj, text);
-       elm_object_item_disabled_set(obj, !enable);
+       elm_object_text_set(obj, text);
+       elm_object_disabled_set(obj, !enable);
 
        __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug know whether current device is connected by me
+ *     @return   If connected, return TRUE, else return FALSE
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] dev the pointer to the device
+ */
 static bool __wfd_is_device_connected_with_me(struct ug_data *ugd, device_type_s *dev)
 {
-       int i;
+       __FUNC_ENTER__;
+       int i = 0;
 
-       for(i=0; i<ugd->raw_connected_peer_cnt; i++)
-       {
-               if (strncmp(ugd->raw_connected_peers[i].mac_addr, dev->mac_addr, strlen(ugd->raw_connected_peers[i].mac_addr)) == 0)
+       for (i = 0; i < ugd->raw_connected_peer_cnt; i++) {
+               if (strncmp(ugd->raw_connected_peers[i].mac_addr,
+                       dev->mac_addr, strlen(ugd->raw_connected_peers[i].mac_addr)) == 0) {
                        return TRUE;
+               }
        }
+
+       __FUNC_EXIT__;
        return FALSE;
 }
 
+/**
+ *     This function let the ug know whether current device is connected by other peer
+ *     @return   If connected, return TRUE, else return FALSE
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] dev the pointer to the device
+ */
 static bool __wfd_is_device_busy(struct ug_data *ugd, device_type_s *dev)
 {
-       if (__wfd_is_device_connected_with_me(ugd, dev) == TRUE)
-               return FALSE;
+       __FUNC_ENTER__;
 
-       if (ugd->I_am_group_owner == TRUE)
-       {
-               if (dev->is_connected || dev->is_group_owner)
+       if (ugd->I_am_group_owner == TRUE) {
+               if (dev->is_connected || dev->is_group_owner) {
                        return TRUE;
-               else
+               } else {
                        return FALSE;
-       }
-       else
-       {
-               if (dev->is_connected == TRUE && dev->is_group_owner == TRUE)
+               }
+       } else {
+               if (dev->is_connected == TRUE && dev->is_group_owner == TRUE) {
                        return FALSE;
-               if (dev->is_connected == TRUE && dev->is_group_owner == FALSE)
+               }
+
+               if (dev->is_connected == TRUE && dev->is_group_owner == FALSE) {
                        return TRUE;
-               if (dev->is_connected == FALSE)
+               }
+
+               if (dev->is_connected == FALSE) {
                        return FALSE;
+               }
        }
 
+       __FUNC_EXIT__;
        return FALSE;
 }
 
+/**
+ *     This function let the ug calculate how many devices are avaliable
+ *     @return   TRUE
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] dev the pointer to the number of avaliable devices
+ */
 static bool __wfd_is_any_device_available(struct ug_data *ugd, int* no_of_available_dev)
 {
-    int i =0 ;
-    for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-    {
-        if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
-               ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_DISCONNECTED)
-               (*no_of_available_dev)++;
-    }
-    return TRUE;
+       __FUNC_ENTER__;
+       int i = 0;
+
+       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+               /* Not include the device which is connected with me */
+               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                       continue;
+               }
+               if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
+                       ugd->raw_discovered_peers[i].conn_status != PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+                       (*no_of_available_dev)++;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return TRUE;
 }
 
+/**
+ *     This function let the ug calculate how many devices are busy
+ *     @return   TRUE
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] dev the pointer to the number of busy devices
+ */
 static bool __wfd_is_any_device_busy(struct ug_data *ugd, int* no_of_busy_dev)
 {
-    int i =0 ;
-    for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-    {
-        if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]))
-            (*no_of_busy_dev)++;
-    }
-    return TRUE;
-}
+       __FUNC_ENTER__;
+       int i = 0;
 
-static bool __wfd_is_any_device_connect_failed(struct ug_data *ugd, int* no_of_connect_failed_dev)
-{
-    int i =0 ;
-    for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-    {
-        if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
-               ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT)
-               (*no_of_connect_failed_dev)++;
-
-    }
-    return TRUE;
+       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+               /* Not include the device which is connected with me */
+               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                       continue;
+               }
+               if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i])) {
+                       (*no_of_busy_dev)++;
+               }
+       }
+
+       __FUNC_EXIT__;
+       return TRUE;
 }
 
-static Evas_Object *_create_basic_genlist(void *data)
+/**
+ *     This function let the ug calculate how many devices are connected failed
+ *     @return   TRUE
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] dev the pointer to the number of connected failed devices
+ */
+static bool __wfd_is_any_device_connect_failed(struct ug_data *ugd, int* no_of_connect_failed_dev)
 {
        __FUNC_ENTER__;
+       int i = 0;
 
-       struct ug_data *ugd = (struct ug_data*) data;
-       Evas_Object *genlist;
-       Elm_Object_Item *separator_item;
+       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+               /* Not include the device which is connected with me */
+               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                       continue;
+               }
+               if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
+                       ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+                       (*no_of_connect_failed_dev)++;
+               }
 
+       }
 
-       genlist = elm_genlist_add(ugd->naviframe);
+       __FUNC_EXIT__;
+       return TRUE;
+}
 
+/**
+ *     This function let the ug get the device status
+ *     @return  If success, return 0-3(available: 0, connected: 1, busy: 2, connected failed: 3), else return -1
+ *     @param[in] ugd the pointer to the main data structure
+ *     @param[in] device the pointer to the number of connected failed devices
+ */
+int wfd_get_device_status(void *data, device_type_s *device)
+{
+       __FUNC_ENTER__;
+       int ret = -1;
+       int status = -1;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-       separator_item = elm_genlist_item_append(genlist, &sep_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       elm_genlist_item_select_mode_set(separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)");
+               return -1;
+       }
 
-       ugd->head = elm_genlist_item_append(genlist, &head_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _gl_header_sel, (void*) ugd);
+       /* check whether it is connected device  */
+       ret = __wfd_is_device_connected_with_me(ugd, device);
+       if (ret) {
+               DBG(LOG_VERBOSE, "This is connected device");
+               status = 1;
+               goto err_exit;
+       }
 
-       //elm_genlist_item_select_mode_set(ugd->head, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       /* check whether it is busy device  */
+       ret = __wfd_is_device_busy(ugd, device);
+       if (ret) {
+               DBG(LOG_VERBOSE, "This is busy device");
+               status = 2;
+               goto err_exit;
+       }
 
+       /* check whether it is available device  */
+       if (device->conn_status != PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+               DBG(LOG_VERBOSE, "This is available device");
+               status = 0;
+       } else {
+               DBG(LOG_VERBOSE, "This is connected failed device");
+               status = 3;
+       }
+
+err_exit:
        __FUNC_EXIT__;
+       return status;
+}
 
-       return genlist;
+/**
+ *     This function let the ug delete the separator
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ */
+static void __wfd_separator_del(void *data, Evas_Object *obj)
+{
+       __FUNC_ENTER__;
+       elm_genlist_item_class_free(data);
+       return;
 }
 
-static Evas_Object *_create_about_genlist(void *data)
+/**
+ *     This function let the ug add a dialogue separator
+ *     @return   the separator item
+ *     @param[in] genlist the pointer to the genlist
+ *     @param[in] separator_style the style of separator
+ */
+Elm_Object_Item *wfd_add_dialogue_separator(Evas_Object *genlist, const char *separator_style)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
+       assertm_if(NULL == genlist, "NULL!!");
 
-    struct ug_data *ugd = (struct ug_data*) data;
+       static Elm_Genlist_Item_Class *separator_itc;
+       separator_itc = elm_genlist_item_class_new();
+       separator_itc->item_style = separator_style;
+       separator_itc->func.text_get = NULL;
+       separator_itc->func.content_get = NULL;
+       separator_itc->func.state_get = NULL;
+       separator_itc->func.del = __wfd_separator_del;
 
-    ugd->about_wfd_item = elm_genlist_item_append(ugd->genlist, &name_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _gl_about_wifi_sel, (void*) ugd);
+       Elm_Object_Item *sep = elm_genlist_item_append(
+                                       genlist,
+                                       separator_itc,
+                                       separator_itc,
+                                       NULL,
+                                       ELM_GENLIST_ITEM_GROUP,
+                                       NULL,
+                                       NULL);
 
-    /* add end separator */
-    ugd->about_wfdsp_sep_end_item = elm_genlist_item_append(ugd->genlist, &sep_itc_end, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-    elm_genlist_item_select_mode_set(ugd->about_wfdsp_sep_end_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       assertm_if(NULL == sep, "NULL!!");
 
-    __FUNC_EXIT__;
+       elm_genlist_item_select_mode_set(sep, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-    return ugd->genlist;
+       __FUNC_EXIT__;
+       return sep;
 }
 
-static Evas_Object *_create_no_device_genlist(void *data)
+/**
+ *     This function let the ug create the main genlist
+ *     @return   the main genlist
+ *     @param[in] data the pointer to the main data structure
+ */
+static Evas_Object *_create_basic_genlist(void *data)
 {
-    __FUNC_ENTER__;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       Evas_Object *genlist;
+
+       genlist = elm_genlist_add(ugd->naviframe);
+       wfd_add_dialogue_separator(genlist, "dialogue/separator");
+       ugd->head = elm_genlist_item_append(genlist, &head_itc, ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, _gl_header_sel, (void *)ugd);
+
+       __FUNC_EXIT__;
+       return genlist;
+}
 
-    struct ug_data *ugd = (struct ug_data*) data;
+/**
+ *     This function let the ug create the about item to append the genlist
+ *     @return   the main item
+ *     @param[in] data the pointer to the main data structure
+ */
+static Evas_Object *_create_about_genlist(void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    ugd->nodevice_title_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       ugd->about_wfd_sep_high_item = wfd_add_dialogue_separator(ugd->genlist, "dialogue/separator");
+       ugd->about_wfd_item = elm_genlist_item_append(ugd->genlist, &name_itc, ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, _gl_about_wifi_sel, (void *)ugd);
+       ugd->about_wfd_sep_low_item = wfd_add_dialogue_separator(ugd->genlist, "dialogue/separator/end");
 
-    ugd->nodevice_item = elm_genlist_item_append(ugd->genlist, &noitem_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       __FUNC_EXIT__;
+       return ugd->genlist;
+}
 
-       ugd->nodevice_sep_low_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+/**
+ *     This function let the ug create no device item to append the genlist
+ *     @return   the main item
+ *     @param[in] data the pointer to the main data structure
+ */
+static Evas_Object *_create_no_device_genlist(void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    elm_genlist_item_select_mode_set(ugd->nodevice_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       ugd->nodevice_title_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       ugd->nodevice_item = elm_genlist_item_append(ugd->genlist, &noitem_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       elm_genlist_item_select_mode_set(ugd->nodevice_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-    __FUNC_EXIT__;
-    return ugd->genlist;
+       __FUNC_EXIT__;
+       return ugd->genlist;
 }
 
+/**
+ *     This function let the ug create multi connect button
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 int _create_multi_button_genlist(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-       ugd->multi_button_sep_high_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
-       /* if not connected and number of devices is less than 2, don't show the button */
-       if (ugd->raw_multi_selected_peer_cnt > 1 ||
-               ugd->gl_available_peer_cnt > 1 ||
-               ugd->gl_connected_peer_cnt > 0) {
-               ugd->multi_button_item = elm_genlist_item_append(ugd->genlist, &button_itc, ugd, NULL,
-                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
-               ugd->multi_button_sep_low_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       wfd_refresh_wifi_direct_state(ugd);
+
+       /* show the button */
+       if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
+               if (ugd->raw_multi_selected_peer_cnt > 1 ||
+                       ugd->gl_connected_peer_cnt > 0 ||
+                       ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING) {
+                       ugd->multi_button_sep_item = wfd_add_dialogue_separator(ugd->genlist, "dialogue/separator");
+                       ugd->multi_button_item = elm_genlist_item_append(ugd->genlist, &button_itc, ugd, NULL,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               }
+       } else {
+               if (ugd->gl_available_peer_cnt > 1 ||
+                       ugd->gl_connected_peer_cnt > 0 ||
+                       ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING) {
+                       ugd->multi_button_sep_item = wfd_add_dialogue_separator(ugd->genlist, "dialogue/separator");
+                       ugd->multi_button_item = elm_genlist_item_append(ugd->genlist, &button_itc, ugd, NULL,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               }
        }
 
-    evas_object_show(ugd->multi_btn);
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
-
+/**
+ *     This function let the ug create busy device list
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 int _create_busy_dev_list(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-       ugd->busy_wfd_item = elm_genlist_item_append(ugd->genlist, &title_busy_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
-    elm_genlist_item_select_mode_set(ugd->busy_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
+       ugd->busy_wfd_item = elm_genlist_item_append(ugd->genlist, &title_busy_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       elm_genlist_item_select_mode_set(ugd->busy_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug create avaliable device list
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 static int _create_available_dev_genlist(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    ugd->avlbl_wfd_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    // elm_genlist_item_select_mode_set(ugd->avlbl_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       ugd->avlbl_wfd_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug create multi connect device list
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 static int _create_multi_connect_dev_genlist(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    ugd->multi_connect_wfd_item = elm_genlist_item_append(ugd->genlist, &title_multi_connect_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    // elm_genlist_item_select_mode_set(ugd->avlbl_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       ugd->multi_connect_wfd_item = elm_genlist_item_append(ugd->genlist, &title_multi_connect_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug create connected device list
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 int _create_connected_dev_genlist(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    ugd->conn_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       ugd->conn_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       elm_genlist_item_select_mode_set(ugd->conn_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-    elm_genlist_item_select_mode_set(ugd->conn_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug create connected falied device list
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
 int _create_connected_failed_dev_genlist(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    ugd->conn_failed_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_failed_itc, (void*)ugd, NULL,
-                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       ugd->conn_failed_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_failed_itc, (void *)ugd, NULL,
+               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+       elm_genlist_item_select_mode_set(ugd->conn_failed_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-    elm_genlist_item_select_mode_set(ugd->conn_failed_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
+/**
+ *     This function let the ug make the display callback for connect failed peers
+ *     @return   if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
+ *     @param[in] data the pointer to the user data
+ */
 static Eina_Bool _connect_failed_peers_display_cb(void *user_data)
 {
        int interval = 0;
-       struct ug_data *ugd = (struct ug_data*) user_data;
+       int res = -1;
+       struct ug_data *ugd = (struct ug_data *) user_data;
 
        if (NULL == ugd) {
                DBG(LOG_ERROR, "NULL parameters.\n");
@@ -703,363 +796,291 @@ static Eina_Bool _connect_failed_peers_display_cb(void *user_data)
                return ECORE_CALLBACK_RENEW;
        }
 
-       /* re-discovery */
-       wfd_client_start_discovery(ugd);
-
-       /* get peers and update the view */
-       wfd_ug_get_discovered_peers(ugd);
-       wfd_ug_get_connected_peers(ugd);
-       wfd_ug_view_update_peers(ugd);
+       /* start discovery again */
+       res = wifi_direct_start_discovery(FALSE, MAX_SCAN_TIME_OUT);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res);
+               ugd->is_re_discover = TRUE;
+               wifi_direct_cancel_discovery();
+       } else {
+               DBG(LOG_VERBOSE, "Discovery is started\n");
+               ugd->is_re_discover = FALSE;
+       }
 
        return ECORE_CALLBACK_CANCEL;
 }
 
+/**
+ *     This function let the ug free the peers
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfd_ug_view_free_peers(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int i;
-
-    for(i = 0; i < ugd->gl_connected_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "%dth connected peer = %x is deleted\n", i, ugd->gl_connected_peers[i]);
-        if (ugd->gl_connected_peers[i].gl_item != NULL)
-        {
-            elm_object_item_del(ugd->gl_connected_peers[i].gl_item);
-            ugd->gl_connected_peers[i].gl_item = NULL;
-            DBG(LOG_VERBOSE, "Deleted item\n");
-        }
-    }
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       int i = 0;
+
+       for (i = 0; i < ugd->gl_connected_peer_cnt; i++) {
+               DBG(LOG_VERBOSE, "%dth connected peer = %x is deleted\n", i, ugd->gl_connected_peers[i]);
+               if (ugd->gl_connected_peers[i].gl_item != NULL) {
+                       elm_object_item_del(ugd->gl_connected_peers[i].gl_item);
+                       ugd->gl_connected_peers[i].gl_item = NULL;
+                       DBG(LOG_VERBOSE, "Deleted item\n");
+               }
+       }
+
        ugd->gl_connected_peer_cnt = 0;
 
-    for(i = 0; i < ugd->gl_connected_failed_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "%dth connected failed peer = %x is deleted\n", i, ugd->gl_connected_failed_peers[i]);
-       if (ugd->gl_connected_failed_peers[i].gl_item != NULL)
-       {
-           elm_object_item_del(ugd->gl_connected_failed_peers[i].gl_item);
-           ugd->gl_connected_failed_peers[i].gl_item = NULL;
-           DBG(LOG_VERBOSE, "Deleted item\n");
+       for (i = 0; i < ugd->gl_connected_failed_peer_cnt; i++) {
+               DBG(LOG_VERBOSE, "%dth connected failed peer = %x is deleted\n", i, ugd->gl_connected_failed_peers[i]);
+               if (ugd->gl_connected_failed_peers[i].gl_item != NULL) {
+                   elm_object_item_del(ugd->gl_connected_failed_peers[i].gl_item);
+                   ugd->gl_connected_failed_peers[i].gl_item = NULL;
+                   DBG(LOG_VERBOSE, "Deleted item\n");
+               }
        }
-    }
-
-    ugd->gl_connected_failed_peer_cnt = 0;
-
-    for(i = 0; i < ugd->gl_available_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "%dth discovered peer = %x is deleted\n", i, ugd->gl_available_peers[i]);
-        if (ugd->gl_available_peers[i].gl_item != NULL)
-        {
-            elm_object_item_del(ugd->gl_available_peers[i].gl_item);
-            ugd->gl_available_peers[i].gl_item = NULL;
-            DBG(LOG_VERBOSE, "Deleted item\n");
-        }
-    }
+
+       ugd->gl_connected_failed_peer_cnt = 0;
+
+       for (i = 0; i < ugd->gl_available_peer_cnt; i++) {
+               DBG(LOG_VERBOSE, "%dth discovered peer = %x is deleted\n", i, ugd->gl_available_peers[i]);
+               if (ugd->gl_available_peers[i].gl_item != NULL) {
+                       elm_object_item_del(ugd->gl_available_peers[i].gl_item);
+                       ugd->gl_available_peers[i].gl_item = NULL;
+                       DBG(LOG_VERBOSE, "Deleted item\n");
+               }
+       }
+
        ugd->gl_available_peer_cnt = 0;
 
-    for(i = 0; i < ugd->gl_busy_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "%dth busy peer = %x is deleted\n", i, ugd->gl_busy_peers[i]);
-        if (ugd->gl_busy_peers[i].gl_item != NULL)
-        {
-            elm_object_item_del(ugd->gl_busy_peers[i].gl_item);
-            ugd->gl_busy_peers[i].gl_item = NULL;
-            DBG(LOG_VERBOSE, "Deleted item\n");
-        }
-    }
+       for (i = 0; i < ugd->gl_busy_peer_cnt; i++) {
+               DBG(LOG_VERBOSE, "%dth busy peer = %x is deleted\n", i, ugd->gl_busy_peers[i]);
+               if (ugd->gl_busy_peers[i].gl_item != NULL) {
+                       elm_object_item_del(ugd->gl_busy_peers[i].gl_item);
+                       ugd->gl_busy_peers[i].gl_item = NULL;
+                       DBG(LOG_VERBOSE, "Deleted item\n");
+               }
+       }
+
        ugd->gl_busy_peer_cnt = 0;
 
-    for(i = 0; i < ugd->gl_multi_connect_peer_cnt; i++)
-    {
-        DBG(LOG_VERBOSE, "%dth busy peer = %x is deleted\n", i, ugd->gl_multi_connect_peers[i]);
-        if (ugd->gl_multi_connect_peers[i].gl_item != NULL)
-        {
-            elm_object_item_del(ugd->gl_multi_connect_peers[i].gl_item);
-            ugd->gl_multi_connect_peers[i].gl_item = NULL;
-            DBG(LOG_VERBOSE, "Deleted item\n");
-        }
-    }
+       for (i = 0; i < ugd->gl_multi_connect_peer_cnt; i++) {
+               DBG(LOG_VERBOSE, "%dth multi connect peer = %x is deleted\n", i, ugd->gl_multi_connect_peers[i]);
+               if (ugd->gl_multi_connect_peers[i].gl_item != NULL) {
+                       elm_object_item_del(ugd->gl_multi_connect_peers[i].gl_item);
+                       ugd->gl_multi_connect_peers[i].gl_item = NULL;
+                       DBG(LOG_VERBOSE, "Deleted item\n");
+               }
+       }
+
        ugd->gl_multi_connect_peer_cnt = 0;
 
-    if(ugd->nodevice_title_item != NULL)
-    {
-        elm_object_item_del(ugd->nodevice_title_item);
-        ugd->nodevice_title_item = NULL;
-    }
-    if(ugd->nodevice_item != NULL)
-    {
-        elm_object_item_del(ugd->nodevice_item);
-        ugd->nodevice_item = NULL;
-    }
-    if(ugd->nodevice_sep_low_item != NULL)
-    {
-        elm_object_item_del(ugd->nodevice_sep_low_item);
-        ugd->nodevice_sep_low_item = NULL;
-    }
-    if(ugd->about_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->about_wfd_item);
-        ugd->about_wfd_item = NULL;
-    }
-
-    if(ugd->conn_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->conn_wfd_item);
-        ugd->conn_wfd_item = NULL;
-    }
-    if(ugd->conn_failed_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->conn_failed_wfd_item);
-        ugd->conn_failed_wfd_item = NULL;
-    }
-    if(ugd->conn_failed_wfd_sep_item != NULL)
-    {
-        elm_object_item_del(ugd->conn_failed_wfd_sep_item);
-        ugd->conn_failed_wfd_sep_item = NULL;
-    }
-    if(ugd->display_timer != NULL)
-    {
-        elm_object_item_del(ugd->display_timer);
-        ugd->display_timer = NULL;
-    }
-    if(ugd->multi_connect_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->multi_connect_wfd_item);
-        ugd->multi_connect_wfd_item = NULL;
-    }
-    if(ugd->avlbl_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->avlbl_wfd_item);
-        ugd->avlbl_wfd_item = NULL;
-    }
-    if(ugd->busy_wfd_item != NULL)
-    {
-        elm_object_item_del(ugd->busy_wfd_item);
-        ugd->busy_wfd_item = NULL;
-    }
-    if(ugd->busy_wfd_sep_item != NULL)
-    {
-        elm_object_item_del(ugd->busy_wfd_sep_item);
-        ugd->busy_wfd_sep_item = NULL;
-    }
-
-    if(ugd->multi_button_item != NULL)
-    {
-        elm_object_item_del(ugd->multi_button_item);
-        ugd->multi_button_item = NULL;
-    }
-    if(ugd->multi_button_sep_high_item != NULL)
-    {
-        elm_object_item_del(ugd->multi_button_sep_high_item);
-        ugd->multi_button_sep_high_item = NULL;
-    }
-    if(ugd->multi_button_sep_low_item != NULL)
-    {
-        elm_object_item_del(ugd->multi_button_sep_low_item);
-        ugd->multi_button_sep_low_item = NULL;
-    }
-    if(ugd->about_wfdsp_sep_end_item != NULL)
-    {
-        elm_object_item_del(ugd->about_wfdsp_sep_end_item);
-        ugd->about_wfdsp_sep_end_item = NULL;
-    }
-
-    __FUNC_EXIT__;
-}
+       if (ugd->nodevice_title_item != NULL) {
+               elm_object_item_del(ugd->nodevice_title_item);
+               ugd->nodevice_title_item = NULL;
+       }
+
+       if (ugd->nodevice_item != NULL) {
+               elm_object_item_del(ugd->nodevice_item);
+               ugd->nodevice_item = NULL;
+       }
 
+       if (ugd->about_wfd_item != NULL) {
+               elm_object_item_del(ugd->about_wfd_item);
+               ugd->about_wfd_item = NULL;
+       }
+
+       if (ugd->about_wfd_sep_high_item != NULL) {
+               elm_object_item_del(ugd->about_wfd_sep_high_item);
+               ugd->about_wfd_sep_high_item = NULL;
+       }
+
+       if (ugd->about_wfd_sep_low_item != NULL) {
+               elm_object_item_del(ugd->about_wfd_sep_low_item);
+               ugd->about_wfd_sep_low_item = NULL;
+       }
+
+       if (ugd->conn_wfd_item != NULL) {
+               elm_object_item_del(ugd->conn_wfd_item);
+               ugd->conn_wfd_item = NULL;
+       }
+
+       if (ugd->conn_failed_wfd_item != NULL) {
+               elm_object_item_del(ugd->conn_failed_wfd_item);
+               ugd->conn_failed_wfd_item = NULL;
+       }
 
+       if (ugd->display_timer != NULL) {
+               ecore_timer_del(ugd->display_timer);
+               ugd->display_timer = NULL;
+       }
+
+       if (ugd->multi_connect_wfd_item != NULL) {
+               elm_object_item_del(ugd->multi_connect_wfd_item);
+               ugd->multi_connect_wfd_item = NULL;
+       }
+
+       if (ugd->avlbl_wfd_item != NULL) {
+               elm_object_item_del(ugd->avlbl_wfd_item);
+               ugd->avlbl_wfd_item = NULL;
+       }
+
+       if (ugd->busy_wfd_item != NULL) {
+               elm_object_item_del(ugd->busy_wfd_item);
+               ugd->busy_wfd_item = NULL;
+       }
+
+       if (ugd->multi_button_item != NULL) {
+               elm_object_item_del(ugd->multi_button_item);
+               ugd->multi_button_item = NULL;
+       }
+
+       if (ugd->multi_button_sep_item != NULL) {
+               elm_object_item_del(ugd->multi_button_sep_item);
+               ugd->multi_button_sep_item = NULL;
+       }
+
+       __FUNC_EXIT__;
+}
+
+/**
+ *     This function let the ug update the peers
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfd_ug_view_update_peers(void *data)
 {
-    __FUNC_ENTER__;
-
-    struct ug_data *ugd = (struct ug_data*) data;
-    int no_of_busy_dev = 0;
-    int no_of_available_dev = 0;
-    int no_of_conn_dev = 0;
-    int no_of_conn_failed_dev = 0;
-    int i = 0 ;
-    int res = 0;
-    bool is_group_owner = FALSE;
-    int count = 0;
-
-    wfd_ug_view_free_peers(ugd);
-
-    if(ugd->wfd_status == WFD_LINK_STATUS_DEACTIVATED)
-    {
-        DBG(LOG_VERBOSE, "Device is deactivated, no need to update UI.");
-        // Add seperator...
-       ugd->multi_button_sep_high_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                                                                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
-        _create_about_genlist(ugd);
-        return;
-    }
-
-    res = wifi_direct_is_group_owner(&is_group_owner);
-    if (res != WIFI_DIRECT_ERROR_NONE)
-    {
-        DBG(LOG_VERBOSE, "Fail to get group_owner_state. ret=[%d]", res);
-        ugd->I_am_group_owner = FALSE;
-        // continue...
-    }
-    else
-    {
-       ugd->I_am_group_owner = is_group_owner;
-    }
-
-    __wfd_is_any_device_busy(ugd, &no_of_busy_dev);
-    __wfd_is_any_device_available(ugd, &no_of_available_dev);
-    __wfd_is_any_device_connect_failed(ugd, &no_of_conn_failed_dev);
-    no_of_conn_dev = ugd->raw_connected_peer_cnt;
-
-    ugd->gl_available_peer_cnt = no_of_available_dev;
-    ugd->gl_connected_peer_cnt = no_of_conn_dev;
-    ugd->gl_connected_failed_peer_cnt = no_of_conn_failed_dev;
-    ugd->gl_busy_peer_cnt = no_of_busy_dev;
-
-    DBG(LOG_VERBOSE, "conn_dev=[%d], conn_failed_dev=[%d], avail_dev=[%d], busy_dev=[%d], GO=[%d]\n",
-                       no_of_conn_dev, no_of_conn_failed_dev, no_of_available_dev, no_of_busy_dev, is_group_owner);
-
-    if (no_of_conn_dev == 0 && no_of_conn_failed_dev == 0 &&
-       no_of_available_dev == 0 && no_of_busy_dev == 0)
-    {
-        DBG(LOG_ERROR, "There are No peers\n");
-        _create_no_device_genlist(ugd);
-        _create_about_genlist(ugd);
-        return;
-    }
-
-    if (no_of_conn_dev > 0)
-    {
-        if (!ugd->conn_wfd_item)
-               _create_connected_dev_genlist(ugd);
-
-        count = 0;
-        for(i = 0;  i < ugd->raw_connected_peer_cnt; i++)
-        {
-               if (ugd->gl_connected_peers[count].gl_item)
-                       elm_object_item_del(ugd->gl_connected_peers[count].gl_item);
-
-               memcpy(&ugd->gl_connected_peers[count], &ugd->raw_connected_peers[i], sizeof(device_type_s));
-
-            ugd->gl_connected_peers[count].gl_item =
-                       elm_genlist_item_append(ugd->genlist, &peer_conn_itc, (void*) &(ugd->gl_connected_peers[i]), NULL,
-                                                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
-            elm_genlist_item_select_mode_set(ugd->gl_connected_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-            count++;
-        }
-    }
-
-    if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE)
-    {
-       if (ugd->raw_multi_selected_peer_cnt > 0)
-       {
-                       if (ugd->avlbl_wfd_item == NULL)
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       int no_of_busy_dev = 0;
+       int no_of_available_dev = 0;
+       int no_of_conn_dev = 0;
+       int no_of_conn_failed_dev = 0;
+       int i = 0 ;
+       int res = 0;
+       bool is_group_owner = FALSE;
+       int count = 0;
+
+       wfd_ug_view_free_peers(ugd);
+
+       if (ugd->wfd_status == WIFI_DIRECT_STATE_DEACTIVATED) {
+               DBG(LOG_VERBOSE, "Device is deactivated, no need to update UI.");
+               _create_about_genlist(ugd);
+               return;
+       }
+
+       res = wifi_direct_is_group_owner(&is_group_owner);
+       if (res != WIFI_DIRECT_ERROR_NONE) {
+               DBG(LOG_VERBOSE, "Fail to get group_owner_state. ret=[%d]", res);
+               ugd->I_am_group_owner = FALSE;
+       } else {
+               ugd->I_am_group_owner = is_group_owner;
+       }
+
+       __wfd_is_any_device_busy(ugd, &no_of_busy_dev);
+       __wfd_is_any_device_available(ugd, &no_of_available_dev);
+       __wfd_is_any_device_connect_failed(ugd, &no_of_conn_failed_dev);
+       no_of_conn_dev = ugd->raw_connected_peer_cnt;
+
+       ugd->gl_available_peer_cnt = no_of_available_dev;
+       ugd->gl_connected_peer_cnt = no_of_conn_dev;
+       ugd->gl_connected_failed_peer_cnt = no_of_conn_failed_dev;
+       ugd->gl_busy_peer_cnt = no_of_busy_dev;
+
+       DBG(LOG_VERBOSE, "conn_dev=[%d], conn_failed_dev=[%d], avail_dev=[%d], busy_dev=[%d], GO=[%d]\n",
+               no_of_conn_dev, no_of_conn_failed_dev, no_of_available_dev, no_of_busy_dev, is_group_owner);
+
+       if (no_of_conn_dev == 0 && no_of_conn_failed_dev == 0 &&
+               no_of_available_dev == 0 && no_of_busy_dev == 0) {
+               DBG(LOG_ERROR, "There are No peers\n");
+               _create_no_device_genlist(ugd);
+               _create_about_genlist(ugd);
+               return;
+       }
+
+       /* display connect peers */
+       if (no_of_conn_dev > 0) {
+               if (!ugd->conn_wfd_item) {
+                       _create_connected_dev_genlist(ugd);
+               }
+
+               count = 0;
+               for (i = 0; i < ugd->raw_connected_peer_cnt; i++) {
+                       if (ugd->gl_connected_peers[count].gl_item) {
+                               elm_object_item_del(ugd->gl_connected_peers[count].gl_item);
+                       }
+
+                       memcpy(&ugd->gl_connected_peers[count], &ugd->raw_connected_peers[i], sizeof(device_type_s));
+                       ugd->gl_connected_peers[count].gl_item = elm_genlist_item_append(ugd->genlist, &peer_conn_itc,
+                               (void *)&(ugd->gl_connected_peers[i]), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+                       elm_genlist_item_select_mode_set(ugd->gl_connected_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+                       count++;
+               }
+       }
+
+       if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
+               if (ugd->raw_multi_selected_peer_cnt > 0) {
+                       if (ugd->raw_connected_peer_cnt < ugd->raw_multi_selected_peer_cnt &&
+                               ugd->multi_connect_wfd_item == NULL) {
                                _create_multi_connect_dev_genlist(ugd);
+                       }
 
                        count = 0;
-                       for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++)
-                       {
-                               if (ugd->raw_multi_selected_peers[i].conn_status != PEER_CONN_STATUS_CONNECTED)
-                               {
-                                       if (ugd->gl_multi_connect_peers[count].gl_item)
+                       for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
+                               if (ugd->raw_multi_selected_peers[i].conn_status != PEER_CONN_STATUS_CONNECTED) {
+                                       if (ugd->gl_multi_connect_peers[count].gl_item) {
                                                elm_object_item_del(ugd->gl_multi_connect_peers[count].gl_item);
+                                       }
 
                                        memcpy(&ugd->gl_multi_connect_peers[count], &ugd->raw_multi_selected_peers[i], sizeof(device_type_s));
-
-                                       ugd->gl_multi_connect_peers[count].gl_item =
-                                                       elm_genlist_item_append(ugd->genlist, &peer_itc, (void*) &(ugd->gl_multi_connect_peers[count]), NULL,
-                                                                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+                                       ugd->gl_multi_connect_peers[count].gl_item = elm_genlist_item_append(ugd->genlist, &peer_itc,
+                                               (void *) &(ugd->gl_multi_connect_peers[count]), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
                                        count++;
                                }
-                               else
-                               {
-                                       // device is connected..
-                                       // skip it...
-                               }
                        }
+
                        ugd->gl_multi_connect_peer_cnt = count;
-       }
-
-       _create_multi_button_genlist(ugd);
-    }
-    else
-    {
-       // Note that
-       // If GC, no display available peers
-       // Otherwise, display available peers
-#if 0
-               if (no_of_available_dev > 0 && (no_of_conn_dev == 0 || is_group_owner==TRUE))
-#else
-               // display available peers
-               if (no_of_available_dev > 0)
-#endif
-               {
-                       if (ugd->avlbl_wfd_item == NULL)
+               }
+
+               _create_multi_button_genlist(ugd);
+       } else {
+               /*
+               * Note that
+               * If GC, no display available peers
+               * Otherwise, display available peers
+               */
+               if (no_of_available_dev > 0 && (no_of_conn_dev == 0 || is_group_owner == TRUE)) {
+                       if (ugd->avlbl_wfd_item == NULL) {
                                _create_available_dev_genlist(ugd);
+                       }
 
                        count = 0;
-                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-                       {
+                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+                               /* Not include the device which is connected with me */
+                               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                                       continue;
+                               }
                                if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
-                                       ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_DISCONNECTED)
-                               {
-                                       if (ugd->gl_available_peers[count].gl_item)
+                                       ugd->raw_discovered_peers[i].conn_status != PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+                                       if (ugd->gl_available_peers[count].gl_item) {
                                                elm_object_item_del(ugd->gl_available_peers[count].gl_item);
+                                       }
 
                                        memcpy(&ugd->gl_available_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s));
-
-                                       ugd->gl_available_peers[count].gl_item =
-                                                       elm_genlist_item_append(ugd->genlist, &peer_itc, (void*) &(ugd->gl_available_peers[count]), NULL,
-                                                                               ELM_GENLIST_ITEM_NONE, _gl_peer_sel, (void*) &(ugd->gl_available_peers[count]));
-                                       count++;
-                               }
-                               else
-                               {
-                                       // device is busy or connected..
-                                       // skip it...
-                               }
-                       }
-               }
-
-               _create_multi_button_genlist(ugd);
-
-               // If connected, not display busy device...
-               if (no_of_conn_dev == 0 && no_of_busy_dev > 0)
-               {
-                       if (ugd->busy_wfd_item == NULL)
-                               _create_busy_dev_list(ugd);
-
-                       count = 0;
-                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-                       {
-                               if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) == TRUE)
-                               {
-                                       if (ugd->gl_busy_peers[count].gl_item)
-                                               elm_object_item_del(ugd->gl_busy_peers[count].gl_item);
-
-                                       memcpy(&ugd->gl_busy_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s));
-
-                                       ugd->gl_busy_peers[count].gl_item =
-                                                       elm_genlist_item_append(ugd->genlist, &peer_busy_itc, (void*) &(ugd->gl_busy_peers[count]), NULL,
-                                                                               ELM_GENLIST_ITEM_NONE, _gl_busy_peer_sel, ugd);
-                                       //elm_genlist_item_select_mode_set(ugd->gl_busy_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+                                       ugd->gl_available_peers[count].gl_item = elm_genlist_item_append(ugd->genlist, &peer_itc,
+                                               (void *)&(ugd->gl_available_peers[count]), NULL, ELM_GENLIST_ITEM_NONE, _gl_peer_sel,
+                                               (void *)&(ugd->gl_available_peers[count]));
                                        count++;
                                }
-                               else
-                               {
-                                       // device is available or connected..
-                                       // skip it...
-                               }
                        }
-                       ugd->busy_wfd_sep_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
                }
 
                /* display connect failed peers */
-               if (no_of_conn_failed_dev > 0)
-               {
-                       if (!ugd->conn_failed_wfd_item)
+               if (no_of_conn_failed_dev > 0) {
+                       if (!ugd->conn_failed_wfd_item) {
                                _create_connected_failed_dev_genlist(ugd);
+                       }
 
                        /* add timer for disappearing failed peers after N secs */
                        if (NULL == ugd->display_timer) {
@@ -1068,86 +1089,102 @@ void wfd_ug_view_update_peers(void *data)
                        }
 
                        count = 0;
-                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++)
-                       {
+                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+                               /* Not include the device which is connected with me */
+                               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                                       continue;
+                               }
                                if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) &&
-                                       ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT)
-                               {
-                                       if (ugd->gl_connected_failed_peers[count].gl_item)
+                                       ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+                                       if (ugd->gl_connected_failed_peers[count].gl_item) {
                                                elm_object_item_del(ugd->gl_connected_failed_peers[count].gl_item);
+                                       }
 
                                        memcpy(&ugd->gl_connected_failed_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s));
-
-                                       ugd->gl_connected_failed_peers[count].gl_item =
-                                                       elm_genlist_item_append(ugd->genlist, &peer_conn_failed_itc, (void*) &(ugd->gl_connected_failed_peers[count]), NULL,
-                                                                               ELM_GENLIST_ITEM_NONE, NULL, ugd);
+                                       ugd->gl_connected_failed_peers[count].gl_item = elm_genlist_item_append(ugd->genlist, &peer_conn_failed_itc,
+                                               (void *)&(ugd->gl_connected_failed_peers[count]), NULL, ELM_GENLIST_ITEM_NONE, NULL, ugd);
                                        elm_genlist_item_select_mode_set(ugd->gl_connected_failed_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
                                        count++;
                                }
                        }
+               }
 
-                       ugd->conn_failed_wfd_sep_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL,
-                                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               _create_multi_button_genlist(ugd);
 
+               /* If connected, not display busy device */
+               if (no_of_conn_dev == 0 && no_of_busy_dev > 0) {
+                       if (ugd->busy_wfd_item == NULL) {
+                               _create_busy_dev_list(ugd);
+                       }
+
+                       count = 0;
+                       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+                               /* Not include the device which is connected with me */
+                               if (__wfd_is_device_connected_with_me(ugd, &ugd->raw_discovered_peers[i])) {
+                                       continue;
+                               }
+                               if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) == TRUE) {
+                                       if (ugd->gl_busy_peers[count].gl_item) {
+                                               elm_object_item_del(ugd->gl_busy_peers[count].gl_item);
+                                       }
+
+                                       memcpy(&ugd->gl_busy_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s));
+                                       ugd->gl_busy_peers[count].gl_item = elm_genlist_item_append(ugd->genlist, &peer_busy_itc,
+                                               (void *)&(ugd->gl_busy_peers[count]), NULL, ELM_GENLIST_ITEM_NONE, _gl_busy_peer_sel, ugd);
+                                       count++;
+                               }
+                       }
                }
-    }
-    _create_about_genlist(ugd);
+       }
+       _create_about_genlist(ugd);
 
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
 }
 
-
+/**
+ *     This function let the ug create the main view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void create_wfd_ug_view(void *data)
 {
-    __FUNC_ENTER__;
-
-    struct ug_data *ugd = (struct ug_data*) data;
-    Evas_Object *back_btn = NULL;
-    Elm_Object_Item *navi_item = NULL;
-    Evas_Object *control_bar = NULL;
-    Elm_Object_Item *item = NULL;
-
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)");
-        return;
-    }
-
-    ugd->naviframe = elm_naviframe_add(ugd->base);
-    elm_object_part_content_set(ugd->base, "elm.swallow.content", ugd->naviframe);
-    evas_object_show(ugd->naviframe);
-
-    back_btn = elm_button_add(ugd->naviframe);
-    elm_object_style_set(back_btn, "naviframe/back_btn/default");
-    evas_object_smart_callback_add(back_btn, "clicked", _back_btn_cb, (void*) ugd);
-    elm_object_focus_allow_set(back_btn, EINA_FALSE);
-
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       Elm_Object_Item *navi_item = NULL;
 
-    ugd->genlist = _create_basic_genlist(ugd);
-    if(ugd->genlist == NULL)
-    {
-        DBG(LOG_ERROR, "Failed to create basic genlist");
-        return;
-    }
-    elm_object_style_set (ugd->genlist, "dialogue");
-    evas_object_show(ugd->genlist);
-    wfd_refresh_wifi_direct_state(ugd);
-    if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING)
-       ugd->wfd_onoff = TRUE;
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)");
+               return;
+       }
 
-    navi_item = elm_naviframe_item_push(ugd->naviframe, _("IDS_WFD_HEADER_WIFI_DIRECT"), back_btn, NULL, ugd->genlist, NULL); // dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT")
+       ugd->naviframe = elm_naviframe_add(ugd->base);
+       elm_object_part_content_set(ugd->base, "elm.swallow.content", ugd->naviframe);
+       evas_object_show(ugd->naviframe);
 
-    control_bar = elm_toolbar_add(ugd->naviframe);
-    elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
-    evas_object_show(control_bar);
+       ugd->back_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(ugd->back_btn, "naviframe/back_btn/default");
+       evas_object_smart_callback_add(ugd->back_btn, "clicked", _back_btn_cb, (void *)ugd);
+       elm_object_focus_allow_set(ugd->back_btn, EINA_FALSE);
 
-    ugd->scan_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_SCAN"), _scan_btn_cb, (void*) ugd);
-    item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL);
-    elm_object_item_disabled_set(item, EINA_TRUE);
+       ugd->genlist = _create_basic_genlist(ugd);
+       if (ugd->genlist == NULL) {
+               DBG(LOG_ERROR, "Failed to create basic genlist");
+               return;
+       }
 
-    elm_object_item_disabled_set(ugd->scan_btn, !ugd->wfd_onoff);
+       evas_object_show(ugd->genlist);
+       wfd_refresh_wifi_direct_state(ugd);
+       if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) {
+               ugd->wfd_onoff = TRUE;
+       }
 
-    elm_object_item_part_content_set(navi_item, "controlbar", control_bar);
+       navi_item = elm_naviframe_item_push(ugd->naviframe, _("IDS_WFD_HEADER_WIFI_DIRECT"), ugd->back_btn, NULL, ugd->genlist, NULL);
+       /* create scan button */
+       ugd->scan_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(ugd->scan_btn, "naviframe/toolbar/default");
+       elm_object_text_set(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"));
+       evas_object_smart_callback_add(ugd->scan_btn, "clicked", _scan_btn_cb, (void *)ugd);
+       elm_object_item_part_content_set(navi_item, "toolbar_button1", ugd->scan_btn);
 
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
 }
index aea5ce5..680179a 100755 (executable)
 Elm_Gen_Item_Class select_all_itc;
 Elm_Gen_Item_Class device_itc;
 
-
+/**
+ *     This function let the ug call it when click 'back' button in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 void _multiconnect_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(!ugd)
-    {
-        DBG(LOG_ERROR, "The param is NULL\n");
-        return;
-    }
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
 
-    ugd->multiconn_view_genlist = NULL;
-    elm_naviframe_item_pop(ugd->naviframe);
+       if (!ugd) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
 
-    __FUNC_EXIT__;
-    return;
-}
+       ugd->multiconn_view_genlist = NULL;
+       elm_naviframe_item_pop(ugd->naviframe);
 
-void reset_multi_conn_dev_list(void *data)
-{
-       struct ug_data *ugd = (struct ug_data*) data;
-       int i;
-    for (i = 0; i < MAX_PEER_NUM; i++)
-    {
-       ugd->multi_conn_dev_list[i].dev_sel_state = FALSE;
-       ugd->multi_conn_dev_list[i].peer.gl_item = NULL;
-    }
-    ugd->gl_available_dev_cnt_at_multiconn_view = 0;
+       __FUNC_EXIT__;
+       return;
 }
 
+/**
+ *     This function let the ug reset the connected failed peers
+ *     @return   false
+ *     @param[in] event_info the pointer to the event information
+ */
 gboolean __wfd_multi_connect_reset_cb(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       int i = 0;
+       struct ug_data *ugd = (struct ug_data *)data;
+
+       /* remove the failed peers*/
+       for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
+               if (ugd->raw_multi_selected_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT) {
+                       memset(&ugd->raw_multi_selected_peers[i], 0x00, sizeof(device_type_s));
+                       ugd->raw_multi_selected_peer_cnt--;
+               }
+       }
 
-    ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE;
-    ugd->raw_multi_selected_peer_cnt = 0;
        wfd_ug_view_update_peers(ugd);
 
        __FUNC_EXIT__;
        return false;
 }
 
+/**
+ *     This function let the ug free the selected peers in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
+void wfd_free_multi_selected_peers(void *data)
+{
+       __FUNC_ENTER__;
+       int i = 0;
+       struct ug_data *ugd = (struct ug_data *)data;
+
+       /* destroy the created group */
+       wifi_direct_destroy_group();
+
+       /* release the selected peers */
+       for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
+               memset(&ugd->raw_multi_selected_peers[i], 0x00, sizeof(device_type_s));
+       }
+
+       ugd->raw_multi_selected_peer_cnt = 0;
+       ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE;
+
+       __FUNC_EXIT__;
+
+}
+
+/**
+ *     This function let the ug stop to connect to selected peer
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
 int wfd_stop_multi_connect(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+
+       /* change the title of failed peers */
+       ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_COMPLETED;
+       wfd_ug_view_refresh_glitem(ugd->multi_connect_wfd_item);
 
-    ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_COMPLETED;
-    wfd_client_set_p2p_group_owner_intent(7);
+       wfd_client_set_p2p_group_owner_intent(7);
 
-    g_timeout_add(1000 /*ms*/, __wfd_multi_connect_reset_cb, ugd);
+       /* after 30s, remove the failed peers */
+       g_timeout_add(30000 /*ms*/, __wfd_multi_connect_reset_cb, ugd);
 
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
        return 0;
 }
 
-int wfd_start_multi_connect(void* data)
+/**
+ *     This function let the ug start to connect the selected peers
+ *     @return   If success, return 0, else return -1
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_start_multi_connect(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-       int i;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
        int res;
 
-       if (ugd->raw_multi_selected_peer_cnt > 0)
-       {
+       if (ugd->raw_multi_selected_peer_cnt > 0) {
                ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_IN_PROGRESS;
-               if (wfd_client_set_p2p_group_owner_intent(15) == WIFI_DIRECT_ERROR_NONE)
-               {
-                       for (i=0;i<ugd->raw_multi_selected_peer_cnt; i++)
-                       {
-                               res = wfd_client_connect(ugd->raw_multi_selected_peers[i].mac_addr);
-                               if (res == -1)
-                               {
-                                       DBG(LOG_VERBOSE, "Failed to connect [%s].\n", ugd->raw_multi_selected_peers[i].ssid);
-                                       ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
-                               }
-                               else
-                               {
-                                       ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_CONNECTING;
-                                       break;
-                               }
-                       }
 
-                       if (i >= ugd->raw_multi_selected_peer_cnt)
-                       {
-                               wfd_client_set_p2p_group_owner_intent(7);
+               res = wfd_client_group_add();
+               if (res == -1) {
+                       DBG(LOG_ERROR, "Failed to add group");
+                       wfd_free_multi_selected_peers(ugd);
 
-                               DBG(LOG_VERBOSE, "All connect trails are failed.\n");
-                               return -1;
-                       }
-               }
-               else
-               {
-                       // error popup...
-                       DBG(LOG_VERBOSE, "Setting GO intent is failed.\n");
+                       __FUNC_EXIT__;
                        return -1;
                }
 
-       }
-       else
-       {
+       } else {
                DBG(LOG_VERBOSE, "No selected peers.\n");
                return -1;
        }
@@ -145,46 +164,42 @@ int wfd_start_multi_connect(void* data)
        return 0;
 }
 
-gboolean wfd_multi_connect_next_cb(void* data)
+/**
+ *     This function let the ug connect to the next selected peer automatically
+ *     @return   If stop the timer, return false, else return true
+ *     @param[in] data the pointer to the main data structure
+ */
+gboolean wfd_multi_connect_next_cb(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
        int i;
        int res;
 
        // Reset g_source handler..
        ugd->g_source_multi_connect_next = 0;
 
-       if (ugd->raw_multi_selected_peer_cnt > 0)
-       {
+       if (ugd->raw_multi_selected_peer_cnt > 0) {
                ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_IN_PROGRESS;
-               for (i=0;i<ugd->raw_multi_selected_peer_cnt; i++)
-               {
-                       if (ugd->raw_multi_selected_peers[i].conn_status == PEER_CONN_STATUS_WAIT_FOR_CONNECT)
-                       {
+               for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) {
+                       if (ugd->raw_multi_selected_peers[i].conn_status == PEER_CONN_STATUS_WAIT_FOR_CONNECT) {
                                res = wfd_client_connect(ugd->raw_multi_selected_peers[i].mac_addr);
-                               if (res == -1)
-                               {
+                               if (res == -1) {
                                        DBG(LOG_VERBOSE, "Failed to connect [%s].\n", ugd->raw_multi_selected_peers[i].ssid);
                                        ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT;
-                               }
-                               else
-                               {
+                               } else {
                                        ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_CONNECTING;
                                        break;
                                }
                        }
                }
 
-               if (i >= ugd->raw_multi_selected_peer_cnt)
-               {
+               if (i >= ugd->raw_multi_selected_peer_cnt) {
                        // All selected peers are touched.
                        DBG(LOG_VERBOSE, "Stop Multi Connect...\n");
                        wfd_stop_multi_connect(ugd);
                }
-       }
-       else
-       {
+       } else {
                DBG(LOG_VERBOSE, "No selected peers.\n");
                return -1;
        }
@@ -193,40 +208,42 @@ gboolean wfd_multi_connect_next_cb(void* data)
        return false;
 }
 
-
-void _connect_btn_cb(void *data, Evas_Object * obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'connect' button in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+void _connect_btn_cb(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    int i = 0;
-    int count = 0;
-    char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
-    DBG(LOG_VERBOSE, "_connect_btn_cb \n");
-
-    for (i = 0; i < ugd->gl_available_peer_cnt ; i++)
-    {
-       if (TRUE == ugd->multi_conn_dev_list[i].dev_sel_state)
-       {
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
+       int i = 0;
+       int count = 0;
+       char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
+       DBG(LOG_VERBOSE, "_connect_btn_cb \n");
+
+       for (i = 0; i < ugd->gl_available_peer_cnt ; i++) {
+               if (TRUE == ugd->multi_conn_dev_list[i].dev_sel_state) {
                        DBG(LOG_VERBOSE, "ugd->peers[i].mac_addr = %s, i = %d\n", ugd->multi_conn_dev_list[i].peer.mac_addr, i);
 
-                       memcpy(&ugd->raw_multi_selected_peers[count], &ugd->multi_conn_dev_list[i].peer,sizeof(device_type_s));
+                       memcpy(&ugd->raw_multi_selected_peers[count], &ugd->multi_conn_dev_list[i].peer, sizeof(device_type_s));
                        ugd->raw_multi_selected_peers[count].conn_status = PEER_CONN_STATUS_WAIT_FOR_CONNECT;
                        count++;
-       }
-    }
+               }
+       }
 
-    ugd->raw_multi_selected_peer_cnt = count;
+       ugd->raw_multi_selected_peer_cnt = count;
 
-    /* if more than 7 device selected, show the popup */
-    if (count > MAX_POPUP_PEER_NUM) {
+       /* if more than 7 device selected, show the popup */
+       if (count > MAX_POPUP_PEER_NUM) {
                snprintf(popup_text, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_MULTI_CONNECT"), count);
                wfd_ug_warn_popup(ugd, popup_text, POP_TYPE_MULTI_CONNECT_POPUP);
-    }
+       }
 
-    if (wfd_start_multi_connect(ugd) != -1)
-    {
-       wfd_ug_view_update_peers(ugd);
-    }
+       /* start multi connection */
+       wfd_start_multi_connect(ugd);
 
        elm_naviframe_item_pop(ugd->naviframe);
 
@@ -238,8 +255,92 @@ void _connect_btn_cb(void *data, Evas_Object * obj, void *event_info)
        return;
 }
 
+/**
+ *     This function let the ug delete 'select(n)' notify
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
+static void _wfd_multi_del_select_info_label(void *data)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *)data;
 
+       if (NULL == ugd) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
 
+       if (ugd->notify) {
+               evas_object_del(ugd->notify);
+               ugd->notify = NULL;
+       }
+
+       if (ugd->notify_layout) {
+               evas_object_del(ugd->notify_layout);
+               ugd->notify_layout = NULL;
+       }
+
+       __FUNC_EXIT__;
+       return;
+}
+
+/**
+ *     This function let the ug add 'select(n)' notify
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] count the number of selected peers
+ */
+static void _wfd_multi_add_select_info_label(void *data, int count)
+{
+       __FUNC_ENTER__;
+
+       char select_lablel[MAX_POPUP_TEXT_SIZE] = {0};
+       struct ug_data *ugd = (struct ug_data *)data;
+
+       if (NULL == ugd || count <= 0) {
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
+       }
+
+       /* delete previous notify */
+       _wfd_multi_del_select_info_label(ugd);
+
+       /* add notify */
+       ugd->notify = elm_notify_add(ugd->base);
+       if (NULL == ugd->notify) {
+               DBG(LOG_ERROR, "Add notify failed\n");
+               return;
+       }
+
+       /* set the align to center of bottom */
+       elm_notify_align_set(ugd->notify, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       ugd->notify_layout = elm_layout_add(ugd->notify);
+       if (NULL == ugd->notify_layout) {
+               evas_object_del(ugd->notify);
+               ugd->notify = NULL;
+               return;
+       }
+
+       elm_layout_theme_set(ugd->notify_layout, "standard", "selectioninfo", "vertical/bottom_64");
+       elm_object_content_set(ugd->notify, ugd->notify_layout);
+
+       snprintf(select_lablel, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_SELECTED_DEVICE_NUM"), count);
+       elm_object_part_text_set(ugd->notify_layout, "elm.text", select_lablel);
+       elm_notify_timeout_set(ugd->notify, 3);
+       evas_object_show(ugd->notify);
+
+       __FUNC_EXIT__;
+       return;
+}
+
+/**
+ *     This function let the ug call it when click the peer in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _wfd_gl_multi_sel_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
@@ -252,20 +353,20 @@ static void _wfd_gl_multi_sel_cb(void *data, Evas_Object *obj, void *event_info)
        Eina_Bool state = 0;
        Evas_Object *chk_box = NULL;
        char msg[MAX_POPUP_TEXT_SIZE] = {0};
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *)data;
        Elm_Object_Item *item = (Elm_Object_Item *)event_info;
 
        if (NULL == ugd || NULL == item) {
-           DBG(LOG_ERROR, "The param is NULL\n");
-           return;
+               DBG(LOG_ERROR, "The param is NULL\n");
+               return;
        }
 
        elm_genlist_item_selected_set(item, EINA_FALSE);
        index = elm_genlist_item_index_get(item) - 3; /* subtract the previous items */
        DBG(LOG_VERBOSE, "selected index = %d \n", index);
        if (index < 0) {
-           DBG(LOG_ERROR, "The index is invalid.\n");
-           return;
+               DBG(LOG_ERROR, "The index is invalid.\n");
+               return;
        }
 
        chk_box = elm_object_item_part_content_get((Elm_Object_Item *)event_info, "elm.icon.1");
@@ -296,17 +397,26 @@ static void _wfd_gl_multi_sel_cb(void *data, Evas_Object *obj, void *event_info)
 
        if (sel_count > 0) {
                snprintf(msg, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_SELECTED_DEVICE_NUM"), sel_count);
-               wfd_ug_tickernoti_popup(msg);
+               _wfd_multi_add_select_info_label(ugd, sel_count);
+       } else {
+               _wfd_multi_del_select_info_label(ugd);
        }
 
        __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug call it when click the 'select all' item in multi connect view
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _wfd_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
 {
        int sel_count = 0;
        char msg[MAX_POPUP_TEXT_SIZE] = {0};
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *)data;
 
        elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
 
@@ -316,19 +426,19 @@ static void _wfd_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
        }
 
        Evas_Object *sel_chkbox = elm_object_item_part_content_get(ugd->mcview_select_all_item, "elm.icon");
-       if (sel_chkbox==NULL)
-       {
+       if (sel_chkbox == NULL) {
                DBG(LOG_VERBOSE, "select-all chkbox is NULL\n");
                return;
        }
-       Eina_Bool state = elm_check_state_get(sel_chkbox);
 
-       if (state==TRUE)
+       Eina_Bool state = elm_check_state_get(sel_chkbox);
+       if (state == TRUE) {
                state = FALSE;
-       else
+       } else {
                state = TRUE;
-       elm_check_state_set(sel_chkbox, state);
+       }
 
+       elm_check_state_set(sel_chkbox, state);
        DBG(LOG_VERBOSE, "state = %d \n", state);
 
        int i = 0;
@@ -357,20 +467,27 @@ static void _wfd_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
        /* tickernoti popup */
        if (sel_count > 0) {
                snprintf(msg, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_SELECTED_DEVICE_NUM"), sel_count);
-               wfd_ug_tickernoti_popup(msg);
+               _wfd_multi_add_select_info_label(ugd, sel_count);
+       } else {
+               _wfd_multi_del_select_info_label(ugd);
        }
-
-    //elm_check_state_set(ugd->mcview_select_all_icon, EINA_FALSE);
 }
 
-
+/**
+ *     This function let the ug get the label of peer
+ *     @return   the label of peer
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_wfd_gl_device_label_get(void *data, Evas_Object *obj, const char *part)
 {
        DBG(LOG_VERBOSE, "part %s", part);
-       device_type_s *peer = (device_type_s*) data;
+       device_type_s *peer = (device_type_s *)data;
 
-       if (NULL == peer)
+       if (NULL == peer) {
                return NULL;
+       }
 
        if (!strcmp(part, "elm.text")) {
                return strdup(peer->ssid);
@@ -378,94 +495,89 @@ static char *_wfd_gl_device_label_get(void *data, Evas_Object *obj, const char *
        return NULL;
 }
 
-
+/**
+ *     This function let the ug get the icon path of peer
+ *     @return   the  icon path of titile
+ *     @param[in] peer the pointer to the peer
+ */
 static char *__wfd_get_device_icon_path(device_type_s *peer)
 {
-       char *img_path = NULL;
-
-        switch(peer->category)
-        {
-        case WFD_DEVICE_TYPE_COMPUTER:
-            img_path = WFD_ICON_DEVICE_COMPUTER;
-            break;
-        case WFD_DEVICE_TYPE_INPUT_DEVICE:
-            img_path = WFD_ICON_DEVICE_INPUT_DEVICE;
-            break;
-        case WFD_DEVICE_TYPE_PRINTER:
-            img_path = WFD_ICON_DEVICE_PRINTER;
-            break;
-        case WFD_DEVICE_TYPE_CAMERA:
-            img_path = WFD_ICON_DEVICE_CAMERA;
-            break;
-        case WFD_DEVICE_TYPE_STORAGE:
-            img_path = WFD_ICON_DEVICE_STORAGE;
-            break;
-        case WFD_DEVICE_TYPE_NW_INFRA:
-            img_path = WFD_ICON_DEVICE_NETWORK_INFRA;
-            break;
-        case WFD_DEVICE_TYPE_DISPLAYS:
-            img_path = WFD_ICON_DEVICE_DISPLAY;
-            break;
-        case WFD_DEVICE_TYPE_MM_DEVICES:
-            img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE;
-            break;
-        case WFD_DEVICE_TYPE_GAME_DEVICES:
-            img_path = WFD_ICON_DEVICE_GAMING_DEVICE;
-            break;
-        case WFD_DEVICE_TYPE_TELEPHONE:
-            img_path = WFD_ICON_DEVICE_TELEPHONE;
-            break;
-        case WFD_DEVICE_TYPE_AUDIO:
-            img_path = WFD_ICON_DEVICE_AUDIO_DEVICE;
-            break;
-        default:
-               img_path = WFD_ICON_DEVICE_COMPUTER;
-               break;
-        }
+       char *img_path = NULL;
+
+       switch (peer->category) {
+       case WFD_DEVICE_TYPE_COMPUTER:
+               img_path = WFD_ICON_DEVICE_COMPUTER;
+               break;
+       case WFD_DEVICE_TYPE_INPUT_DEVICE:
+               img_path = WFD_ICON_DEVICE_INPUT_DEVICE;
+               break;
+       case WFD_DEVICE_TYPE_PRINTER:
+               img_path = WFD_ICON_DEVICE_PRINTER;
+               break;
+       case WFD_DEVICE_TYPE_CAMERA:
+               img_path = WFD_ICON_DEVICE_CAMERA;
+               break;
+       case WFD_DEVICE_TYPE_STORAGE:
+               img_path = WFD_ICON_DEVICE_STORAGE;
+               break;
+       case WFD_DEVICE_TYPE_NW_INFRA:
+               img_path = WFD_ICON_DEVICE_NETWORK_INFRA;
+               break;
+       case WFD_DEVICE_TYPE_DISPLAYS:
+               img_path = WFD_ICON_DEVICE_DISPLAY;
+               break;
+       case WFD_DEVICE_TYPE_MM_DEVICES:
+               img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE;
+               break;
+       case WFD_DEVICE_TYPE_GAME_DEVICES:
+               img_path = WFD_ICON_DEVICE_GAMING_DEVICE;
+               break;
+       case WFD_DEVICE_TYPE_TELEPHONE:
+               img_path = WFD_ICON_DEVICE_TELEPHONE;
+               break;
+       case WFD_DEVICE_TYPE_AUDIO:
+               img_path = WFD_ICON_DEVICE_AUDIO_DEVICE;
+               break;
+       default:
+               img_path = WFD_ICON_DEVICE_COMPUTER;
+               break;
+       }
 
        return img_path;
 }
 
 
-
+/**
+ *     This function let the ug call it when click the check box
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _wfd_check_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       struct ug_data *ugd = (struct ug_data*) data;
-       if (NULL == ugd || NULL == obj) {
+       if (NULL == obj) {
                DBG(LOG_ERROR, "NULL parameters.\n");
                return;
        }
 
-       int i = 0;
-       bool is_sel = FALSE;
-       Elm_Object_Item *item = NULL;
-       Evas_Object *chk_box = NULL;
        Eina_Bool state = elm_check_state_get(obj);
        elm_check_state_set(obj, !state);
-
        DBG(LOG_VERBOSE, "state = %d \n", state);
-
-#if 0
-       /* set the state of all the available devices */
-       for (i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view; i++) {
-               is_sel = state;
-               ugd->multi_conn_dev_list[i].dev_sel_state = state;
-               item = ugd->multi_conn_dev_list[i].peer.gl_item;
-               chk_box = elm_object_item_part_content_get(item, "elm.icon.1");
-               elm_check_state_set(chk_box, state);
-       }
-
-       /* update the connect button */
-       wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), is_sel);
-#endif
 }
 
-
+/**
+ *     This function let the ug get the icon of peer
+ *     @return   the icon of peer
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static Evas_Object *_wfd_gl_device_icon_get(void *data, Evas_Object *obj, const char *part)
 {
        char *img_path = NULL;
-       device_type_s *peer = (device_type_s*) data;
-       Evas_Objecticon = NULL;
+       device_type_s *peer = (device_type_s *) data;
+       Evas_Object *icon = NULL;
 
        DBG(LOG_VERBOSE, "Part %s", part);
 
@@ -473,9 +585,9 @@ static Evas_Object *_wfd_gl_device_icon_get(void *data, Evas_Object *obj, const
                DBG(LOG_VERBOSE, "Part %s", part);
                icon = elm_check_add(obj);
                elm_check_state_set(icon, EINA_FALSE);
-           evas_object_smart_callback_add(icon, "changed", _wfd_check_clicked_cb, (void *)data);
+               evas_object_smart_callback_add(icon, "changed", _wfd_check_clicked_cb, (void *)data);
        } else if (!strcmp(part, "elm.icon.2")) {
-               img_path = __wfd_get_device_icon_path(peer);
+               img_path = __wfd_get_device_icon_path(peer);
                icon = elm_icon_add(obj);
                elm_icon_file_set(icon, img_path, NULL);
                evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
@@ -486,7 +598,13 @@ static Evas_Object *_wfd_gl_device_icon_get(void *data, Evas_Object *obj, const
        return icon;
 }
 
-
+/**
+ *     This function let the ug get the label of select all
+ *     @return   the label of select all
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static char *_wfd_gl_select_all_label_get(void *data, Evas_Object *obj, const char *part)
 {
        if (!strcmp(part, "elm.text")) {
@@ -496,10 +614,16 @@ static char *_wfd_gl_select_all_label_get(void *data, Evas_Object *obj, const ch
        return NULL;
 }
 
+/**
+ *     This function let the ug get the icon of select all
+ *     @return   the icon of select all
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] part the pointer to the part of item
+ */
 static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, const char *part)
 {
-       struct ug_data *ugd = (struct ug_data*) data;
-       Evas_Object* icon = NULL;
+       Evas_Object *icon = NULL;
 
        if (!strcmp(part, "elm.icon")) {
                DBG(LOG_VERBOSE, "Part %s", part);
@@ -511,185 +635,173 @@ static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, co
        return icon;
 }
 
+/**
+ *     This function let the ug fee the multi connect devices
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_free_multiconnect_device(struct ug_data *ugd)
+{
+       __FUNC_ENTER__;
 
+       int i = 0;
 
+       if (ugd->multiconn_view_genlist == NULL) {
+               return 0;
+       }
 
-int _wfd_free_multiconnect_device(struct ug_data *ugd)
-{
-    __FUNC_ENTER__;
-
-    int count = 0;
-    int i = 0;
-
-    if (ugd->multiconn_view_genlist == NULL)
-    {
-       return 0;
-    }
-
-    if (ugd->mcview_title_item != NULL)
-    {
-        elm_object_item_del(ugd->mcview_title_item);
-        ugd->mcview_title_item = NULL;
-    }
-
-    if (ugd->mcview_select_all_item != NULL)
-    {
-        elm_object_item_del(ugd->mcview_select_all_item);
-        ugd->mcview_select_all_item = NULL;
-    }
-
-    if (ugd->mcview_nodevice_item != NULL)
-    {
-        elm_object_item_del(ugd->mcview_nodevice_item);
-        ugd->mcview_nodevice_item = NULL;
-    }
-
-    for(i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view;  i++)
-    {
-        if (ugd->multi_conn_dev_list[i].peer.gl_item != NULL)
-        {
-            elm_object_item_del(ugd->multi_conn_dev_list[i].peer.gl_item);
-            ugd->multi_conn_dev_list[i].peer.gl_item = NULL;
-        }
-    }
-    ugd->gl_available_dev_cnt_at_multiconn_view = 0;
-
-    __FUNC_EXIT__;
-    return 0;
+       if (ugd->mcview_title_item != NULL) {
+               elm_object_item_del(ugd->mcview_title_item);
+               ugd->mcview_title_item = NULL;
+       }
+
+       if (ugd->mcview_select_all_item != NULL) {
+               elm_object_item_del(ugd->mcview_select_all_item);
+               ugd->mcview_select_all_item = NULL;
+       }
+
+       if (ugd->mcview_nodevice_item != NULL) {
+               elm_object_item_del(ugd->mcview_nodevice_item);
+               ugd->mcview_nodevice_item = NULL;
+       }
+
+       for (i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view;  i++) {
+               if (ugd->multi_conn_dev_list[i].peer.gl_item != NULL) {
+                       elm_object_item_del(ugd->multi_conn_dev_list[i].peer.gl_item);
+                       ugd->multi_conn_dev_list[i].peer.gl_item = NULL;
+               }
+       }
+       ugd->gl_available_dev_cnt_at_multiconn_view = 0;
+
+       __FUNC_EXIT__;
+       return 0;
 }
 
-int _wfd_update_multiconnect_device(struct ug_data *ugd)
+/**
+ *     This function let the ug update the multi connect devices
+ *     @return   0
+ *     @param[in] data the pointer to the main data structure
+ */
+int wfd_update_multiconnect_device(struct ug_data *ugd)
 {
-    __FUNC_ENTER__;
-
-    int count = 0;
-    device_type_s *device = NULL;
-    Evas_Object *genlist = NULL;
-    int i = 0;
-
-    genlist = ugd->multiconn_view_genlist;
-    if (ugd->multiconn_view_genlist == NULL)
-    {
-       return 0;
-    }
-
-    _wfd_free_multiconnect_device(ugd);
-
-    count = 0;
-    for(i = 0; i < ugd->raw_discovered_peer_cnt;  i++)
-    {
-       device = &ugd->raw_discovered_peers[i];
-       if (device->is_connected == FALSE)
-       {
+       __FUNC_ENTER__;
+
+       int count = 0;
+       device_type_s *device = NULL;
+       Evas_Object *genlist = NULL;
+       int i = 0;
+
+       genlist = ugd->multiconn_view_genlist;
+       if (ugd->multiconn_view_genlist == NULL) {
+               return 0;
+       }
+
+       wfd_free_multiconnect_device(ugd);
+
+       count = 0;
+       for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+               device = &ugd->raw_discovered_peers[i];
+               if (device->is_connected == FALSE) {
                        count++;
-       }
-    }
-    ugd->gl_available_dev_cnt_at_multiconn_view = count;
+               }
+       }
+       ugd->gl_available_dev_cnt_at_multiconn_view = count;
 
-    if (ugd->gl_available_dev_cnt_at_multiconn_view == 0)
-    {
+       if (ugd->gl_available_dev_cnt_at_multiconn_view == 0) {
                DBG(LOG_ERROR, "There are No peers\n");
-        ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-        ugd->mcview_nodevice_item = elm_genlist_item_append(genlist, &noitem_itc, (void*)ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-        elm_genlist_item_select_mode_set(ugd->mcview_nodevice_item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-    }
-    else
-    {
-        ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
-       ugd->mcview_select_all_item = elm_genlist_item_append(genlist, &select_all_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_sel_cb, ugd);
+               ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+               ugd->mcview_nodevice_item = elm_genlist_item_append(genlist, &noitem_itc, (void *)ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               elm_genlist_item_select_mode_set(ugd->mcview_nodevice_item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       } else {
+               ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+               ugd->mcview_select_all_item = elm_genlist_item_append(genlist, &select_all_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_sel_cb, ugd);
 
                count = 0;
-               for(i = 0; i < ugd->raw_discovered_peer_cnt;  i++)
-               {
+               for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
                        device = &ugd->raw_discovered_peers[i];
-                       if (device->is_connected == FALSE)
-                       {
+                       if (device->is_connected == FALSE) {
                                DBG(LOG_VERBOSE, "%dth peer being added on genlist\n", i);
 
-                               if (ugd->multi_conn_dev_list[count].peer.gl_item != NULL)
+                               if (ugd->multi_conn_dev_list[count].peer.gl_item != NULL) {
                                        elm_object_item_del(ugd->multi_conn_dev_list[count].peer.gl_item);
-                               ugd->multi_conn_dev_list[count].peer.gl_item = NULL;
+                               }
 
+                               ugd->multi_conn_dev_list[count].peer.gl_item = NULL;
                                memcpy(&ugd->multi_conn_dev_list[count].peer, device, sizeof(device_type_s));
-
                                ugd->multi_conn_dev_list[count].dev_sel_state = FALSE;
-                               ugd->multi_conn_dev_list[count].peer.gl_item =
-                                               elm_genlist_item_append(genlist, &device_itc, (void*) &ugd->multi_conn_dev_list[count].peer,
-                                                               NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_multi_sel_cb, ugd);
+                               ugd->multi_conn_dev_list[count].peer.gl_item = elm_genlist_item_append(genlist, &device_itc,
+                                       (void *)&ugd->multi_conn_dev_list[count].peer, NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_multi_sel_cb, ugd);
                                count++;
                        }
                }
-    }
+       }
 
-    __FUNC_EXIT__;
-    return 0;
+       __FUNC_EXIT__;
+       return 0;
 }
 
-void _wifid_create_multiconnect_view(struct ug_data *ugd)
+/**
+ *     This function let the ug create the view for multi connection
+ *     @return   void
+ *     @param[in] ugd the pointer to the main data structure
+ */
+void wfd_create_multiconnect_view(struct ug_data *ugd)
 {
        __FUNC_ENTER__;
 
-    Evas_Object *back_btn = NULL;
-    Evas_Object *control_bar = NULL;
-    Evas_Object *genlist = NULL;
-
-    Elm_Object_Item *navi_item = NULL;
-       Elm_Object_Item *item = NULL;
-
-    if(ugd == NULL)
-    {
-        DBG(LOG_ERROR, "Incorrect parameter(NULL)");
-        return;
-    }
-
-    select_all_itc.item_style = "1text.1icon.3";
-    select_all_itc.func.text_get = _wfd_gl_select_all_label_get;
-    select_all_itc.func.content_get = _wfd_gl_select_all_icon_get;
-    select_all_itc.func.state_get = NULL;
-    select_all_itc.func.del = NULL;
-
-    device_itc.item_style = "1text.2icon.2";
-    device_itc.func.text_get = _wfd_gl_device_label_get;
-    device_itc.func.content_get = _wfd_gl_device_icon_get;
-    device_itc.func.state_get = NULL;
-    device_itc.func.del = NULL;
-
-    DBG(LOG_VERBOSE, "_wifid_create_multiconnect_view");
-    back_btn = elm_button_add(ugd->naviframe);
-    elm_object_style_set(back_btn, "naviframe/back_btn/default");
-    evas_object_smart_callback_add(back_btn, "clicked", _multiconnect_view_back_btn_cb, (void*) ugd);
-    elm_object_focus_allow_set(back_btn, EINA_FALSE);
+       Evas_Object *back_btn = NULL;
+       Evas_Object *genlist = NULL;
+       Elm_Object_Item *navi_item = NULL;
 
-    genlist = elm_genlist_add(ugd->naviframe);
-    ugd->multiconn_view_genlist = genlist;
-    elm_object_style_set(ugd->multiconn_view_genlist, "dialogue");
-
-    ugd->mcview_title_item = NULL;
-
-    _wfd_update_multiconnect_device(ugd);
-
-    evas_object_show(genlist);
-
-    navi_item = elm_naviframe_item_push(ugd->naviframe, _("Multi connect"), back_btn, NULL, genlist, NULL);
-
-    control_bar = elm_toolbar_add(ugd->naviframe);
-    elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
-    evas_object_show(control_bar);
-
-    ugd->multi_scan_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_SCAN"), _scan_btn_cb, (void*) ugd);
-    item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL);
-    elm_object_item_disabled_set(item, EINA_TRUE);
-    ugd->multi_connect_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_CONNECT"), _connect_btn_cb, (void*) ugd);
-
-    if (ugd->multi_connect_btn) {
-       wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), FALSE);
-    }
+       if (ugd == NULL) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)");
+               return;
+       }
 
-    item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL);
-    elm_object_item_disabled_set(item, EINA_TRUE);
-    elm_object_item_part_content_set(navi_item, "controlbar", control_bar);
+       select_all_itc.item_style = "1text.1icon.3";
+       select_all_itc.func.text_get = _wfd_gl_select_all_label_get;
+       select_all_itc.func.content_get = _wfd_gl_select_all_icon_get;
+       select_all_itc.func.state_get = NULL;
+       select_all_itc.func.del = NULL;
+
+       device_itc.item_style = "1text.2icon.2";
+       device_itc.func.text_get = _wfd_gl_device_label_get;
+       device_itc.func.content_get = _wfd_gl_device_icon_get;
+       device_itc.func.state_get = NULL;
+       device_itc.func.del = NULL;
+
+       DBG(LOG_VERBOSE, "_wifid_create_multiconnect_view");
+       back_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(back_btn, "naviframe/back_btn/default");
+       evas_object_smart_callback_add(back_btn, "clicked", _multiconnect_view_back_btn_cb, (void *)ugd);
+       elm_object_focus_allow_set(back_btn, EINA_FALSE);
+
+       genlist = elm_genlist_add(ugd->naviframe);
+       ugd->multiconn_view_genlist = genlist;
+       ugd->mcview_title_item = NULL;
+
+       wfd_update_multiconnect_device(ugd);
+
+       evas_object_show(genlist);
+
+       navi_item = elm_naviframe_item_push(ugd->naviframe, _("Multi connect"), back_btn, NULL, genlist, NULL);
+
+       /* create scan button */
+       ugd->multi_scan_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(ugd->multi_scan_btn, "naviframe/toolbar/default");
+       elm_object_text_set(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"));
+       evas_object_smart_callback_add(ugd->multi_scan_btn, "clicked", _scan_btn_cb, (void *)ugd);
+       elm_object_item_part_content_set(navi_item, "toolbar_button1", ugd->multi_scan_btn);
+
+       /* create connect button */
+       ugd->multi_connect_btn = elm_button_add(ugd->naviframe);
+       elm_object_style_set(ugd->multi_connect_btn, "naviframe/toolbar/default");
+       elm_object_text_set(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"));
+       evas_object_smart_callback_add(ugd->multi_connect_btn, "clicked", _connect_btn_cb, (void *)ugd);
+       elm_object_disabled_set(ugd->multi_connect_btn, EINA_TRUE);
+       elm_object_item_part_content_set(navi_item, "toolbar_button2", ugd->multi_connect_btn);
 
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
 }
index 254a4e9..1c1e890 100755 (executable)
 #include "wfd_ug_view.h"
 #include "wfd_client.h"
 
-static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    // TODO: Turn off WiFi
-    ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATED;
-    wfd_wifi_off(ugd);
-
-     evas_object_del(ugd->act_popup);
-     ugd->act_popup = NULL;
-    __FUNC_EXIT__;
-}
-
-static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
-{
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    // TODO: set genlist head item as "WiFi Direct"
-    ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
-    wfd_ug_view_refresh_glitem(ugd->head);
-
-     evas_object_del(ugd->act_popup);
-     ugd->act_popup = NULL;
-    __FUNC_EXIT__;
-}
-
-static void _wfd_ug_act_popup_disconnect_ok_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'ok' button in hotspot action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
-
-       char *mac_addr = NULL;
-       struct ug_data *ugd = (struct ug_data*) data;
-
-       if (NULL == ugd) {
-               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-               return;
-       }
-
-       if (ugd->gl_connected_peer_cnt < 1) {
-               DBG(LOG_ERROR, "No connected peer\n");
-               evas_object_del(ugd->act_popup);
-               ugd->act_popup = NULL;
-               return;
-       }
-
-       /* just one peer */
-       mac_addr = ugd->gl_connected_peers[0].mac_addr;
-       wfd_client_disconnect(mac_addr);
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
-               wfd_stop_multi_connect(ugd);
+       int result = -1;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       result = wfd_mobile_ap_off(ugd);
+       if (0 == result) {
+               /* refresh the header */
+               ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING;
+               wfd_ug_view_refresh_glitem(ugd->head);
+
+               /* while activating/deactivating, disable the buttons */
+               if (ugd->scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->multi_scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->back_btn) {
+                       elm_object_disabled_set(ugd->back_btn, TRUE);
+               }
        }
 
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
-
        __FUNC_EXIT__;
 }
 
-static void _wfd_ug_act_popup_disconnect_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'cancel' button in hotspot action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-       struct ug_data *ugd = (struct ug_data*) data;
-       if (NULL == ugd) {
-               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-               return;
-       }
+       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+       wfd_ug_view_refresh_glitem(ugd->head);
 
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
-
        __FUNC_EXIT__;
 }
 
-static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'ok' button in wifi action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
-
-       struct ug_data *ugd = (struct ug_data*) data;
-       if (NULL == ugd) {
-               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-               return;
-       }
-
-       wfd_client_disconnect(NULL);
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
-               wfd_stop_multi_connect(ugd);
+       int result = -1;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       result = wfd_wifi_off(ugd);
+       if (0 == result) {
+               /* refresh the header */
+               ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING;
+               wfd_ug_view_refresh_glitem(ugd->head);
+
+               /* while activating/deactivating, disable the buttons */
+               if (ugd->scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->multi_scan_btn) {
+                       wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE);
+               }
+
+               if (ugd->back_btn) {
+                       elm_object_disabled_set(ugd->back_btn, TRUE);
+               }
        }
 
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
-
        __FUNC_EXIT__;
 }
 
-static void _wfd_ug_act_popup_disconnect_all_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'cancel' button in wifi action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-       struct ug_data *ugd = (struct ug_data*) data;
-       if (NULL == ugd) {
-               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
-               return;
-       }
+       ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
+       wfd_ug_view_refresh_glitem(ugd->head);
 
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
-
        __FUNC_EXIT__;
 }
 
-static void _wfd_ug_act_popup_scan_again_ok_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'ok' button in disconnect all popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
-
-       struct ug_data *ugd = (struct ug_data*) data;
+       int i = 0;
+       struct ug_data *ugd = (struct ug_data *) data;
        if (NULL == ugd) {
                DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
                return;
        }
 
-       if (ugd->conn_wfd_item != NULL) {
-               elm_object_item_del(ugd->conn_wfd_item);
-               ugd->conn_wfd_item = NULL;
-       }
-
-       /* cancel the current connection */
        wfd_client_disconnect(NULL);
-       if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
-               wfd_stop_multi_connect(ugd);
+
+       if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
+               wfd_free_multi_selected_peers(ugd);
+       } else {
+               /* update the connecting icon */
+               for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) {
+                       ugd->raw_discovered_peers[i].conn_status = PEER_CONN_STATUS_DISCONNECTED;
+                       wfd_ug_view_refresh_glitem(ugd->raw_discovered_peers[i].gl_item);
+               }
        }
 
-       /* start discovery again */
-       wfd_client_start_discovery(ugd);
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
 
        __FUNC_EXIT__;
 }
 
-static void _wfd_ug_act_popup_scan_again_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'cancel' button in disconnect all popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_act_popup_disconnect_all_cancel_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
 
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *) data;
+       if (NULL == ugd) {
+               DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
+               return;
+       }
 
        evas_object_del(ugd->act_popup);
        ugd->act_popup = NULL;
@@ -185,10 +205,17 @@ static void _wfd_ug_act_popup_scan_again_cancel_cb(void *data, Evas_Object *obj,
        __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug create a action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] message the pointer to the text of popup
+ *     @param[in] popup_type the message type
+ */
 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
 {
        __FUNC_ENTER__;
-       struct ug_data *ugd = (struct ug_data*) data;
+       struct ug_data *ugd = (struct ug_data *) data;
        Evas_Object *popup = NULL;
        Evas_Object *btn1 = NULL, *btn2 = NULL;
 
@@ -202,7 +229,7 @@ void wfd_ug_act_popup(void *data, const char *message, int popup_type)
        elm_object_style_set(btn2, "popup_button/default");
 
        /* set the different text by type */
-       if (popup_type == POPUP_TYPE_WIFI_OFF) {
+       if (popup_type == POPUP_TYPE_WIFI_OFF || popup_type == POPUP_TYPE_HOTSPOT_OFF) {
                elm_object_text_set(btn1, S_("IDS_COM_SK_YES"));
                elm_object_text_set(btn2, S_("IDS_COM_SK_NO"));
        } else {
@@ -215,18 +242,16 @@ void wfd_ug_act_popup(void *data, const char *message, int popup_type)
 
        /* set the different callback by type */
        if (popup_type == POPUP_TYPE_WIFI_OFF) {
-               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void*) ugd);
-               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void*) ugd);
-       } else if (popup_type == POP_TYPE_DISCONNECT) {
-               //evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_ok_cb, (void*) ugd);
-               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void*) ugd);
-               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_cancel_cb, (void*) ugd);
-       } else if (popup_type == POP_TYPE_DISCONNECT_ALL) {
-               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void*) ugd);
-               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_cancel_cb, (void*) ugd);
-       } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
-               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_scan_again_ok_cb, (void*) ugd);
-               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_scan_again_cancel_cb, (void*) ugd);
+               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
+               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
+       } else if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
+               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
+               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
+       } else if (popup_type == POP_TYPE_DISCONNECT ||
+               popup_type == POP_TYPE_DISCONNECT_ALL ||
+               popup_type == POP_TYPE_SCAN_AGAIN) {
+               evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
+               evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_cancel_cb, (void *)ugd);
        }
 
        evas_object_show(popup);
@@ -234,135 +259,121 @@ void wfd_ug_act_popup(void *data, const char *message, int popup_type)
        __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug remove the action popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ */
 void wfg_ug_act_popup_remove(void *data)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(ugd->act_popup)
-    {
-        evas_object_del(ugd->act_popup);
-        ugd->act_popup = NULL;
-    }
-    __FUNC_EXIT__;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+
+       if (ugd->act_popup) {
+               evas_object_del(ugd->act_popup);
+               ugd->act_popup = NULL;
+       }
+       __FUNC_EXIT__;
 }
 
+/**
+ *     This function let the ug call it when click 'ok' button in warning popup of terminated problem
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    evas_object_del(ugd->warn_popup);
-    ugd->warn_popup = NULL;
+       evas_object_del(ugd->warn_popup);
+       ugd->warn_popup = NULL;
 
-    wfd_ug_view_free_peers(ugd);
+       wfd_ug_view_free_peers(ugd);
 
-    ug_destroy_me(ugd->ug);
-    __FUNC_EXIT__;
+       ug_destroy_me(ugd->ug);
+       __FUNC_EXIT__;
 }
 
-static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
+/**
+ *     This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
 {
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-    evas_object_del(ugd->warn_popup);
-    ugd->warn_popup = NULL;
+       evas_object_del(ugd->warn_popup);
+       ugd->warn_popup = NULL;
 
-    __FUNC_EXIT__;
-}
+       /* turn off the Wi-Fi Direct */
+       wfd_client_switch_off(ugd);
 
-void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
-{
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-    Evas_Object *popup = NULL;
-    Evas_Object *btn = NULL;
-
-    popup = elm_popup_add(ugd->base);
-    evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    elm_object_text_set(popup, message);
-
-    btn = elm_button_add(popup);
-    elm_object_style_set(btn, "popup_button/default");
-    elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
-    elm_object_part_content_set(popup, "button1", btn);
-    if(popup_type == POPUP_TYPE_TERMINATE)
-        evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void*) ugd);
-    else
-        evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void*) ugd);
-
-    evas_object_show(popup);
-    ugd->warn_popup = popup;
-    __FUNC_EXIT__;
-}
+       /* antomaticlly turn on tethering mode */
+       if (TRUE == ugd->is_hotspot_off) {
+               wfd_mobile_ap_on(ugd);
+       }
 
-void wfg_ug_warn_popup_remove(void *data)
-{
-    __FUNC_ENTER__;
-    struct ug_data *ugd = (struct ug_data*) data;
-
-    if(ugd->warn_popup)
-    {
-        evas_object_del(ugd->warn_popup);
-        ugd->warn_popup = NULL;
-    }
-    __FUNC_EXIT__;
+       __FUNC_EXIT__;
 }
 
-
-void wfd_ug_tickernoti_popup(char *msg)
+/**
+ *     This function let the ug call it when click 'ok' button in warning popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] obj the pointer to the evas object
+ *     @param[in] event_info the pointer to the event information
+ */
+static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
 {
        __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
 
-       int ret = -1;
-       bundle *b = NULL;
+       evas_object_del(ugd->warn_popup);
+       ugd->warn_popup = NULL;
 
-       b = bundle_create();
-       if (!b) {
-               DBG(LOG_ERROR, "FAIL: bundle_create()\n");
-               return;
-       }
-
-       /* tickernoti style */
-       ret = bundle_add(b, "0", "info");
-       if (ret) {
-               DBG(LOG_ERROR, "Fail to add tickernoti style\n");
-               bundle_free(b);
-               return;
-       }
-
-       /* popup text */
-       ret = bundle_add(b, "1", msg);
-       if (ret) {
-               DBG(LOG_ERROR, "Fail to add popup text\n");
-               bundle_free(b);
-               return;
-       }
+       __FUNC_EXIT__;
+}
 
-       /* orientation of tickernoti */
-       ret = bundle_add(b, "2", "1");
-       if (ret) {
-               DBG(LOG_ERROR, "Fail to add orientation of tickernoti\n");
-               bundle_free(b);
-               return;
-       }
+/**
+ *     This function let the ug create a warning popup
+ *     @return   void
+ *     @param[in] data the pointer to the main data structure
+ *     @param[in] message the pointer to the text of popup
+ *     @param[in] popup_type the message type
+ */
+void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
+{
+       __FUNC_ENTER__;
+       struct ug_data *ugd = (struct ug_data *) data;
+       Evas_Object *popup = NULL;
+       Evas_Object *btn = NULL;
 
-       /* timeout(second) of tickernoti */
-       ret = bundle_add(b, "3", "3");
-       if (ret) {
-               DBG(LOG_ERROR, "Fail to add timeout of tickernoti\n");
-               bundle_free(b);
-               return;
-       }
+       popup = elm_popup_add(ugd->base);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_part_text_set(popup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION"));
+       elm_object_text_set(popup, message);
 
-       /* launch tickernoti */
-       ret = syspopup_launch(TICKERNOTI_SYSPOPUP, b);
-       if (ret) {
-               DBG(LOG_ERROR, "Fail to launch syspopup\n");
+       btn = elm_button_add(popup);
+       elm_object_style_set(btn, "popup_button/default");
+       elm_object_text_set(btn, S_("IDS_COM_SK_OK"));
+       elm_object_part_content_set(popup, "button1", btn);
+       if (popup_type == POPUP_TYPE_TERMINATE) {
+               evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void *)ugd);
+       } else if (popup_type == POP_TYPE_AUTOMATIC_TURN_OFF) {
+               evas_object_smart_callback_add(btn, "clicked", _wfd_ug_automatic_turn_off_popup_cb, (void *)ugd);
+       } else {
+               evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
        }
 
-       bundle_free(b);
+       evas_object_show(popup);
+       ugd->warn_popup = popup;
        __FUNC_EXIT__;
 }
 
index ec6ebd5..f07d6c1 100755 (executable)
 
 #define WIFI_DIRECT_APP_MID            "wfd-ugapp"
 
-#define WFD_APP_LOG_LOW        LOG_VERBOSE
-#define WFD_APP_LOG_HIGH       LOG_INFO
-#define WFD_APP_LOG_ERROR      LOG_ERROR
-#define WFD_APP_LOG_WARN       LOG_WARN
-#define WFD_APP_LOG_ASSERT     LOG_FATAL
-#define WFD_APP_LOG_EXCEPTION  LOG_FATAL
+#define WFD_APP_LOG_LOW        LOG_VERBOSE
+#define WFD_APP_LOG_HIGH       LOG_INFO
+#define WFD_APP_LOG_ERROR      LOG_ERROR
+#define WFD_APP_LOG_WARN       LOG_WARN
+#define WFD_APP_LOG_ASSERT     LOG_FATAL
+#define WFD_APP_LOG_EXCEPTION  LOG_FATAL
 #define WFD_MAX_SIZE            128
 #define WFD_MAC_ADDRESS_SIZE    18
 
-char * wfd_app_trim_path(const char* filewithpath);
+char *wfd_app_trim_path(const char *filewithpath);
 int wfd_app_gettid();
 
 #define WFD_APP_LOG(log_level, format, args...) \
-       LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),##args)
-#define __WFD_APP_FUNC_ENTER__ LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
-#define __WFD_APP_FUNC_EXIT__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
+       LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), ##args)
+#define __WFD_APP_FUNC_ENTER__ LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
+#define __WFD_APP_FUNC_EXIT__  LOG(LOG_VERBOSE,  WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
 
 #else /** _DLOG_UTIL */
 
-#define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(), ##args)
-#define __WFD_APP_FUNC_ENTER__ printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
-#define __WFD_APP_FUNC_EXIT__  printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__)
+#define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), ##args)
+#define __WFD_APP_FUNC_ENTER__ printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
+#define __WFD_APP_FUNC_EXIT__  printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__, wfd_app_gettid(), __func__)
 
 #endif /** _USE_DLOG_UTIL */
 
 
 
 #define assertm_if(expr, fmt, arg...) do { \
-   if(expr) { \
+       if (expr) { \
          WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
                 exit(1); \
-   } \
-} while (0)                    // retvm if
-
+       } \
+} while (0)
 
 
 #endif /* __WFD_APP_UTIL_H__ */
index 02c544d..61b7b31 100755 (executable)
 
 #define PACKAGE "org.tizen.wifi-direct-ugapp"
 #define LOCALEDIR "/usr/apps/org.tizen.wifi-direct-ugapp"
-
-typedef struct
-{
-    Evas_Object *win;
-    struct ui_gadget *wifi_direct_ug;
+#define DESKTOP_ICON "/usr/apps/org.tizen.setting/res/icons/A01-1_icon_Wi-Fi_direct.png"
+
+typedef struct {
+       Evas_Object *win;
+       Evas_Object *bg;
+       Evas_Object *conform;
+       Evas_Object *top_layout;
+       Evas_Object *icon;
+       ui_gadget_h wifi_direct_ug;
 } wfd_appdata_t;
 
 #endif  /* __WFD_UG_APP_MAIN_H__ */
index 8ecdaf2..d9d9262 100755 (executable)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.wifi-direct-ugapp" version="0.6.2" install-location="internal-only">
        <label>WifiDirectUgapp</label>
-       <author email="sungsik.jang@samsung.com" href="www.samsung.com">Sungsik Jang</author>
-       <author email="dwmax.lee@samsung.com" href="www.samsung.com">Dongwook Lee</author>
+       <author email="lastkgb.kim@samsung.com" href="www.samsung.com">Sungsik Jang</author>
+       <author email="jinmin@samsung.com" href="www.samsung.com">Dongwook Lee</author>
        <description>WiFi Direct UG Application</description>
        <ui-application appid="org.tizen.wifi-direct-ugapp" exec="/usr/apps/org.tizen.wifi-direct-ugapp/bin/wifi-direct-ugapp" nodisplay="true" multiple="false" type="capp" taskmanage="false">
                <label>WifiDirectUgapp</label>
index b0d35d6..14f326a 100755 (executable)
@@ -37,202 +37,328 @@ static struct ug_cbs wifi_direct_cbs;
 
 wfd_appdata_t *wfd_get_appdata()
 {
-    return g_wfd_ad;
+       return g_wfd_ad;
 }
 
-void
-_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv)
+void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
 {
        __WFD_APP_FUNC_ENTER__;
 
-    Evas_Object *base = NULL;
-    base = ug_get_layout(ug);
+       Evas_Object *base = NULL;
+       base = ug_get_layout(ug);
 
-    if (!base)
-    {
-       WFD_APP_LOG(WFD_APP_LOG_LOW,"ug_get_layout failed!");
-        ug_destroy(ug);
-        return;
-    }
+       if (!base) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "ug_get_layout failed!");
+               ug_destroy(ug);
+               return;
+       }
 
-    switch (mode)
-    {
-        case UG_MODE_FULLVIEW:
-            evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-            elm_win_resize_object_add(ug_get_window(), base);
-            evas_object_show(base);
-            break;
-        default:
-          break;
-    }
+       switch (mode) {
+       case UG_MODE_FULLVIEW:
+               evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(ug_get_window(), base);
+               evas_object_show(base);
+               break;
+       default:
+               break;
+       }
 }
 
-void
-_ug_destroy_cb(struct ui_gadget *ug, void *priv)
+void _ug_destroy_cb(ui_gadget_h ug, void *priv)
 {
        __WFD_APP_FUNC_ENTER__;
 
-    // TODO: free all memory allocation
+       // TODO: free all memory allocation
 
-    ug_destroy(ug);
-    elm_exit();
+       ug_destroy(ug);
+       elm_exit();
 }
 
-void ug_result_cb(struct ui_gadget *ug, bundle * result, void *priv)
+void ug_result_cb(ui_gadget_h ug, service_h service, void *priv)
 {
        __WFD_APP_FUNC_ENTER__;
 
-    // TODO: free all memory allocation
+       // TODO: free all memory allocation
 
 }
 
-static int load_wifi_direct_ug(struct ui_gadget *parent_ug, void *data)
+static int load_wifi_direct_ug(ui_gadget_h parent_ug, void *data)
 {
        __WFD_APP_FUNC_ENTER__;
-    wfd_appdata_t *ugd = (wfd_appdata_t *)data;
-    bundle *param = NULL;
+       wfd_appdata_t *ugd = (wfd_appdata_t *)data;
+       service_h handle = NULL;
 
-    UG_INIT_EFL(ugd->win, UG_OPT_INDICATOR_ENABLE);
+       UG_INIT_EFL(ugd->win, UG_OPT_INDICATOR_ENABLE);
 
-    memset(&wifi_direct_cbs, 0, sizeof(struct ug_cbs));
+       memset(&wifi_direct_cbs, 0, sizeof(struct ug_cbs));
 
-    wifi_direct_cbs.layout_cb = _ug_layout_cb;
-    wifi_direct_cbs.result_cb = ug_result_cb;
-    wifi_direct_cbs.destroy_cb = _ug_destroy_cb;
-    wifi_direct_cbs.priv = ugd;
+       wifi_direct_cbs.layout_cb = _ug_layout_cb;
+       wifi_direct_cbs.result_cb = ug_result_cb;
+       wifi_direct_cbs.destroy_cb = _ug_destroy_cb;
+       wifi_direct_cbs.priv = ugd;
 
-    ugd->wifi_direct_ug = ug_create(parent_ug, "setting-wifidirect-efl", UG_MODE_FULLVIEW, param, &wifi_direct_cbs);
-    if (ugd->wifi_direct_ug)
-        return TRUE;
-    else
-        return FALSE;
+       ugd->wifi_direct_ug = ug_create(parent_ug, "setting-wifidirect-efl", UG_MODE_FULLVIEW, handle, &wifi_direct_cbs);
+       if (ugd->wifi_direct_ug) {
+               return TRUE;
+       } else {
+               return FALSE;
+       }
 }
 
 
 static void _win_del(void *data, Evas_Object * obj, void *event)
 {
-    elm_exit();
+       elm_exit();
 }
 
 static Evas_Object *_create_win(Evas_Object * parent, const char *name)
 {
-    Evas_Object *eo;
-    int w, h;
+       Evas_Object *eo;
+       int w, h;
+
+       eo = elm_win_add(parent, name, ELM_WIN_BASIC);
+       if (eo) {
+               elm_win_title_set(eo, name);
+               elm_win_alpha_set(eo, EINA_TRUE);
+               elm_win_conformant_set(eo, EINA_TRUE);
+               evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
+               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+               evas_object_resize(eo, w, h);
+               evas_object_show(eo);
+       }
+
+       return eo;
+}
+
+static Evas_Object* _set_win_icon(wfd_appdata_t *ad)
+{
+       __WFD_APP_FUNC_ENTER__;
+
+       Evas_Object *icon = evas_object_image_add(evas_object_evas_get(ad->win));
+       evas_object_image_file_set(icon, DESKTOP_ICON, NULL);
+       elm_win_icon_object_set(ad->win, icon);
+
+       __WFD_APP_FUNC_EXIT__;
+       return icon;
+}
+
+static Evas_Object *_create_bg(Evas_Object *parent)
+{
+       __WFD_APP_FUNC_ENTER__;
 
-    eo = elm_win_add(parent, name, ELM_WIN_BASIC);
-    if (eo)
-    {
-        elm_win_title_set(eo, name);
-        elm_win_borderless_set(eo, EINA_TRUE);
-        elm_win_alpha_set(eo, EINA_TRUE);
-        evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
-        ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
-        evas_object_resize(eo, w, h);
-        evas_object_show(eo);
-        //evas_object_raise(eo);
-    }
+       if (NULL == parent) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
+               return NULL;
+       }
 
-    return eo;
+       Evas_Object *bg = elm_bg_add(parent);
+       if (NULL == bg) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Create background failed\n");
+               return NULL;
+       }
+
+       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(parent, bg);
+       evas_object_show(bg);
+
+       __WFD_APP_FUNC_EXIT__;
+       return bg;
 }
 
+static Evas_Object *_create_layout_main(Evas_Object *parent)
+{
+       __WFD_APP_FUNC_ENTER__;
+
+       if (NULL == parent) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
+               return NULL;
+       }
+
+       Evas_Object *layout = elm_layout_add(parent);
+       if (NULL == layout) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Create layout failed\n");
+               return NULL;
+       }
+
+       const char *profile = elm_config_profile_get();
+       if (!strcmp(profile, "mobile")) {
+               elm_layout_theme_set(layout, "layout", "application", "default");
+       } else if (!strcmp(profile, "desktop")) {
+               elm_layout_theme_set(layout, "layout", "application", "noindicator");
+       }
+
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_content_set(parent, layout);
+       evas_object_show(layout);
+
+       __WFD_APP_FUNC_EXIT__;
+       return layout;
+}
+
+static void _win_profile_changed_cb(void *data, Evas_Object * obj, void *event_info)
+{
+       __WFD_APP_FUNC_ENTER__;
+
+       if (data == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
+               return -1;
+       }
+
+       wfd_appdata_t *ad = (wfd_appdata_t *)data;
+       const char *profile = elm_config_profile_get();
+
+       if (!strcmp(profile, "desktop")) {  /* desktop mode */
+               /* hide layout's indicator area */
+               elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_HIDE);
+
+               /* set window icon */
+               if (!ad->icon)  {
+                       ad->icon = _set_win_icon(ad);
+               }
+       }
+       else {  /* mobile mode */
+               /* show layout's indicator area */
+               elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       }
+
+       __WFD_APP_FUNC_EXIT__;
+}
 
 static int _app_create(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_ENTER__;
+       wfd_appdata_t *ad = wfd_get_appdata();
 
-    wfd_appdata_t *ad = wfd_get_appdata();
+       if (data == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
+               return -1;
+       }
+
+       bindtextdomain(PACKAGE, LOCALEDIR);
+
+       ad->win = _create_win(NULL, PACKAGE);
+       evas_object_smart_callback_add(ad->win, "profile,changed", _win_profile_changed_cb, ad);
+
+       /*Add conformat for indicator */
+       ad->bg = _create_bg(ad->win);
+       if (ad->bg == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to create background");
+               return -1;
+       }
 
-    if (data == NULL)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n");
-        return -1;
-    }
+       ad->conform = elm_conformant_add(ad->win);
+       if (ad->conform == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to create elm conformant");
+               return -1;
+       }
 
-    bindtextdomain(PACKAGE, LOCALEDIR);
+       elm_win_resize_object_add(ad->win, ad->conform);
+       evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_show(ad->conform);
 
-    ad->win = _create_win(NULL, PACKAGE);
-    elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+       ad->top_layout = _create_layout_main(ad->conform);
+       if (ad->top_layout == NULL) {
+               WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to create top layout");
+               return -1;
+       }
 
-    int r;
+       elm_object_content_set(ad->conform, ad->top_layout);
 
-    if (!ecore_x_display_get())
-        return -1;
+       int r;
 
-    r = appcore_set_i18n(PACKAGE, NULL);
-    if (r != 0)
-    {
-        WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
-        return -1;
-    }
+       if (!ecore_x_display_get()) {
+               return -1;
+       }
 
-    __WFD_APP_FUNC_EXIT__;
+       r = appcore_set_i18n(PACKAGE, NULL);
+       if (r != 0) {
+               WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n");
+               return -1;
+       }
 
-    return 0;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 static int _app_terminate(void *data)
 {
        __WFD_APP_FUNC_ENTER__;
 
-       if (data == NULL)
-       {
+       if (data == NULL) {
                WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n");
                return -1;
        }
 
        wfd_appdata_t *ad = (wfd_appdata_t *) data;
 
-       if (ad->win)
-       {
+       if (ad->win) {
                evas_object_del(ad->win);
                ad->win = NULL;
        }
 
-       __WFD_APP_FUNC_EXIT__;
+       if (ad->bg) {
+               evas_object_del(ad->bg);
+               ad->bg = NULL;
+       }
+
+       if (ad->conform) {
+               evas_object_del(ad->conform);
+               ad->conform = NULL;
+       }
+
+       if (ad->top_layout) {
+               evas_object_del(ad->top_layout);
+               ad->top_layout = NULL;
+       }
 
+       if (ad->icon) {
+               evas_object_del(ad->icon);
+               ad->icon = NULL;
+       }
+
+       __WFD_APP_FUNC_EXIT__;
        return 0;
 }
 
 static int _app_pause(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 static int _app_resume(void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_ENTER__;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
-static int _app_reset(bundle * b, void *data)
+static int _app_reset(bundle *b, void *data)
 {
-    __WFD_APP_FUNC_ENTER__;
-
-    wfd_appdata_t *ad = wfd_get_appdata();
+       __WFD_APP_FUNC_ENTER__;
 
-    load_wifi_direct_ug(NULL, ad);
+       wfd_appdata_t *ad = wfd_get_appdata();
+       load_wifi_direct_ug(NULL, ad);
 
-    __WFD_APP_FUNC_EXIT__;
-    return 0;
+       __WFD_APP_FUNC_EXIT__;
+       return 0;
 }
 
 int main(int argc, char *argv[])
 {
-    wfd_appdata_t ad;
-    struct appcore_ops ops = {
-        .create = _app_create,
-        .terminate = _app_terminate,
-        .pause = _app_pause,
-        .resume = _app_resume,
-        .reset = _app_reset,
-    };
-
-    memset(&ad, 0x0, sizeof(wfd_appdata_t));
-    ops.data = &ad;
-    g_wfd_ad = &ad;
-
-    return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+       wfd_appdata_t ad;
+       struct appcore_ops ops = {
+               .create = _app_create,
+               .terminate = _app_terminate,
+               .pause = _app_pause,
+               .resume = _app_resume,
+               .reset = _app_reset,
+       };
+
+       memset(&ad, 0x0, sizeof(wfd_appdata_t));
+       ops.data = &ad;
+       g_wfd_ad = &ad;
+
+       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 }
index 94fb896..7cf7310 100644 (file)
 char *wfd_app_trim_path(const char *filewithpath)
 {
 #if 0
-    char *filename = NULL;
-    if ((filename = strrchr(filewithpath, '/')) == NULL)
-        return (char *) filewithpath;
-    else
-        return (filename + 1);
+       char *filename = NULL;
+       if ((filename = strrchr(filewithpath, '/')) == NULL)
+           return (char *) filewithpath;
+       else
+           return (filename + 1);
 #else
-    static char *filename[100];
-    char *strptr = NULL;
-    int start = 0;
-    const char *space = "                                        ";
-    int len = strlen(filewithpath);
+       static char *filename[100];
+       char *strptr = NULL;
+       int start = 0;
+       const char *space = "                                        ";
+       int len = strlen(filewithpath);
 
-    if (len > 20)
-    {
-        strptr = (char *) filewithpath + (len - 20);
-        start = 0;
-    }
-    else if (len < 20)
-    {
-        strptr = (char *) filewithpath;
-        start = 20 - len;
-    }
-    strncpy((char *) filename, space, strlen(space));
-    strncpy((char *) filename + start, strptr, 50);
+       if (len > 20) {
+               strptr = (char *) filewithpath + (len - 20);
+               start = 0;
+       } else if (len < 20) {
+               strptr = (char *) filewithpath;
+               start = 20 - len;
+       }
 
-    return (char *) filename;
+       strncpy((char *) filename, space, strlen(space));
+       strncpy((char *) filename + start, strptr, 50);
+
+       return (char *) filename;
 #endif
 }
 
@@ -67,10 +65,9 @@ char *wfd_app_trim_path(const char *filewithpath)
 int wfd_app_gettid()
 {
 #ifdef __NR_gettid
-    return syscall(__NR_gettid);
+       return syscall(__NR_gettid);
 #else
-    fprintf(stderr,
-            "__NR_gettid is not defined, please include linux/unistd.h ");
-    return -1;
+       fprintf(stderr, "__NR_gettid is not defined, please include linux/unistd.h ");
+       return -1;
 #endif
 }