4 * Copyright 2012 Samsung Electronics Co., Ltd
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
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-service.h>
23 #include <cert-svc/cpkcs12.h>
24 #include <cert-svc/cprimitives.h>
25 #include <ui-gadget.h>
26 #include <efl_assist.h>
27 #include <vconf-keys.h>
28 #include <glib/gstdio.h>
29 #include <efl_extension.h>
33 #include "common_eap_connect.h"
34 #include "i18nmanager.h"
35 #include "common_utils.h"
36 #include "common_ip_info.h"
38 #define GENLIST_ITEM_HEIGHT 96
40 #define EAP_TLS_PATH "/tmp/"
41 #define EAP_TLS_CA_CERT_PATH "ca_cert.pem"
42 #define EAP_TLS_USER_CERT_PATH "user_cert.pem"
43 #define EAP_TLS_PRIVATEKEY_PATH "privatekey.pem"
45 #define EAP_TYPE_UNKNOWN "UNKNOWN"
46 #define EAP_TYPE_PEAP "PEAP"
47 #define EAP_TYPE_TLS "TLS"
48 #define EAP_TYPE_TTLS "TTLS"
49 #define EAP_TYPE_SIM "SIM"
50 #define EAP_TYPE_AKA "AKA"
52 #define EAP_AUTH_TYPE_PAP "PAP"
53 #define EAP_AUTH_TYPE_MSCHAP "MSCHAP"
54 #define EAP_AUTH_TYPE_MSCHAPV2 "MSCHAPV2"
55 #define EAP_AUTH_TYPE_GTC "GTC"
56 #define EAP_AUTH_TYPE_MD5 "MD5"
57 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
60 EAP_SEC_TYPE_UNKNOWN = 0,
70 EAP_SEC_AUTH_NONE = 0,
73 EAP_SEC_AUTH_MSCHAPV2,
87 Elm_Genlist_Item_Type flags;
92 Evas_Object *btn_obj[3];
95 struct eap_info_list {
98 Elm_Object_Item *eap_method_item;
99 Elm_Object_Item *eap_auth_item;
100 Elm_Object_Item *user_cert_item;
101 Elm_Object_Item *id_item;
102 Elm_Object_Item *pswd_item;
105 static const _Expand_List_t list_eap_type[] = {
106 {"UNKNOWN", ELM_GENLIST_ITEM_NONE},
107 {"PEAP", ELM_GENLIST_ITEM_NONE},
108 {"TLS", ELM_GENLIST_ITEM_NONE},
109 {"TTLS", ELM_GENLIST_ITEM_NONE},
110 {"SIM", ELM_GENLIST_ITEM_NONE},
111 {"AKA", ELM_GENLIST_ITEM_NONE},
112 {NULL, ELM_GENLIST_ITEM_NONE}
115 static const _Expand_List_t list_eap_auth[] = {
116 {"IDS_ST_BODY_NONE", ELM_GENLIST_ITEM_NONE},
117 {"PAP", ELM_GENLIST_ITEM_NONE},
118 {"MSCHAP", ELM_GENLIST_ITEM_NONE},
119 {"MSCHAPV2", ELM_GENLIST_ITEM_NONE},
120 {"GTC", ELM_GENLIST_ITEM_NONE},
121 {NULL, ELM_GENLIST_ITEM_NONE}
124 static unsigned short selected_cert = 0;
126 struct common_eap_connect_data {
127 Elm_Object_Item *eap_type_item;
128 Elm_Object_Item *eap_auth_item;
129 Elm_Object_Item *eap_user_cert_item;
130 Elm_Object_Item *eap_id_item;
131 Elm_Object_Item *eap_pw_item;
132 Elm_Object_Item *eap_chkbox_item;
134 Evas_Object *sub_popup;
135 Evas_Object *info_popup;
136 Evas_Object *genlist;
137 Eina_Bool eap_done_ok;
140 const char *str_pkg_name;
144 char *user_cert_path;
145 char *privatekey_path;
146 GSList *cert_candidates;
147 Evas_Object *confirm;
155 static Elm_Genlist_Item_Class g_eap_type_itc;
156 static Elm_Genlist_Item_Class g_eap_auth_itc;
157 static Elm_Genlist_Item_Class g_eap_user_cert_itc;
158 static Elm_Genlist_Item_Class g_eap_entry_itc;
159 static Elm_Genlist_Item_Class g_eap_chkbox_itc;
160 static Evas_Object *g_pwd_entry = NULL;
161 static gboolean keypad_state = FALSE;
162 static _Btn_click_t click;
164 static void (*_eap_view_deref_cb)(void) = NULL;
166 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type, eap_connect_data_t *eap_data);
167 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data);
168 static void _delete_eap_auth_item(eap_connect_data_t *eap_data);
169 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data);
170 static void _delete_eap_id_item(eap_connect_data_t *eap_data);
171 static void _delete_eap_pw_items(eap_connect_data_t *eap_data);
172 static void _delete_eap_entry_items(eap_connect_data_t *eap_data);
173 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap);
174 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap);
175 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type);
176 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type);
177 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
178 static gboolean __cert_extract_files(const char *cert_alias,eap_connect_data_t *eap_data);
179 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
181 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
184 static void ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
187 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
189 if (eap_data->sub_popup != NULL) {
190 evas_object_del(eap_data->sub_popup);
191 eap_data->sub_popup = NULL;
195 static void cert_ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
198 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
200 if (eap_data->sub_popup != NULL) {
201 evas_object_del(eap_data->sub_popup);
202 eap_data->sub_popup = NULL;
205 if (eap_data->cert_candidates != NULL) {
206 g_slist_free_full(eap_data->cert_candidates, g_free);
207 eap_data->cert_candidates = NULL;
211 static void move_dropdown(eap_connect_data_t *eap_data, Evas_Object *obj)
213 Evas_Coord x, y, w , h;
215 evas_object_geometry_get(obj, &x, &y, &w, &h);
216 evas_object_move(eap_data->sub_popup, x + (w / 2), y + h);
219 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
221 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
222 elm_genlist_item_selected_set(item, FALSE);
225 static void _select_confirm_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
227 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
228 retm_if(eap_data == NULL);
230 if (eap_data->confirm != NULL) {
231 evas_object_del(eap_data->confirm);
232 eap_data->confirm = NULL;
236 static void __gl_eap_type_sub_sel_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
238 __COMMON_FUNC_ENTER__;
239 retm_if(obj == NULL);
245 g_snprintf(str, 1024, sc(PACKAGE,I18N_TYPE_SIM_method_desc_popup),
246 (val == 1) ? "SIM2" : "SIM1");
247 txt = evas_textblock_text_utf8_to_markup(NULL, str);
248 elm_object_domain_translatable_text_set(obj, PACKAGE, txt);
250 __COMMON_FUNC_EXIT__;
253 static void _gl_eap_type_sub_sel(void *data, Evas_Object *obj, void *event_info)
255 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
256 eap_type_t sel_index = EAP_SEC_TYPE_UNKNOWN;
257 char buf[1024] = {'\0'};
259 eap_type_t pre_index = __common_eap_connect_popup_get_eap_type(eap_data->ap);
260 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
262 if (strcmp(label, EAP_TYPE_UNKNOWN) == 0)
263 sel_index = EAP_SEC_TYPE_UNKNOWN;
264 else if (strcmp(label, EAP_TYPE_PEAP) == 0)
265 sel_index = EAP_SEC_TYPE_PEAP;
266 else if (strcmp(label, EAP_TYPE_TLS) == 0)
267 sel_index = EAP_SEC_TYPE_TLS;
268 else if (strcmp(label, EAP_TYPE_TTLS) == 0)
269 sel_index = EAP_SEC_TYPE_TTLS;
270 else if (strcmp(label, EAP_TYPE_SIM) == 0)
271 sel_index = EAP_SEC_TYPE_SIM;
272 else if (strcmp(label, EAP_TYPE_AKA) == 0)
273 sel_index = EAP_SEC_TYPE_AKA;
275 DEBUG_LOG(UG_NAME_NORMAL, "previous index = %d; selected index = %d;",
276 pre_index, sel_index);
277 if ((pre_index != EAP_SEC_TYPE_SIM && sel_index == EAP_SEC_TYPE_SIM) ||
278 (pre_index != EAP_SEC_TYPE_AKA && sel_index == EAP_SEC_TYPE_AKA)) {
279 popup_btn_info_t popup_data;
281 value = common_util_get_system_registry(
282 VCONF_TELEPHONY_DEFAULT_DATA_SERVICE);
284 memset(&popup_data, 0, sizeof(popup_data));
285 g_snprintf(buf, sizeof(buf),
286 sc(PACKAGE, I18N_TYPE_SIM_method_desc_popup),
287 (value == 1) ? "SIM2" : "SIM1");
288 popup_data.title_txt = "IDS_WIFI_BODY_EAP_METHOD";
289 popup_data.info_txt = evas_textblock_text_utf8_to_markup(NULL, buf);
290 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
291 popup_data.btn1_cb = _select_confirm_popup_ok_cb;
292 popup_data.btn1_data = eap_data;
294 eap_data->confirm = common_utils_show_info_popup(eap_data->win,
296 g_free(popup_data.info_txt);
297 evas_object_smart_callback_add(eap_data->confirm, "language,changed",
298 __gl_eap_type_sub_sel_language_changed_cb, (void *)value);
300 _create_and_update_list_items_based_on_rules(sel_index, data);
301 wifi_eap_type_e type;
302 wifi_ap_set_eap_type(eap_data->ap,
303 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
304 wifi_ap_get_eap_type(eap_data->ap, &type);
305 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
308 if (eap_data->sub_popup != NULL) {
309 evas_object_del(eap_data->sub_popup);
310 eap_data->sub_popup = NULL;
313 if (pre_index != sel_index) {
314 wifi_eap_type_e type;
315 wifi_ap_set_eap_type(eap_data->ap,
316 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
317 wifi_ap_get_eap_type(eap_data->ap, &type);
318 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
319 _create_and_update_list_items_based_on_rules(sel_index, eap_data);
321 if (sel_index == EAP_SEC_TYPE_PEAP) {
322 /* If previous auth type was PAP or MSCHAP & when PEAP
323 * EAP method is selected, then set back MSCHAPV2
325 eap_auth_t auth_type;
327 auth_type = __common_eap_connect_popup_get_auth_type(eap_data->ap);
328 if (auth_type == EAP_SEC_AUTH_PAP ||
329 auth_type == EAP_SEC_AUTH_MSCHAP) {
330 wifi_ap_set_eap_auth_type(eap_data->ap,
331 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
333 if(eap_data->eap_auth_item != NULL)
334 elm_genlist_item_update(eap_data->eap_auth_item);
338 DEBUG_LOG(UG_NAME_NORMAL, "pre_index == sel_index[%d]",
342 if(eap_data->eap_type_item != NULL)
343 elm_genlist_item_update(eap_data->eap_type_item);
346 static CertSvcStringList stringList;
347 static CertSvcInstance instance;
348 static CertSvcStoreCertList *certList = NULL;
350 static void _gl_eap_user_cert_sel(void *data, Evas_Object *obj,
353 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
354 const char *cert_alias = elm_object_item_text_get((Elm_Object_Item *) event_info);
359 if (eap_data->sub_popup != NULL) {
360 evas_object_del(eap_data->sub_popup);
361 eap_data->sub_popup = NULL;
364 if (eap_data->ca_cert_path) {
365 g_unlink(eap_data->ca_cert_path);
366 eap_data->ca_cert_path = NULL;
368 if (eap_data->user_cert_path) {
369 g_unlink(eap_data->user_cert_path);
370 eap_data->user_cert_path = NULL;
372 if (eap_data->privatekey_path) {
373 g_unlink(eap_data->privatekey_path);
374 eap_data->privatekey_path = NULL;
377 if (strcmp(cert_alias, sc(PACKAGE, I18N_TYPE_None)) == 0) {
378 if (eap_data->cert_alias != NULL) {
379 g_free(eap_data->cert_alias);
380 eap_data->cert_alias = NULL;
382 } else if (__cert_extract_files(cert_alias, eap_data)) {
383 if (eap_data->cert_alias != NULL) {
384 g_free(eap_data->cert_alias);
385 eap_data->cert_alias = NULL;
387 eap_data->cert_alias = g_strdup(cert_alias);
390 if(eap_data->eap_user_cert_item != NULL)
391 elm_genlist_item_update(eap_data->eap_user_cert_item);
393 if (eap_data->cert_candidates != NULL) {
394 g_slist_free_full(eap_data->cert_candidates, g_free);
395 eap_data->cert_candidates = NULL;
399 static void _create_eap_cert_list(eap_connect_data_t *eap_data,
404 Evas_Object *ctxpopup;
405 Elm_Object_Item *it = NULL;
410 if (eap_data->sub_popup != NULL) {
411 evas_object_del(eap_data->sub_popup);
412 eap_data->sub_popup = NULL;
415 ctxpopup = elm_ctxpopup_add(eap_data->win);
416 eap_data->sub_popup = ctxpopup;
417 elm_object_style_set(ctxpopup, "dropdown/list");
418 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
419 cert_ctxpopup_dismissed_cb, NULL);
420 evas_object_smart_callback_add(ctxpopup,"dismissed",
421 cert_ctxpopup_dismissed_cb, eap_data);
422 elm_ctxpopup_direction_priority_set(ctxpopup,
423 ELM_CTXPOPUP_DIRECTION_DOWN,
424 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
425 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
426 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
428 if (certsvc_instance_new(&instance) == CERTSVC_FAIL) {
429 INFO_LOG(UG_NAME_ERR, "Failed to create new instance");
433 certsvc_pkcs12_get_certificate_list_from_store(instance, WIFI_STORE, DISABLED, &certList, &list_length);
435 if (eap_data->cert_candidates) {
436 g_slist_free_full(eap_data->cert_candidates, g_free);
437 eap_data->cert_candidates = NULL;
440 it = elm_ctxpopup_item_append(ctxpopup, "IDS_ST_BODY_NONE", NULL,
441 _gl_eap_user_cert_sel, eap_data);
442 elm_object_item_domain_text_translatable_set(it,
445 while(certList != NULL) {
446 char *char_buffer = NULL;
447 CertSvcString buffer;
449 buffer.privateHandler = (char *)certList->gname;
450 buffer.privateLength = strlen(certList->gname);
451 INFO_LOG(UG_NAME_NORMAL, "gname in processing : %s", certList->gname);
453 char_buffer = g_strndup(buffer.privateHandler, buffer.privateLength);
454 if (char_buffer == NULL)
457 elm_ctxpopup_item_append(ctxpopup, char_buffer, NULL,
458 _gl_eap_user_cert_sel, eap_data);
459 eap_data->cert_candidates =
460 g_slist_prepend(eap_data->cert_candidates, char_buffer);
462 certsvc_string_free(buffer);
463 certList = certList->next;
466 move_dropdown(eap_data, btn);
467 evas_object_show(ctxpopup);
470 certsvc_instance_free(instance);
473 static void _gl_eap_cert_list_btn_cb(void *data, Evas_Object *obj,
476 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
477 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
480 elm_genlist_item_selected_set(item, EINA_FALSE);
482 if (keypad_state == FALSE) {
483 _create_eap_cert_list(eap_data, obj);
485 click.btn_click[EAP_CERT_BTN] = FALSE;
486 click.btn_obj[EAP_CERT_BTN] = NULL;
488 click.btn_click[EAP_CERT_BTN] = TRUE;
489 click.btn_obj[EAP_CERT_BTN] = obj;
493 static char *_gl_eap_user_cert_text_get(void *data, Evas_Object *obj, const char *part)
495 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
497 if (!g_strcmp0(part, "elm.text.main")) {
498 return g_strdup(sc(eap_data->str_pkg_name,
499 I18N_TYPE_User_Certificate));
505 static Evas_Object *_gl_eap_user_cert_content_get(void *data,
506 Evas_Object *obj, const char *part)
508 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
509 Evas_Object *btn = NULL;
510 Evas_Object *ly = NULL;
513 if (!strcmp(part, "elm.icon.entry")) {
514 ly = elm_layout_add(obj);
515 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
516 "eap_dropdown_button");
517 btn = elm_button_add(obj);
519 if (eap_data->cert_alias == NULL) {
520 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
521 sc(eap_data->str_pkg_name, I18N_TYPE_None));
523 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
524 eap_data->cert_alias);
527 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
528 elm_object_style_set(btn, "dropdown/label");
529 evas_object_propagate_events_set(btn, EINA_FALSE);
530 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
532 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
534 evas_object_smart_callback_add(btn, "clicked",
535 _gl_eap_cert_list_btn_cb, eap_data);
537 elm_layout_content_set(ly, "btn", btn);
543 static void _gl_eap_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
545 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
548 elm_genlist_item_selected_set(item, EINA_FALSE);
552 static void _create_eap_type_list(eap_connect_data_t *eap_data,
555 Evas_Object *ctxpopup = NULL;
556 int i = EAP_SEC_TYPE_PEAP;
557 int sim_state = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
558 Elm_Object_Item *it = NULL;
560 sim_state = common_utils_get_sim_state();
562 if (eap_data->sub_popup != NULL) {
563 evas_object_del(eap_data->sub_popup);
566 ctxpopup = elm_ctxpopup_add(eap_data->win);
567 eap_data->sub_popup = ctxpopup;
568 elm_object_style_set(ctxpopup, "dropdown/list");
569 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
570 eext_ctxpopup_back_cb, NULL);
571 evas_object_smart_callback_add(ctxpopup,"dismissed",
572 ctxpopup_dismissed_cb, eap_data);
573 elm_ctxpopup_direction_priority_set(ctxpopup,
574 ELM_CTXPOPUP_DIRECTION_DOWN,
575 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
576 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
577 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
579 /* eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap); */
580 while (list_eap_type[i].name != NULL) {
581 it = elm_ctxpopup_item_append(ctxpopup, list_eap_type[i].name,
582 NULL, _gl_eap_type_sub_sel, eap_data);
584 if ((i == EAP_SEC_TYPE_SIM || i == EAP_SEC_TYPE_AKA) &&
585 sim_state != VCONFKEY_TELEPHONY_SIM_INSERTED) {
586 elm_object_item_disabled_set(it, EINA_TRUE);
591 move_dropdown(eap_data, btn);
592 evas_object_show(ctxpopup);
595 static void _gl_eap_type_btn_cb(void *data, Evas_Object *obj, void *event_info)
597 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
598 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
601 elm_genlist_item_selected_set(item, EINA_FALSE);
603 if (keypad_state == FALSE) {
604 _create_eap_type_list(eap_data, obj);
606 click.btn_click[EAP_TYPE_BTN] = FALSE;
607 click.btn_obj[EAP_TYPE_BTN] = NULL;
609 click.btn_click[EAP_TYPE_BTN] = TRUE;
610 click.btn_obj[EAP_TYPE_BTN] = obj;
614 static char *_gl_eap_type_text_get(void *data, Evas_Object *obj, const char *part)
616 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
618 if (!g_strcmp0(part, "elm.text.main")) {
619 return g_strdup(sc(eap_data->str_pkg_name, I18N_TYPE_EAP_method));
625 static Evas_Object *_gl_eap_type_content_get(void *data,
626 Evas_Object *obj, const char *part)
628 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
629 eap_type_t sel_sub_item_id = __common_eap_connect_popup_get_eap_type(eap_data->ap);
630 Evas_Object *btn = NULL;
631 Evas_Object *ly = NULL;
634 if (!strcmp(part, "elm.icon.entry")) {
635 ly = elm_layout_add(obj);
636 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
637 "eap_dropdown_button");
638 btn = elm_button_add(obj);
640 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
641 list_eap_type[sel_sub_item_id].name);
643 elm_object_text_set(btn, buf);
644 elm_object_style_set(btn, "dropdown/label");
645 evas_object_propagate_events_set(btn, EINA_FALSE);
646 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
648 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
650 evas_object_smart_callback_add(btn, "clicked",
651 _gl_eap_type_btn_cb, eap_data);
653 elm_layout_content_set(ly, "btn", btn);
659 static void _gl_eap_auth_sub_sel(void *data, Evas_Object *obj, void *event_info)
661 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
662 eap_auth_t sel_index = EAP_SEC_AUTH_NONE;
664 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
666 if (strcmp(label, sc(PACKAGE, I18N_TYPE_None)) == 0)
667 sel_index = EAP_SEC_AUTH_NONE;
668 else if (strcmp(label, EAP_AUTH_TYPE_PAP) == 0)
669 sel_index = EAP_SEC_AUTH_PAP;
670 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAP) == 0)
671 sel_index = EAP_SEC_AUTH_MSCHAP;
672 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAPV2) == 0)
673 sel_index = EAP_SEC_AUTH_MSCHAPV2;
674 else if (strcmp(label, EAP_AUTH_TYPE_GTC) == 0)
675 sel_index = EAP_SEC_AUTH_GTC;
676 else if (strcmp(label, EAP_AUTH_TYPE_MD5) == 0)
677 sel_index = EAP_SEC_AUTH_MD5;
679 wifi_ap_set_eap_auth_type(eap_data->ap,
680 __common_eap_connect_popup_get_wlan_auth_type(sel_index));
682 if (eap_data->sub_popup != NULL) {
683 evas_object_del(eap_data->sub_popup);
684 eap_data->sub_popup = NULL;
687 if(eap_data->eap_auth_item != NULL)
688 elm_genlist_item_update(eap_data->eap_auth_item);
691 static void _create_eap_auth_list(eap_connect_data_t *eap_data,
694 Elm_Object_Item *it = NULL;
695 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
696 Evas_Object *ctxpopup;
699 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
701 if (eap_data->sub_popup != NULL) {
702 evas_object_del(eap_data->sub_popup);
705 ctxpopup = elm_ctxpopup_add(eap_data->win);
706 eap_data->sub_popup = ctxpopup;
707 elm_object_style_set(ctxpopup, "dropdown/list");
708 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
709 evas_object_smart_callback_add(ctxpopup,"dismissed", ctxpopup_dismissed_cb, eap_data);
710 elm_ctxpopup_direction_priority_set(ctxpopup,
711 ELM_CTXPOPUP_DIRECTION_DOWN,
712 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
713 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
714 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
716 while (list_eap_auth[i].name != NULL) {
717 if ((eap_type != EAP_SEC_TYPE_PEAP) ||
718 (eap_type == EAP_SEC_TYPE_PEAP && i != 1 &&
720 it = elm_ctxpopup_item_append(ctxpopup, list_eap_auth[i].name,
721 NULL, _gl_eap_auth_sub_sel, eap_data);
723 elm_object_item_domain_text_translatable_set(it,
729 move_dropdown(eap_data, btn);
730 evas_object_show(ctxpopup);
733 static void _gl_eap_auth_btn_cb(void *data, Evas_Object *obj, void *event_info)
735 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
736 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
739 elm_genlist_item_selected_set(item, EINA_FALSE);
741 if (keypad_state == FALSE) {
742 _create_eap_auth_list(eap_data, obj);
744 click.btn_click[EAP_AUTH_BTN] = FALSE;
745 click.btn_obj[EAP_AUTH_BTN] = NULL;
747 click.btn_click[EAP_AUTH_BTN] = TRUE;
748 click.btn_obj[EAP_AUTH_BTN] = obj;
752 static char *_gl_eap_auth_text_get(void *data, Evas_Object *obj, const char *part)
754 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
756 if (!g_strcmp0(part, "elm.text.main")) {
757 return g_strdup(sc(eap_data->str_pkg_name,
758 I18N_TYPE_Phase_2_authentication));
764 static Evas_Object *_gl_eap_auth_content_get(void *data,
765 Evas_Object *obj, const char *part)
767 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
768 eap_auth_t sel_sub_item_id = __common_eap_connect_popup_get_auth_type(eap_data->ap);
769 Evas_Object *btn = NULL;
770 Evas_Object *ly = NULL;
773 if (!strcmp(part, "elm.icon.entry")) {
774 ly = elm_layout_add(obj);
775 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
776 "eap_dropdown_button");
777 btn = elm_button_add(obj);
779 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
780 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
781 sc(PACKAGE, I18N_TYPE_None));
783 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
784 list_eap_auth[sel_sub_item_id].name);
787 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
788 elm_object_style_set(btn, "dropdown/label");
789 evas_object_propagate_events_set(btn, EINA_FALSE);
790 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
792 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
794 evas_object_smart_callback_add(btn, "clicked",
795 _gl_eap_auth_btn_cb, eap_data);
797 elm_layout_content_set(ly, "btn", btn);
803 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
805 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
810 Evas_Object *entry = NULL;
811 Elm_Object_Item *next_item = NULL;
814 switch (entry_info->entry_id) {
815 case ENTRY_TYPE_USER_ID:
816 eap_type = __common_eap_connect_popup_get_eap_type(
819 if (eap_type == EAP_SEC_TYPE_TLS) {
820 entry = elm_object_item_part_content_get(entry_info->item,
823 elm_object_focus_set(entry, EINA_FALSE);
826 next_item = elm_genlist_item_next_get(entry_info->item);
828 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
829 elm_genlist_item_select_mode_get(next_item) !=
830 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
831 entry = elm_object_item_part_content_get(
832 next_item, "elm.icon.entry");
834 elm_object_focus_set(entry, EINA_TRUE);
839 next_item = elm_genlist_item_next_get(next_item);
843 case ENTRY_TYPE_PASSWORD:
844 entry = elm_object_item_part_content_get(entry_info->item,
847 elm_object_focus_set(entry, EINA_FALSE);
855 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
857 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
862 if (elm_object_focus_get(obj)) {
863 if (elm_entry_is_empty(obj)) {
864 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
866 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
870 if (entry_info->entry_txt) {
871 g_free(entry_info->entry_txt);
872 entry_info->entry_txt = NULL;
875 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
877 if (entry_text != NULL && entry_text[0] != '\0') {
878 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
884 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
886 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
895 if (elm_object_focus_get(obj)) {
896 if (elm_entry_is_empty(obj)) {
897 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
899 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
904 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
906 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
911 if (!elm_entry_is_empty(obj)) {
912 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
915 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
918 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
920 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
925 if (entry_info->entry_txt) {
926 g_free(entry_info->entry_txt);
927 entry_info->entry_txt = NULL;
930 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
931 if (entry_text != NULL && entry_text[0] != '\0')
932 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
936 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
937 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
940 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
943 common_utils_send_message_to_net_popup("Password length",
944 "Lengthy Password", "notification", NULL);
947 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
949 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
954 Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
956 elm_object_focus_set(entry, EINA_TRUE);
957 elm_entry_entry_set(entry, "");
961 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
963 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
968 if (!g_strcmp0(part, "elm.text.main")) {
969 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
975 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
977 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
982 if (g_strcmp0(part, "elm.icon.entry") == 0) {
983 Evas_Object *entry = NULL;
984 char *guide_txt = NULL;
985 char *accepted = NULL;
986 Eina_Bool hide_entry_txt = EINA_FALSE;
987 Elm_Input_Panel_Layout panel_type;
991 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
993 static Elm_Entry_Filter_Limit_Size limit_filter_data;
995 switch (entry_info->entry_id)
997 case ENTRY_TYPE_USER_ID:
998 panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
999 guide_txt = entry_info->guide_txt;
1001 if (eap_type == EAP_SEC_TYPE_TLS) {
1002 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1004 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1007 case ENTRY_TYPE_PASSWORD:
1008 panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1009 guide_txt = entry_info->guide_txt;
1010 hide_entry_txt = EINA_TRUE;
1011 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1017 entry = elm_entry_add(obj);
1018 retvm_if(NULL == entry, NULL);
1020 elm_entry_single_line_set(entry, EINA_TRUE);
1021 elm_entry_scrollable_set(entry, EINA_TRUE);
1022 elm_entry_password_set(entry, hide_entry_txt);
1023 elm_entry_prediction_allow_set(entry, EINA_FALSE);
1024 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
1026 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
1027 PACKAGE, guide_txt);
1028 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0)) {
1029 elm_entry_entry_set(entry, entry_info->entry_txt);
1032 elm_entry_input_panel_layout_set(entry, panel_type);
1033 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
1035 limit_filter_data.max_char_count = 200;
1036 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
1038 Elm_Entry_Filter_Accept_Set digits_filter_data;
1039 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1040 digits_filter_data.accepted = accepted;
1041 elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digits_filter_data);
1043 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(entry);
1044 if (imf_ctxt && entry_info->input_panel_cb) {
1045 ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1046 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1047 entry_info->input_panel_cb,
1048 entry_info->input_panel_cb_data);
1049 DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1052 evas_object_smart_callback_add(entry, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1053 evas_object_smart_callback_add(entry, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1054 evas_object_smart_callback_add(entry, "changed", _gl_eap_entry_changed_cb, entry_info);
1055 evas_object_smart_callback_add(entry, "focused", _gl_eap_entry_focused_cb, entry_info);
1056 evas_object_smart_callback_add(entry, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1057 evas_object_smart_callback_add(entry, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1059 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD) {
1060 g_pwd_entry = entry;
1064 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1065 Evas_Object *btn = elm_button_add(obj);
1066 elm_object_style_set(btn, "editfield_clear");
1067 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1074 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1076 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1077 if (entry_info == NULL) {
1081 if (entry_info->entry_txt) {
1082 g_free(entry_info->entry_txt);
1088 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1090 if (obj == NULL || g_pwd_entry == NULL) {
1094 Eina_Bool state = elm_check_state_get(obj);
1096 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1098 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1102 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1105 char *str_pkg_name = (char *)data;
1107 if (!g_strcmp0(part, "elm.text.main.left")) {
1109 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1116 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1117 Evas_Object *obj, const char *part)
1119 Evas_Object *check = NULL;
1121 if(!g_strcmp0(part, "elm.icon.right")) {
1122 check = elm_check_add(obj);
1123 evas_object_propagate_events_set(check, EINA_FALSE);
1125 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1126 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1127 evas_object_smart_callback_add(check, "changed",
1128 _chk_changed_cb, NULL);
1130 elm_object_focus_allow_set(check, EINA_FALSE);
1137 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1139 Elm_Object_Item *item = NULL;
1141 item = (Elm_Object_Item *)ei;
1146 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1148 elm_genlist_item_selected_set(item, EINA_FALSE);
1150 Eina_Bool state = elm_check_state_get(ck);
1151 elm_check_state_set(ck, !state);
1153 _chk_changed_cb(NULL, ck, NULL);
1156 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1158 elm_genlist_realized_items_update(obj);
1161 static void __common_eap_connect_popup_init_item_class(void *data)
1163 g_eap_type_itc.item_style = "entry.main";
1164 g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1165 g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1166 g_eap_type_itc.func.state_get = NULL;
1167 g_eap_type_itc.func.del = NULL;
1169 g_eap_auth_itc.item_style = "entry.main";
1170 g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1171 g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1172 g_eap_auth_itc.func.state_get = NULL;
1173 g_eap_auth_itc.func.del = NULL;
1175 g_eap_user_cert_itc.item_style = "entry.main";
1176 g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1177 g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1178 g_eap_user_cert_itc.func.state_get = NULL;
1179 g_eap_user_cert_itc.func.del = NULL;
1181 g_eap_entry_itc.item_style = "entry.main";
1182 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1183 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1184 g_eap_entry_itc.func.state_get = NULL;
1185 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1187 g_eap_chkbox_itc.item_style = "1line";
1188 g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1189 g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1190 g_eap_chkbox_itc.func.state_get = NULL;
1191 g_eap_chkbox_itc.func.del = NULL;
1194 static gboolean __cert_extract_files(const char *cert_alias,
1195 eap_connect_data_t *eap_data)
1199 int cert_counts = 0;
1201 gchar *ca_cert_path = NULL;
1202 gchar *user_cert_path = NULL;
1203 gchar *privatekey_path = NULL;
1205 CertSvcInstance cert_instance;
1206 CertSvcString cert_alias_str;
1207 CertSvcCertificateList cert_list;
1208 CertSvcCertificate user_certificate;
1209 CertSvcCertificate ca_certificate;
1210 CertSvcCertificate *selected_certificate = NULL;
1212 EVP_PKEY *privatekey = NULL;
1214 ret = certsvc_instance_new(&cert_instance);
1215 if (ret != CERTSVC_SUCCESS) {
1216 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1219 ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1220 if (ret != CERTSVC_SUCCESS) {
1221 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1224 ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1225 if (ret != CERTSVC_SUCCESS) {
1226 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1229 ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1230 if (cert_counts < 1) {
1231 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1234 INFO_LOG(UG_NAME_NORMAL, "cert counts: %d", cert_counts);
1235 selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1236 if (selected_certificate == NULL) {
1237 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1240 ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1241 if (ret != CERTSVC_SUCCESS) {
1242 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1245 cert_index = cert_counts - 1;
1247 selected_certificate[0] = user_certificate;
1249 ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1251 user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1252 cert_alias, EAP_TLS_USER_CERT_PATH);
1253 if ((fp = fopen(user_cert_path, "w")) == NULL) {
1256 ret = PEM_write_X509(fp, x509);
1258 certsvc_certificate_free_x509(x509);
1259 INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1261 ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1262 EAP_TLS_CA_CERT_PATH);
1263 while (cert_index) {
1264 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1265 if (ret != CERTSVC_SUCCESS) {
1266 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1270 selected_certificate[cert_counts-cert_index] = ca_certificate;
1273 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1274 if ((fp = fopen(ca_cert_path, "a")) == NULL) {
1277 ret = PEM_write_X509(fp, x509);
1279 certsvc_certificate_free_x509(x509);
1281 INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1282 ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1283 if (ret != CERTSVC_SUCCESS) {
1284 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1287 if (validity == 0) {
1288 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1292 ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1294 privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1295 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1297 if ((fp = fopen(privatekey_path, "w")) == NULL) {
1300 ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1302 certsvc_pkcs12_free_evp_pkey(privatekey);
1303 INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1305 g_free(selected_certificate);
1306 certsvc_instance_free(cert_instance);
1308 eap_data->ca_cert_path = ca_cert_path;
1309 eap_data->user_cert_path = user_cert_path;
1310 eap_data->privatekey_path = privatekey_path;
1315 g_free(ca_cert_path);
1316 g_free(user_cert_path);
1317 g_free(privatekey_path);
1319 if (selected_certificate) {
1320 g_free(selected_certificate);
1323 certsvc_instance_free(cert_instance);
1327 /* This creates EAP type, Auth type, CA certificate, User certificate,
1328 * User Id, Anonymous Id and Password items.
1330 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1331 eap_connect_data_t *eap_data)
1333 __COMMON_FUNC_ENTER__;
1334 Evas_Object* view_list = eap_data->genlist;
1335 Elm_Object_Item *insert_after_item = NULL;
1336 Elm_Object_Item *prev_item = NULL;
1337 common_utils_entry_info_t *edit_box_details;
1338 Eina_Bool auth_reqd = EINA_FALSE;
1339 Eina_Bool user_cert_reqd = EINA_FALSE;
1340 Eina_Bool id_reqd = EINA_FALSE;
1341 Eina_Bool pw_reqd = EINA_FALSE;
1343 if (NULL == eap_data->eap_type_item) {
1344 /* Create EAP method/type */
1345 eap_data->eap_type_item = elm_genlist_item_append(
1346 view_list, &g_eap_type_itc,
1348 ELM_GENLIST_ITEM_NONE,
1349 _gl_eap_item_sel_cb, eap_data);
1353 case EAP_SEC_TYPE_PEAP:
1354 insert_after_item = eap_data->eap_type_item;
1355 auth_reqd = EINA_TRUE;
1356 user_cert_reqd = EINA_FALSE;
1357 id_reqd = EINA_TRUE;
1358 pw_reqd = EINA_TRUE;
1360 case EAP_SEC_TYPE_TLS:
1361 insert_after_item = eap_data->eap_type_item;
1362 auth_reqd = EINA_FALSE;
1363 user_cert_reqd = EINA_TRUE;
1364 id_reqd = EINA_TRUE;
1365 pw_reqd = EINA_FALSE;
1367 case EAP_SEC_TYPE_TTLS:
1368 insert_after_item = eap_data->eap_type_item;
1369 auth_reqd = EINA_TRUE;
1370 user_cert_reqd = EINA_FALSE;
1371 id_reqd = EINA_TRUE;
1372 pw_reqd = EINA_TRUE;
1374 case EAP_SEC_TYPE_SIM:
1375 case EAP_SEC_TYPE_AKA:
1376 _delete_eap_entry_items(eap_data);
1377 auth_reqd = EINA_FALSE;
1378 user_cert_reqd = EINA_FALSE;
1379 id_reqd = EINA_FALSE;
1380 pw_reqd = EINA_FALSE;
1386 if (auth_reqd == EINA_TRUE) {
1387 if (eap_data->eap_auth_item == NULL) {
1388 /* Add EAP phase2 authentication */
1389 eap_data->eap_auth_item = elm_genlist_item_insert_after(
1390 view_list, &g_eap_auth_itc, eap_data, NULL,
1391 insert_after_item, ELM_GENLIST_ITEM_NONE,
1392 _gl_eap_item_sel_cb, eap_data);
1395 _delete_eap_auth_item(eap_data);
1398 if (user_cert_reqd == EINA_TRUE) {
1399 if (eap_data->eap_user_cert_item == NULL) {
1400 prev_item = eap_data->eap_type_item;
1402 /* Add User certificate */
1403 eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1404 view_list, &g_eap_user_cert_itc, eap_data, NULL,
1405 prev_item, ELM_GENLIST_ITEM_NONE,
1406 _gl_eap_item_sel_cb, eap_data);
1409 _delete_eap_user_cert_item(eap_data);
1412 if (id_reqd == EINA_TRUE) {
1413 if (eap_data->eap_id_item == NULL) {
1414 if (new_type == EAP_SEC_TYPE_PEAP ||
1415 new_type == EAP_SEC_TYPE_TTLS) {
1416 prev_item = eap_data->eap_auth_item;
1418 prev_item = eap_data->eap_user_cert_item;
1422 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1423 if (edit_box_details == NULL) {
1427 edit_box_details->ap = eap_data->ap;
1428 edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1429 edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1430 edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1431 edit_box_details->item = elm_genlist_item_insert_after(
1432 view_list, &g_eap_entry_itc, edit_box_details,
1434 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1435 eap_data->eap_id_item = edit_box_details->item;
1438 _delete_eap_id_item(eap_data);
1441 if (pw_reqd == EINA_TRUE) {
1442 if (eap_data->eap_pw_item == NULL) {
1443 /* Add EAP Password */
1444 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1445 if (edit_box_details == NULL) {
1449 edit_box_details->ap = eap_data->ap;
1450 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1451 edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1452 edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1453 edit_box_details->item = elm_genlist_item_insert_after(
1454 view_list, &g_eap_entry_itc,
1455 edit_box_details, NULL,
1456 eap_data->eap_id_item,
1457 ELM_GENLIST_ITEM_NONE,
1458 _gl_editbox_sel_cb, NULL);
1459 eap_data->eap_pw_item = edit_box_details->item;
1461 _update_eap_id_item_enter_key(eap_data);
1464 if (eap_data->eap_chkbox_item == NULL) {
1465 /* Add Show Password checkbox */
1466 eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1467 view_list, &g_eap_chkbox_itc,
1468 eap_data->str_pkg_name, NULL,
1469 eap_data->eap_pw_item,
1470 ELM_GENLIST_ITEM_NONE,
1471 _gl_eap_chkbox_sel, NULL);
1474 _delete_eap_pw_items(eap_data);
1477 __COMMON_FUNC_EXIT__;
1481 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1483 if (eap_data->eap_id_item == NULL)
1486 Evas_Object *entry = NULL;
1487 eap_type_t eap_type;
1489 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1490 entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1493 if (eap_type == EAP_SEC_TYPE_TLS) {
1494 elm_entry_input_panel_return_key_type_set(entry,
1495 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1497 elm_entry_input_panel_return_key_type_set(entry,
1498 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1503 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1505 __COMMON_FUNC_ENTER__;
1507 if (eap_data->eap_auth_item != NULL) {
1508 elm_object_item_del(eap_data->eap_auth_item);
1509 eap_data->eap_auth_item = NULL;
1512 __COMMON_FUNC_EXIT__;
1516 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1518 __COMMON_FUNC_ENTER__;
1520 if (eap_data->eap_user_cert_item != NULL) {
1521 elm_object_item_del(eap_data->eap_user_cert_item);
1522 eap_data->eap_user_cert_item = NULL;
1525 __COMMON_FUNC_EXIT__;
1529 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1531 __COMMON_FUNC_ENTER__;
1533 if (eap_data->eap_id_item != NULL) {
1534 elm_object_item_del(eap_data->eap_id_item);
1535 eap_data->eap_id_item = NULL;
1538 __COMMON_FUNC_EXIT__;
1542 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1544 __COMMON_FUNC_ENTER__;
1546 _update_eap_id_item_enter_key(eap_data);
1548 if (eap_data->eap_pw_item != NULL) {
1549 elm_object_item_del(eap_data->eap_pw_item);
1550 eap_data->eap_pw_item = NULL;
1553 if (eap_data->eap_chkbox_item) {
1554 elm_object_item_del(eap_data->eap_chkbox_item);
1555 eap_data->eap_chkbox_item = NULL;
1558 __COMMON_FUNC_EXIT__;
1562 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1564 __COMMON_FUNC_ENTER__;
1566 if (eap_data->eap_auth_item != NULL) {
1567 elm_object_item_del(eap_data->eap_auth_item);
1568 eap_data->eap_auth_item = NULL;
1571 if (eap_data->eap_user_cert_item != NULL) {
1572 elm_object_item_del(eap_data->eap_user_cert_item);
1573 eap_data->eap_user_cert_item = NULL;
1576 if (eap_data->eap_id_item != NULL) {
1577 elm_object_item_del(eap_data->eap_id_item);
1578 eap_data->eap_id_item = NULL;
1581 if (eap_data->eap_pw_item != NULL) {
1582 elm_object_item_del(eap_data->eap_pw_item);
1583 eap_data->eap_pw_item = NULL;
1586 if (eap_data->eap_chkbox_item != NULL) {
1587 elm_object_item_del(eap_data->eap_chkbox_item);
1588 eap_data->eap_chkbox_item = NULL;
1591 __COMMON_FUNC_EXIT__;
1595 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1597 __COMMON_FUNC_ENTER__;
1598 assertm_if(NULL == parent, "NULL!!");
1600 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1601 Evas_Object* view_list = NULL;
1602 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1603 retvm_if(eap_data == NULL, NULL);
1605 __common_eap_connect_popup_init_item_class(eap_data);
1607 eap_data->eap_done_ok = FALSE;
1608 eap_data->genlist = view_list = elm_genlist_add(parent);
1609 elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1610 elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1612 evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1614 evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1616 /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1617 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1618 wifi_ap_set_eap_type(eap_data->ap,
1619 (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1620 WIFI_EAP_TYPE_PEAP :
1621 __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1623 wifi_ap_set_eap_auth_type(eap_data->ap,
1624 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
1628 /* Create the entry items */
1629 _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1631 evas_object_show(view_list);
1632 evas_object_smart_callback_add(view_list, "language,changed",
1633 gl_lang_changed, NULL);
1635 __COMMON_FUNC_EXIT__;
1639 static Eina_Bool _enable_scan_updates_cb(void *data)
1641 /* Lets enable the scan updates */
1642 wlan_manager_enable_scan_result_update();
1644 /* Reset the ecore timer handle */
1645 common_util_manager_ecore_scan_update_timer_reset();
1647 return ECORE_CALLBACK_CANCEL;
1650 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1652 if (eap_data == NULL) {
1656 if (eap_data->conf != NULL) {
1657 evas_object_smart_callback_del(eap_data->conf,
1658 "virtualkeypad,state,on",
1659 _eap_popup_keypad_on_cb);
1660 evas_object_smart_callback_del(eap_data->conf,
1661 "virtualkeypad,state,off",
1662 _eap_popup_keypad_off_cb);
1665 if (eap_data->ssid != NULL) {
1666 g_free(eap_data->ssid);
1667 eap_data->ssid = NULL;
1670 if (eap_data->cert_alias) {
1671 g_free(eap_data->cert_alias);
1672 eap_data->cert_alias = NULL;
1675 if (eap_data->ca_cert_path) {
1676 g_free(eap_data->ca_cert_path);
1677 eap_data->ca_cert_path = NULL;
1680 if (eap_data->user_cert_path) {
1681 g_free(eap_data->user_cert_path);
1682 eap_data->user_cert_path = NULL;
1685 if (eap_data->privatekey_path) {
1686 g_free(eap_data->privatekey_path);
1687 eap_data->privatekey_path = NULL;
1690 wifi_ap_destroy(eap_data->ap);
1691 eap_data->ap = NULL;
1693 if(eap_data->info_popup){
1694 evas_object_del(eap_data->info_popup);
1695 eap_data->info_popup = NULL;
1698 if (eap_data->popup != NULL) {
1699 evas_object_hide(eap_data->popup);
1700 evas_object_del(eap_data->popup);
1703 if(_eap_view_deref_cb != NULL) {
1704 _eap_view_deref_cb();
1705 _eap_view_deref_cb = NULL;
1708 /* A delay is needed to get the smooth Input panel closing animation effect */
1709 common_util_managed_ecore_scan_update_timer_add(0.1,
1710 _enable_scan_updates_cb, NULL);
1713 static void __common_eap_connect_destroy_cb(void *data, Evas_Object *obj,
1716 __common_eap_connect_cleanup((eap_connect_data_t *)data);
1719 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1721 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1723 if (eap_data->info_popup != NULL) {
1724 evas_object_del(eap_data->info_popup);
1725 eap_data->info_popup = NULL;
1729 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1732 char *str_id = NULL;
1733 char *str_pw = NULL;
1734 bool favorite = FALSE;
1735 wifi_eap_type_e eap_type;
1736 wifi_eap_auth_type_e eap_auth_type;
1737 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1738 popup_btn_info_t popup_data;
1740 __COMMON_FUNC_ENTER__;
1741 if (eap_data->eap_done_ok == TRUE) {
1742 __COMMON_FUNC_EXIT__;
1746 eap_data->eap_done_ok = TRUE;
1748 wifi_ap_get_eap_type(eap_data->ap, &eap_type);
1749 wifi_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1751 wifi_ap_is_favorite(eap_data->ap, &favorite);
1752 if (favorite == TRUE) {
1753 wlan_manager_forget(eap_data->ap);
1754 wifi_ap_refresh(eap_data->ap);
1756 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1757 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1760 wifi_ap_set_eap_ca_cert_file(eap_data->ap, "");
1761 wifi_ap_set_eap_client_cert_file(eap_data->ap, "");
1762 wifi_ap_set_eap_private_key_info(eap_data->ap, "", "");
1765 case WIFI_EAP_TYPE_PEAP:
1766 case WIFI_EAP_TYPE_TTLS:
1768 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1769 if (str_id == NULL || str_id[0] == '\0') {
1770 memset(&popup_data, 0, sizeof(popup_data));
1771 popup_data.title_txt = eap_data->ssid;
1772 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1773 popup_data.btn1_cb = _info_popup_ok_cb;
1774 popup_data.btn1_data = eap_data;
1775 popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1776 eap_data->eap_done_ok = FALSE;
1777 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1782 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1783 if (str_pw == NULL || str_pw[0] == '\0') {
1784 memset(&popup_data, 0, sizeof(popup_data));
1785 popup_data.title_txt = eap_data->ssid;
1786 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1787 popup_data.btn1_cb = _info_popup_ok_cb;
1788 popup_data.btn1_data = eap_data;
1789 popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1790 eap_data->eap_done_ok = FALSE;
1791 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1796 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1797 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1798 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1801 case WIFI_EAP_TYPE_TLS:
1802 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1803 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1805 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1806 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1807 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1808 wifi_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1809 wifi_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1810 wifi_ap_set_eap_private_key_info(eap_data->ap,
1811 eap_data->privatekey_path, NULL);
1814 case WIFI_EAP_TYPE_SIM:
1815 case WIFI_EAP_TYPE_AKA:
1819 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1823 if (eap_data->is_hidden) {
1824 wifi_ap_h hidden_ap;
1826 wifi_ap_get_essid(eap_data->ap, &ssid);
1827 wifi_ap_hidden_create(ssid, &hidden_ap);
1831 case WIFI_EAP_TYPE_PEAP:
1832 case WIFI_EAP_TYPE_TTLS:
1833 wifi_ap_set_eap_type(hidden_ap, eap_type);
1834 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1835 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1837 case WIFI_EAP_TYPE_TLS:
1838 wifi_ap_set_eap_type(hidden_ap, eap_type);
1839 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1840 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1841 wifi_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1842 wifi_ap_set_eap_client_cert_file(hidden_ap,eap_data->user_cert_path);
1843 wifi_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1845 case WIFI_EAP_TYPE_SIM:
1846 case WIFI_EAP_TYPE_AKA:
1849 wlan_manager_connect(hidden_ap);
1851 wlan_manager_connect(eap_data->ap);
1853 __common_eap_connect_cleanup(eap_data);
1855 __COMMON_FUNC_EXIT__;
1858 static gboolean delay_create_context_popup(gpointer data)
1860 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1862 if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1863 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1865 click.btn_click[EAP_CERT_BTN] = FALSE;
1866 click.btn_obj[EAP_CERT_BTN] = NULL;
1867 } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1868 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1870 click.btn_click[EAP_AUTH_BTN] = FALSE;
1871 click.btn_obj[EAP_AUTH_BTN] = NULL;
1872 } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1873 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1875 click.btn_click[EAP_TYPE_BTN] = FALSE;
1876 click.btn_obj[EAP_TYPE_BTN] = NULL;
1881 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1888 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1890 keypad_state = FALSE;
1892 common_util_managed_idle_add(delay_create_context_popup,
1893 (gpointer)eap_data);
1895 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
1898 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1905 keypad_state = TRUE;
1906 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
1909 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
1910 Evas_Object *conf, const char *pkg_name,
1911 wifi_device_info_t *device_info, void (*deref_func)(void))
1913 __COMMON_FUNC_ENTER__;
1915 Evas_Object *popup = NULL;
1916 Evas_Object *list = NULL;
1917 Evas_Object *box = NULL;
1919 if (layout_main == NULL || device_info == NULL || pkg_name == NULL) {
1923 eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
1924 if (eap_data == NULL) {
1928 eap_data->str_pkg_name = pkg_name;
1929 eap_data->win = win;
1930 eap_data->conf = conf;
1931 eap_data->ssid = g_strdup(device_info->ssid);
1933 if (device_info->is_hidden == true) {
1934 /* Hidden Wi-Fi network */
1937 wifi_ap_get_essid(device_info->ap, &ssid);
1941 wifi_ap_hidden_create(ssid, &(eap_data->ap));
1944 eap_data->is_hidden = TRUE;
1946 /* Clone the Wi-Fi AP handle */
1947 wifi_ap_clone(&(eap_data->ap), device_info->ap);
1950 /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
1951 wlan_manager_disable_scan_result_update();
1953 _eap_view_deref_cb = deref_func;
1954 click.btn_click[EAP_TYPE_BTN] = FALSE;
1955 click.btn_obj[EAP_TYPE_BTN] = NULL;
1956 click.btn_click[EAP_AUTH_BTN] = FALSE;
1957 click.btn_obj[EAP_AUTH_BTN] = NULL;
1958 click.btn_click[EAP_CERT_BTN] = FALSE;
1959 click.btn_obj[EAP_CERT_BTN] = NULL;
1960 keypad_state = FALSE;
1962 popup_btn_info_t popup_btn_data;
1963 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
1965 popup_btn_data.title_txt = device_info->ssid;
1966 popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
1967 popup_btn_data.btn1_data = eap_data;
1968 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
1969 popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
1970 popup_btn_data.btn2_data = eap_data;
1971 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
1973 popup = common_utils_show_info_popup(layout_main,
1975 eap_data->popup = popup;
1976 evas_object_show(popup);
1977 elm_object_focus_set(popup, EINA_TRUE);
1979 box = elm_box_add(popup);
1980 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1982 /* Create an EAP connect view list */
1983 list = _create_list(box, eap_data);
1984 elm_object_content_set(box, list);
1986 elm_box_pack_end(box, list);
1987 evas_object_size_hint_min_set(box, -1, ELM_SCALE_SIZE(300));
1988 elm_object_content_set(popup, box);
1990 evas_object_smart_callback_add(eap_data->conf,
1991 "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
1993 evas_object_smart_callback_add(eap_data->conf,
1994 "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
1997 __COMMON_FUNC_EXIT__;
2001 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
2003 wifi_eap_type_e wlan_eap_type = WLAN_SEC_EAP_TYPE_PEAP;
2005 case EAP_SEC_TYPE_PEAP:
2006 wlan_eap_type = WIFI_EAP_TYPE_PEAP;
2008 case EAP_SEC_TYPE_TLS:
2009 wlan_eap_type = WIFI_EAP_TYPE_TLS;
2011 case EAP_SEC_TYPE_TTLS:
2012 wlan_eap_type = WIFI_EAP_TYPE_TTLS;
2014 case EAP_SEC_TYPE_SIM:
2015 wlan_eap_type = WIFI_EAP_TYPE_SIM;
2017 case EAP_SEC_TYPE_AKA:
2018 wlan_eap_type = WIFI_EAP_TYPE_AKA;
2021 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2025 return wlan_eap_type;
2028 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2030 wifi_eap_auth_type_e wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2031 switch (auth_type) {
2032 case EAP_SEC_AUTH_NONE:
2033 wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2035 case EAP_SEC_AUTH_PAP:
2036 wlan_auth_type = WIFI_EAP_AUTH_TYPE_PAP;
2038 case EAP_SEC_AUTH_MSCHAP:
2039 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAP;
2041 case EAP_SEC_AUTH_MSCHAPV2:
2042 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
2044 case EAP_SEC_AUTH_GTC:
2045 wlan_auth_type = WIFI_EAP_AUTH_TYPE_GTC;
2047 case EAP_SEC_AUTH_MD5:
2048 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MD5;
2051 /* This case should never occur */
2052 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2055 return wlan_auth_type;
2058 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap)
2060 wifi_eap_type_e wlan_eap_type = 0;
2061 int ret = wifi_ap_get_eap_type(ap, &wlan_eap_type);
2062 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2063 ret = wifi_ap_set_eap_type(ap, WIFI_EAP_TYPE_PEAP);
2066 if (WIFI_ERROR_NONE != ret) {
2067 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2068 return EAP_SEC_TYPE_UNKNOWN;
2071 switch (wlan_eap_type) {
2072 case WIFI_EAP_TYPE_PEAP: /**< EAP PEAP type */
2073 return EAP_SEC_TYPE_PEAP;
2075 case WIFI_EAP_TYPE_TLS: /**< EAP TLS type */
2076 return EAP_SEC_TYPE_TLS;
2078 case WIFI_EAP_TYPE_TTLS: /**< EAP TTLS type */
2079 return EAP_SEC_TYPE_TTLS;
2081 case WIFI_EAP_TYPE_SIM: /**< EAP SIM type */
2082 return EAP_SEC_TYPE_SIM;
2084 case WIFI_EAP_TYPE_AKA: /**< EAP AKA type */
2085 return EAP_SEC_TYPE_AKA;
2088 return EAP_SEC_TYPE_PEAP;
2090 return EAP_SEC_TYPE_PEAP;
2093 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap)
2095 wifi_eap_auth_type_e wlan_auth_type = 0;
2096 int ret = wifi_ap_get_eap_auth_type(ap, &wlan_auth_type);
2097 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2098 ret = wifi_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2101 if (WIFI_ERROR_NONE != ret) {
2102 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2103 return EAP_SEC_AUTH_NONE;
2106 switch (wlan_auth_type) {
2107 case WIFI_EAP_AUTH_TYPE_NONE: /**< EAP phase2 authentication none */
2108 return EAP_SEC_AUTH_NONE;
2110 case WIFI_EAP_AUTH_TYPE_PAP: /**< EAP phase2 authentication PAP */
2111 return EAP_SEC_AUTH_PAP;
2113 case WIFI_EAP_AUTH_TYPE_MSCHAP: /**< EAP phase2 authentication MSCHAP */
2114 return EAP_SEC_AUTH_MSCHAP;
2116 case WIFI_EAP_AUTH_TYPE_MSCHAPV2: /**< EAP phase2 authentication MSCHAPv2 */
2117 return EAP_SEC_AUTH_MSCHAPV2;
2119 case WIFI_EAP_AUTH_TYPE_GTC: /**< EAP phase2 authentication GTC */
2120 return EAP_SEC_AUTH_GTC;
2122 case WIFI_EAP_AUTH_TYPE_MD5: /**< EAP phase2 authentication MD5 */
2123 return EAP_SEC_AUTH_MD5;
2126 return EAP_SEC_AUTH_NONE;
2128 return EAP_SEC_AUTH_NONE;
2131 static char *_eap_info_get_user_cert_alias(wifi_ap_h ap)
2135 char *filename = NULL;
2136 char *cert_name = NULL;
2138 int filename_len = 0;
2140 wifi_ap_get_eap_client_cert_file(ap, &path);
2144 filename = strrchr(path, '/');
2145 if (filename == NULL) {
2146 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2151 cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2152 if (cert_name == NULL) {
2153 /* For truncated path, available filename will be followed
2154 * with ellipsis(...) & excluding any remaining part of
2155 * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2156 filename_len = strlen(filename);
2157 alias = g_try_malloc0(filename_len - 10);
2158 if (alias == NULL) {
2159 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2162 g_strlcpy(alias, filename, filename_len - 13);
2163 g_strlcat(alias, "...", filename_len - 10);
2164 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2169 alias_len = cert_name - filename;
2171 alias = g_try_malloc0(alias_len + 1);
2172 if (alias == NULL) {
2173 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2177 g_strlcpy(alias, filename, alias_len + 1);
2178 INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2186 /* This creates Auth type, ID, Anonymous Id and Password items
2187 * This function should be called after creating the EAP type item
2189 eap_info_list_t *eap_info_append_items(wifi_ap_h ap, Evas_Object* view_list,
2190 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2191 void *input_panel_cb_data)
2193 __COMMON_FUNC_ENTER__;
2195 eap_type_t eap_type;
2196 eap_auth_t auth_type;
2197 char *temp_str = NULL;
2198 Eina_Bool append_continue = TRUE;
2199 eap_info_list_t *eap_info_list_data = NULL;
2200 Elm_Object_Item* item = NULL;
2201 if (!view_list || !str_pkg_name || !ap) {
2202 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2206 eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2207 if (eap_info_list_data == NULL) {
2211 eap_info_list_data->ap = ap;
2212 eap_type = __common_eap_connect_popup_get_eap_type(ap);
2213 auth_type = __common_eap_connect_popup_get_auth_type(ap);
2215 item = common_utils_add_2_line_txt_disabled_item(view_list,
2217 sc(str_pkg_name, I18N_TYPE_EAP_method),
2218 list_eap_type[eap_type].name);
2219 eap_info_list_data->eap_method_item = item;
2221 eap_info_list_data->eap_type = eap_type;
2224 case EAP_SEC_TYPE_UNKNOWN:
2225 case EAP_SEC_TYPE_PEAP:
2226 case EAP_SEC_TYPE_TLS:
2227 case EAP_SEC_TYPE_TTLS:
2229 case EAP_SEC_TYPE_SIM:
2230 case EAP_SEC_TYPE_AKA:
2232 append_continue = FALSE;
2236 if (append_continue) {
2237 if (eap_type == EAP_SEC_TYPE_PEAP ||
2238 eap_type == EAP_SEC_TYPE_TTLS) {
2239 /* Add EAP phase2 authentication */
2240 item = common_utils_add_2_line_txt_disabled_item(
2241 view_list, "2line.top",
2242 sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2243 list_eap_auth[auth_type].name);
2244 eap_info_list_data->eap_auth_item = item;
2247 if (eap_type == EAP_SEC_TYPE_TLS) {
2248 /* Add User certificate */
2249 temp_str = _eap_info_get_user_cert_alias(ap);
2251 if (temp_str == NULL || strlen(temp_str) == 0) {
2252 if (temp_str != NULL) {
2255 temp_str = g_strdup(sc(str_pkg_name,
2256 I18N_TYPE_Unspecified));
2259 item = common_utils_add_2_line_txt_disabled_item(
2260 view_list, "2line.top",
2261 sc(str_pkg_name, I18N_TYPE_User_Certificate),
2263 eap_info_list_data->user_cert_item = item;
2270 wifi_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set);
2271 item = common_utils_add_2_line_txt_disabled_item(view_list, "2line.top",
2272 sc(str_pkg_name, I18N_TYPE_Identity), temp_str);
2273 eap_info_list_data->id_item = item;
2277 common_utils_entry_info_t *edit_box_details;
2279 /* Add EAP Password */
2280 g_eap_entry_itc.item_style = "entry.main";
2281 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2282 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2283 g_eap_entry_itc.func.state_get = NULL;
2284 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2286 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2287 if (edit_box_details == NULL) {
2288 g_free(eap_info_list_data);
2292 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2293 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2294 edit_box_details->entry_txt = NULL;
2295 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2296 edit_box_details->input_panel_cb = input_panel_cb;
2297 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2298 edit_box_details->item = elm_genlist_item_append(view_list,
2299 &g_eap_entry_itc, edit_box_details, NULL,
2300 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2301 elm_genlist_item_select_mode_set(edit_box_details->item,
2302 ELM_OBJECT_SELECT_MODE_NONE);
2303 eap_info_list_data->pswd_item = edit_box_details->item;
2307 __COMMON_FUNC_EXIT__;
2308 return eap_info_list_data;
2312 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2314 if (!eap_info_list_data) {
2315 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2318 char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2320 wifi_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2326 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2328 if (!eap_info_list_data) {
2329 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2333 g_free(eap_info_list_data);
2336 void eap_connect_data_free(eap_connect_data_t *eap_data)
2338 __common_eap_connect_cleanup(eap_data);