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