Fix password popup to show genlist
[apps/native/ug-wifi-efl.git] / sources / libraries / Common / common_eap_connect.c
1 /*
2  * Wi-Fi
3  *
4  * Copyright 2012 Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.tizenopensource.org/license
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <openssl/x509.h>
21 #include <openssl/pem.h>
22 #include <cert-service.h>
23 #include <cert-svc/cpkcs12.h>
24 #include <cert-svc/cprimitives.h>
25 #include <ui-gadget.h>
26 #include <efl_assist.h>
27 #include <vconf-keys.h>
28 #include <glib/gstdio.h>
29 #include <efl_extension.h>
30
31 #include "common.h"
32 #include "ug_wifi.h"
33 #include "common_eap_connect.h"
34 #include "i18nmanager.h"
35 #include "common_utils.h"
36 #include "common_ip_info.h"
37
38 #define GENLIST_ITEM_HEIGHT                             96
39
40 #define EAP_TLS_PATH                    "/tmp/"
41 #define EAP_TLS_CA_CERT_PATH            "ca_cert.pem"
42 #define EAP_TLS_USER_CERT_PATH          "user_cert.pem"
43 #define EAP_TLS_PRIVATEKEY_PATH         "privatekey.pem"
44
45 #define EAP_TYPE_UNKNOWN                "UNKNOWN"
46 #define EAP_TYPE_PEAP                   "PEAP"
47 #define EAP_TYPE_TLS                            "TLS"
48 #define EAP_TYPE_TTLS                   "TTLS"
49 #define EAP_TYPE_SIM                            "SIM"
50 #define EAP_TYPE_AKA                            "AKA"
51
52 #define EAP_AUTH_TYPE_PAP                       "PAP"
53 #define EAP_AUTH_TYPE_MSCHAP                            "MSCHAP"
54 #define EAP_AUTH_TYPE_MSCHAPV2                  "MSCHAPV2"
55 #define EAP_AUTH_TYPE_GTC                               "GTC"
56 #define EAP_AUTH_TYPE_MD5                               "MD5"
57 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE    "db/telephony/dualsim/default_data_service"
58
59 typedef enum {
60         EAP_SEC_TYPE_UNKNOWN  = 0,
61         EAP_SEC_TYPE_PEAP,
62         EAP_SEC_TYPE_TLS,
63         EAP_SEC_TYPE_TTLS,
64         EAP_SEC_TYPE_SIM,
65         EAP_SEC_TYPE_AKA,
66         EAP_SEC_TYPE_NULL
67 } eap_type_t;
68
69 typedef enum {
70         EAP_SEC_AUTH_NONE  = 0,
71         EAP_SEC_AUTH_PAP,
72         EAP_SEC_AUTH_MSCHAP,
73         EAP_SEC_AUTH_MSCHAPV2,
74         EAP_SEC_AUTH_GTC,
75         EAP_SEC_AUTH_MD5,
76         EAP_SEC_AUTH_NULL
77 } eap_auth_t;
78
79 typedef enum {
80         EAP_TYPE_BTN = 0,
81         EAP_AUTH_BTN,
82         EAP_CERT_BTN,
83 } eap_btn_t;
84
85 typedef struct {
86         char *name;
87         Elm_Genlist_Item_Type flags;
88 } _Expand_List_t;
89
90 typedef struct {
91         int btn_click[3];
92         Evas_Object *btn_obj[3];
93 } _Btn_click_t;
94
95 struct eap_info_list {
96         wifi_ap_h ap;
97         eap_type_t eap_type;
98         Elm_Object_Item *eap_method_item;
99         Elm_Object_Item *eap_auth_item;
100         Elm_Object_Item *user_cert_item;
101         Elm_Object_Item *id_item;
102         Elm_Object_Item *pswd_item;
103 };
104
105 static const _Expand_List_t list_eap_type[] = {
106         {"UNKNOWN", ELM_GENLIST_ITEM_NONE},
107         {"PEAP", ELM_GENLIST_ITEM_NONE},
108         {"TLS", ELM_GENLIST_ITEM_NONE},
109         {"TTLS", ELM_GENLIST_ITEM_NONE},
110         {"SIM", ELM_GENLIST_ITEM_NONE},
111         {"AKA", ELM_GENLIST_ITEM_NONE},
112         {NULL, ELM_GENLIST_ITEM_NONE}
113 };
114
115 static const _Expand_List_t list_eap_auth[] = {
116         {"IDS_ST_BODY_NONE", ELM_GENLIST_ITEM_NONE},
117         {"PAP", ELM_GENLIST_ITEM_NONE},
118         {"MSCHAP", ELM_GENLIST_ITEM_NONE},
119         {"MSCHAPV2", ELM_GENLIST_ITEM_NONE},
120         {"GTC", ELM_GENLIST_ITEM_NONE},
121         {NULL, ELM_GENLIST_ITEM_NONE}
122 };
123
124 static unsigned short selected_cert = 0;
125
126 struct common_eap_connect_data {
127         Elm_Object_Item *eap_type_item;
128         Elm_Object_Item *eap_auth_item;
129         Elm_Object_Item *eap_user_cert_item;
130         Elm_Object_Item *eap_id_item;
131         Elm_Object_Item *eap_pw_item;
132         Elm_Object_Item *eap_chkbox_item;
133         Evas_Object *popup;
134         Evas_Object *sub_popup;
135         Evas_Object *info_popup;
136         Evas_Object *genlist;
137         Eina_Bool eap_done_ok;
138         Evas_Object *win;
139         Evas_Object *conf;
140         const char *str_pkg_name;
141         wifi_ap_h ap;
142         char *cert_alias;
143         char *ca_cert_path;
144         char *user_cert_path;
145         char *privatekey_path;
146         GSList *cert_candidates;
147         Evas_Object *confirm;
148         char *ssid;
149
150         int key_status;
151
152         bool is_hidden;
153 };
154
155 static Elm_Genlist_Item_Class g_eap_type_itc;
156 static Elm_Genlist_Item_Class g_eap_auth_itc;
157 static Elm_Genlist_Item_Class g_eap_user_cert_itc;
158 static Elm_Genlist_Item_Class g_eap_entry_itc;
159 static Elm_Genlist_Item_Class g_eap_chkbox_itc;
160 static Evas_Object *g_pwd_entry = NULL;
161 static gboolean keypad_state = FALSE;
162 static _Btn_click_t click;
163
164 static void (*_eap_view_deref_cb)(void) = NULL;
165
166 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type, eap_connect_data_t *eap_data);
167 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data);
168 static void _delete_eap_auth_item(eap_connect_data_t *eap_data);
169 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data);
170 static void _delete_eap_id_item(eap_connect_data_t *eap_data);
171 static void _delete_eap_pw_items(eap_connect_data_t *eap_data);
172 static void _delete_eap_entry_items(eap_connect_data_t *eap_data);
173 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap);
174 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap);
175 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type);
176 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type);
177 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
178 static gboolean __cert_extract_files(const char *cert_alias,eap_connect_data_t *eap_data);
179 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
180                 void *event_info);
181 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
182                 void *event_info);
183
184 static void ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
185                 void *event_info)
186 {
187         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
188
189         if (eap_data->sub_popup != NULL) {
190                 evas_object_del(eap_data->sub_popup);
191                 eap_data->sub_popup = NULL;
192         }
193 }
194
195 static void cert_ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
196                 void *event_info)
197 {
198         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
199
200         if (eap_data->sub_popup != NULL) {
201                 evas_object_del(eap_data->sub_popup);
202                 eap_data->sub_popup = NULL;
203         }
204
205         if (eap_data->cert_candidates != NULL) {
206                 g_slist_free_full(eap_data->cert_candidates, g_free);
207                 eap_data->cert_candidates = NULL;
208         }
209 }
210
211 static void move_dropdown(eap_connect_data_t *eap_data, Evas_Object *obj)
212 {
213         Evas_Coord x, y, w , h;
214
215         evas_object_geometry_get(obj, &x, &y, &w, &h);
216         evas_object_move(eap_data->sub_popup, x + (w / 2), y + h);
217 }
218
219 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
220 {
221         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
222         elm_genlist_item_selected_set(item, FALSE);
223 }
224
225 static void _select_confirm_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
226 {
227         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
228         retm_if(eap_data == NULL);
229
230         if (eap_data->confirm != NULL) {
231                 evas_object_del(eap_data->confirm);
232                 eap_data->confirm = NULL;
233         }
234 }
235
236 static void __gl_eap_type_sub_sel_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
237 {
238         __COMMON_FUNC_ENTER__;
239         retm_if(obj == NULL);
240
241         int val = (int)data;
242         char str[1024];
243         char *txt = NULL;
244
245         g_snprintf(str, 1024, sc(PACKAGE,I18N_TYPE_SIM_method_desc_popup),
246                         (val == 1) ? "SIM2" : "SIM1");
247         txt = evas_textblock_text_utf8_to_markup(NULL, str);
248         elm_object_domain_translatable_text_set(obj, PACKAGE, txt);
249         g_free(txt);
250         __COMMON_FUNC_EXIT__;
251 }
252
253 static void _gl_eap_type_sub_sel(void *data, Evas_Object *obj, void *event_info)
254 {
255         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
256         eap_type_t sel_index = EAP_SEC_TYPE_UNKNOWN;
257         char buf[1024] = {'\0'};
258
259         eap_type_t pre_index = __common_eap_connect_popup_get_eap_type(eap_data->ap);
260         const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
261
262         if (strcmp(label, EAP_TYPE_UNKNOWN) == 0)
263                 sel_index = EAP_SEC_TYPE_UNKNOWN;
264         else if (strcmp(label, EAP_TYPE_PEAP) == 0)
265                 sel_index = EAP_SEC_TYPE_PEAP;
266         else if (strcmp(label, EAP_TYPE_TLS) == 0)
267                 sel_index = EAP_SEC_TYPE_TLS;
268         else if (strcmp(label, EAP_TYPE_TTLS) == 0)
269                 sel_index = EAP_SEC_TYPE_TTLS;
270         else if (strcmp(label, EAP_TYPE_SIM) == 0)
271                 sel_index = EAP_SEC_TYPE_SIM;
272         else if (strcmp(label, EAP_TYPE_AKA) == 0)
273                 sel_index = EAP_SEC_TYPE_AKA;
274
275         DEBUG_LOG(UG_NAME_NORMAL, "previous index = %d; selected index = %d;",
276                         pre_index, sel_index);
277         if ((pre_index != EAP_SEC_TYPE_SIM && sel_index == EAP_SEC_TYPE_SIM) ||
278                         (pre_index != EAP_SEC_TYPE_AKA && sel_index == EAP_SEC_TYPE_AKA)) {
279                 popup_btn_info_t popup_data;
280                 int value = -1;
281                 value = common_util_get_system_registry(
282                                 VCONF_TELEPHONY_DEFAULT_DATA_SERVICE);
283
284                 memset(&popup_data, 0, sizeof(popup_data));
285                 g_snprintf(buf, sizeof(buf),
286                                 sc(PACKAGE, I18N_TYPE_SIM_method_desc_popup),
287                                 (value == 1) ? "SIM2" : "SIM1");
288                 popup_data.title_txt = "IDS_WIFI_BODY_EAP_METHOD";
289                 popup_data.info_txt = evas_textblock_text_utf8_to_markup(NULL, buf);
290                 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
291                 popup_data.btn1_cb = _select_confirm_popup_ok_cb;
292                 popup_data.btn1_data = eap_data;
293
294                 eap_data->confirm = common_utils_show_info_popup(eap_data->win,
295                                 &popup_data);
296                 g_free(popup_data.info_txt);
297                 evas_object_smart_callback_add(eap_data->confirm, "language,changed",
298                                 __gl_eap_type_sub_sel_language_changed_cb, (void *)value);
299
300                 _create_and_update_list_items_based_on_rules(sel_index, data);
301                 wifi_eap_type_e type;
302                 wifi_ap_set_eap_type(eap_data->ap,
303                                 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
304                 wifi_ap_get_eap_type(eap_data->ap, &type);
305                 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
306         }
307
308         if (eap_data->sub_popup != NULL) {
309                 evas_object_del(eap_data->sub_popup);
310                 eap_data->sub_popup = NULL;
311         }
312
313         if (pre_index != sel_index) {
314                 wifi_eap_type_e type;
315                 wifi_ap_set_eap_type(eap_data->ap,
316                                 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
317                 wifi_ap_get_eap_type(eap_data->ap, &type);
318                 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
319                 _create_and_update_list_items_based_on_rules(sel_index, eap_data);
320
321                 if (sel_index == EAP_SEC_TYPE_PEAP) {
322                         /* If previous auth type was PAP or MSCHAP & when PEAP
323                          * EAP method is selected, then set back MSCHAPV2
324                          */
325                         eap_auth_t auth_type;
326
327                         auth_type = __common_eap_connect_popup_get_auth_type(eap_data->ap);
328                         if (auth_type == EAP_SEC_AUTH_PAP ||
329                                         auth_type == EAP_SEC_AUTH_MSCHAP) {
330                                 wifi_ap_set_eap_auth_type(eap_data->ap,
331                                                 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
332
333                                 if(eap_data->eap_auth_item != NULL)
334                                         elm_genlist_item_update(eap_data->eap_auth_item);
335                         }
336                 }
337         } else {
338                 DEBUG_LOG(UG_NAME_NORMAL, "pre_index == sel_index[%d]",
339                                 sel_index);
340         }
341
342         if(eap_data->eap_type_item != NULL)
343                 elm_genlist_item_update(eap_data->eap_type_item);
344 }
345
346 static CertSvcStringList stringList;
347 static CertSvcInstance instance;
348 static CertSvcStoreCertList *certList = NULL;
349
350 static void _gl_eap_user_cert_sel(void *data, Evas_Object *obj,
351                 void *event_info)
352 {
353         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
354         const char *cert_alias = elm_object_item_text_get((Elm_Object_Item *) event_info);
355
356         if (!eap_data)
357                 return;
358
359         if (eap_data->sub_popup != NULL) {
360                 evas_object_del(eap_data->sub_popup);
361                 eap_data->sub_popup = NULL;
362         }
363
364         if (eap_data->ca_cert_path) {
365                 g_unlink(eap_data->ca_cert_path);
366                 eap_data->ca_cert_path = NULL;
367         }
368         if (eap_data->user_cert_path) {
369                 g_unlink(eap_data->user_cert_path);
370                 eap_data->user_cert_path = NULL;
371         }
372         if (eap_data->privatekey_path) {
373                 g_unlink(eap_data->privatekey_path);
374                 eap_data->privatekey_path = NULL;
375         }
376
377         if (strcmp(cert_alias, sc(PACKAGE, I18N_TYPE_None)) == 0) {
378                 if (eap_data->cert_alias != NULL) {
379                         g_free(eap_data->cert_alias);
380                         eap_data->cert_alias = NULL;
381                 }
382         } else if (__cert_extract_files(cert_alias, eap_data)) {
383                 if (eap_data->cert_alias != NULL) {
384                         g_free(eap_data->cert_alias);
385                         eap_data->cert_alias = NULL;
386                 }
387                 eap_data->cert_alias = g_strdup(cert_alias);
388         }
389
390         if(eap_data->eap_user_cert_item != NULL)
391                 elm_genlist_item_update(eap_data->eap_user_cert_item);
392
393         if (eap_data->cert_candidates != NULL) {
394                 g_slist_free_full(eap_data->cert_candidates, g_free);
395                 eap_data->cert_candidates = NULL;
396         }
397 }
398
399 static void _create_eap_cert_list(eap_connect_data_t *eap_data,
400                 Evas_Object *btn)
401 {
402         int list_length = 0;
403         int index = 0;
404         Evas_Object *ctxpopup;
405         Elm_Object_Item *it = NULL;
406
407         if (!eap_data)
408                 return;
409
410         if (eap_data->sub_popup != NULL) {
411                 evas_object_del(eap_data->sub_popup);
412                 eap_data->sub_popup = NULL;
413         }
414
415         ctxpopup = elm_ctxpopup_add(eap_data->win);
416         eap_data->sub_popup = ctxpopup;
417         elm_object_style_set(ctxpopup, "dropdown/list");
418         eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
419                         cert_ctxpopup_dismissed_cb, NULL);
420         evas_object_smart_callback_add(ctxpopup,"dismissed",
421                         cert_ctxpopup_dismissed_cb, eap_data);
422         elm_ctxpopup_direction_priority_set(ctxpopup,
423                         ELM_CTXPOPUP_DIRECTION_DOWN,
424                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
425                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
426                         ELM_CTXPOPUP_DIRECTION_UNKNOWN);
427
428         if (certsvc_instance_new(&instance) == CERTSVC_FAIL) {
429                 INFO_LOG(UG_NAME_ERR, "Failed to create new instance");
430                 return;
431         }
432
433         certsvc_pkcs12_get_certificate_list_from_store(instance, WIFI_STORE, DISABLED, &certList, &list_length);
434
435         if (eap_data->cert_candidates) {
436                 g_slist_free_full(eap_data->cert_candidates, g_free);
437                 eap_data->cert_candidates = NULL;
438         }
439
440         it = elm_ctxpopup_item_append(ctxpopup, "IDS_ST_BODY_NONE", NULL,
441                         _gl_eap_user_cert_sel, eap_data);
442         elm_object_item_domain_text_translatable_set(it,
443                         PACKAGE, EINA_TRUE);
444
445         while(certList != NULL) {
446                 char *char_buffer = NULL;
447                 CertSvcString buffer;
448
449                 buffer.privateHandler = (char *)certList->gname;
450                 buffer.privateLength = strlen(certList->gname);
451                 INFO_LOG(UG_NAME_NORMAL, "gname in processing : %s", certList->gname);
452
453                 char_buffer = g_strndup(buffer.privateHandler, buffer.privateLength);
454                 if (char_buffer == NULL)
455                         goto exit;
456
457                 elm_ctxpopup_item_append(ctxpopup, char_buffer, NULL,
458                                 _gl_eap_user_cert_sel, eap_data);
459                 eap_data->cert_candidates =
460                                 g_slist_prepend(eap_data->cert_candidates, char_buffer);
461
462                 certsvc_string_free(buffer);
463                 certList = certList->next;
464         }
465
466         move_dropdown(eap_data, btn);
467         evas_object_show(ctxpopup);
468
469 exit:
470                 certsvc_instance_free(instance);
471 }
472
473 static void _gl_eap_cert_list_btn_cb(void *data, Evas_Object *obj,
474                 void *event_info)
475 {
476         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
477         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
478
479         if (item)
480                 elm_genlist_item_selected_set(item, EINA_FALSE);
481
482         if (keypad_state == FALSE) {
483                 _create_eap_cert_list(eap_data, obj);
484
485                 click.btn_click[EAP_CERT_BTN] = FALSE;
486                 click.btn_obj[EAP_CERT_BTN] = NULL;
487         } else {
488                 click.btn_click[EAP_CERT_BTN] = TRUE;
489                 click.btn_obj[EAP_CERT_BTN] = obj;
490         }
491 }
492
493 static char *_gl_eap_user_cert_text_get(void *data, Evas_Object *obj, const char *part)
494 {
495         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
496
497         if (!g_strcmp0(part, "elm.text.main")) {
498                 return g_strdup(sc(eap_data->str_pkg_name,
499                                 I18N_TYPE_User_Certificate));
500         }
501
502         return NULL;
503 }
504
505 static Evas_Object *_gl_eap_user_cert_content_get(void *data,
506                 Evas_Object *obj, const char *part)
507 {
508         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
509         Evas_Object *btn = NULL;
510         Evas_Object *ly = NULL;
511         char buf[100];
512
513         if (!strcmp(part, "elm.icon.entry")) {
514                 ly = elm_layout_add(obj);
515                 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
516                                 "eap_dropdown_button");
517                 btn = elm_button_add(obj);
518
519                 if (eap_data->cert_alias == NULL) {
520                         g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
521                                         sc(eap_data->str_pkg_name, I18N_TYPE_None));
522                 } else {
523                         g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
524                                         eap_data->cert_alias);
525                 }
526
527                 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
528                 elm_object_style_set(btn, "dropdown/label");
529                 evas_object_propagate_events_set(btn, EINA_FALSE);
530                 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
531                                 EVAS_HINT_EXPAND);
532                 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
533                                 EVAS_HINT_FILL);
534                 evas_object_smart_callback_add(btn, "clicked",
535                                 _gl_eap_cert_list_btn_cb, eap_data);
536
537                 elm_layout_content_set(ly, "btn", btn);
538                 return ly;
539         }
540         return NULL;
541 }
542
543 static void _gl_eap_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
544 {
545         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
546
547         if (item) {
548                 elm_genlist_item_selected_set(item, EINA_FALSE);
549         }
550 }
551
552 static void _create_eap_type_list(eap_connect_data_t *eap_data,
553                 Evas_Object *btn)
554 {
555         Evas_Object *ctxpopup = NULL;
556         int i = EAP_SEC_TYPE_PEAP;
557         int sim_state = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
558         Elm_Object_Item *it = NULL;
559
560         sim_state = common_utils_get_sim_state();
561
562         if (eap_data->sub_popup != NULL) {
563                 evas_object_del(eap_data->sub_popup);
564         }
565
566         ctxpopup = elm_ctxpopup_add(eap_data->win);
567         eap_data->sub_popup = ctxpopup;
568         elm_object_style_set(ctxpopup, "dropdown/list");
569         eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
570                         eext_ctxpopup_back_cb, NULL);
571         evas_object_smart_callback_add(ctxpopup,"dismissed",
572                         ctxpopup_dismissed_cb, eap_data);
573         elm_ctxpopup_direction_priority_set(ctxpopup,
574                         ELM_CTXPOPUP_DIRECTION_DOWN,
575                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
576                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
577                         ELM_CTXPOPUP_DIRECTION_UNKNOWN);
578
579         /* eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap); */
580         while (list_eap_type[i].name != NULL) {
581                 it = elm_ctxpopup_item_append(ctxpopup, list_eap_type[i].name,
582                                 NULL, _gl_eap_type_sub_sel, eap_data);
583
584                 if ((i == EAP_SEC_TYPE_SIM || i == EAP_SEC_TYPE_AKA) &&
585                                 sim_state != VCONFKEY_TELEPHONY_SIM_INSERTED) {
586                         elm_object_item_disabled_set(it, EINA_TRUE);
587                 }
588
589                 i++;
590         }
591         move_dropdown(eap_data, btn);
592         evas_object_show(ctxpopup);
593 }
594
595 static void _gl_eap_type_btn_cb(void *data, Evas_Object *obj, void *event_info)
596 {
597         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
598         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
599
600         if (item)
601                 elm_genlist_item_selected_set(item, EINA_FALSE);
602
603         if (keypad_state == FALSE) {
604                 _create_eap_type_list(eap_data, obj);
605
606                 click.btn_click[EAP_TYPE_BTN] = FALSE;
607                 click.btn_obj[EAP_TYPE_BTN] = NULL;
608         } else {
609                 click.btn_click[EAP_TYPE_BTN] = TRUE;
610                 click.btn_obj[EAP_TYPE_BTN] = obj;
611         }
612 }
613
614 static char *_gl_eap_type_text_get(void *data, Evas_Object *obj, const char *part)
615 {
616         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
617
618         if (!g_strcmp0(part, "elm.text.main")) {
619                 return g_strdup(sc(eap_data->str_pkg_name, I18N_TYPE_EAP_method));
620         }
621
622         return NULL;
623 }
624
625 static Evas_Object *_gl_eap_type_content_get(void *data,
626                 Evas_Object *obj, const char *part)
627 {
628         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
629         eap_type_t sel_sub_item_id = __common_eap_connect_popup_get_eap_type(eap_data->ap);
630         Evas_Object *btn = NULL;
631         Evas_Object *ly = NULL;
632         char buf[100];
633
634         if (!strcmp(part, "elm.icon.entry")) {
635                 ly = elm_layout_add(obj);
636                 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
637                                 "eap_dropdown_button");
638                 btn = elm_button_add(obj);
639
640                 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
641                                 list_eap_type[sel_sub_item_id].name);
642
643                 elm_object_text_set(btn, buf);
644                 elm_object_style_set(btn, "dropdown/label");
645                 evas_object_propagate_events_set(btn, EINA_FALSE);
646                 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
647                                 EVAS_HINT_EXPAND);
648                 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
649                                 EVAS_HINT_FILL);
650                 evas_object_smart_callback_add(btn, "clicked",
651                                 _gl_eap_type_btn_cb, eap_data);
652
653                 elm_layout_content_set(ly, "btn", btn);
654                 return ly;
655         }
656         return NULL;
657 }
658
659 static void _gl_eap_auth_sub_sel(void *data, Evas_Object *obj, void *event_info)
660 {
661         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
662         eap_auth_t sel_index = EAP_SEC_AUTH_NONE;
663
664         const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
665
666         if (strcmp(label, sc(PACKAGE, I18N_TYPE_None)) == 0)
667                 sel_index = EAP_SEC_AUTH_NONE;
668         else if (strcmp(label, EAP_AUTH_TYPE_PAP) == 0)
669                 sel_index = EAP_SEC_AUTH_PAP;
670         else if (strcmp(label, EAP_AUTH_TYPE_MSCHAP) == 0)
671                 sel_index = EAP_SEC_AUTH_MSCHAP;
672         else if (strcmp(label, EAP_AUTH_TYPE_MSCHAPV2) == 0)
673                 sel_index = EAP_SEC_AUTH_MSCHAPV2;
674         else if (strcmp(label, EAP_AUTH_TYPE_GTC) == 0)
675                 sel_index = EAP_SEC_AUTH_GTC;
676         else if (strcmp(label, EAP_AUTH_TYPE_MD5) == 0)
677                 sel_index = EAP_SEC_AUTH_MD5;
678
679         wifi_ap_set_eap_auth_type(eap_data->ap,
680                 __common_eap_connect_popup_get_wlan_auth_type(sel_index));
681
682         if (eap_data->sub_popup != NULL) {
683                 evas_object_del(eap_data->sub_popup);
684                 eap_data->sub_popup = NULL;
685         }
686
687         if(eap_data->eap_auth_item != NULL)
688                 elm_genlist_item_update(eap_data->eap_auth_item);
689 }
690
691 static void _create_eap_auth_list(eap_connect_data_t *eap_data,
692                 Evas_Object *btn)
693 {
694         Elm_Object_Item *it = NULL;
695         eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
696         Evas_Object *ctxpopup;
697         int i = 0;
698
699         eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
700
701         if (eap_data->sub_popup != NULL) {
702                 evas_object_del(eap_data->sub_popup);
703         }
704
705         ctxpopup = elm_ctxpopup_add(eap_data->win);
706         eap_data->sub_popup = ctxpopup;
707         elm_object_style_set(ctxpopup, "dropdown/list");
708         eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
709         evas_object_smart_callback_add(ctxpopup,"dismissed", ctxpopup_dismissed_cb, eap_data);
710         elm_ctxpopup_direction_priority_set(ctxpopup,
711                         ELM_CTXPOPUP_DIRECTION_DOWN,
712                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
713                         ELM_CTXPOPUP_DIRECTION_UNKNOWN,
714                         ELM_CTXPOPUP_DIRECTION_UNKNOWN);
715
716         while (list_eap_auth[i].name != NULL) {
717                 if ((eap_type != EAP_SEC_TYPE_PEAP) ||
718                                 (eap_type == EAP_SEC_TYPE_PEAP && i != 1 &&
719                                                 i != 2)) {
720                         it = elm_ctxpopup_item_append(ctxpopup, list_eap_auth[i].name,
721                                 NULL, _gl_eap_auth_sub_sel, eap_data);
722                         if (i == 0) {
723                                 elm_object_item_domain_text_translatable_set(it,
724                                                 PACKAGE, EINA_TRUE);
725                         }
726                 }
727                 i++;
728         }
729         move_dropdown(eap_data, btn);
730         evas_object_show(ctxpopup);
731 }
732
733 static void _gl_eap_auth_btn_cb(void *data, Evas_Object *obj, void *event_info)
734 {
735         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
736         eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
737
738         if (item)
739                 elm_genlist_item_selected_set(item, EINA_FALSE);
740
741         if (keypad_state == FALSE) {
742                 _create_eap_auth_list(eap_data, obj);
743
744                 click.btn_click[EAP_AUTH_BTN] = FALSE;
745                 click.btn_obj[EAP_AUTH_BTN] = NULL;
746         } else {
747                 click.btn_click[EAP_AUTH_BTN] = TRUE;
748                 click.btn_obj[EAP_AUTH_BTN] = obj;
749         }
750 }
751
752 static char *_gl_eap_auth_text_get(void *data, Evas_Object *obj, const char *part)
753 {
754         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
755
756         if (!g_strcmp0(part, "elm.text.main")) {
757                 return g_strdup(sc(eap_data->str_pkg_name,
758                                 I18N_TYPE_Phase_2_authentication));
759         }
760
761         return NULL;
762 }
763
764 static Evas_Object *_gl_eap_auth_content_get(void *data,
765                 Evas_Object *obj, const char *part)
766 {
767         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
768         eap_auth_t sel_sub_item_id = __common_eap_connect_popup_get_auth_type(eap_data->ap);
769         Evas_Object *btn = NULL;
770         Evas_Object *ly = NULL;
771         char buf[100];
772
773         if (!strcmp(part, "elm.icon.entry")) {
774                 ly = elm_layout_add(obj);
775                 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
776                                 "eap_dropdown_button");
777                 btn = elm_button_add(obj);
778
779                 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
780                         g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
781                                         sc(PACKAGE, I18N_TYPE_None));
782                 } else {
783                         g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
784                                         list_eap_auth[sel_sub_item_id].name);
785                 }
786
787                 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
788                 elm_object_style_set(btn, "dropdown/label");
789                 evas_object_propagate_events_set(btn, EINA_FALSE);
790                 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
791                                 EVAS_HINT_EXPAND);
792                 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
793                                 EVAS_HINT_FILL);
794                 evas_object_smart_callback_add(btn, "clicked",
795                                 _gl_eap_auth_btn_cb, eap_data);
796
797                 elm_layout_content_set(ly, "btn", btn);
798                 return ly;
799         }
800         return NULL;
801 }
802
803 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
804 {
805         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
806         if (!entry_info) {
807                 return;
808         }
809
810         Evas_Object *entry = NULL;
811         Elm_Object_Item *next_item = NULL;
812         eap_type_t eap_type;
813
814         switch (entry_info->entry_id) {
815         case ENTRY_TYPE_USER_ID:
816                 eap_type = __common_eap_connect_popup_get_eap_type(
817                                 entry_info->ap);
818
819                 if (eap_type == EAP_SEC_TYPE_TLS) {
820                         entry = elm_object_item_part_content_get(entry_info->item,
821                                         "elm.icon.entry");
822                         if (entry) {
823                                 elm_object_focus_set(entry, EINA_FALSE);
824                         }
825                 } else {
826                         next_item = elm_genlist_item_next_get(entry_info->item);
827                         while (next_item) {
828                                 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
829                                         elm_genlist_item_select_mode_get(next_item) !=
830                                                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
831                                         entry = elm_object_item_part_content_get(
832                                                         next_item, "elm.icon.entry");
833                                         if (entry) {
834                                                 elm_object_focus_set(entry, EINA_TRUE);
835                                                 return;
836                                         }
837                                 }
838
839                                 next_item = elm_genlist_item_next_get(next_item);
840                         }
841                 }
842                 break;
843         case ENTRY_TYPE_PASSWORD:
844                 entry = elm_object_item_part_content_get(entry_info->item,
845                                 "elm.icon.entry");
846                 if (entry) {
847                         elm_object_focus_set(entry, EINA_FALSE);
848                 }
849                 break;
850         default:
851                 break;
852         }
853 }
854
855 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
856 {
857         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
858         if (!entry_info) {
859                 return;
860         }
861
862         if (elm_object_focus_get(obj)) {
863                 if (elm_entry_is_empty(obj)) {
864                         elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
865                 } else {
866                         elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
867                 }
868         }
869
870         if (entry_info->entry_txt) {
871                 g_free(entry_info->entry_txt);
872                 entry_info->entry_txt = NULL;
873         }
874
875         char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
876
877         if (entry_text != NULL && entry_text[0] != '\0') {
878                 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
879         }
880
881         g_free(entry_text);
882 }
883
884 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
885 {
886         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
887         if (!entry_info) {
888                 return;
889         }
890
891         if (obj == NULL) {
892                 return;
893         }
894
895         if (elm_object_focus_get(obj)) {
896                 if (elm_entry_is_empty(obj)) {
897                         elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
898                 } else {
899                         elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
900                 }
901         }
902 }
903
904 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
905 {
906         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
907         if (!entry_info) {
908                 return;
909         }
910
911         if (!elm_entry_is_empty(obj)) {
912                 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
913         }
914
915         elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
916 }
917
918 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
919 {
920         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
921         if (!entry_info) {
922                 return;
923         }
924
925         if (entry_info->entry_txt) {
926                 g_free(entry_info->entry_txt);
927                 entry_info->entry_txt = NULL;
928         }
929
930         char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
931         if (entry_text != NULL && entry_text[0] != '\0')
932                 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
933
934         g_free(entry_text);
935
936         elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
937         elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
938 }
939
940 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
941                 void *event_info)
942 {
943         common_utils_send_message_to_net_popup("Password length",
944                         "Lengthy Password", "notification", NULL);
945 }
946
947 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
948 {
949         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
950         if (!entry_info) {
951                 return;
952         }
953
954         Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
955         if (entry) {
956                 elm_object_focus_set(entry, EINA_TRUE);
957                 elm_entry_entry_set(entry, "");
958         }
959 }
960
961 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
962 {
963         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
964         if (!entry_info) {
965                 return NULL;
966         }
967
968         if (!g_strcmp0(part, "elm.text.main")) {
969                 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
970         }
971
972         return NULL;
973 }
974
975 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
976 {
977         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
978         if (!entry_info) {
979                 return NULL;
980         }
981
982         if (g_strcmp0(part, "elm.icon.entry") == 0) {
983                 Evas_Object *entry = NULL;
984                 char *guide_txt = NULL;
985                 char *accepted = NULL;
986                 Eina_Bool hide_entry_txt = EINA_FALSE;
987                 Elm_Input_Panel_Layout panel_type;
988                 int return_key_type;
989                 eap_type_t eap_type;
990
991                 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
992
993                 static Elm_Entry_Filter_Limit_Size limit_filter_data;
994
995                 switch (entry_info->entry_id)
996                 {
997                 case ENTRY_TYPE_USER_ID:
998                         panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
999                         guide_txt = entry_info->guide_txt;
1000
1001                         if (eap_type == EAP_SEC_TYPE_TLS) {
1002                                 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1003                         } else {
1004                                 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1005                         }
1006                         break;
1007                 case ENTRY_TYPE_PASSWORD:
1008                         panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1009                         guide_txt = entry_info->guide_txt;
1010                         hide_entry_txt = EINA_TRUE;
1011                         return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1012                         break;
1013                 default:
1014                         return NULL;
1015                 }
1016
1017                 entry = elm_entry_add(obj);
1018                 retvm_if(NULL == entry, NULL);
1019
1020                 elm_entry_single_line_set(entry, EINA_TRUE);
1021                 elm_entry_scrollable_set(entry, EINA_TRUE);
1022                 elm_entry_password_set(entry, hide_entry_txt);
1023                 elm_entry_prediction_allow_set(entry, EINA_FALSE);
1024                 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
1025
1026                 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
1027                                 PACKAGE, guide_txt);
1028                 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0)) {
1029                         elm_entry_entry_set(entry, entry_info->entry_txt);
1030                 }
1031
1032                 elm_entry_input_panel_layout_set(entry, panel_type);
1033                 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
1034
1035                 limit_filter_data.max_char_count = 200;
1036                 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
1037
1038                 Elm_Entry_Filter_Accept_Set digits_filter_data;
1039                 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1040                 digits_filter_data.accepted = accepted;
1041                 elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digits_filter_data);
1042
1043                 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(entry);
1044                 if (imf_ctxt && entry_info->input_panel_cb) {
1045                         ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1046                                         ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1047                                         entry_info->input_panel_cb,
1048                                         entry_info->input_panel_cb_data);
1049                         DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1050                 }
1051
1052                 evas_object_smart_callback_add(entry, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1053                 evas_object_smart_callback_add(entry, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1054                 evas_object_smart_callback_add(entry, "changed", _gl_eap_entry_changed_cb, entry_info);
1055                 evas_object_smart_callback_add(entry, "focused", _gl_eap_entry_focused_cb, entry_info);
1056                 evas_object_smart_callback_add(entry, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1057                 evas_object_smart_callback_add(entry, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1058
1059                 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD) {
1060                         g_pwd_entry = entry;
1061                 }
1062
1063                 return entry;
1064         } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1065                 Evas_Object *btn = elm_button_add(obj);
1066                 elm_object_style_set(btn, "editfield_clear");
1067                 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1068                 return btn;
1069         }
1070
1071         return NULL;
1072 }
1073
1074 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1075 {
1076         common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1077         if (entry_info == NULL) {
1078                 return;
1079         }
1080
1081         if (entry_info->entry_txt) {
1082                 g_free(entry_info->entry_txt);
1083         }
1084
1085         g_free(entry_info);
1086 }
1087
1088 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1089 {
1090         if (obj == NULL || g_pwd_entry == NULL) {
1091                 return;
1092         }
1093
1094         Eina_Bool state = elm_check_state_get(obj);
1095         if (state) {
1096                 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1097         } else {
1098                 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1099         }
1100 }
1101
1102 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1103                 const char *part)
1104 {
1105         char *str_pkg_name = (char *)data;
1106
1107         if (!g_strcmp0(part, "elm.text.main.left")) {
1108                 char buf[1024];
1109                 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1110                 return strdup(buf);
1111         }
1112         return NULL;
1113
1114 }
1115
1116 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1117                 Evas_Object *obj, const char *part)
1118 {
1119         Evas_Object *check = NULL;
1120
1121         if(!g_strcmp0(part, "elm.icon.right")) {
1122                 check = elm_check_add(obj);
1123                 evas_object_propagate_events_set(check, EINA_FALSE);
1124
1125                 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1126                 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1127                 evas_object_smart_callback_add(check, "changed",
1128                                 _chk_changed_cb, NULL);
1129
1130                 elm_object_focus_allow_set(check, EINA_FALSE);
1131
1132                 return check;
1133         }
1134         return NULL;
1135 }
1136
1137 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1138 {
1139         Elm_Object_Item *item = NULL;
1140
1141         item = (Elm_Object_Item *)ei;
1142         if (item == NULL) {
1143                 return;
1144         }
1145
1146         Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1147
1148         elm_genlist_item_selected_set(item, EINA_FALSE);
1149
1150         Eina_Bool state = elm_check_state_get(ck);
1151         elm_check_state_set(ck, !state);
1152
1153         _chk_changed_cb(NULL, ck, NULL);
1154 }
1155
1156 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1157 {
1158         elm_genlist_realized_items_update(obj);
1159 }
1160
1161 static void __common_eap_connect_popup_init_item_class(void *data)
1162 {
1163         g_eap_type_itc.item_style = "entry.main";
1164         g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1165         g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1166         g_eap_type_itc.func.state_get = NULL;
1167         g_eap_type_itc.func.del = NULL;
1168
1169         g_eap_auth_itc.item_style = "entry.main";
1170         g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1171         g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1172         g_eap_auth_itc.func.state_get = NULL;
1173         g_eap_auth_itc.func.del = NULL;
1174
1175         g_eap_user_cert_itc.item_style = "entry.main";
1176         g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1177         g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1178         g_eap_user_cert_itc.func.state_get = NULL;
1179         g_eap_user_cert_itc.func.del = NULL;
1180
1181         g_eap_entry_itc.item_style = "entry.main";
1182         g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1183         g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1184         g_eap_entry_itc.func.state_get = NULL;
1185         g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1186
1187         g_eap_chkbox_itc.item_style = "1line";
1188         g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1189         g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1190         g_eap_chkbox_itc.func.state_get = NULL;
1191         g_eap_chkbox_itc.func.del = NULL;
1192 }
1193
1194 static gboolean __cert_extract_files(const char *cert_alias,
1195                 eap_connect_data_t *eap_data)
1196 {
1197         int ret;
1198         int validity;
1199         int cert_counts = 0;
1200         int cert_index;
1201         gchar *ca_cert_path = NULL;
1202         gchar *user_cert_path = NULL;
1203         gchar *privatekey_path = NULL;
1204         FILE *fp;
1205         CertSvcInstance cert_instance;
1206         CertSvcString cert_alias_str;
1207         CertSvcCertificateList cert_list;
1208         CertSvcCertificate user_certificate;
1209         CertSvcCertificate ca_certificate;
1210         CertSvcCertificate *selected_certificate = NULL;
1211         X509 *x509 = NULL;
1212         EVP_PKEY *privatekey = NULL;
1213
1214         ret = certsvc_instance_new(&cert_instance);
1215         if (ret != CERTSVC_SUCCESS) {
1216                 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1217                 goto error;
1218         }
1219         ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1220         if (ret != CERTSVC_SUCCESS) {
1221                 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1222                 goto error;
1223         }
1224         ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1225         if (ret != CERTSVC_SUCCESS) {
1226                 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1227                 goto error;
1228         }
1229         ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1230         if (cert_counts < 1) {
1231                 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1232                 goto error;
1233         }
1234         INFO_LOG(UG_NAME_NORMAL, "cert counts: %d", cert_counts);
1235         selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1236         if (selected_certificate == NULL) {
1237                 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1238                 goto error;
1239         }
1240         ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1241         if (ret != CERTSVC_SUCCESS) {
1242                 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1243                 goto error;
1244         }
1245         cert_index = cert_counts - 1;
1246
1247         selected_certificate[0] = user_certificate;
1248
1249         ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1250
1251         user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1252                                 cert_alias, EAP_TLS_USER_CERT_PATH);
1253         if ((fp = fopen(user_cert_path, "w")) == NULL) {
1254                 goto error;
1255         }
1256         ret = PEM_write_X509(fp, x509);
1257         fclose(fp);
1258         certsvc_certificate_free_x509(x509);
1259         INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1260
1261         ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1262                                 EAP_TLS_CA_CERT_PATH);
1263         while (cert_index) {
1264                 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1265                 if (ret != CERTSVC_SUCCESS) {
1266                         ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1267                         goto error;
1268                 }
1269
1270                 selected_certificate[cert_counts-cert_index] = ca_certificate;
1271                 cert_index--;
1272
1273                 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1274                 if ((fp = fopen(ca_cert_path, "a")) == NULL) {
1275                         goto error;
1276                 }
1277                 ret = PEM_write_X509(fp, x509);
1278                 fclose(fp);
1279                 certsvc_certificate_free_x509(x509);
1280         }
1281         INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1282         ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1283         if (ret != CERTSVC_SUCCESS) {
1284                 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1285                 goto error;
1286         }
1287         if (validity == 0) {
1288                 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1289                 goto error;
1290         }
1291
1292         ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1293
1294         privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1295                                 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1296
1297         if ((fp = fopen(privatekey_path, "w")) == NULL) {
1298                 goto error;
1299         }
1300         ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1301         fclose(fp);
1302         certsvc_pkcs12_free_evp_pkey(privatekey);
1303         INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1304
1305         g_free(selected_certificate);
1306         certsvc_instance_free(cert_instance);
1307
1308         eap_data->ca_cert_path = ca_cert_path;
1309         eap_data->user_cert_path = user_cert_path;
1310         eap_data->privatekey_path = privatekey_path;
1311
1312         return TRUE;
1313
1314 error:
1315         g_free(ca_cert_path);
1316         g_free(user_cert_path);
1317         g_free(privatekey_path);
1318
1319         if (selected_certificate) {
1320                 g_free(selected_certificate);
1321         }
1322
1323         certsvc_instance_free(cert_instance);
1324         return FALSE;
1325 }
1326
1327 /* This creates EAP type, Auth type, CA certificate, User certificate,
1328  * User Id, Anonymous Id and Password items.
1329  */
1330 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1331                 eap_connect_data_t *eap_data)
1332 {
1333         __COMMON_FUNC_ENTER__;
1334         Evas_Object* view_list = eap_data->genlist;
1335         Elm_Object_Item *insert_after_item = NULL;
1336         Elm_Object_Item *prev_item = NULL;
1337         common_utils_entry_info_t *edit_box_details;
1338         Eina_Bool auth_reqd = EINA_FALSE;
1339         Eina_Bool user_cert_reqd = EINA_FALSE;
1340         Eina_Bool id_reqd = EINA_FALSE;
1341         Eina_Bool pw_reqd = EINA_FALSE;
1342
1343         if (NULL == eap_data->eap_type_item) {
1344                 /* Create EAP method/type */
1345                 eap_data->eap_type_item = elm_genlist_item_append(
1346                                                 view_list, &g_eap_type_itc,
1347                                                 eap_data, NULL,
1348                                                 ELM_GENLIST_ITEM_NONE,
1349                                                 _gl_eap_item_sel_cb, eap_data);
1350         }
1351
1352         switch (new_type) {
1353         case EAP_SEC_TYPE_PEAP:
1354                 insert_after_item = eap_data->eap_type_item;
1355                 auth_reqd = EINA_TRUE;
1356                 user_cert_reqd = EINA_FALSE;
1357                 id_reqd = EINA_TRUE;
1358                 pw_reqd = EINA_TRUE;
1359                 break;
1360         case EAP_SEC_TYPE_TLS:
1361                 insert_after_item = eap_data->eap_type_item;
1362                 auth_reqd = EINA_FALSE;
1363                 user_cert_reqd = EINA_TRUE;
1364                 id_reqd = EINA_TRUE;
1365                 pw_reqd = EINA_FALSE;
1366                 break;
1367         case EAP_SEC_TYPE_TTLS:
1368                 insert_after_item = eap_data->eap_type_item;
1369                 auth_reqd = EINA_TRUE;
1370                 user_cert_reqd = EINA_FALSE;
1371                 id_reqd = EINA_TRUE;
1372                 pw_reqd = EINA_TRUE;
1373                 break;
1374         case EAP_SEC_TYPE_SIM:
1375         case EAP_SEC_TYPE_AKA:
1376                 _delete_eap_entry_items(eap_data);
1377                 auth_reqd = EINA_FALSE;
1378                 user_cert_reqd = EINA_FALSE;
1379                 id_reqd = EINA_FALSE;
1380                 pw_reqd = EINA_FALSE;
1381                 break;
1382         default:
1383                 break;
1384         }
1385
1386         if (auth_reqd == EINA_TRUE) {
1387                 if (eap_data->eap_auth_item == NULL) {
1388                         /* Add EAP phase2 authentication */
1389                         eap_data->eap_auth_item = elm_genlist_item_insert_after(
1390                                         view_list, &g_eap_auth_itc, eap_data, NULL,
1391                                         insert_after_item, ELM_GENLIST_ITEM_NONE,
1392                                         _gl_eap_item_sel_cb, eap_data);
1393                 }
1394         } else {
1395                 _delete_eap_auth_item(eap_data);
1396         }
1397
1398         if (user_cert_reqd == EINA_TRUE) {
1399                 if (eap_data->eap_user_cert_item == NULL) {
1400                         prev_item = eap_data->eap_type_item;
1401
1402                         /* Add User certificate */
1403                         eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1404                                         view_list, &g_eap_user_cert_itc, eap_data, NULL,
1405                                         prev_item, ELM_GENLIST_ITEM_NONE,
1406                                         _gl_eap_item_sel_cb, eap_data);
1407                 }
1408         } else {
1409                 _delete_eap_user_cert_item(eap_data);
1410         }
1411
1412         if (id_reqd == EINA_TRUE) {
1413                 if (eap_data->eap_id_item == NULL) {
1414                         if (new_type == EAP_SEC_TYPE_PEAP ||
1415                                         new_type == EAP_SEC_TYPE_TTLS) {
1416                                 prev_item = eap_data->eap_auth_item;
1417                         } else {
1418                                 prev_item = eap_data->eap_user_cert_item;
1419                         }
1420
1421                         /* Add EAP ID */
1422                         edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1423                         if (edit_box_details == NULL) {
1424                                 return;
1425                         }
1426
1427                         edit_box_details->ap = eap_data->ap;
1428                         edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1429                         edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1430                         edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1431                         edit_box_details->item = elm_genlist_item_insert_after(
1432                                         view_list, &g_eap_entry_itc, edit_box_details,
1433                                         NULL, prev_item,
1434                                         ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1435                         eap_data->eap_id_item = edit_box_details->item;
1436                 }
1437         } else {
1438                 _delete_eap_id_item(eap_data);
1439         }
1440
1441         if (pw_reqd == EINA_TRUE) {
1442                 if (eap_data->eap_pw_item == NULL) {
1443                         /* Add EAP Password */
1444                         edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1445                         if (edit_box_details == NULL) {
1446                                 return;
1447                         }
1448
1449                         edit_box_details->ap = eap_data->ap;
1450                         edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1451                         edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1452                         edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1453                         edit_box_details->item = elm_genlist_item_insert_after(
1454                                         view_list, &g_eap_entry_itc,
1455                                         edit_box_details, NULL,
1456                                         eap_data->eap_id_item,
1457                                         ELM_GENLIST_ITEM_NONE,
1458                                         _gl_editbox_sel_cb, NULL);
1459                         eap_data->eap_pw_item = edit_box_details->item;
1460
1461                         _update_eap_id_item_enter_key(eap_data);
1462                 }
1463
1464                 if (eap_data->eap_chkbox_item == NULL) {
1465                         /* Add Show Password checkbox */
1466                         eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1467                                         view_list, &g_eap_chkbox_itc,
1468                                         eap_data->str_pkg_name, NULL,
1469                                         eap_data->eap_pw_item,
1470                                         ELM_GENLIST_ITEM_NONE,
1471                                         _gl_eap_chkbox_sel, NULL);
1472                 }
1473         } else {
1474                 _delete_eap_pw_items(eap_data);
1475         }
1476
1477         __COMMON_FUNC_EXIT__;
1478         return;
1479 }
1480
1481 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1482 {
1483         if (eap_data->eap_id_item == NULL)
1484                 return;
1485
1486         Evas_Object *entry = NULL;
1487         eap_type_t eap_type;
1488
1489         eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1490         entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1491                         "elm.icon.entry");
1492         if (entry) {
1493                 if (eap_type == EAP_SEC_TYPE_TLS) {
1494                         elm_entry_input_panel_return_key_type_set(entry,
1495                                         ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1496                 } else {
1497                         elm_entry_input_panel_return_key_type_set(entry,
1498                                         ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1499                 }
1500         }
1501 }
1502
1503 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1504 {
1505         __COMMON_FUNC_ENTER__;
1506
1507         if (eap_data->eap_auth_item != NULL) {
1508                 elm_object_item_del(eap_data->eap_auth_item);
1509                 eap_data->eap_auth_item = NULL;
1510         }
1511
1512         __COMMON_FUNC_EXIT__;
1513         return;
1514 }
1515
1516 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1517 {
1518         __COMMON_FUNC_ENTER__;
1519
1520         if (eap_data->eap_user_cert_item != NULL) {
1521                 elm_object_item_del(eap_data->eap_user_cert_item);
1522                 eap_data->eap_user_cert_item = NULL;
1523         }
1524
1525         __COMMON_FUNC_EXIT__;
1526         return;
1527 }
1528
1529 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1530 {
1531         __COMMON_FUNC_ENTER__;
1532
1533         if (eap_data->eap_id_item != NULL) {
1534                 elm_object_item_del(eap_data->eap_id_item);
1535                 eap_data->eap_id_item = NULL;
1536         }
1537
1538         __COMMON_FUNC_EXIT__;
1539         return;
1540 }
1541
1542 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1543 {
1544         __COMMON_FUNC_ENTER__;
1545
1546         _update_eap_id_item_enter_key(eap_data);
1547
1548         if (eap_data->eap_pw_item != NULL) {
1549                 elm_object_item_del(eap_data->eap_pw_item);
1550                 eap_data->eap_pw_item = NULL;
1551         }
1552
1553         if (eap_data->eap_chkbox_item) {
1554                 elm_object_item_del(eap_data->eap_chkbox_item);
1555                 eap_data->eap_chkbox_item = NULL;
1556         }
1557
1558         __COMMON_FUNC_EXIT__;
1559         return;
1560 }
1561
1562 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1563 {
1564         __COMMON_FUNC_ENTER__;
1565
1566         if (eap_data->eap_auth_item != NULL) {
1567                 elm_object_item_del(eap_data->eap_auth_item);
1568                 eap_data->eap_auth_item = NULL;
1569         }
1570
1571         if (eap_data->eap_user_cert_item != NULL) {
1572                 elm_object_item_del(eap_data->eap_user_cert_item);
1573                 eap_data->eap_user_cert_item = NULL;
1574         }
1575
1576         if (eap_data->eap_id_item != NULL) {
1577                 elm_object_item_del(eap_data->eap_id_item);
1578                 eap_data->eap_id_item = NULL;
1579         }
1580
1581         if (eap_data->eap_pw_item != NULL) {
1582                 elm_object_item_del(eap_data->eap_pw_item);
1583                 eap_data->eap_pw_item = NULL;
1584         }
1585
1586         if (eap_data->eap_chkbox_item != NULL) {
1587                 elm_object_item_del(eap_data->eap_chkbox_item);
1588                 eap_data->eap_chkbox_item = NULL;
1589         }
1590
1591         __COMMON_FUNC_EXIT__;
1592         return;
1593 }
1594
1595 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1596 {
1597         __COMMON_FUNC_ENTER__;
1598         assertm_if(NULL == parent, "NULL!!");
1599
1600         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1601         Evas_Object* view_list = NULL;
1602         eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1603         retvm_if(eap_data == NULL, NULL);
1604
1605         __common_eap_connect_popup_init_item_class(eap_data);
1606
1607         eap_data->eap_done_ok = FALSE;
1608         eap_data->genlist = view_list = elm_genlist_add(parent);
1609         elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1610         elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1611
1612         evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1613                         EVAS_HINT_EXPAND);
1614         evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1615
1616         /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1617         eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1618         wifi_ap_set_eap_type(eap_data->ap,
1619                         (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1620                         WIFI_EAP_TYPE_PEAP :
1621                         __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1622
1623         wifi_ap_set_eap_auth_type(eap_data->ap,
1624                                         WIFI_EAP_AUTH_TYPE_MSCHAPV2);
1625
1626         selected_cert = 0;
1627
1628         /* Create the entry items */
1629         _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1630
1631         evas_object_show(view_list);
1632         evas_object_smart_callback_add(view_list, "language,changed",
1633                         gl_lang_changed, NULL);
1634
1635         __COMMON_FUNC_EXIT__;
1636         return view_list;
1637 }
1638
1639 static Eina_Bool _enable_scan_updates_cb(void *data)
1640 {
1641         /* Lets enable the scan updates */
1642         wlan_manager_enable_scan_result_update();
1643
1644         /* Reset the ecore timer handle */
1645         common_util_manager_ecore_scan_update_timer_reset();
1646
1647         return ECORE_CALLBACK_CANCEL;
1648 }
1649
1650 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1651 {
1652         if (eap_data == NULL) {
1653                 return;
1654         }
1655
1656         if (eap_data->conf != NULL) {
1657                 evas_object_smart_callback_del(eap_data->conf,
1658                                 "virtualkeypad,state,on",
1659                                 _eap_popup_keypad_on_cb);
1660                 evas_object_smart_callback_del(eap_data->conf,
1661                                 "virtualkeypad,state,off",
1662                                 _eap_popup_keypad_off_cb);
1663         }
1664
1665         if (eap_data->ssid != NULL) {
1666                 g_free(eap_data->ssid);
1667                 eap_data->ssid = NULL;
1668         }
1669
1670         if (eap_data->cert_alias) {
1671                 g_free(eap_data->cert_alias);
1672                 eap_data->cert_alias = NULL;
1673         }
1674
1675         if (eap_data->ca_cert_path) {
1676                 g_free(eap_data->ca_cert_path);
1677                 eap_data->ca_cert_path = NULL;
1678         }
1679
1680         if (eap_data->user_cert_path) {
1681                 g_free(eap_data->user_cert_path);
1682                 eap_data->user_cert_path = NULL;
1683         }
1684
1685         if (eap_data->privatekey_path) {
1686                 g_free(eap_data->privatekey_path);
1687                 eap_data->privatekey_path = NULL;
1688         }
1689
1690         wifi_ap_destroy(eap_data->ap);
1691         eap_data->ap = NULL;
1692
1693         if(eap_data->info_popup){
1694                 evas_object_del(eap_data->info_popup);
1695                 eap_data->info_popup = NULL;
1696         }
1697
1698         if (eap_data->popup != NULL) {
1699                 evas_object_hide(eap_data->popup);
1700                 evas_object_del(eap_data->popup);
1701         }
1702
1703         if(_eap_view_deref_cb != NULL) {
1704                 _eap_view_deref_cb();
1705                 _eap_view_deref_cb = NULL;
1706         }
1707
1708         /* A delay is needed to get the smooth Input panel closing animation effect */
1709         common_util_managed_ecore_scan_update_timer_add(0.1,
1710                         _enable_scan_updates_cb, NULL);
1711 }
1712
1713 static void __common_eap_connect_destroy_cb(void *data,  Evas_Object *obj,
1714                 void *event_info)
1715 {
1716         __common_eap_connect_cleanup((eap_connect_data_t *)data);
1717 }
1718
1719 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1720 {
1721         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1722
1723         if (eap_data->info_popup != NULL) {
1724                 evas_object_del(eap_data->info_popup);
1725                 eap_data->info_popup = NULL;
1726         }
1727 }
1728
1729 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1730                 void *event_info)
1731 {
1732         char *str_id = NULL;
1733         char *str_pw = NULL;
1734         bool favorite = FALSE;
1735         wifi_eap_type_e eap_type;
1736         wifi_eap_auth_type_e eap_auth_type;
1737         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1738         popup_btn_info_t popup_data;
1739
1740         __COMMON_FUNC_ENTER__;
1741         if (eap_data->eap_done_ok == TRUE) {
1742                 __COMMON_FUNC_EXIT__;
1743                 return;
1744         }
1745
1746         eap_data->eap_done_ok = TRUE;
1747
1748         wifi_ap_get_eap_type(eap_data->ap, &eap_type);
1749         wifi_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1750
1751         wifi_ap_is_favorite(eap_data->ap, &favorite);
1752         if (favorite == TRUE) {
1753                 wlan_manager_forget(eap_data->ap);
1754                 wifi_ap_refresh(eap_data->ap);
1755
1756                 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1757                 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1758         }
1759
1760         wifi_ap_set_eap_ca_cert_file(eap_data->ap, "");
1761         wifi_ap_set_eap_client_cert_file(eap_data->ap, "");
1762         wifi_ap_set_eap_private_key_info(eap_data->ap, "", "");
1763
1764         switch (eap_type) {
1765         case WIFI_EAP_TYPE_PEAP:
1766         case WIFI_EAP_TYPE_TTLS:
1767
1768                 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1769                 if (str_id == NULL || str_id[0] == '\0') {
1770                         memset(&popup_data, 0, sizeof(popup_data));
1771                         popup_data.title_txt = eap_data->ssid;
1772                         popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1773                         popup_data.btn1_cb = _info_popup_ok_cb;
1774                         popup_data.btn1_data = eap_data;
1775                         popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1776                         eap_data->eap_done_ok = FALSE;
1777                         eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1778                                                 &popup_data);
1779                         return;
1780                 }
1781
1782                 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1783                 if (str_pw == NULL || str_pw[0] == '\0') {
1784                         memset(&popup_data, 0, sizeof(popup_data));
1785                         popup_data.title_txt = eap_data->ssid;
1786                         popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1787                         popup_data.btn1_cb = _info_popup_ok_cb;
1788                         popup_data.btn1_data = eap_data;
1789                         popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1790                         eap_data->eap_done_ok = FALSE;
1791                         eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1792                                                 &popup_data);
1793                         return;
1794                 }
1795
1796                 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1797                 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1798                 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1799                 break;
1800
1801         case WIFI_EAP_TYPE_TLS:
1802                 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1803                 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1804
1805                 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1806                 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1807                 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1808                 wifi_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1809                 wifi_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1810                 wifi_ap_set_eap_private_key_info(eap_data->ap,
1811                                 eap_data->privatekey_path, NULL);
1812                 break;
1813
1814         case WIFI_EAP_TYPE_SIM:
1815         case WIFI_EAP_TYPE_AKA:
1816                 break;
1817
1818         default:
1819                 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1820                 break;
1821         }
1822
1823         if (eap_data->is_hidden) {
1824                 wifi_ap_h hidden_ap;
1825                 char *ssid;
1826                 wifi_ap_get_essid(eap_data->ap, &ssid);
1827                 wifi_ap_hidden_create(ssid, &hidden_ap);
1828                 g_free(ssid);
1829
1830                 switch (eap_type) {
1831                         case WIFI_EAP_TYPE_PEAP:
1832                         case WIFI_EAP_TYPE_TTLS:
1833                                 wifi_ap_set_eap_type(hidden_ap, eap_type);
1834                                 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1835                                 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1836                                 break;
1837                         case WIFI_EAP_TYPE_TLS:
1838                         wifi_ap_set_eap_type(hidden_ap, eap_type);
1839                         wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1840                         wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1841                         wifi_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1842                         wifi_ap_set_eap_client_cert_file(hidden_ap,eap_data->user_cert_path);
1843                         wifi_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1844                                 break;
1845                         case WIFI_EAP_TYPE_SIM:
1846                         case WIFI_EAP_TYPE_AKA:
1847                                 break;
1848                 }
1849                 wlan_manager_connect(hidden_ap);
1850         } else
1851                 wlan_manager_connect(eap_data->ap);
1852
1853         __common_eap_connect_cleanup(eap_data);
1854
1855         __COMMON_FUNC_EXIT__;
1856 }
1857
1858 static gboolean delay_create_context_popup(gpointer data)
1859 {
1860         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1861
1862         if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1863                 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1864
1865                 click.btn_click[EAP_CERT_BTN] = FALSE;
1866                 click.btn_obj[EAP_CERT_BTN] = NULL;
1867         } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1868                 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1869
1870                 click.btn_click[EAP_AUTH_BTN] = FALSE;
1871                 click.btn_obj[EAP_AUTH_BTN] = NULL;
1872         } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1873                 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1874
1875                 click.btn_click[EAP_TYPE_BTN] = FALSE;
1876                 click.btn_obj[EAP_TYPE_BTN] = NULL;
1877         }
1878         return FALSE;
1879 }
1880
1881 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1882                 void *event_info)
1883 {
1884         if (data == NULL) {
1885                 return;
1886         }
1887
1888         eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1889
1890         keypad_state = FALSE;
1891
1892         common_util_managed_idle_add(delay_create_context_popup,
1893                         (gpointer)eap_data);
1894
1895         INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
1896 }
1897
1898 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1899                 void *event_info)
1900 {
1901         if (data == NULL) {
1902                 return;
1903         }
1904
1905         keypad_state = TRUE;
1906         INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
1907 }
1908
1909 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
1910                 Evas_Object *conf, const char *pkg_name,
1911                 wifi_device_info_t *device_info, void (*deref_func)(void))
1912 {
1913         __COMMON_FUNC_ENTER__;
1914
1915         Evas_Object *popup = NULL;
1916         Evas_Object *list = NULL;
1917         Evas_Object *box = NULL;
1918
1919         if (layout_main == NULL || device_info == NULL || pkg_name == NULL) {
1920                 return NULL;
1921         }
1922
1923         eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
1924         if (eap_data == NULL) {
1925                 return NULL;
1926         }
1927
1928         eap_data->str_pkg_name = pkg_name;
1929         eap_data->win = win;
1930         eap_data->conf = conf;
1931         eap_data->ssid = g_strdup(device_info->ssid);
1932
1933         if (device_info->is_hidden == true) {
1934                 /* Hidden Wi-Fi network */
1935                 char *ssid = NULL;
1936
1937                 wifi_ap_get_essid(device_info->ap, &ssid);
1938                 if (ssid == NULL)
1939                         return NULL;
1940
1941                 wifi_ap_hidden_create(ssid, &(eap_data->ap));
1942                 g_free(ssid);
1943
1944                 eap_data->is_hidden = TRUE;
1945         } else {
1946                 /* Clone the Wi-Fi AP handle */
1947                 wifi_ap_clone(&(eap_data->ap), device_info->ap);
1948         }
1949
1950         /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
1951         wlan_manager_disable_scan_result_update();
1952
1953         _eap_view_deref_cb = deref_func;
1954         click.btn_click[EAP_TYPE_BTN] = FALSE;
1955         click.btn_obj[EAP_TYPE_BTN] = NULL;
1956         click.btn_click[EAP_AUTH_BTN] = FALSE;
1957         click.btn_obj[EAP_AUTH_BTN] = NULL;
1958         click.btn_click[EAP_CERT_BTN] = FALSE;
1959         click.btn_obj[EAP_CERT_BTN] = NULL;
1960         keypad_state = FALSE;
1961
1962         popup_btn_info_t popup_btn_data;
1963         memset(&popup_btn_data, 0, sizeof(popup_btn_data));
1964
1965         popup_btn_data.title_txt = device_info->ssid;
1966         popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
1967         popup_btn_data.btn1_data = eap_data;
1968         popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
1969         popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
1970         popup_btn_data.btn2_data = eap_data;
1971         popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
1972
1973         popup = common_utils_show_info_popup(layout_main,
1974                         &popup_btn_data);
1975         eap_data->popup = popup;
1976         evas_object_show(popup);
1977         elm_object_focus_set(popup, EINA_TRUE);
1978
1979         box = elm_box_add(popup);
1980         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1981
1982         /* Create an EAP connect view list */
1983         list = _create_list(box, eap_data);
1984         elm_object_content_set(box, list);
1985
1986         elm_box_pack_end(box, list);
1987         evas_object_size_hint_min_set(box, -1, ELM_SCALE_SIZE(300));
1988         elm_object_content_set(popup, box);
1989
1990         evas_object_smart_callback_add(eap_data->conf,
1991                         "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
1992                         eap_data);
1993         evas_object_smart_callback_add(eap_data->conf,
1994                         "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
1995                         eap_data);
1996
1997         __COMMON_FUNC_EXIT__;
1998         return eap_data;
1999 }
2000
2001 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
2002 {
2003         wifi_eap_type_e wlan_eap_type = WLAN_SEC_EAP_TYPE_PEAP;
2004         switch (eap_type) {
2005         case EAP_SEC_TYPE_PEAP:
2006                 wlan_eap_type = WIFI_EAP_TYPE_PEAP;
2007                 break;
2008         case EAP_SEC_TYPE_TLS:
2009                 wlan_eap_type = WIFI_EAP_TYPE_TLS;
2010                 break;
2011         case EAP_SEC_TYPE_TTLS:
2012                 wlan_eap_type = WIFI_EAP_TYPE_TTLS;
2013                 break;
2014         case EAP_SEC_TYPE_SIM:
2015                 wlan_eap_type = WIFI_EAP_TYPE_SIM;
2016                 break;
2017         case EAP_SEC_TYPE_AKA:
2018                 wlan_eap_type = WIFI_EAP_TYPE_AKA;
2019                 break;
2020         default:
2021                 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2022                 break;
2023         }
2024
2025         return wlan_eap_type;
2026 }
2027
2028 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2029 {
2030         wifi_eap_auth_type_e wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2031         switch (auth_type) {
2032         case EAP_SEC_AUTH_NONE:
2033                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2034                 break;
2035         case EAP_SEC_AUTH_PAP:
2036                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_PAP;
2037                 break;
2038         case EAP_SEC_AUTH_MSCHAP:
2039                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAP;
2040                 break;
2041         case EAP_SEC_AUTH_MSCHAPV2:
2042                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
2043                 break;
2044         case EAP_SEC_AUTH_GTC:
2045                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_GTC;
2046                 break;
2047         case EAP_SEC_AUTH_MD5:
2048                 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MD5;
2049                 break;
2050         default:
2051                 /* This case should never occur */
2052                 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2053                 break;
2054         }
2055         return wlan_auth_type;
2056 }
2057
2058 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap)
2059 {
2060         wifi_eap_type_e wlan_eap_type = 0;
2061         int ret = wifi_ap_get_eap_type(ap, &wlan_eap_type);
2062         if (WIFI_ERROR_OPERATION_FAILED == ret) {
2063                 ret = wifi_ap_set_eap_type(ap, WIFI_EAP_TYPE_PEAP);
2064         }
2065
2066         if (WIFI_ERROR_NONE != ret) {
2067                 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2068                 return EAP_SEC_TYPE_UNKNOWN;
2069         }
2070
2071         switch (wlan_eap_type) {
2072         case WIFI_EAP_TYPE_PEAP:  /**< EAP PEAP type */
2073                 return EAP_SEC_TYPE_PEAP;
2074
2075         case WIFI_EAP_TYPE_TLS:  /**< EAP TLS type */
2076                 return EAP_SEC_TYPE_TLS;
2077
2078         case WIFI_EAP_TYPE_TTLS:  /**< EAP TTLS type */
2079                 return EAP_SEC_TYPE_TTLS;
2080
2081         case WIFI_EAP_TYPE_SIM:  /**< EAP SIM type */
2082                 return EAP_SEC_TYPE_SIM;
2083
2084         case WIFI_EAP_TYPE_AKA:  /**< EAP AKA type */
2085                 return EAP_SEC_TYPE_AKA;
2086
2087         default:
2088                 return EAP_SEC_TYPE_PEAP;
2089         }
2090         return EAP_SEC_TYPE_PEAP;
2091 }
2092
2093 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap)
2094 {
2095         wifi_eap_auth_type_e wlan_auth_type = 0;
2096         int ret = wifi_ap_get_eap_auth_type(ap, &wlan_auth_type);
2097         if (WIFI_ERROR_OPERATION_FAILED == ret) {
2098                 ret = wifi_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2099         }
2100
2101         if (WIFI_ERROR_NONE != ret) {
2102                 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2103                 return EAP_SEC_AUTH_NONE;
2104         }
2105
2106         switch (wlan_auth_type) {
2107         case WIFI_EAP_AUTH_TYPE_NONE:  /**< EAP phase2 authentication none */
2108                 return EAP_SEC_AUTH_NONE;
2109
2110         case WIFI_EAP_AUTH_TYPE_PAP:  /**< EAP phase2 authentication PAP */
2111                 return EAP_SEC_AUTH_PAP;
2112
2113         case WIFI_EAP_AUTH_TYPE_MSCHAP:  /**< EAP phase2 authentication MSCHAP */
2114                 return EAP_SEC_AUTH_MSCHAP;
2115
2116         case WIFI_EAP_AUTH_TYPE_MSCHAPV2:  /**< EAP phase2 authentication MSCHAPv2 */
2117                 return EAP_SEC_AUTH_MSCHAPV2;
2118
2119         case WIFI_EAP_AUTH_TYPE_GTC:  /**< EAP phase2 authentication GTC */
2120                 return EAP_SEC_AUTH_GTC;
2121
2122         case WIFI_EAP_AUTH_TYPE_MD5:  /**< EAP phase2 authentication MD5 */
2123                 return EAP_SEC_AUTH_MD5;
2124
2125         default:
2126                 return EAP_SEC_AUTH_NONE;
2127         }
2128         return EAP_SEC_AUTH_NONE;
2129 }
2130
2131 static char *_eap_info_get_user_cert_alias(wifi_ap_h ap)
2132 {
2133         char *path = NULL;
2134         char *alias = NULL;
2135         char *filename = NULL;
2136         char *cert_name = NULL;
2137         int alias_len = 0;
2138         int filename_len = 0;
2139
2140         wifi_ap_get_eap_client_cert_file(ap, &path);
2141         if (path == NULL)
2142                 return NULL;
2143
2144         filename = strrchr(path, '/');
2145         if (filename == NULL) {
2146                 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2147                 goto EXIT;
2148         }
2149
2150         filename++;
2151         cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2152         if (cert_name == NULL) {
2153                 /* For truncated path, available filename will be followed
2154                  * with ellipsis(...) & excluding any remaining part of
2155                  * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2156                 filename_len = strlen(filename);
2157                 alias = g_try_malloc0(filename_len - 10);
2158                 if (alias == NULL) {
2159                         ERROR_LOG(UG_NAME_ERR, "malloc fail");
2160                         goto EXIT;
2161                 }
2162                 g_strlcpy(alias, filename, filename_len - 13);
2163                 g_strlcat(alias, "...", filename_len - 10);
2164                 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2165                 goto EXIT;
2166         }
2167
2168         cert_name--;
2169         alias_len = cert_name - filename;
2170
2171         alias = g_try_malloc0(alias_len + 1);
2172         if (alias == NULL) {
2173                 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2174                 goto EXIT;
2175         }
2176
2177         g_strlcpy(alias, filename, alias_len + 1);
2178         INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2179
2180 EXIT:
2181         g_free(path);
2182
2183         return alias;
2184 }
2185
2186 /* This creates Auth type, ID, Anonymous Id and Password items
2187  * This function should be called after creating the EAP type item
2188  */
2189 eap_info_list_t *eap_info_append_items(wifi_ap_h ap, Evas_Object* view_list,
2190                 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2191                 void *input_panel_cb_data)
2192 {
2193         __COMMON_FUNC_ENTER__;
2194
2195         eap_type_t eap_type;
2196         eap_auth_t auth_type;
2197         char *temp_str = NULL;
2198         Eina_Bool append_continue = TRUE;
2199         eap_info_list_t *eap_info_list_data = NULL;
2200         Elm_Object_Item* item = NULL;
2201         if (!view_list || !str_pkg_name || !ap) {
2202                 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2203                 return NULL;
2204         }
2205
2206         eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2207         if (eap_info_list_data == NULL) {
2208                 return NULL;
2209         }
2210
2211         eap_info_list_data->ap = ap;
2212         eap_type = __common_eap_connect_popup_get_eap_type(ap);
2213         auth_type = __common_eap_connect_popup_get_auth_type(ap);
2214
2215         item = common_utils_add_2_line_txt_disabled_item(view_list,
2216                         "2line.top",
2217                         sc(str_pkg_name, I18N_TYPE_EAP_method),
2218                         list_eap_type[eap_type].name);
2219         eap_info_list_data->eap_method_item = item;
2220
2221         eap_info_list_data->eap_type = eap_type;
2222
2223         switch (eap_type) {
2224         case EAP_SEC_TYPE_UNKNOWN:
2225         case EAP_SEC_TYPE_PEAP:
2226         case EAP_SEC_TYPE_TLS:
2227         case EAP_SEC_TYPE_TTLS:
2228                 break;
2229         case EAP_SEC_TYPE_SIM:
2230         case EAP_SEC_TYPE_AKA:
2231         default:
2232                 append_continue = FALSE;
2233                 break;
2234         }
2235
2236         if (append_continue) {
2237                 if (eap_type == EAP_SEC_TYPE_PEAP ||
2238                                 eap_type == EAP_SEC_TYPE_TTLS) {
2239                         /* Add EAP phase2 authentication */
2240                         item = common_utils_add_2_line_txt_disabled_item(
2241                                         view_list, "2line.top",
2242                                         sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2243                                         list_eap_auth[auth_type].name);
2244                         eap_info_list_data->eap_auth_item = item;
2245                 }
2246
2247                 if (eap_type == EAP_SEC_TYPE_TLS) {
2248                         /* Add User certificate */
2249                         temp_str = _eap_info_get_user_cert_alias(ap);
2250
2251                         if (temp_str == NULL || strlen(temp_str) == 0) {
2252                                 if (temp_str != NULL) {
2253                                         g_free(temp_str);
2254                                 }
2255                                 temp_str = g_strdup(sc(str_pkg_name,
2256                                                 I18N_TYPE_Unspecified));
2257                         }
2258
2259                         item = common_utils_add_2_line_txt_disabled_item(
2260                                         view_list, "2line.top",
2261                                         sc(str_pkg_name, I18N_TYPE_User_Certificate),
2262                                         temp_str);
2263                         eap_info_list_data->user_cert_item = item;
2264                         g_free(temp_str);
2265                 }
2266
2267                 /* Add EAP ID */
2268                 bool is_paswd_set;
2269                 temp_str = NULL;
2270                 wifi_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set);
2271                 item = common_utils_add_2_line_txt_disabled_item(view_list, "2line.top",
2272                                 sc(str_pkg_name, I18N_TYPE_Identity), temp_str);
2273                 eap_info_list_data->id_item = item;
2274                 g_free(temp_str);
2275
2276 #if 0
2277                 common_utils_entry_info_t *edit_box_details;
2278
2279                 /* Add EAP Password */
2280                 g_eap_entry_itc.item_style = "entry.main";
2281                 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2282                 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2283                 g_eap_entry_itc.func.state_get = NULL;
2284                 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2285
2286                 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2287                 if (edit_box_details == NULL) {
2288                         g_free(eap_info_list_data);
2289                         return NULL;
2290                 }
2291
2292                 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2293                 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2294                 edit_box_details->entry_txt = NULL;
2295                 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2296                 edit_box_details->input_panel_cb = input_panel_cb;
2297                 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2298                 edit_box_details->item = elm_genlist_item_append(view_list,
2299                                 &g_eap_entry_itc, edit_box_details, NULL,
2300                                 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2301                 elm_genlist_item_select_mode_set(edit_box_details->item,
2302                                 ELM_OBJECT_SELECT_MODE_NONE);
2303                 eap_info_list_data->pswd_item = edit_box_details->item;
2304 #endif
2305         }
2306
2307         __COMMON_FUNC_EXIT__;
2308         return eap_info_list_data;
2309 }
2310
2311 #if 0
2312 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2313 {
2314         if (!eap_info_list_data) {
2315                 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2316                 return;
2317         }
2318         char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2319
2320         wifi_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2321         g_free(txt);
2322         return;
2323 }
2324 #endif
2325
2326 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2327 {
2328         if (!eap_info_list_data) {
2329                 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2330                 return;
2331         }
2332
2333         g_free(eap_info_list_data);
2334 }
2335
2336 void eap_connect_data_free(eap_connect_data_t *eap_data)
2337 {
2338         __common_eap_connect_cleanup(eap_data);
2339 }