Display wireless password popup again if failed 49/105249/1
authorJiwan Kim <ji-wan.kim@samsung.com>
Fri, 16 Dec 2016 06:03:07 +0000 (15:03 +0900)
committerJiwan Kim <ji-wan.kim@samsung.com>
Fri, 16 Dec 2016 06:03:07 +0000 (15:03 +0900)
 - Show wireless password popup with 'Wrong password' message
   when it failed with invalid password.

Change-Id: If87b932bf70aced5c69166385743581deb0836ff
Signed-off-by: Jiwan Kim <ji-wan.kim@samsung.com>
include/common/datamgr.h
include/define.h
include/layout/network.h
src/data/system/data_wireless.c
src/layout/layout_network.c

index 67ae396..e5eba98 100644 (file)
@@ -25,6 +25,7 @@ struct datamgr;
 enum event_type {
        EVENT_DATA_INIT_DONE_WIRELESS,
        EVENT_DATA_INIT_FAIL_WIRELESS,
+       EVENT_DATA_INVALID_PWD_WIRELESS,
        EVENT_DATA_UPDATE_DONE,
        EVENT_DATA_SELECT_DONE,
        EVENT_DATA_SELECT_FAIL,
index 8aa7138..ebbe10b 100644 (file)
 
 #define PART_WIFI_POPUP_BTN_CANCEL "part.popup.bottom.cancel"
 #define PART_WIFI_POPUP_BTN_OK "part.popup.bottom.ok"
+#define PART_WIFI_POPUP_ERROR_MSG "part.error_msg"
 
 #define PART_VIEW_BOTTOM_BTN1 "part.view.bottom.btn1"
 #define PART_VIEW_BOTTOM_BTN2 "part.view.bottom.btn2"
index 0358c5d..8d2c914 100644 (file)
@@ -64,6 +64,7 @@
 #define STR_WIRED_FAILED "Wired network connection failed.<br>Press retry button or plug a network cable into the back of your TV."
 #define STR_OK "OK"
 #define STR_CANCEL "Cancel"
+#define STR_WIRELESS_WRONG_PWD "Wrong password"
 
 /* Count */
 #define COUNT_NETWORK_TYPE 3
index 1652018..0975fef 100644 (file)
@@ -435,9 +435,15 @@ static void _wifi_connected_cb(wifi_error_e err, void *data)
        priv = data;
 
        if (err != WIFI_ERROR_NONE) {
-               _ERR("Connect ap failed. err [%x]", err);
-               if (priv->event_cb)
-                       priv->event_cb(EVENT_DATA_SELECT_FAIL, priv->cb_data);
+               _ERR("Connect ap failed. err [%s]", wifi_error_to_string(err));
+               if (err == WIFI_ERROR_INVALID_KEY) {
+                       _DBG("Invalid password");
+                       if (priv->event_cb)
+                               priv->event_cb(EVENT_DATA_INVALID_PWD_WIRELESS, priv->cb_data);
+               } else {
+                       if (priv->event_cb)
+                               priv->event_cb(EVENT_DATA_SELECT_FAIL, priv->cb_data);
+               }
 
                return;
        }
@@ -461,7 +467,7 @@ static void _wifi_connect_new_ap(struct _priv *priv)
 
        r = wifi_connect(ap_info->ap, _wifi_connected_cb, priv);
        if (r != WIFI_ERROR_NONE)
-               _ERR("Wifi connect failed.");
+               _ERR("Wifi connect failed. [%s]", wifi_error_to_string(r));
 }
 
 static void _wifi_prev_ap_disconnected(wifi_error_e err, void *data)
index b83c2ac..f9613d0 100644 (file)
@@ -77,6 +77,7 @@ struct _priv {
        struct datamgr *wirelessmgr;
        Elm_Object_Item *selected_wireless_item;
        Elm_Object_Item *focused_wireless_item;
+       Elm_Object_Item *connecting_wireless_item;
        Evas_Object *passcode_popup;
        Evas_Object *passcode_entry;
        enum network_type cur_type;
@@ -91,6 +92,8 @@ static void _remove_wifi_passcode_popup(struct _priv *priv);
 static void _retry_wired_network(struct _priv *priv);
 static void _retry_wireless_network(struct _priv *priv);
 static void _wireless_selected_cb(Elm_Object_Item *it, void *data);
+static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name,
+               bool isReconnect);
 
 static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
                Evas_Event_Mouse_Move *ev)
@@ -455,7 +458,7 @@ static void _grid_remove_connecting_state(Elm_Object_Item *it, void *data)
                return;
        }
 
-       if (it != priv->selected_wireless_item)
+       if (it != priv->connecting_wireless_item)
                elm_object_item_signal_emit(it, SIG_LOADING_STOP, SRC_ELM);
 }
 
@@ -643,7 +646,7 @@ static void _data_event_cb(enum event_type type, void *data)
                break;
 
        case EVENT_DATA_SELECT_DONE:
-               elm_object_item_signal_emit(priv->selected_wireless_item,
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
                                SIG_LOADING_STOP, SRC_ELM);
 
                if (!listmgr_update_grid(priv->listmgr, LIST_WIRELESS))
@@ -653,9 +656,11 @@ static void _data_event_cb(enum event_type type, void *data)
 
        case EVENT_DATA_SELECT_FAIL:
                _DBG("Failed to connect");
-               elm_object_item_signal_emit(priv->selected_wireless_item,
+               listmgr_foreach_list(priv->listmgr, LIST_WIRELESS,
+                               _grid_remove_connecting_state, priv);
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
                                SIG_LOADING_STOP, SRC_ELM);
-               elm_object_item_signal_emit(priv->selected_wireless_item,
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
                                SIG_CONNECTION_FAIL, SRC_ELM);
 
                /* Update connection state for all items.
@@ -665,6 +670,35 @@ static void _data_event_cb(enum event_type type, void *data)
                        _ERR("Listmgr update list failed.");
                break;
 
+       case EVENT_DATA_INVALID_PWD_WIRELESS: {
+               char *wifi_name;
+               struct wifi_ap_info *ap_info;
+               ap_info = elm_object_item_data_get(priv->connecting_wireless_item);
+               if (!ap_info) {
+                       _ERR("Get data failed.");
+                       break;
+               }
+               wifi_name = ap_info->essid;
+
+               _DBG("Invalid password");
+               /* Remove connection state from other items */
+               listmgr_foreach_list(priv->listmgr, LIST_WIRELESS,
+                               _grid_remove_connecting_state, priv);
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
+                               SIG_LOADING_STOP, SRC_ELM);
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
+                               SIG_CONNECTION_FAIL, SRC_ELM);
+
+               /* Update connection state for all items.
+                * When profile is switched to ethernet,
+                * 'Connected' check icon still remains.. */
+               if (!listmgr_update_grid(priv->listmgr, LIST_WIRELESS))
+                       _ERR("Listmgr update list failed.");
+
+               _draw_wifi_passcode_popup(priv, wifi_name, true);
+               break;
+       }
+
        case EVENT_DATA_UPDATE_WIRED:
                SETTING_TRACE("Updated wired network");
                /* Wired network setting is changed */
@@ -693,13 +727,14 @@ static void _connect_wifi_with_passcode(struct _priv *priv)
                return;
        }
 
-       if (!datamgr_select(priv->wirelessmgr, priv->selected_wireless_item,
+       priv->connecting_wireless_item = priv->selected_wireless_item;
+       if (!datamgr_select(priv->wirelessmgr, priv->connecting_wireless_item,
                        passcode)) {
                _ERR("Unavailable status for selecting wifi.");
                return;
        }
 
-       elm_object_item_signal_emit(priv->selected_wireless_item,
+       elm_object_item_signal_emit(priv->connecting_wireless_item,
                        SIG_LOADING_START, SRC_ELM);
 
        /* Remove connection state from other items */
@@ -727,6 +762,10 @@ static void _popup_clicked_cb(int id, void *data, Evas_Object *obj)
 
        case EO_BTN_OK:
                _connect_wifi_with_passcode(priv);
+
+               /* Update status for all items */
+               if (!listmgr_update_grid(priv->listmgr, LIST_WIRELESS))
+                       _ERR("Listmgr update list failed.");
                break;
 
        default:
@@ -902,7 +941,8 @@ static void _remove_wifi_passcode_popup(struct _priv *priv)
        priv->passcode_popup = NULL;
 }
 
-static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name)
+static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name,
+               bool isReconnect)
 {
        Evas_Object *popup, *ly, *entry, *btn1, *btn2;
        Evas_Object *scroller;
@@ -980,6 +1020,9 @@ static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name)
        /* Set focus into entry */
        elm_object_focus_set(priv->popup_btn1, EINA_TRUE);
 
+       if (isReconnect)
+               elm_object_part_text_set(ly, PART_WIFI_POPUP_ERROR_MSG, STR_WIRELESS_WRONG_PWD);
+
        evas_object_show(popup);
 
        return true;
@@ -1011,13 +1054,13 @@ static void _wireless_selected_cb(Elm_Object_Item *it, void *data)
        }
 
        required = settings_wireless_passharase_required(ap_info->ap);
-       _DBG("Passphrase required : %s", (required) ? "True" : "False");
+       _DBG("[%s] required : %s", ap_info->essid, (required) ? "True" : "False");
        if (required) {
                wifi_name = ap_info->essid;
                if (!wifi_name)
                        return;
 
-               if (!_draw_wifi_passcode_popup(priv, wifi_name)) {
+               if (!_draw_wifi_passcode_popup(priv, wifi_name, false)) {
                        _ERR("Draw passcode popup failed.");
                        return;
                }
@@ -1027,7 +1070,8 @@ static void _wireless_selected_cb(Elm_Object_Item *it, void *data)
                        return;
                }
 
-               elm_object_item_signal_emit(priv->selected_wireless_item,
+               priv->connecting_wireless_item = priv->selected_wireless_item;
+               elm_object_item_signal_emit(priv->connecting_wireless_item,
                                SIG_LOADING_START, SRC_ELM);
 
                /* Remove connection state from other items */