4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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
10 * http://www.tizenopensource.org/license
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.
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 <vconf-keys.h>
26 #include <glib/gstdio.h>
27 #include <efl_extension.h>
31 #include "common_eap_connect.h"
32 #include "i18nmanager.h"
33 #include "common_utils.h"
34 #include "common_ip_info.h"
36 #define GENLIST_ITEM_HEIGHT 96
37 #define MAX_LABEL_LENGTH 512
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"
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 #define EAP_TYPE_AKA_PRIME "AKA'"
51 #define EAP_TYPE_FAST "FAST"
52 #define EAP_TYPE_PWD "PWD"
54 #define EAP_AUTH_TYPE_PAP "PAP"
55 #define EAP_AUTH_TYPE_MSCHAP "MSCHAP"
56 #define EAP_AUTH_TYPE_MSCHAPV2 "MSCHAPV2"
57 #define EAP_AUTH_TYPE_GTC "GTC"
58 #define EAP_AUTH_TYPE_MD5 "MD5"
59 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
62 EAP_SEC_TYPE_UNKNOWN = 0,
68 EAP_SEC_TYPE_AKA_PRIME,
75 EAP_SEC_AUTH_NONE = 0,
78 EAP_SEC_AUTH_MSCHAPV2,
92 Elm_Genlist_Item_Type flags;
97 Evas_Object *btn_obj[3];
100 struct eap_info_list {
101 wifi_manager_ap_h ap;
103 Elm_Object_Item *eap_method_item;
104 Elm_Object_Item *eap_auth_item;
105 Elm_Object_Item *user_cert_item;
106 Elm_Object_Item *id_item;
107 Elm_Object_Item *pswd_item;
110 static const _Expand_List_t list_eap_type[] = {
111 {"UNKNOWN", ELM_GENLIST_ITEM_NONE},
112 {"PEAP", ELM_GENLIST_ITEM_NONE},
113 {"TLS", ELM_GENLIST_ITEM_NONE},
114 {"TTLS", ELM_GENLIST_ITEM_NONE},
115 {"SIM", ELM_GENLIST_ITEM_NONE},
116 {"AKA", ELM_GENLIST_ITEM_NONE},
117 {"AKA'", ELM_GENLIST_ITEM_NONE},
118 {"FAST", ELM_GENLIST_ITEM_NONE},
119 {"PWD", ELM_GENLIST_ITEM_NONE},
120 {NULL, ELM_GENLIST_ITEM_NONE}
123 static const _Expand_List_t list_eap_auth[] = {
124 {"IDS_ST_BODY_NONE", ELM_GENLIST_ITEM_NONE},
125 {"PAP", ELM_GENLIST_ITEM_NONE},
126 {"MSCHAP", ELM_GENLIST_ITEM_NONE},
127 {"MSCHAPV2", ELM_GENLIST_ITEM_NONE},
128 {"GTC", ELM_GENLIST_ITEM_NONE},
129 {NULL, ELM_GENLIST_ITEM_NONE}
132 static unsigned short selected_cert = 0;
134 struct common_eap_connect_data {
135 Elm_Object_Item *eap_type_item;
136 Elm_Object_Item *eap_auth_item;
137 Elm_Object_Item *eap_user_cert_item;
138 Elm_Object_Item *eap_id_item;
139 Elm_Object_Item *eap_pw_item;
140 Elm_Object_Item *eap_chkbox_item;
142 Evas_Object *sub_popup;
143 Evas_Object *info_popup;
144 Evas_Object *genlist;
145 Eina_Bool eap_done_ok;
148 const char *str_pkg_name;
149 wifi_manager_ap_h ap;
152 char *user_cert_path;
153 char *privatekey_path;
154 GSList *cert_candidates;
155 Evas_Object *confirm;
163 static Elm_Genlist_Item_Class g_eap_type_itc;
164 static Elm_Genlist_Item_Class g_eap_auth_itc;
165 static Elm_Genlist_Item_Class g_eap_user_cert_itc;
166 static Elm_Genlist_Item_Class g_eap_entry_itc;
167 static Elm_Genlist_Item_Class g_eap_chkbox_itc;
168 static Evas_Object *g_pwd_entry = NULL;
169 static gboolean keypad_state = FALSE;
170 static _Btn_click_t click;
172 static void (*_eap_view_deref_cb)(void) = NULL;
174 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type, eap_connect_data_t *eap_data);
175 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data);
176 static void _delete_eap_auth_item(eap_connect_data_t *eap_data);
177 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data);
178 static void _delete_eap_id_item(eap_connect_data_t *eap_data);
179 static void _delete_eap_pw_items(eap_connect_data_t *eap_data);
180 static void _delete_eap_entry_items(eap_connect_data_t *eap_data);
181 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_manager_ap_h ap);
182 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_manager_ap_h ap);
183 static wifi_manager_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type);
184 static wifi_manager_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type);
185 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
186 static gboolean __cert_extract_files(const char *cert_alias, eap_connect_data_t *eap_data);
187 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
189 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
192 static void ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
195 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
197 if (eap_data->sub_popup != NULL) {
198 evas_object_del(eap_data->sub_popup);
199 eap_data->sub_popup = NULL;
203 static void cert_ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
206 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
208 if (eap_data->sub_popup != NULL) {
209 evas_object_del(eap_data->sub_popup);
210 eap_data->sub_popup = NULL;
213 if (eap_data->cert_candidates != NULL) {
214 g_slist_free_full(eap_data->cert_candidates, g_free);
215 eap_data->cert_candidates = NULL;
219 static void move_dropdown(eap_connect_data_t *eap_data, Evas_Object *obj)
221 Evas_Coord x, y, w , h;
223 evas_object_geometry_get(obj, &x, &y, &w, &h);
224 evas_object_move(eap_data->sub_popup, x + (w / 2), y + h);
227 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
229 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
230 elm_genlist_item_selected_set(item, FALSE);
233 static void _select_confirm_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
235 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
236 retm_if(eap_data == NULL);
238 if (eap_data->confirm != NULL) {
239 evas_object_del(eap_data->confirm);
240 eap_data->confirm = NULL;
244 static void __gl_eap_type_sub_sel_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
246 __COMMON_FUNC_ENTER__;
247 retm_if(obj == NULL);
253 g_snprintf(str, 1024, sc(PACKAGE, I18N_TYPE_SIM_method_desc_popup),
254 (val == 1) ? "SIM2" : "SIM1");
255 txt = evas_textblock_text_utf8_to_markup(NULL, str);
256 elm_object_domain_translatable_text_set(obj, PACKAGE, txt);
258 __COMMON_FUNC_EXIT__;
261 static void _gl_eap_type_sub_sel(void *data, Evas_Object *obj, void *event_info)
263 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
264 eap_type_t sel_index = EAP_SEC_TYPE_UNKNOWN;
265 char buf[1024] = {'\0'};
267 eap_type_t pre_index = __common_eap_connect_popup_get_eap_type(eap_data->ap);
268 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
270 if (strcmp(label, EAP_TYPE_UNKNOWN) == 0)
271 sel_index = EAP_SEC_TYPE_UNKNOWN;
272 else if (strcmp(label, EAP_TYPE_PEAP) == 0)
273 sel_index = EAP_SEC_TYPE_PEAP;
274 else if (strcmp(label, EAP_TYPE_TLS) == 0)
275 sel_index = EAP_SEC_TYPE_TLS;
276 else if (strcmp(label, EAP_TYPE_TTLS) == 0)
277 sel_index = EAP_SEC_TYPE_TTLS;
278 else if (strcmp(label, EAP_TYPE_SIM) == 0)
279 sel_index = EAP_SEC_TYPE_SIM;
280 else if (strcmp(label, EAP_TYPE_AKA) == 0)
281 sel_index = EAP_SEC_TYPE_AKA;
282 else if (strcmp(label, EAP_TYPE_AKA_PRIME) == 0)
283 sel_index = EAP_SEC_TYPE_AKA_PRIME;
284 else if (strcmp(label, EAP_TYPE_FAST) == 0)
285 sel_index = EAP_SEC_TYPE_FAST;
286 else if (strcmp(label, EAP_TYPE_PWD) == 0)
287 sel_index = EAP_SEC_TYPE_PWD;
289 DEBUG_LOG(UG_NAME_NORMAL, "previous index = %d; selected index = %d;",
290 pre_index, sel_index);
291 if ((pre_index != EAP_SEC_TYPE_SIM && sel_index == EAP_SEC_TYPE_SIM) ||
292 (pre_index != EAP_SEC_TYPE_AKA && sel_index == EAP_SEC_TYPE_AKA) ||
293 (pre_index != EAP_SEC_TYPE_AKA_PRIME && sel_index == EAP_SEC_TYPE_AKA_PRIME)) {
294 popup_btn_info_t popup_data;
296 value = common_util_get_system_registry(
297 VCONF_TELEPHONY_DEFAULT_DATA_SERVICE);
299 memset(&popup_data, 0, sizeof(popup_data));
300 g_snprintf(buf, sizeof(buf),
301 sc(PACKAGE, I18N_TYPE_SIM_method_desc_popup),
302 (value == 1) ? "SIM2" : "SIM1");
303 popup_data.title_txt = "IDS_WIFI_BODY_EAP_METHOD";
304 popup_data.info_txt = evas_textblock_text_utf8_to_markup(NULL, buf);
305 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
306 popup_data.btn1_cb = _select_confirm_popup_ok_cb;
307 popup_data.btn1_data = eap_data;
309 eap_data->confirm = common_utils_show_info_popup(eap_data->win,
311 g_free(popup_data.info_txt);
312 evas_object_smart_callback_add(eap_data->confirm, "language,changed",
313 __gl_eap_type_sub_sel_language_changed_cb, (void *)value);
315 _create_and_update_list_items_based_on_rules(sel_index, data);
316 wifi_manager_eap_type_e type;
317 wifi_manager_ap_set_eap_type(eap_data->ap,
318 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
319 wifi_manager_ap_get_eap_type(eap_data->ap, &type);
320 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
323 if (eap_data->sub_popup != NULL) {
324 evas_object_del(eap_data->sub_popup);
325 eap_data->sub_popup = NULL;
328 if (pre_index != sel_index) {
329 wifi_manager_eap_type_e type;
330 wifi_manager_ap_set_eap_type(eap_data->ap,
331 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
332 wifi_manager_ap_get_eap_type(eap_data->ap, &type);
333 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
334 _create_and_update_list_items_based_on_rules(sel_index, eap_data);
336 if (sel_index == EAP_SEC_TYPE_PEAP) {
337 /* If previous auth type was PAP or MSCHAP & when PEAP
338 * EAP method is selected, then set back MSCHAPV2
340 eap_auth_t auth_type;
342 auth_type = __common_eap_connect_popup_get_auth_type(eap_data->ap);
343 if (auth_type == EAP_SEC_AUTH_PAP ||
344 auth_type == EAP_SEC_AUTH_MSCHAP) {
345 wifi_manager_ap_set_eap_auth_type(eap_data->ap,
346 WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2);
348 if (eap_data->eap_auth_item != NULL)
349 elm_genlist_item_update(eap_data->eap_auth_item);
353 DEBUG_LOG(UG_NAME_NORMAL, "pre_index == sel_index[%d]",
357 if (eap_data->eap_type_item != NULL)
358 elm_genlist_item_update(eap_data->eap_type_item);
361 static CertSvcInstance instance;
362 static CertSvcStoreCertList *certList = NULL;
364 static void _gl_eap_user_cert_sel(void *data, Evas_Object *obj,
367 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
368 const char *cert_alias = elm_object_item_text_get((Elm_Object_Item *) event_info);
373 if (eap_data->sub_popup != NULL) {
374 evas_object_del(eap_data->sub_popup);
375 eap_data->sub_popup = NULL;
378 if (eap_data->ca_cert_path) {
379 g_unlink(eap_data->ca_cert_path);
380 eap_data->ca_cert_path = NULL;
382 if (eap_data->user_cert_path) {
383 g_unlink(eap_data->user_cert_path);
384 eap_data->user_cert_path = NULL;
386 if (eap_data->privatekey_path) {
387 g_unlink(eap_data->privatekey_path);
388 eap_data->privatekey_path = NULL;
391 if (strcmp(cert_alias, sc(PACKAGE, I18N_TYPE_None)) == 0) {
392 if (eap_data->cert_alias != NULL) {
393 g_free(eap_data->cert_alias);
394 eap_data->cert_alias = NULL;
396 } else if (__cert_extract_files(cert_alias, eap_data)) {
397 if (eap_data->cert_alias != NULL) {
398 g_free(eap_data->cert_alias);
399 eap_data->cert_alias = NULL;
401 eap_data->cert_alias = g_strdup(cert_alias);
404 if (eap_data->eap_user_cert_item != NULL)
405 elm_genlist_item_update(eap_data->eap_user_cert_item);
407 if (eap_data->cert_candidates != NULL) {
408 g_slist_free_full(eap_data->cert_candidates, g_free);
409 eap_data->cert_candidates = NULL;
413 static void _create_eap_cert_list(eap_connect_data_t *eap_data,
416 size_t list_length = 0;
417 Evas_Object *ctxpopup;
418 Elm_Object_Item *it = NULL;
423 if (eap_data->sub_popup != NULL) {
424 evas_object_del(eap_data->sub_popup);
425 eap_data->sub_popup = NULL;
428 ctxpopup = elm_ctxpopup_add(eap_data->win);
429 eap_data->sub_popup = ctxpopup;
430 elm_object_style_set(ctxpopup, "dropdown/list");
431 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
432 cert_ctxpopup_dismissed_cb, NULL);
433 evas_object_smart_callback_add(ctxpopup, "dismissed",
434 cert_ctxpopup_dismissed_cb, eap_data);
435 elm_ctxpopup_direction_priority_set(ctxpopup,
436 ELM_CTXPOPUP_DIRECTION_DOWN,
437 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
438 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
439 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
441 if (certsvc_instance_new(&instance) == CERTSVC_FAIL) {
442 INFO_LOG(UG_NAME_ERR, "Failed to create new instance");
446 if (certsvc_pkcs12_get_certificate_list_from_store(instance, WIFI_STORE, DISABLED, &certList, &list_length) != CERTSVC_SUCCESS) {
447 INFO_LOG(UG_NAME_ERR, "Failed to get certificate list");
451 if (eap_data->cert_candidates) {
452 g_slist_free_full(eap_data->cert_candidates, g_free);
453 eap_data->cert_candidates = NULL;
456 it = elm_ctxpopup_item_append(ctxpopup, "IDS_ST_BODY_NONE", NULL,
457 _gl_eap_user_cert_sel, eap_data);
458 elm_object_item_domain_text_translatable_set(it,
461 while (certList != NULL) {
462 char *char_buffer = NULL;
463 CertSvcString buffer;
465 buffer.privateHandler = (char *)certList->gname;
466 buffer.privateLength = strlen(certList->gname);
467 INFO_LOG(UG_NAME_NORMAL, "gname in processing : %s", certList->gname);
469 char_buffer = g_strndup(buffer.privateHandler, buffer.privateLength);
470 if (char_buffer == NULL)
473 elm_ctxpopup_item_append(ctxpopup, char_buffer, NULL,
474 _gl_eap_user_cert_sel, eap_data);
475 eap_data->cert_candidates =
476 g_slist_prepend(eap_data->cert_candidates, char_buffer);
478 certsvc_string_free(buffer);
479 certList = certList->next;
482 move_dropdown(eap_data, btn);
483 evas_object_show(ctxpopup);
486 certsvc_instance_free(instance);
489 static void _gl_eap_cert_list_btn_cb(void *data, Evas_Object *obj,
492 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
493 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
496 elm_genlist_item_selected_set(item, EINA_FALSE);
498 if (keypad_state == FALSE) {
499 _create_eap_cert_list(eap_data, obj);
501 click.btn_click[EAP_CERT_BTN] = FALSE;
502 click.btn_obj[EAP_CERT_BTN] = NULL;
504 click.btn_click[EAP_CERT_BTN] = TRUE;
505 click.btn_obj[EAP_CERT_BTN] = obj;
509 static char *_gl_eap_user_cert_text_get(void *data, Evas_Object *obj, const char *part)
511 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
513 if (!g_strcmp0(part, "elm.text.sub")) {
514 return g_strdup(sc(eap_data->str_pkg_name,
515 I18N_TYPE_User_Certificate));
521 static Evas_Object *_gl_eap_user_cert_content_get(void *data,
522 Evas_Object *obj, const char *part)
524 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
525 Evas_Object *btn = NULL;
526 Evas_Object *ly = NULL;
529 if (!strcmp(part, "elm.swallow.icon.0")) {
530 ly = elm_layout_add(obj);
531 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
532 "eap_dropdown_button");
533 btn = elm_button_add(obj);
535 if (eap_data->cert_alias == NULL) {
536 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
537 sc(eap_data->str_pkg_name, I18N_TYPE_None));
539 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
540 eap_data->cert_alias);
543 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
544 elm_object_style_set(btn, "dropdown/label");
545 evas_object_propagate_events_set(btn, EINA_FALSE);
546 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
548 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
550 evas_object_smart_callback_add(btn, "clicked",
551 _gl_eap_cert_list_btn_cb, eap_data);
553 elm_layout_content_set(ly, "btn", btn);
559 static void _gl_eap_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
561 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
564 elm_genlist_item_selected_set(item, EINA_FALSE);
567 static void _create_eap_type_list(eap_connect_data_t *eap_data,
570 Evas_Object *ctxpopup = NULL;
571 int i = EAP_SEC_TYPE_PEAP;
572 int sim_state = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
573 Elm_Object_Item *it = NULL;
575 sim_state = common_utils_get_sim_state();
577 if (eap_data->sub_popup != NULL)
578 evas_object_del(eap_data->sub_popup);
580 ctxpopup = elm_ctxpopup_add(eap_data->win);
581 eap_data->sub_popup = ctxpopup;
582 elm_object_style_set(ctxpopup, "dropdown/list");
583 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
584 eext_ctxpopup_back_cb, NULL);
585 evas_object_smart_callback_add(ctxpopup, "dismissed",
586 ctxpopup_dismissed_cb, eap_data);
587 elm_ctxpopup_direction_priority_set(ctxpopup,
588 ELM_CTXPOPUP_DIRECTION_DOWN,
589 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
590 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
591 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
593 /* eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap); */
594 while (list_eap_type[i].name != NULL) {
595 it = elm_ctxpopup_item_append(ctxpopup, list_eap_type[i].name,
596 NULL, _gl_eap_type_sub_sel, eap_data);
598 if ((i == EAP_SEC_TYPE_SIM || i == EAP_SEC_TYPE_AKA ||
599 i == EAP_SEC_TYPE_AKA_PRIME) &&
600 sim_state != VCONFKEY_TELEPHONY_SIM_INSERTED) {
601 elm_object_item_disabled_set(it, EINA_TRUE);
607 move_dropdown(eap_data, btn);
608 evas_object_show(ctxpopup);
611 static void _gl_eap_type_btn_cb(void *data, Evas_Object *obj, void *event_info)
613 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
614 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
617 elm_genlist_item_selected_set(item, EINA_FALSE);
619 if (keypad_state == FALSE) {
620 _create_eap_type_list(eap_data, obj);
622 click.btn_click[EAP_TYPE_BTN] = FALSE;
623 click.btn_obj[EAP_TYPE_BTN] = NULL;
625 click.btn_click[EAP_TYPE_BTN] = TRUE;
626 click.btn_obj[EAP_TYPE_BTN] = obj;
630 static char *_gl_eap_type_text_get(void *data, Evas_Object *obj, const char *part)
632 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
634 if (!g_strcmp0(part, "elm.text.sub"))
635 return g_strdup(sc(eap_data->str_pkg_name, I18N_TYPE_EAP_method));
640 static Evas_Object *_gl_eap_type_content_get(void *data,
641 Evas_Object *obj, const char *part)
643 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
644 eap_type_t sel_sub_item_id = __common_eap_connect_popup_get_eap_type(eap_data->ap);
645 Evas_Object *btn = NULL;
646 Evas_Object *ly = NULL;
649 if (!strcmp(part, "elm.swallow.icon.0")) {
650 ly = elm_layout_add(obj);
651 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
652 "eap_dropdown_button");
653 btn = elm_button_add(obj);
655 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
656 list_eap_type[sel_sub_item_id].name);
658 elm_object_text_set(btn, buf);
659 elm_object_style_set(btn, "dropdown/label");
660 evas_object_propagate_events_set(btn, EINA_FALSE);
661 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
663 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
665 evas_object_smart_callback_add(btn, "clicked",
666 _gl_eap_type_btn_cb, eap_data);
668 elm_layout_content_set(ly, "btn", btn);
674 static void _gl_eap_auth_sub_sel(void *data, Evas_Object *obj, void *event_info)
676 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
677 eap_auth_t sel_index = EAP_SEC_AUTH_NONE;
679 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
681 if (strcmp(label, sc(PACKAGE, I18N_TYPE_None)) == 0)
682 sel_index = EAP_SEC_AUTH_NONE;
683 else if (strcmp(label, EAP_AUTH_TYPE_PAP) == 0)
684 sel_index = EAP_SEC_AUTH_PAP;
685 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAP) == 0)
686 sel_index = EAP_SEC_AUTH_MSCHAP;
687 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAPV2) == 0)
688 sel_index = EAP_SEC_AUTH_MSCHAPV2;
689 else if (strcmp(label, EAP_AUTH_TYPE_GTC) == 0)
690 sel_index = EAP_SEC_AUTH_GTC;
691 else if (strcmp(label, EAP_AUTH_TYPE_MD5) == 0)
692 sel_index = EAP_SEC_AUTH_MD5;
694 wifi_manager_ap_set_eap_auth_type(eap_data->ap,
695 __common_eap_connect_popup_get_wlan_auth_type(sel_index));
697 if (eap_data->sub_popup != NULL) {
698 evas_object_del(eap_data->sub_popup);
699 eap_data->sub_popup = NULL;
702 if (eap_data->eap_auth_item != NULL)
703 elm_genlist_item_update(eap_data->eap_auth_item);
706 static void _create_eap_auth_list(eap_connect_data_t *eap_data,
709 Elm_Object_Item *it = NULL;
710 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
711 Evas_Object *ctxpopup;
714 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
716 if (eap_data->sub_popup != NULL)
717 evas_object_del(eap_data->sub_popup);
719 ctxpopup = elm_ctxpopup_add(eap_data->win);
720 eap_data->sub_popup = ctxpopup;
721 elm_object_style_set(ctxpopup, "dropdown/list");
722 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
723 evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismissed_cb, eap_data);
724 elm_ctxpopup_direction_priority_set(ctxpopup,
725 ELM_CTXPOPUP_DIRECTION_DOWN,
726 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
727 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
728 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
730 while (list_eap_auth[i].name != NULL) {
731 if ((eap_type != EAP_SEC_TYPE_PEAP && eap_type != EAP_SEC_TYPE_FAST) ||
732 (eap_type == EAP_SEC_TYPE_PEAP && i != 1 &&
734 (eap_type == EAP_SEC_TYPE_FAST && i !=1 &&
736 it = elm_ctxpopup_item_append(ctxpopup, list_eap_auth[i].name,
737 NULL, _gl_eap_auth_sub_sel, eap_data);
739 elm_object_item_domain_text_translatable_set(it,
745 move_dropdown(eap_data, btn);
746 evas_object_show(ctxpopup);
749 static void _gl_eap_auth_btn_cb(void *data, Evas_Object *obj, void *event_info)
751 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
752 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
755 elm_genlist_item_selected_set(item, EINA_FALSE);
757 if (keypad_state == FALSE) {
758 _create_eap_auth_list(eap_data, obj);
760 click.btn_click[EAP_AUTH_BTN] = FALSE;
761 click.btn_obj[EAP_AUTH_BTN] = NULL;
763 click.btn_click[EAP_AUTH_BTN] = TRUE;
764 click.btn_obj[EAP_AUTH_BTN] = obj;
768 static char *_gl_eap_auth_text_get(void *data, Evas_Object *obj, const char *part)
770 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
772 if (!g_strcmp0(part, "elm.text.sub")) {
773 return g_strdup(sc(eap_data->str_pkg_name,
774 I18N_TYPE_Phase_2_authentication));
780 static Evas_Object *_gl_eap_auth_content_get(void *data,
781 Evas_Object *obj, const char *part)
783 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
784 eap_auth_t sel_sub_item_id = __common_eap_connect_popup_get_auth_type(eap_data->ap);
785 Evas_Object *btn = NULL;
786 Evas_Object *ly = NULL;
789 if (!strcmp(part, "elm.swallow.icon.0")) {
790 ly = elm_layout_add(obj);
791 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH, "eap_dropdown_button");
792 btn = elm_button_add(obj);
794 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
795 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
796 sc(PACKAGE, I18N_TYPE_None));
798 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
799 list_eap_auth[sel_sub_item_id].name);
802 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
803 elm_object_style_set(btn, "dropdown/label");
804 evas_object_propagate_events_set(btn, EINA_FALSE);
805 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
807 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
809 evas_object_smart_callback_add(btn, "clicked",
810 _gl_eap_auth_btn_cb, eap_data);
812 elm_layout_content_set(ly, "btn", btn);
818 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
820 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
824 Evas_Object *entry = NULL;
825 Elm_Object_Item *next_item = NULL;
828 switch (entry_info->entry_id) {
829 case ENTRY_TYPE_USER_ID:
830 eap_type = __common_eap_connect_popup_get_eap_type(
833 if (eap_type == EAP_SEC_TYPE_TLS) {
834 entry = elm_object_item_part_content_get(entry_info->item,
837 elm_object_focus_set(entry, EINA_FALSE);
840 next_item = elm_genlist_item_next_get(entry_info->item);
842 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
843 elm_genlist_item_select_mode_get(next_item) !=
844 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
845 entry = elm_object_item_part_content_get(
846 next_item, "elm.icon.entry");
848 elm_object_focus_set(entry, EINA_TRUE);
853 next_item = elm_genlist_item_next_get(next_item);
857 case ENTRY_TYPE_PASSWORD:
858 entry = elm_object_item_part_content_get(entry_info->item,
861 elm_object_focus_set(entry, EINA_FALSE);
868 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
870 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
874 if (elm_object_focus_get(obj)) {
875 if (elm_entry_is_empty(obj))
876 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
878 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
881 if (entry_info->entry_txt) {
882 g_free(entry_info->entry_txt);
883 entry_info->entry_txt = NULL;
886 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
888 if (entry_text != NULL && entry_text[0] != '\0')
889 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
894 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
896 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
903 if (elm_object_focus_get(obj)) {
904 if (elm_entry_is_empty(obj))
905 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
907 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
911 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
913 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
917 if (!elm_entry_is_empty(obj))
918 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
920 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
923 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
925 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
929 if (entry_info->entry_txt) {
930 g_free(entry_info->entry_txt);
931 entry_info->entry_txt = NULL;
934 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
935 if (entry_text != NULL && entry_text[0] != '\0')
936 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
940 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
941 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
944 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
947 common_utils_send_message_to_net_popup("Password length",
948 "Lengthy Password", "notification", NULL);
951 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
953 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
957 Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
959 elm_object_focus_set(entry, EINA_TRUE);
960 elm_entry_entry_set(entry, "");
964 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
966 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
970 if (!g_strcmp0(part, "elm.text.sub"))
971 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
976 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
978 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
982 if (g_strcmp0(part, "elm.swallow.content") == 0) {
983 Evas_Object *entry = NULL;
984 Evas_Object *box = NULL;
985 Evas_Object *tpad = NULL;
986 Evas_Object *lpad = NULL;
987 Evas_Object *label = NULL;
988 Evas_Object *layout = NULL;
989 Evas_Object *editfield = NULL;
990 char buf[MAX_LABEL_LENGTH] = {0, };
991 char *guide_txt = NULL;
992 char *accepted = NULL;
993 Eina_Bool hide_entry_txt = EINA_FALSE;
994 Elm_Input_Panel_Layout panel_type;
999 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
1001 static Elm_Entry_Filter_Limit_Size limit_filter_data;
1003 switch (entry_info->entry_id) {
1004 case ENTRY_TYPE_USER_ID:
1005 panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
1006 guide_txt = entry_info->guide_txt;
1008 if (eap_type == EAP_SEC_TYPE_TLS)
1009 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1011 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1014 case ENTRY_TYPE_PASSWORD:
1015 panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1016 guide_txt = entry_info->guide_txt;
1017 hide_entry_txt = EINA_TRUE;
1018 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1024 entry = elm_box_add(obj);
1025 elm_box_align_set(entry, 0.0, 0.0);
1027 tpad = evas_object_rectangle_add(entry);
1028 evas_object_size_hint_min_set(tpad, 0, ELM_SCALE_SIZE(10));
1029 evas_object_show(tpad);
1030 elm_box_pack_end(entry, tpad);
1032 box = elm_box_add(entry);
1033 evas_object_size_hint_align_set(box, 0.0, 0.0);
1034 elm_box_horizontal_set(box, EINA_TRUE);
1035 elm_box_pack_end(entry, box);
1036 evas_object_show(box);
1038 lpad = evas_object_rectangle_add(box);
1039 evas_object_size_hint_min_set(lpad, ELM_SCALE_SIZE(15), 0);
1040 evas_object_show(lpad);
1041 elm_box_pack_end(box, lpad);
1042 evas_object_show(box);
1044 label = elm_label_add(box);
1045 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=30>%s</font_size>",
1046 dgettext(PACKAGE, entry_info->title_txt));
1047 elm_object_text_set(label, buf);
1048 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1049 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
1050 elm_box_pack_end(box, label);
1051 evas_object_show(label);
1053 layout = elm_layout_add(entry);
1054 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
1055 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1056 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1058 editfield = elm_entry_add(layout);
1059 elm_entry_single_line_set(editfield, EINA_TRUE);
1060 elm_entry_scrollable_set(editfield, EINA_TRUE);
1061 elm_entry_password_set(editfield, hide_entry_txt);
1062 elm_entry_prediction_allow_set(editfield, EINA_FALSE);
1063 elm_entry_autocapital_type_set(editfield, ELM_AUTOCAPITAL_TYPE_NONE);
1065 elm_object_domain_translatable_part_text_set(editfield, "elm.guide",
1066 PACKAGE, guide_txt);
1067 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0))
1068 elm_entry_entry_set(editfield, entry_info->entry_txt);
1070 elm_entry_input_panel_layout_set(editfield, panel_type);
1071 elm_entry_input_panel_return_key_type_set(editfield, return_key_type);
1073 limit_filter_data.max_char_count = 200;
1074 elm_entry_markup_filter_append(editfield, elm_entry_filter_limit_size, &limit_filter_data);
1076 Elm_Entry_Filter_Accept_Set digits_filter_data;
1077 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1078 digits_filter_data.accepted = accepted;
1079 elm_entry_markup_filter_append(editfield, elm_entry_filter_accept_set, &digits_filter_data);
1081 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(editfield);
1082 if (imf_ctxt && entry_info->input_panel_cb) {
1083 ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1084 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1085 entry_info->input_panel_cb,
1086 entry_info->input_panel_cb_data);
1087 DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1090 evas_object_smart_callback_add(editfield, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1091 evas_object_smart_callback_add(editfield, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1092 evas_object_smart_callback_add(editfield, "changed", _gl_eap_entry_changed_cb, entry_info);
1093 evas_object_smart_callback_add(editfield, "focused", _gl_eap_entry_focused_cb, entry_info);
1094 evas_object_smart_callback_add(editfield, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1095 evas_object_smart_callback_add(editfield, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1097 elm_object_part_content_set(layout, "elm.swallow.content", editfield);
1098 evas_object_show(layout);
1099 elm_box_pack_end(entry, layout);
1101 evas_object_size_hint_min_set(entry, 0, ELM_SCALE_SIZE(height));
1102 elm_object_focus_set(entry, EINA_FALSE);
1103 evas_object_show(entry);
1105 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD)
1106 g_pwd_entry = editfield;
1109 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1110 Evas_Object *btn = elm_button_add(obj);
1111 elm_object_style_set(btn, "editfield_clear");
1112 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1119 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1121 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1122 if (entry_info == NULL)
1125 if (entry_info->entry_txt)
1126 g_free(entry_info->entry_txt);
1131 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1133 if (obj == NULL || g_pwd_entry == NULL)
1136 Eina_Bool state = elm_check_state_get(obj);
1138 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1140 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1141 elm_entry_cursor_end_set(g_pwd_entry);
1144 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1147 char *str_pkg_name = (char *)data;
1149 if (!strcmp("elm.text", part)) {
1151 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1158 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1159 Evas_Object *obj, const char *part)
1161 Evas_Object *check = NULL;
1163 if (!strcmp("elm.swallow.icon", part)) {
1164 check = elm_check_add(obj);
1165 evas_object_propagate_events_set(check, EINA_FALSE);
1167 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1168 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1169 evas_object_smart_callback_add(check, "changed",
1170 _chk_changed_cb, NULL);
1172 elm_object_focus_allow_set(check, EINA_FALSE);
1179 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1181 Elm_Object_Item *item = NULL;
1183 item = (Elm_Object_Item *)ei;
1187 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1189 elm_genlist_item_selected_set(item, EINA_FALSE);
1191 Eina_Bool state = elm_check_state_get(ck);
1192 elm_check_state_set(ck, !state);
1194 _chk_changed_cb(NULL, ck, NULL);
1197 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1199 elm_genlist_realized_items_update(obj);
1202 static void __common_eap_connect_popup_init_item_class(void *data)
1204 g_eap_type_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1205 g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1206 g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1207 g_eap_type_itc.func.state_get = NULL;
1208 g_eap_type_itc.func.del = NULL;
1210 g_eap_auth_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1211 g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1212 g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1213 g_eap_auth_itc.func.state_get = NULL;
1214 g_eap_auth_itc.func.del = NULL;
1216 g_eap_user_cert_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1217 g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1218 g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1219 g_eap_user_cert_itc.func.state_get = NULL;
1220 g_eap_user_cert_itc.func.del = NULL;
1222 g_eap_entry_itc.item_style = WIFI_GENLIST_FULL_STYLE;
1223 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1224 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1225 g_eap_entry_itc.func.state_get = NULL;
1226 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1228 g_eap_chkbox_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
1229 g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1230 g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1231 g_eap_chkbox_itc.func.state_get = NULL;
1232 g_eap_chkbox_itc.func.del = NULL;
1235 static gboolean __cert_extract_files(const char *cert_alias,
1236 eap_connect_data_t *eap_data)
1240 size_t cert_counts = 0;
1242 gchar *ca_cert_path = NULL;
1243 gchar *user_cert_path = NULL;
1244 gchar *privatekey_path = NULL;
1246 CertSvcInstance cert_instance;
1247 CertSvcString cert_alias_str;
1248 CertSvcCertificateList cert_list;
1249 CertSvcCertificate user_certificate;
1250 CertSvcCertificate ca_certificate;
1251 CertSvcCertificate *selected_certificate = NULL;
1253 EVP_PKEY *privatekey = NULL;
1255 ret = certsvc_instance_new(&cert_instance);
1256 if (ret != CERTSVC_SUCCESS) {
1257 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1260 ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1261 if (ret != CERTSVC_SUCCESS) {
1262 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1265 ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1266 if (ret != CERTSVC_SUCCESS) {
1267 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1270 ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1271 if (cert_counts < 1) {
1272 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1275 INFO_LOG(UG_NAME_NORMAL, "cert counts: %zd", cert_counts);
1276 selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1277 if (selected_certificate == NULL) {
1278 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1281 ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1282 if (ret != CERTSVC_SUCCESS) {
1283 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1286 cert_index = cert_counts - 1;
1288 selected_certificate[0] = user_certificate;
1290 ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1292 user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1293 cert_alias, EAP_TLS_USER_CERT_PATH);
1294 if ((fp = fopen(user_cert_path, "w")) == NULL)
1297 ret = PEM_write_X509(fp, x509);
1299 certsvc_certificate_free_x509(x509);
1300 INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1302 ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1303 EAP_TLS_CA_CERT_PATH);
1304 while (cert_index) {
1305 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1306 if (ret != CERTSVC_SUCCESS) {
1307 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1311 selected_certificate[cert_counts-cert_index] = ca_certificate;
1314 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1315 if ((fp = fopen(ca_cert_path, "a")) == NULL)
1318 ret = PEM_write_X509(fp, x509);
1320 certsvc_certificate_free_x509(x509);
1322 INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1323 ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1324 if (ret != CERTSVC_SUCCESS) {
1325 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1328 if (validity == 0) {
1329 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1333 ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1335 privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1336 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1338 if ((fp = fopen(privatekey_path, "w")) == NULL)
1341 ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1343 certsvc_pkcs12_free_evp_pkey(privatekey);
1344 INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1346 g_free(selected_certificate);
1347 certsvc_instance_free(cert_instance);
1349 eap_data->ca_cert_path = ca_cert_path;
1350 eap_data->user_cert_path = user_cert_path;
1351 eap_data->privatekey_path = privatekey_path;
1356 g_free(ca_cert_path);
1357 g_free(user_cert_path);
1358 g_free(privatekey_path);
1360 if (selected_certificate)
1361 g_free(selected_certificate);
1363 certsvc_instance_free(cert_instance);
1367 /* This creates EAP type, Auth type, CA certificate, User certificate,
1368 * User Id, Anonymous Id and Password items.
1370 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1371 eap_connect_data_t *eap_data)
1373 __COMMON_FUNC_ENTER__;
1374 Evas_Object* view_list = eap_data->genlist;
1375 Elm_Object_Item *insert_after_item = NULL;
1376 Elm_Object_Item *prev_item = NULL;
1377 common_utils_entry_info_t *edit_box_details;
1378 Eina_Bool auth_reqd = EINA_FALSE;
1379 Eina_Bool user_cert_reqd = EINA_FALSE;
1380 Eina_Bool id_reqd = EINA_FALSE;
1381 Eina_Bool pw_reqd = EINA_FALSE;
1383 if (NULL == eap_data->eap_type_item) {
1384 /* Create EAP method/type */
1385 eap_data->eap_type_item = elm_genlist_item_append(
1386 view_list, &g_eap_type_itc,
1388 ELM_GENLIST_ITEM_NONE,
1389 _gl_eap_item_sel_cb, eap_data);
1393 case EAP_SEC_TYPE_PEAP:
1394 insert_after_item = eap_data->eap_type_item;
1395 auth_reqd = EINA_TRUE;
1396 user_cert_reqd = EINA_FALSE;
1397 id_reqd = EINA_TRUE;
1398 pw_reqd = EINA_TRUE;
1400 case EAP_SEC_TYPE_TLS:
1401 insert_after_item = eap_data->eap_type_item;
1402 auth_reqd = EINA_FALSE;
1403 user_cert_reqd = EINA_TRUE;
1404 id_reqd = EINA_TRUE;
1405 pw_reqd = EINA_FALSE;
1407 case EAP_SEC_TYPE_TTLS:
1408 insert_after_item = eap_data->eap_type_item;
1409 auth_reqd = EINA_TRUE;
1410 user_cert_reqd = EINA_FALSE;
1411 id_reqd = EINA_TRUE;
1412 pw_reqd = EINA_TRUE;
1414 case EAP_SEC_TYPE_SIM:
1415 insert_after_item = eap_data->eap_type_item;
1416 auth_reqd = EINA_FALSE;
1417 user_cert_reqd = EINA_FALSE;
1418 id_reqd = EINA_FALSE;
1419 pw_reqd = EINA_FALSE;
1421 case EAP_SEC_TYPE_AKA:
1422 _delete_eap_entry_items(eap_data);
1423 insert_after_item = eap_data->eap_type_item;
1424 auth_reqd = EINA_FALSE;
1425 user_cert_reqd = EINA_FALSE;
1426 id_reqd = EINA_FALSE;
1427 pw_reqd = EINA_FALSE;
1429 case EAP_SEC_TYPE_AKA_PRIME:
1430 _delete_eap_entry_items(eap_data);
1431 insert_after_item = eap_data->eap_type_item;
1432 auth_reqd = EINA_FALSE;
1433 user_cert_reqd = EINA_FALSE;
1434 id_reqd = EINA_FALSE;
1435 pw_reqd = EINA_FALSE;
1437 case EAP_SEC_TYPE_FAST:
1438 insert_after_item = eap_data->eap_type_item;
1439 auth_reqd = EINA_TRUE;
1440 user_cert_reqd = EINA_FALSE;
1441 id_reqd = EINA_TRUE;
1442 pw_reqd = EINA_TRUE;
1444 case EAP_SEC_TYPE_PWD:
1445 insert_after_item = eap_data->eap_type_item;
1446 auth_reqd = EINA_FALSE;
1447 user_cert_reqd = EINA_FALSE;
1448 id_reqd = EINA_TRUE;
1449 pw_reqd = EINA_TRUE;
1455 if (auth_reqd == EINA_TRUE) {
1456 if (eap_data->eap_auth_item == NULL) {
1457 /* Add EAP phase2 authentication */
1458 eap_data->eap_auth_item = elm_genlist_item_insert_after(
1459 view_list, &g_eap_auth_itc, eap_data, NULL,
1460 insert_after_item, ELM_GENLIST_ITEM_NONE,
1461 _gl_eap_item_sel_cb, eap_data);
1464 _delete_eap_auth_item(eap_data);
1467 if (user_cert_reqd == EINA_TRUE) {
1468 if (eap_data->eap_user_cert_item == NULL) {
1469 prev_item = eap_data->eap_type_item;
1471 /* Add User certificate */
1472 eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1473 view_list, &g_eap_user_cert_itc, eap_data, NULL,
1474 prev_item, ELM_GENLIST_ITEM_NONE,
1475 _gl_eap_item_sel_cb, eap_data);
1478 _delete_eap_user_cert_item(eap_data);
1481 if (id_reqd == EINA_TRUE) {
1482 if (eap_data->eap_id_item == NULL) {
1483 if (new_type == EAP_SEC_TYPE_PEAP ||
1484 new_type == EAP_SEC_TYPE_TTLS) {
1485 prev_item = eap_data->eap_auth_item;
1486 } else if(new_type == EAP_SEC_TYPE_FAST ||
1487 new_type == EAP_SEC_TYPE_PWD) {
1488 prev_item = eap_data->eap_type_item;
1491 prev_item = eap_data->eap_user_cert_item;
1495 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1496 if (edit_box_details == NULL)
1499 edit_box_details->ap = eap_data->ap;
1500 edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1501 edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1502 edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1503 edit_box_details->item = elm_genlist_item_insert_after(
1504 view_list, &g_eap_entry_itc, edit_box_details,
1506 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1507 eap_data->eap_id_item = edit_box_details->item;
1510 _delete_eap_id_item(eap_data);
1513 if (pw_reqd == EINA_TRUE) {
1514 if (eap_data->eap_pw_item == NULL) {
1515 /* Add EAP Password */
1516 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1517 if (edit_box_details == NULL)
1520 edit_box_details->ap = eap_data->ap;
1521 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1522 edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1523 edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1524 edit_box_details->item = elm_genlist_item_insert_after(
1525 view_list, &g_eap_entry_itc,
1526 edit_box_details, NULL,
1527 eap_data->eap_id_item,
1528 ELM_GENLIST_ITEM_NONE,
1529 _gl_editbox_sel_cb, NULL);
1530 eap_data->eap_pw_item = edit_box_details->item;
1532 _update_eap_id_item_enter_key(eap_data);
1535 if (eap_data->eap_chkbox_item == NULL) {
1536 /* Add Show Password checkbox */
1537 eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1538 view_list, &g_eap_chkbox_itc,
1539 eap_data->str_pkg_name, NULL,
1540 eap_data->eap_pw_item,
1541 ELM_GENLIST_ITEM_NONE,
1542 _gl_eap_chkbox_sel, NULL);
1545 _delete_eap_pw_items(eap_data);
1548 __COMMON_FUNC_EXIT__;
1552 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1554 if (eap_data->eap_id_item == NULL)
1557 Evas_Object *entry = NULL;
1558 eap_type_t eap_type;
1560 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1561 entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1564 if (eap_type == EAP_SEC_TYPE_TLS) {
1565 elm_entry_input_panel_return_key_type_set(entry,
1566 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1568 elm_entry_input_panel_return_key_type_set(entry,
1569 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1574 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1576 __COMMON_FUNC_ENTER__;
1578 if (eap_data->eap_auth_item != NULL) {
1579 elm_object_item_del(eap_data->eap_auth_item);
1580 eap_data->eap_auth_item = NULL;
1583 __COMMON_FUNC_EXIT__;
1587 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1589 __COMMON_FUNC_ENTER__;
1591 if (eap_data->eap_user_cert_item != NULL) {
1592 elm_object_item_del(eap_data->eap_user_cert_item);
1593 eap_data->eap_user_cert_item = NULL;
1596 __COMMON_FUNC_EXIT__;
1600 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1602 __COMMON_FUNC_ENTER__;
1604 if (eap_data->eap_id_item != NULL) {
1605 elm_object_item_del(eap_data->eap_id_item);
1606 eap_data->eap_id_item = NULL;
1609 __COMMON_FUNC_EXIT__;
1613 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1615 __COMMON_FUNC_ENTER__;
1617 _update_eap_id_item_enter_key(eap_data);
1619 if (eap_data->eap_pw_item != NULL) {
1620 elm_object_item_del(eap_data->eap_pw_item);
1621 eap_data->eap_pw_item = NULL;
1624 if (eap_data->eap_chkbox_item) {
1625 elm_object_item_del(eap_data->eap_chkbox_item);
1626 eap_data->eap_chkbox_item = NULL;
1629 __COMMON_FUNC_EXIT__;
1633 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1635 __COMMON_FUNC_ENTER__;
1637 if (eap_data->eap_auth_item != NULL) {
1638 elm_object_item_del(eap_data->eap_auth_item);
1639 eap_data->eap_auth_item = NULL;
1642 if (eap_data->eap_user_cert_item != NULL) {
1643 elm_object_item_del(eap_data->eap_user_cert_item);
1644 eap_data->eap_user_cert_item = NULL;
1647 if (eap_data->eap_id_item != NULL) {
1648 elm_object_item_del(eap_data->eap_id_item);
1649 eap_data->eap_id_item = NULL;
1652 if (eap_data->eap_pw_item != NULL) {
1653 elm_object_item_del(eap_data->eap_pw_item);
1654 eap_data->eap_pw_item = NULL;
1657 if (eap_data->eap_chkbox_item != NULL) {
1658 elm_object_item_del(eap_data->eap_chkbox_item);
1659 eap_data->eap_chkbox_item = NULL;
1662 __COMMON_FUNC_EXIT__;
1666 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1668 __COMMON_FUNC_ENTER__;
1669 assertm_if(NULL == parent, "NULL!!");
1671 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1672 Evas_Object* view_list = NULL;
1673 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1674 retvm_if(eap_data == NULL, NULL);
1676 __common_eap_connect_popup_init_item_class(eap_data);
1678 eap_data->eap_done_ok = FALSE;
1679 eap_data->genlist = view_list = elm_genlist_add(parent);
1680 //elm_genlist_realization_mode_set(view_list, EINA_TRUE);
1681 elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1682 elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1684 evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1686 evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1688 /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1689 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1690 wifi_manager_ap_set_eap_type(eap_data->ap,
1691 (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1692 WIFI_MANAGER_EAP_TYPE_PEAP :
1693 __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1695 wifi_manager_ap_set_eap_auth_type(eap_data->ap,
1696 WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2);
1700 /* Create the entry items */
1701 _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1703 evas_object_smart_callback_add(view_list, "language,changed",
1704 gl_lang_changed, NULL);
1706 __COMMON_FUNC_EXIT__;
1710 static Eina_Bool _enable_scan_updates_cb(void *data)
1712 /* Lets enable the scan updates */
1713 wlan_manager_enable_scan_result_update();
1715 /* Reset the ecore timer handle */
1716 common_util_manager_ecore_scan_update_timer_reset();
1718 return ECORE_CALLBACK_CANCEL;
1721 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1723 if (eap_data == NULL)
1726 if (eap_data->conf != NULL) {
1727 evas_object_smart_callback_del(eap_data->conf,
1728 "virtualkeypad,state,on",
1729 _eap_popup_keypad_on_cb);
1730 evas_object_smart_callback_del(eap_data->conf,
1731 "virtualkeypad,state,off",
1732 _eap_popup_keypad_off_cb);
1735 if (eap_data->ssid != NULL) {
1736 g_free(eap_data->ssid);
1737 eap_data->ssid = NULL;
1740 if (eap_data->cert_alias) {
1741 g_free(eap_data->cert_alias);
1742 eap_data->cert_alias = NULL;
1745 if (eap_data->ca_cert_path) {
1746 g_free(eap_data->ca_cert_path);
1747 eap_data->ca_cert_path = NULL;
1750 if (eap_data->user_cert_path) {
1751 g_free(eap_data->user_cert_path);
1752 eap_data->user_cert_path = NULL;
1755 if (eap_data->privatekey_path) {
1756 g_free(eap_data->privatekey_path);
1757 eap_data->privatekey_path = NULL;
1760 wifi_manager_ap_destroy(eap_data->ap);
1761 eap_data->ap = NULL;
1763 if (eap_data->info_popup) {
1764 evas_object_del(eap_data->info_popup);
1765 eap_data->info_popup = NULL;
1768 if (eap_data->popup != NULL) {
1769 evas_object_hide(eap_data->popup);
1770 evas_object_del(eap_data->popup);
1773 if (_eap_view_deref_cb != NULL) {
1774 _eap_view_deref_cb();
1775 _eap_view_deref_cb = NULL;
1778 /* A delay is needed to get the smooth Input panel closing animation effect */
1779 common_util_managed_ecore_scan_update_timer_add(0.1,
1780 _enable_scan_updates_cb, NULL);
1783 static void __common_eap_connect_destroy_cb(void *data, Evas_Object *obj,
1786 __common_eap_connect_cleanup((eap_connect_data_t *)data);
1789 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1791 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1793 if (eap_data->info_popup != NULL) {
1794 evas_object_del(eap_data->info_popup);
1795 eap_data->info_popup = NULL;
1799 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1802 char *str_id = NULL;
1803 char *str_pw = NULL;
1804 bool favorite = FALSE;
1805 wifi_manager_eap_type_e eap_type;
1806 wifi_manager_eap_auth_type_e eap_auth_type;
1807 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1808 popup_btn_info_t popup_data;
1810 __COMMON_FUNC_ENTER__;
1811 if (eap_data->eap_done_ok == TRUE) {
1812 __COMMON_FUNC_EXIT__;
1816 eap_data->eap_done_ok = TRUE;
1818 wifi_manager_ap_get_eap_type(eap_data->ap, &eap_type);
1819 wifi_manager_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1821 wifi_manager_ap_is_favorite(eap_data->ap, &favorite);
1822 if (favorite == TRUE) {
1823 wlan_manager_forget(eap_data->ap);
1824 wifi_manager_ap_refresh(eap_data->ap);
1826 wifi_manager_ap_set_eap_type(eap_data->ap, eap_type);
1827 wifi_manager_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1830 wifi_manager_ap_set_eap_ca_cert_file(eap_data->ap, "");
1831 wifi_manager_ap_set_eap_client_cert_file(eap_data->ap, "");
1832 wifi_manager_ap_set_eap_private_key_info(eap_data->ap, "", "");
1835 case WIFI_MANAGER_EAP_TYPE_PEAP:
1836 case WIFI_MANAGER_EAP_TYPE_TTLS:
1838 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1839 if (str_id == NULL || str_id[0] == '\0') {
1840 memset(&popup_data, 0, sizeof(popup_data));
1841 popup_data.title_txt = eap_data->ssid;
1842 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1843 popup_data.btn1_cb = _info_popup_ok_cb;
1844 popup_data.btn1_data = eap_data;
1845 popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1846 eap_data->eap_done_ok = FALSE;
1847 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1855 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1856 if (str_pw == NULL || str_pw[0] == '\0') {
1857 memset(&popup_data, 0, sizeof(popup_data));
1858 popup_data.title_txt = eap_data->ssid;
1859 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1860 popup_data.btn1_cb = _info_popup_ok_cb;
1861 popup_data.btn1_data = eap_data;
1862 popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1863 eap_data->eap_done_ok = FALSE;
1864 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1873 wifi_manager_ap_set_eap_type(eap_data->ap, eap_type);
1874 wifi_manager_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1875 wifi_manager_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1878 case WIFI_MANAGER_EAP_TYPE_TLS:
1879 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1880 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1882 wifi_manager_ap_set_eap_type(eap_data->ap, eap_type);
1883 wifi_manager_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1884 wifi_manager_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1885 wifi_manager_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1886 wifi_manager_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1887 wifi_manager_ap_set_eap_private_key_info(eap_data->ap,
1888 eap_data->privatekey_path, NULL);
1891 case WIFI_MANAGER_EAP_TYPE_SIM:
1892 case WIFI_MANAGER_EAP_TYPE_AKA:
1893 case WIFI_MANAGER_EAP_TYPE_AKA_PRIME:
1894 wifi_manager_ap_set_eap_type(eap_data->ap, eap_type);
1896 case WIFI_MANAGER_EAP_TYPE_FAST:
1897 case WIFI_MANAGER_EAP_TYPE_PWD:
1898 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1899 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1901 wifi_manager_ap_set_eap_type(eap_data->ap, eap_type);
1902 wifi_manager_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1903 wifi_manager_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1907 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1911 if (eap_data->is_hidden) {
1912 wifi_manager_ap_h hidden_ap;
1914 wifi_manager_ap_get_essid(eap_data->ap, &ssid);
1915 wlan_manager_ap_hidden_create(ssid, &hidden_ap);
1919 case WIFI_MANAGER_EAP_TYPE_PEAP:
1920 case WIFI_MANAGER_EAP_TYPE_TTLS:
1921 wifi_manager_ap_set_eap_type(hidden_ap, eap_type);
1922 wifi_manager_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1923 wifi_manager_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1925 case WIFI_MANAGER_EAP_TYPE_TLS:
1926 wifi_manager_ap_set_eap_type(hidden_ap, eap_type);
1927 wifi_manager_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1928 wifi_manager_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1929 wifi_manager_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1930 wifi_manager_ap_set_eap_client_cert_file(hidden_ap, eap_data->user_cert_path);
1931 wifi_manager_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1933 case WIFI_MANAGER_EAP_TYPE_SIM:
1934 case WIFI_MANAGER_EAP_TYPE_AKA:
1935 case WIFI_MANAGER_EAP_TYPE_AKA_PRIME:
1936 case WIFI_MANAGER_EAP_TYPE_FAST:
1937 case WIFI_MANAGER_EAP_TYPE_PWD:
1940 wlan_manager_connect(hidden_ap);
1942 wlan_manager_connect(eap_data->ap);
1944 __common_eap_connect_cleanup(eap_data);
1949 __COMMON_FUNC_EXIT__;
1952 static gboolean delay_create_context_popup(gpointer data)
1954 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1956 if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1957 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1959 click.btn_click[EAP_CERT_BTN] = FALSE;
1960 click.btn_obj[EAP_CERT_BTN] = NULL;
1961 } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1962 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1964 click.btn_click[EAP_AUTH_BTN] = FALSE;
1965 click.btn_obj[EAP_AUTH_BTN] = NULL;
1966 } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1967 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1969 click.btn_click[EAP_TYPE_BTN] = FALSE;
1970 click.btn_obj[EAP_TYPE_BTN] = NULL;
1975 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1981 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1983 keypad_state = FALSE;
1985 common_util_managed_idle_add(delay_create_context_popup,
1986 (gpointer)eap_data);
1988 INFO_LOG(UG_NAME_NORMAL, "Keypad is down");
1991 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1997 keypad_state = TRUE;
1998 INFO_LOG(UG_NAME_NORMAL, "Keypad is up");
2001 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
2002 Evas_Object *conf, const char *pkg_name,
2003 wifi_device_info_t *device_info, void (*deref_func)(void))
2005 __COMMON_FUNC_ENTER__;
2007 Evas_Object *popup = NULL;
2008 Evas_Object *list = NULL;
2010 if (layout_main == NULL || device_info == NULL || pkg_name == NULL)
2013 eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
2014 if (eap_data == NULL)
2017 eap_data->str_pkg_name = pkg_name;
2018 eap_data->win = win;
2019 eap_data->conf = conf;
2020 eap_data->ssid = g_strdup(device_info->ssid);
2022 if (device_info->is_hidden == true) {
2023 /* Hidden Wi-Fi network */
2026 wifi_manager_ap_get_essid(device_info->ap, &ssid);
2029 g_free(eap_data->ssid);
2034 wlan_manager_ap_hidden_create(ssid, &(eap_data->ap));
2037 eap_data->is_hidden = TRUE;
2039 /* Clone the Wi-Fi AP handle */
2040 wifi_manager_ap_clone(&(eap_data->ap), device_info->ap);
2043 /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
2044 wlan_manager_disable_scan_result_update();
2046 _eap_view_deref_cb = deref_func;
2047 click.btn_click[EAP_TYPE_BTN] = FALSE;
2048 click.btn_obj[EAP_TYPE_BTN] = NULL;
2049 click.btn_click[EAP_AUTH_BTN] = FALSE;
2050 click.btn_obj[EAP_AUTH_BTN] = NULL;
2051 click.btn_click[EAP_CERT_BTN] = FALSE;
2052 click.btn_obj[EAP_CERT_BTN] = NULL;
2053 keypad_state = FALSE;
2055 popup_btn_info_t popup_btn_data;
2056 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
2058 popup_btn_data.title_txt = device_info->ssid;
2059 popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
2060 popup_btn_data.btn1_data = eap_data;
2061 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
2062 popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
2063 popup_btn_data.btn2_data = eap_data;
2064 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
2066 popup = common_utils_show_info_popup(layout_main,
2068 eap_data->popup = popup;
2069 evas_object_show(popup);
2070 elm_object_focus_set(popup, EINA_TRUE);
2072 /* Create an EAP connect view list */
2073 list = _create_list(popup, eap_data);
2074 elm_object_content_set(popup, list);
2076 evas_object_smart_callback_add(eap_data->conf,
2077 "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
2079 evas_object_smart_callback_add(eap_data->conf,
2080 "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
2083 __COMMON_FUNC_EXIT__;
2087 static wifi_manager_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
2089 wifi_manager_eap_type_e wlan_eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
2091 case EAP_SEC_TYPE_PEAP:
2092 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_PEAP;
2094 case EAP_SEC_TYPE_TLS:
2095 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_TLS;
2097 case EAP_SEC_TYPE_TTLS:
2098 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_TTLS;
2100 case EAP_SEC_TYPE_SIM:
2101 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_SIM;
2103 case EAP_SEC_TYPE_AKA:
2104 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_AKA;
2106 case EAP_SEC_TYPE_AKA_PRIME:
2107 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_AKA_PRIME;
2109 case EAP_SEC_TYPE_FAST:
2110 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_FAST;
2112 case EAP_SEC_TYPE_PWD:
2113 wlan_eap_type = WIFI_MANAGER_EAP_TYPE_PWD;
2116 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2120 return wlan_eap_type;
2123 static wifi_manager_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2125 wifi_manager_eap_auth_type_e wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
2126 switch (auth_type) {
2127 case EAP_SEC_AUTH_NONE:
2128 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_NONE;
2130 case EAP_SEC_AUTH_PAP:
2131 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_PAP;
2133 case EAP_SEC_AUTH_MSCHAP:
2134 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP;
2136 case EAP_SEC_AUTH_MSCHAPV2:
2137 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2;
2139 case EAP_SEC_AUTH_GTC:
2140 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_GTC;
2142 case EAP_SEC_AUTH_MD5:
2143 wlan_auth_type = WIFI_MANAGER_EAP_AUTH_TYPE_MD5;
2146 /* This case should never occur */
2147 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2150 return wlan_auth_type;
2153 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_manager_ap_h ap)
2155 wifi_manager_eap_type_e wlan_eap_type = 0;
2156 int ret = wifi_manager_ap_get_eap_type(ap, &wlan_eap_type);
2157 if (WIFI_MANAGER_ERROR_OPERATION_FAILED == ret)
2158 ret = wifi_manager_ap_set_eap_type(ap, WIFI_MANAGER_EAP_TYPE_PEAP);
2160 if (WIFI_MANAGER_ERROR_NONE != ret) {
2161 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2162 return EAP_SEC_TYPE_UNKNOWN;
2165 switch (wlan_eap_type) {
2166 case WIFI_MANAGER_EAP_TYPE_PEAP: /**< EAP PEAP type */
2167 return EAP_SEC_TYPE_PEAP;
2169 case WIFI_MANAGER_EAP_TYPE_TLS: /**< EAP TLS type */
2170 return EAP_SEC_TYPE_TLS;
2172 case WIFI_MANAGER_EAP_TYPE_TTLS: /**< EAP TTLS type */
2173 return EAP_SEC_TYPE_TTLS;
2175 case WIFI_MANAGER_EAP_TYPE_SIM: /**< EAP SIM type */
2176 return EAP_SEC_TYPE_SIM;
2178 case WIFI_MANAGER_EAP_TYPE_AKA: /**< EAP AKA type */
2179 return EAP_SEC_TYPE_AKA;
2181 case WIFI_MANAGER_EAP_TYPE_AKA_PRIME: /**< EAP AKA PRIME type */
2182 return EAP_SEC_TYPE_AKA_PRIME;
2184 case WIFI_MANAGER_EAP_TYPE_FAST: /**< EAP FAST type */
2185 return EAP_SEC_TYPE_FAST;
2187 case WIFI_MANAGER_EAP_TYPE_PWD: /**< EAP PWD type */
2188 return EAP_SEC_TYPE_PWD;
2191 return EAP_SEC_TYPE_PEAP;
2193 return EAP_SEC_TYPE_PEAP;
2196 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_manager_ap_h ap)
2198 wifi_manager_eap_auth_type_e wlan_auth_type = 0;
2199 int ret = wifi_manager_ap_get_eap_auth_type(ap, &wlan_auth_type);
2200 if (WIFI_MANAGER_ERROR_OPERATION_FAILED == ret)
2201 ret = wifi_manager_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2203 if (WIFI_MANAGER_ERROR_NONE != ret) {
2204 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2205 return EAP_SEC_AUTH_NONE;
2208 switch (wlan_auth_type) {
2209 case WIFI_MANAGER_EAP_AUTH_TYPE_NONE: /**< EAP phase2 authentication none */
2210 return EAP_SEC_AUTH_NONE;
2212 case WIFI_MANAGER_EAP_AUTH_TYPE_PAP: /**< EAP phase2 authentication PAP */
2213 return EAP_SEC_AUTH_PAP;
2215 case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAP: /**< EAP phase2 authentication MSCHAP */
2216 return EAP_SEC_AUTH_MSCHAP;
2218 case WIFI_MANAGER_EAP_AUTH_TYPE_MSCHAPV2: /**< EAP phase2 authentication MSCHAPv2 */
2219 return EAP_SEC_AUTH_MSCHAPV2;
2221 case WIFI_MANAGER_EAP_AUTH_TYPE_GTC: /**< EAP phase2 authentication GTC */
2222 return EAP_SEC_AUTH_GTC;
2224 case WIFI_MANAGER_EAP_AUTH_TYPE_MD5: /**< EAP phase2 authentication MD5 */
2225 return EAP_SEC_AUTH_MD5;
2228 return EAP_SEC_AUTH_NONE;
2230 return EAP_SEC_AUTH_NONE;
2233 static char *_eap_info_get_user_cert_alias(wifi_manager_ap_h ap)
2237 char *filename = NULL;
2238 char *cert_name = NULL;
2240 int filename_len = 0;
2242 wifi_manager_ap_get_eap_client_cert_file(ap, &path);
2246 filename = strrchr(path, '/');
2247 if (filename == NULL) {
2248 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2253 cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2254 if (cert_name == NULL) {
2255 /* For truncated path, available filename will be followed
2256 * with ellipsis(...) & excluding any remaining part of
2257 * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2258 filename_len = strlen(filename);
2259 alias = g_try_malloc0(filename_len - 10);
2260 if (alias == NULL) {
2261 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2264 g_strlcpy(alias, filename, filename_len - 13);
2265 g_strlcat(alias, "...", filename_len - 10);
2266 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2271 alias_len = cert_name - filename;
2273 alias = g_try_malloc0(alias_len + 1);
2274 if (alias == NULL) {
2275 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2279 g_strlcpy(alias, filename, alias_len + 1);
2280 INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2288 /* This creates Auth type, ID, Anonymous Id and Password items
2289 * This function should be called after creating the EAP type item
2291 eap_info_list_t *eap_info_append_items(wifi_manager_ap_h ap, Evas_Object* view_list,
2292 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2293 void *input_panel_cb_data)
2295 __COMMON_FUNC_ENTER__;
2297 eap_type_t eap_type;
2298 eap_auth_t auth_type;
2299 char *temp_str = NULL;
2300 Eina_Bool append_continue = TRUE;
2301 eap_info_list_t *eap_info_list_data = NULL;
2302 Elm_Object_Item* item = NULL;
2303 if (!view_list || !str_pkg_name || !ap) {
2304 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2308 eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2309 if (eap_info_list_data == NULL)
2312 eap_info_list_data->ap = ap;
2313 eap_type = __common_eap_connect_popup_get_eap_type(ap);
2314 auth_type = __common_eap_connect_popup_get_auth_type(ap);
2316 item = common_utils_add_2_line_txt_disabled_item(view_list,
2317 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2318 sc(str_pkg_name, I18N_TYPE_EAP_method),
2319 list_eap_type[eap_type].name);
2320 eap_info_list_data->eap_method_item = item;
2322 eap_info_list_data->eap_type = eap_type;
2325 case EAP_SEC_TYPE_UNKNOWN:
2326 case EAP_SEC_TYPE_PEAP:
2327 case EAP_SEC_TYPE_TLS:
2328 case EAP_SEC_TYPE_TTLS:
2329 case EAP_SEC_TYPE_SIM:
2330 case EAP_SEC_TYPE_AKA:
2331 case EAP_SEC_TYPE_AKA_PRIME:
2332 case EAP_SEC_TYPE_FAST:
2333 case EAP_SEC_TYPE_PWD:
2336 append_continue = FALSE;
2340 if (append_continue) {
2341 if (eap_type == EAP_SEC_TYPE_PEAP ||
2342 eap_type == EAP_SEC_TYPE_TTLS) {
2343 /* Add EAP phase2 authentication */
2344 item = common_utils_add_2_line_txt_disabled_item(view_list,
2345 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2346 sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2347 list_eap_auth[auth_type].name);
2348 eap_info_list_data->eap_auth_item = item;
2351 if (eap_type == EAP_SEC_TYPE_TLS) {
2352 /* Add User certificate */
2353 temp_str = _eap_info_get_user_cert_alias(ap);
2355 if (temp_str == NULL || strlen(temp_str) == 0) {
2356 if (temp_str != NULL)
2359 temp_str = g_strdup(sc(str_pkg_name,
2360 I18N_TYPE_Unspecified));
2363 item = common_utils_add_2_line_txt_disabled_item(view_list,
2364 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2365 sc(str_pkg_name, I18N_TYPE_User_Certificate),
2367 eap_info_list_data->user_cert_item = item;
2374 if (wifi_manager_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set) != WIFI_MANAGER_ERROR_NONE) {
2375 ERROR_LOG(UG_NAME_ERR, "Faile to get EAP passphrase!");
2376 g_free(eap_info_list_data);
2379 item = common_utils_add_2_line_txt_disabled_item(view_list,
2380 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2381 sc(str_pkg_name, I18N_TYPE_Identity),
2383 eap_info_list_data->id_item = item;
2387 common_utils_entry_info_t *edit_box_details;
2389 /* Add EAP Password */
2390 g_eap_entry_itc.item_style = "entry.main";
2391 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2392 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2393 g_eap_entry_itc.func.state_get = NULL;
2394 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2396 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2397 if (edit_box_details == NULL) {
2398 g_free(eap_info_list_data);
2402 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2403 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2404 edit_box_details->entry_txt = NULL;
2405 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2406 edit_box_details->input_panel_cb = input_panel_cb;
2407 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2408 edit_box_details->item = elm_genlist_item_append(view_list,
2409 &g_eap_entry_itc, edit_box_details, NULL,
2410 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2411 elm_genlist_item_select_mode_set(edit_box_details->item,
2412 ELM_OBJECT_SELECT_MODE_NONE);
2413 eap_info_list_data->pswd_item = edit_box_details->item;
2417 __COMMON_FUNC_EXIT__;
2418 return eap_info_list_data;
2422 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2424 if (!eap_info_list_data) {
2425 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2428 char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2430 wifi_manager_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2436 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2438 if (!eap_info_list_data) {
2439 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2443 g_free(eap_info_list_data);
2446 void eap_connect_data_free(eap_connect_data_t *eap_data)
2448 __common_eap_connect_cleanup(eap_data);