Update length handling logic of wireless password 81/102081/1
authorJiwan Kim <ji-wan.kim@samsung.com>
Mon, 5 Dec 2016 02:15:02 +0000 (11:15 +0900)
committerJiwan Kim <ji-wan.kim@samsung.com>
Mon, 5 Dec 2016 02:15:02 +0000 (11:15 +0900)
 - Fix for TSAM-10853, TSAM-10855
 - Change to use commit event for password length check
 - Add logic to handle 'delete all' button

Change-Id: I7a0806fba007ebb093cf517e92bb48015a7d2238
Signed-off-by: Jiwan Kim <ji-wan.kim@samsung.com>
src/layout/layout_network.c

index c1f857f..7de3d99 100644 (file)
@@ -811,15 +811,39 @@ static void _popup_entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void
                ) {
                elm_object_focus_set(priv->popup_btn1, EINA_TRUE);
        }
+}
+
+static void _imf_commit_event_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
+{
+       struct _priv *priv = data;
+       const char *buf = NULL;
+       int len = 0;
+
+       if (NULL == priv)
+               return;
+
+       buf = elm_entry_entry_get(priv->passcode_entry);
+       if (NULL == buf)
+               return;
 
-       str = elm_entry_entry_get(priv->passcode_entry);
-       if (strlen(str) >= MIN_WIRELESS_LEN) {
+       len = strlen(buf);
+       if (len >= MIN_WIRELESS_LEN) {
                elm_object_disabled_set(priv->popup_btn2, EINA_FALSE);
        } else {
                elm_object_disabled_set(priv->popup_btn2, EINA_TRUE);
        }
 }
 
+static void _imf_delete_event_cb(void *data, Ecore_IMF_Context *ctx, void *event_info)
+{
+       struct _priv *priv = data;
+
+       if (NULL == priv)
+               return;
+
+       elm_object_disabled_set(priv->popup_btn2, EINA_TRUE);
+}
+
 static void _check_passcode_input_cb(void *data, Evas_Object *entry, char **text)
 {
        struct _priv *priv = data;
@@ -877,6 +901,7 @@ static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name)
 {
        Evas_Object *popup, *ly, *entry, *btn1, *btn2;
        Evas_Object *scroller;
+       Ecore_IMF_Context *ctx;
 
        if (priv->passcode_popup) {
                _ERR("Already popup exists");
@@ -939,6 +964,13 @@ static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name)
        evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
                        _popup_entry_key_down_cb, priv);
 
+       /* Handle special button events */
+       ctx = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
+       ecore_imf_context_event_callback_add(ctx,
+               ECORE_IMF_CALLBACK_COMMIT, _imf_commit_event_cb, priv);
+       ecore_imf_context_event_callback_add(ctx,
+               ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _imf_delete_event_cb, priv);
+
        elm_object_disabled_set(priv->popup_btn2, EINA_TRUE);
        /* Set focus into entry */
        elm_object_focus_set(priv->popup_btn1, EINA_TRUE);