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-svc/cpkcs12.h>
23 #include <cert-svc/cprimitives.h>
24 #include <ui-gadget.h>
25 #include <efl_assist.h>
26 #include <vconf-keys.h>
27 #include <glib/gstdio.h>
28 #include <efl_extension.h>
32 #include "common_eap_connect.h"
33 #include "i18nmanager.h"
34 #include "common_utils.h"
35 #include "common_ip_info.h"
37 #define GENLIST_ITEM_HEIGHT 96
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"
51 #define EAP_AUTH_TYPE_PAP "PAP"
52 #define EAP_AUTH_TYPE_MSCHAP "MSCHAP"
53 #define EAP_AUTH_TYPE_MSCHAPV2 "MSCHAPV2"
54 #define EAP_AUTH_TYPE_GTC "GTC"
55 #define EAP_AUTH_TYPE_MD5 "MD5"
56 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
59 EAP_SEC_TYPE_UNKNOWN = 0,
69 EAP_SEC_AUTH_NONE = 0,
72 EAP_SEC_AUTH_MSCHAPV2,
86 Elm_Genlist_Item_Type flags;
91 Evas_Object *btn_obj[3];
94 struct eap_info_list {
97 Elm_Object_Item *eap_method_item;
98 Elm_Object_Item *eap_auth_item;
99 Elm_Object_Item *user_cert_item;
100 Elm_Object_Item *id_item;
101 Elm_Object_Item *pswd_item;
104 static const _Expand_List_t list_eap_type[] = {
105 {"UNKNOWN", ELM_GENLIST_ITEM_NONE},
106 {"PEAP", ELM_GENLIST_ITEM_NONE},
107 {"TLS", ELM_GENLIST_ITEM_NONE},
108 {"TTLS", ELM_GENLIST_ITEM_NONE},
109 {"SIM", ELM_GENLIST_ITEM_NONE},
110 {"AKA", ELM_GENLIST_ITEM_NONE},
111 {NULL, ELM_GENLIST_ITEM_NONE}
114 static const _Expand_List_t list_eap_auth[] = {
115 {"IDS_ST_BODY_NONE", ELM_GENLIST_ITEM_NONE},
116 {"PAP", ELM_GENLIST_ITEM_NONE},
117 {"MSCHAP", ELM_GENLIST_ITEM_NONE},
118 {"MSCHAPV2", ELM_GENLIST_ITEM_NONE},
119 {"GTC", ELM_GENLIST_ITEM_NONE},
120 {NULL, ELM_GENLIST_ITEM_NONE}
123 static unsigned short selected_cert = 0;
125 struct common_eap_connect_data {
126 Elm_Object_Item *eap_type_item;
127 Elm_Object_Item *eap_auth_item;
128 Elm_Object_Item *eap_user_cert_item;
129 Elm_Object_Item *eap_id_item;
130 Elm_Object_Item *eap_pw_item;
131 Elm_Object_Item *eap_chkbox_item;
133 Evas_Object *sub_popup;
134 Evas_Object *info_popup;
135 Evas_Object *genlist;
136 Eina_Bool eap_done_ok;
139 const char *str_pkg_name;
143 char *user_cert_path;
144 char *privatekey_path;
145 GSList *cert_candidates;
146 Evas_Object *confirm;
154 static Elm_Genlist_Item_Class g_eap_type_itc;
155 static Elm_Genlist_Item_Class g_eap_auth_itc;
156 static Elm_Genlist_Item_Class g_eap_user_cert_itc;
157 static Elm_Genlist_Item_Class g_eap_entry_itc;
158 static Elm_Genlist_Item_Class g_eap_chkbox_itc;
159 static Evas_Object *g_pwd_entry = NULL;
160 static gboolean keypad_state = FALSE;
161 static _Btn_click_t click;
163 static void (*_eap_view_deref_cb)(void) = NULL;
165 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type, eap_connect_data_t *eap_data);
166 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data);
167 static void _delete_eap_auth_item(eap_connect_data_t *eap_data);
168 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data);
169 static void _delete_eap_id_item(eap_connect_data_t *eap_data);
170 static void _delete_eap_pw_items(eap_connect_data_t *eap_data);
171 static void _delete_eap_entry_items(eap_connect_data_t *eap_data);
172 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap);
173 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap);
174 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type);
175 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type);
176 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
177 static gboolean __cert_extract_files(const char *cert_alias,eap_connect_data_t *eap_data);
178 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
180 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
183 static void ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
186 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
188 if (eap_data->sub_popup != NULL) {
189 evas_object_del(eap_data->sub_popup);
190 eap_data->sub_popup = NULL;
194 static void cert_ctxpopup_dismissed_cb(void *data, Evas_Object *obj,
197 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
199 if (eap_data->sub_popup != NULL) {
200 evas_object_del(eap_data->sub_popup);
201 eap_data->sub_popup = NULL;
204 if (eap_data->cert_candidates != NULL) {
205 g_slist_free_full(eap_data->cert_candidates, g_free);
206 eap_data->cert_candidates = NULL;
210 static void move_dropdown(eap_connect_data_t *eap_data, Evas_Object *obj)
212 Evas_Coord x, y, w , h;
214 evas_object_geometry_get(obj, &x, &y, &w, &h);
215 evas_object_move(eap_data->sub_popup, x + (w / 2), y + h);
218 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
220 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
221 elm_genlist_item_selected_set(item, FALSE);
224 static void _select_confirm_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
226 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
227 retm_if(eap_data == NULL);
229 if (eap_data->confirm != NULL) {
230 evas_object_del(eap_data->confirm);
231 eap_data->confirm = NULL;
235 static void __gl_eap_type_sub_sel_language_changed_cb(void *data, Evas_Object *obj, void *event_info)
237 __COMMON_FUNC_ENTER__;
238 retm_if(obj == NULL);
244 g_snprintf(str, 1024, sc(PACKAGE,I18N_TYPE_SIM_method_desc_popup),
245 (val == 1) ? "SIM2" : "SIM1");
246 txt = evas_textblock_text_utf8_to_markup(NULL, str);
247 elm_object_domain_translatable_text_set(obj, PACKAGE, txt);
249 __COMMON_FUNC_EXIT__;
252 static void _gl_eap_type_sub_sel(void *data, Evas_Object *obj, void *event_info)
254 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
255 eap_type_t sel_index = EAP_SEC_TYPE_UNKNOWN;
256 char buf[1024] = {'\0'};
258 eap_type_t pre_index = __common_eap_connect_popup_get_eap_type(eap_data->ap);
259 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
261 if (strcmp(label, EAP_TYPE_UNKNOWN) == 0)
262 sel_index = EAP_SEC_TYPE_UNKNOWN;
263 else if (strcmp(label, EAP_TYPE_PEAP) == 0)
264 sel_index = EAP_SEC_TYPE_PEAP;
265 else if (strcmp(label, EAP_TYPE_TLS) == 0)
266 sel_index = EAP_SEC_TYPE_TLS;
267 else if (strcmp(label, EAP_TYPE_TTLS) == 0)
268 sel_index = EAP_SEC_TYPE_TTLS;
269 else if (strcmp(label, EAP_TYPE_SIM) == 0)
270 sel_index = EAP_SEC_TYPE_SIM;
271 else if (strcmp(label, EAP_TYPE_AKA) == 0)
272 sel_index = EAP_SEC_TYPE_AKA;
274 DEBUG_LOG(UG_NAME_NORMAL, "previous index = %d; selected index = %d;",
275 pre_index, sel_index);
276 if ((pre_index != EAP_SEC_TYPE_SIM && sel_index == EAP_SEC_TYPE_SIM) ||
277 (pre_index != EAP_SEC_TYPE_AKA && sel_index == EAP_SEC_TYPE_AKA)) {
278 popup_btn_info_t popup_data;
280 value = common_util_get_system_registry(
281 VCONF_TELEPHONY_DEFAULT_DATA_SERVICE);
283 memset(&popup_data, 0, sizeof(popup_data));
284 g_snprintf(buf, sizeof(buf),
285 sc(PACKAGE, I18N_TYPE_SIM_method_desc_popup),
286 (value == 1) ? "SIM2" : "SIM1");
287 popup_data.title_txt = "IDS_WIFI_BODY_EAP_METHOD";
288 popup_data.info_txt = evas_textblock_text_utf8_to_markup(NULL, buf);
289 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
290 popup_data.btn1_cb = _select_confirm_popup_ok_cb;
291 popup_data.btn1_data = eap_data;
293 eap_data->confirm = common_utils_show_info_popup(eap_data->win,
295 g_free(popup_data.info_txt);
296 evas_object_smart_callback_add(eap_data->confirm, "language,changed",
297 __gl_eap_type_sub_sel_language_changed_cb, (void *)value);
299 _create_and_update_list_items_based_on_rules(sel_index, data);
300 wifi_eap_type_e type;
301 wifi_ap_set_eap_type(eap_data->ap,
302 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
303 wifi_ap_get_eap_type(eap_data->ap, &type);
304 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
307 if (eap_data->sub_popup != NULL) {
308 evas_object_del(eap_data->sub_popup);
309 eap_data->sub_popup = NULL;
312 if (pre_index != sel_index) {
313 wifi_eap_type_e type;
314 wifi_ap_set_eap_type(eap_data->ap,
315 __common_eap_connect_popup_get_wlan_eap_type(sel_index));
316 wifi_ap_get_eap_type(eap_data->ap, &type);
317 DEBUG_LOG(UG_NAME_NORMAL, "set to new index = %d", type);
318 _create_and_update_list_items_based_on_rules(sel_index, eap_data);
320 if (sel_index == EAP_SEC_TYPE_PEAP) {
321 /* If previous auth type was PAP or MSCHAP & when PEAP
322 * EAP method is selected, then set back MSCHAPV2
324 eap_auth_t auth_type;
326 auth_type = __common_eap_connect_popup_get_auth_type(eap_data->ap);
327 if (auth_type == EAP_SEC_AUTH_PAP ||
328 auth_type == EAP_SEC_AUTH_MSCHAP) {
329 wifi_ap_set_eap_auth_type(eap_data->ap,
330 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
332 if(eap_data->eap_auth_item != NULL)
333 elm_genlist_item_update(eap_data->eap_auth_item);
337 DEBUG_LOG(UG_NAME_NORMAL, "pre_index == sel_index[%d]",
341 if(eap_data->eap_type_item != NULL)
342 elm_genlist_item_update(eap_data->eap_type_item);
345 static CertSvcStringList stringList;
346 static CertSvcInstance instance;
347 static CertSvcStoreCertList *certList = NULL;
349 static void _gl_eap_user_cert_sel(void *data, Evas_Object *obj,
352 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
353 const char *cert_alias = elm_object_item_text_get((Elm_Object_Item *) event_info);
358 if (eap_data->sub_popup != NULL) {
359 evas_object_del(eap_data->sub_popup);
360 eap_data->sub_popup = NULL;
363 if (eap_data->ca_cert_path) {
364 g_unlink(eap_data->ca_cert_path);
365 eap_data->ca_cert_path = NULL;
367 if (eap_data->user_cert_path) {
368 g_unlink(eap_data->user_cert_path);
369 eap_data->user_cert_path = NULL;
371 if (eap_data->privatekey_path) {
372 g_unlink(eap_data->privatekey_path);
373 eap_data->privatekey_path = NULL;
376 if (strcmp(cert_alias, sc(PACKAGE, I18N_TYPE_None)) == 0) {
377 if (eap_data->cert_alias != NULL) {
378 g_free(eap_data->cert_alias);
379 eap_data->cert_alias = NULL;
381 } else if (__cert_extract_files(cert_alias, eap_data)) {
382 if (eap_data->cert_alias != NULL) {
383 g_free(eap_data->cert_alias);
384 eap_data->cert_alias = NULL;
386 eap_data->cert_alias = g_strdup(cert_alias);
389 if(eap_data->eap_user_cert_item != NULL)
390 elm_genlist_item_update(eap_data->eap_user_cert_item);
392 if (eap_data->cert_candidates != NULL) {
393 g_slist_free_full(eap_data->cert_candidates, g_free);
394 eap_data->cert_candidates = NULL;
398 static void _create_eap_cert_list(eap_connect_data_t *eap_data,
403 Evas_Object *ctxpopup;
404 Elm_Object_Item *it = NULL;
409 if (eap_data->sub_popup != NULL) {
410 evas_object_del(eap_data->sub_popup);
411 eap_data->sub_popup = NULL;
414 ctxpopup = elm_ctxpopup_add(eap_data->win);
415 eap_data->sub_popup = ctxpopup;
416 elm_object_style_set(ctxpopup, "dropdown/list");
417 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
418 cert_ctxpopup_dismissed_cb, NULL);
419 evas_object_smart_callback_add(ctxpopup,"dismissed",
420 cert_ctxpopup_dismissed_cb, eap_data);
421 elm_ctxpopup_direction_priority_set(ctxpopup,
422 ELM_CTXPOPUP_DIRECTION_DOWN,
423 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
424 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
425 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
427 if (certsvc_instance_new(&instance) == CERTSVC_FAIL) {
428 INFO_LOG(UG_NAME_ERR, "Failed to create new instance");
432 certsvc_pkcs12_get_certificate_list_from_store(instance, WIFI_STORE, DISABLED, &certList, &list_length);
434 if (eap_data->cert_candidates) {
435 g_slist_free_full(eap_data->cert_candidates, g_free);
436 eap_data->cert_candidates = NULL;
439 it = elm_ctxpopup_item_append(ctxpopup, "IDS_ST_BODY_NONE", NULL,
440 _gl_eap_user_cert_sel, eap_data);
441 elm_object_item_domain_text_translatable_set(it,
444 while(certList != NULL) {
445 char *char_buffer = NULL;
446 CertSvcString buffer;
448 buffer.privateHandler = (char *)certList->gname;
449 buffer.privateLength = strlen(certList->gname);
450 INFO_LOG(UG_NAME_NORMAL, "gname in processing : %s", certList->gname);
452 char_buffer = g_strndup(buffer.privateHandler, buffer.privateLength);
453 if (char_buffer == NULL)
456 elm_ctxpopup_item_append(ctxpopup, char_buffer, NULL,
457 _gl_eap_user_cert_sel, eap_data);
458 eap_data->cert_candidates =
459 g_slist_prepend(eap_data->cert_candidates, char_buffer);
461 certsvc_string_free(buffer);
462 certList = certList->next;
465 move_dropdown(eap_data, btn);
466 evas_object_show(ctxpopup);
469 certsvc_instance_free(instance);
472 static void _gl_eap_cert_list_btn_cb(void *data, Evas_Object *obj,
475 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
476 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
479 elm_genlist_item_selected_set(item, EINA_FALSE);
481 if (keypad_state == FALSE) {
482 _create_eap_cert_list(eap_data, obj);
484 click.btn_click[EAP_CERT_BTN] = FALSE;
485 click.btn_obj[EAP_CERT_BTN] = NULL;
487 click.btn_click[EAP_CERT_BTN] = TRUE;
488 click.btn_obj[EAP_CERT_BTN] = obj;
492 static char *_gl_eap_user_cert_text_get(void *data, Evas_Object *obj, const char *part)
494 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
496 if (!g_strcmp0(part, "elm.text.main")) {
497 return g_strdup(sc(eap_data->str_pkg_name,
498 I18N_TYPE_User_Certificate));
504 static Evas_Object *_gl_eap_user_cert_content_get(void *data,
505 Evas_Object *obj, const char *part)
507 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
508 Evas_Object *btn = NULL;
509 Evas_Object *ly = NULL;
512 if (!strcmp(part, "elm.icon.entry")) {
513 ly = elm_layout_add(obj);
514 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
515 "eap_dropdown_button");
516 btn = elm_button_add(obj);
518 if (eap_data->cert_alias == NULL) {
519 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
520 sc(eap_data->str_pkg_name, I18N_TYPE_None));
522 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
523 eap_data->cert_alias);
526 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
527 elm_object_style_set(btn, "dropdown/label");
528 evas_object_propagate_events_set(btn, EINA_FALSE);
529 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
531 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
533 evas_object_smart_callback_add(btn, "clicked",
534 _gl_eap_cert_list_btn_cb, eap_data);
536 elm_layout_content_set(ly, "btn", btn);
542 static void _gl_eap_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
544 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
547 elm_genlist_item_selected_set(item, EINA_FALSE);
551 static void _create_eap_type_list(eap_connect_data_t *eap_data,
554 Evas_Object *ctxpopup = NULL;
555 int i = EAP_SEC_TYPE_PEAP;
556 int sim_state = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
557 Elm_Object_Item *it = NULL;
559 sim_state = common_utils_get_sim_state();
561 if (eap_data->sub_popup != NULL) {
562 evas_object_del(eap_data->sub_popup);
565 ctxpopup = elm_ctxpopup_add(eap_data->win);
566 eap_data->sub_popup = ctxpopup;
567 elm_object_style_set(ctxpopup, "dropdown/list");
568 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK,
569 eext_ctxpopup_back_cb, NULL);
570 evas_object_smart_callback_add(ctxpopup,"dismissed",
571 ctxpopup_dismissed_cb, eap_data);
572 elm_ctxpopup_direction_priority_set(ctxpopup,
573 ELM_CTXPOPUP_DIRECTION_DOWN,
574 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
575 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
576 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
578 /* eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap); */
579 while (list_eap_type[i].name != NULL) {
580 it = elm_ctxpopup_item_append(ctxpopup, list_eap_type[i].name,
581 NULL, _gl_eap_type_sub_sel, eap_data);
583 if ((i == EAP_SEC_TYPE_SIM || i == EAP_SEC_TYPE_AKA) &&
584 sim_state != VCONFKEY_TELEPHONY_SIM_INSERTED) {
585 elm_object_item_disabled_set(it, EINA_TRUE);
590 move_dropdown(eap_data, btn);
591 evas_object_show(ctxpopup);
594 static void _gl_eap_type_btn_cb(void *data, Evas_Object *obj, void *event_info)
596 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
597 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
600 elm_genlist_item_selected_set(item, EINA_FALSE);
602 if (keypad_state == FALSE) {
603 _create_eap_type_list(eap_data, obj);
605 click.btn_click[EAP_TYPE_BTN] = FALSE;
606 click.btn_obj[EAP_TYPE_BTN] = NULL;
608 click.btn_click[EAP_TYPE_BTN] = TRUE;
609 click.btn_obj[EAP_TYPE_BTN] = obj;
613 static char *_gl_eap_type_text_get(void *data, Evas_Object *obj, const char *part)
615 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
617 if (!g_strcmp0(part, "elm.text.main")) {
618 return g_strdup(sc(eap_data->str_pkg_name, I18N_TYPE_EAP_method));
624 static Evas_Object *_gl_eap_type_content_get(void *data,
625 Evas_Object *obj, const char *part)
627 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
628 eap_type_t sel_sub_item_id = __common_eap_connect_popup_get_eap_type(eap_data->ap);
629 Evas_Object *btn = NULL;
630 Evas_Object *ly = NULL;
633 if (!strcmp(part, "elm.icon.entry")) {
634 ly = elm_layout_add(obj);
635 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
636 "eap_dropdown_button");
637 btn = elm_button_add(obj);
639 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
640 list_eap_type[sel_sub_item_id].name);
642 elm_object_text_set(btn, buf);
643 elm_object_style_set(btn, "dropdown/label");
644 evas_object_propagate_events_set(btn, EINA_FALSE);
645 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
647 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
649 evas_object_smart_callback_add(btn, "clicked",
650 _gl_eap_type_btn_cb, eap_data);
652 elm_layout_content_set(ly, "btn", btn);
658 static void _gl_eap_auth_sub_sel(void *data, Evas_Object *obj, void *event_info)
660 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
661 eap_auth_t sel_index = EAP_SEC_AUTH_NONE;
663 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
665 if (strcmp(label, sc(PACKAGE, I18N_TYPE_None)) == 0)
666 sel_index = EAP_SEC_AUTH_NONE;
667 else if (strcmp(label, EAP_AUTH_TYPE_PAP) == 0)
668 sel_index = EAP_SEC_AUTH_PAP;
669 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAP) == 0)
670 sel_index = EAP_SEC_AUTH_MSCHAP;
671 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAPV2) == 0)
672 sel_index = EAP_SEC_AUTH_MSCHAPV2;
673 else if (strcmp(label, EAP_AUTH_TYPE_GTC) == 0)
674 sel_index = EAP_SEC_AUTH_GTC;
675 else if (strcmp(label, EAP_AUTH_TYPE_MD5) == 0)
676 sel_index = EAP_SEC_AUTH_MD5;
678 wifi_ap_set_eap_auth_type(eap_data->ap,
679 __common_eap_connect_popup_get_wlan_auth_type(sel_index));
681 if (eap_data->sub_popup != NULL) {
682 evas_object_del(eap_data->sub_popup);
683 eap_data->sub_popup = NULL;
686 if(eap_data->eap_auth_item != NULL)
687 elm_genlist_item_update(eap_data->eap_auth_item);
690 static void _create_eap_auth_list(eap_connect_data_t *eap_data,
693 Elm_Object_Item *it = NULL;
694 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
695 Evas_Object *ctxpopup;
698 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
700 if (eap_data->sub_popup != NULL) {
701 evas_object_del(eap_data->sub_popup);
704 ctxpopup = elm_ctxpopup_add(eap_data->win);
705 eap_data->sub_popup = ctxpopup;
706 elm_object_style_set(ctxpopup, "dropdown/list");
707 eext_object_event_callback_add(ctxpopup, EA_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
708 evas_object_smart_callback_add(ctxpopup,"dismissed", ctxpopup_dismissed_cb, eap_data);
709 elm_ctxpopup_direction_priority_set(ctxpopup,
710 ELM_CTXPOPUP_DIRECTION_DOWN,
711 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
712 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
713 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
715 while (list_eap_auth[i].name != NULL) {
716 if ((eap_type != EAP_SEC_TYPE_PEAP) ||
717 (eap_type == EAP_SEC_TYPE_PEAP && i != 1 &&
719 it = elm_ctxpopup_item_append(ctxpopup, list_eap_auth[i].name,
720 NULL, _gl_eap_auth_sub_sel, eap_data);
722 elm_object_item_domain_text_translatable_set(it,
728 move_dropdown(eap_data, btn);
729 evas_object_show(ctxpopup);
732 static void _gl_eap_auth_btn_cb(void *data, Evas_Object *obj, void *event_info)
734 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
735 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
738 elm_genlist_item_selected_set(item, EINA_FALSE);
740 if (keypad_state == FALSE) {
741 _create_eap_auth_list(eap_data, obj);
743 click.btn_click[EAP_AUTH_BTN] = FALSE;
744 click.btn_obj[EAP_AUTH_BTN] = NULL;
746 click.btn_click[EAP_AUTH_BTN] = TRUE;
747 click.btn_obj[EAP_AUTH_BTN] = obj;
751 static char *_gl_eap_auth_text_get(void *data, Evas_Object *obj, const char *part)
753 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
755 if (!g_strcmp0(part, "elm.text.main")) {
756 return g_strdup(sc(eap_data->str_pkg_name,
757 I18N_TYPE_Phase_2_authentication));
763 static Evas_Object *_gl_eap_auth_content_get(void *data,
764 Evas_Object *obj, const char *part)
766 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
767 eap_auth_t sel_sub_item_id = __common_eap_connect_popup_get_auth_type(eap_data->ap);
768 Evas_Object *btn = NULL;
769 Evas_Object *ly = NULL;
772 if (!strcmp(part, "elm.icon.entry")) {
773 ly = elm_layout_add(obj);
774 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
775 "eap_dropdown_button");
776 btn = elm_button_add(obj);
778 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
779 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
780 sc(PACKAGE, I18N_TYPE_None));
782 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
783 list_eap_auth[sel_sub_item_id].name);
786 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
787 elm_object_style_set(btn, "dropdown/label");
788 evas_object_propagate_events_set(btn, EINA_FALSE);
789 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
791 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
793 evas_object_smart_callback_add(btn, "clicked",
794 _gl_eap_auth_btn_cb, eap_data);
796 elm_layout_content_set(ly, "btn", btn);
802 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
804 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
809 Evas_Object *entry = NULL;
810 Elm_Object_Item *next_item = NULL;
813 switch (entry_info->entry_id) {
814 case ENTRY_TYPE_USER_ID:
815 eap_type = __common_eap_connect_popup_get_eap_type(
818 if (eap_type == EAP_SEC_TYPE_TLS) {
819 entry = elm_object_item_part_content_get(entry_info->item,
822 elm_object_focus_set(entry, EINA_FALSE);
825 next_item = elm_genlist_item_next_get(entry_info->item);
827 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
828 elm_genlist_item_select_mode_get(next_item) !=
829 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
830 entry = elm_object_item_part_content_get(
831 next_item, "elm.icon.entry");
833 elm_object_focus_set(entry, EINA_TRUE);
838 next_item = elm_genlist_item_next_get(next_item);
842 case ENTRY_TYPE_PASSWORD:
843 entry = elm_object_item_part_content_get(entry_info->item,
846 elm_object_focus_set(entry, EINA_FALSE);
854 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
856 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
861 if (elm_object_focus_get(obj)) {
862 if (elm_entry_is_empty(obj)) {
863 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
865 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
869 if (entry_info->entry_txt) {
870 g_free(entry_info->entry_txt);
871 entry_info->entry_txt = NULL;
874 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
876 if (entry_text != NULL && entry_text[0] != '\0') {
877 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
883 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
885 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
894 if (elm_object_focus_get(obj)) {
895 if (elm_entry_is_empty(obj)) {
896 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
898 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
903 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
905 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
910 if (!elm_entry_is_empty(obj)) {
911 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
914 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
917 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
919 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
924 if (entry_info->entry_txt) {
925 g_free(entry_info->entry_txt);
926 entry_info->entry_txt = NULL;
929 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
930 if (entry_text != NULL && entry_text[0] != '\0')
931 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
935 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
936 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
939 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
942 common_utils_send_message_to_net_popup("Password length",
943 "Lengthy Password", "notification", NULL);
946 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
948 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
953 Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
955 elm_object_focus_set(entry, EINA_TRUE);
956 elm_entry_entry_set(entry, "");
960 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
962 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
967 if (!g_strcmp0(part, "elm.text.main")) {
968 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
974 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
976 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
981 if (g_strcmp0(part, "elm.icon.entry") == 0) {
982 Evas_Object *entry = NULL;
983 char *guide_txt = NULL;
984 char *accepted = NULL;
985 Eina_Bool hide_entry_txt = EINA_FALSE;
986 Elm_Input_Panel_Layout panel_type;
990 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
992 static Elm_Entry_Filter_Limit_Size limit_filter_data;
994 switch (entry_info->entry_id)
996 case ENTRY_TYPE_USER_ID:
997 panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
998 guide_txt = entry_info->guide_txt;
1000 if (eap_type == EAP_SEC_TYPE_TLS) {
1001 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1003 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1006 case ENTRY_TYPE_PASSWORD:
1007 panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1008 guide_txt = entry_info->guide_txt;
1009 hide_entry_txt = EINA_TRUE;
1010 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1016 entry = elm_entry_add(obj);
1017 retvm_if(NULL == entry, NULL);
1019 elm_entry_single_line_set(entry, EINA_TRUE);
1020 elm_entry_scrollable_set(entry, EINA_TRUE);
1021 elm_entry_password_set(entry, hide_entry_txt);
1022 elm_entry_prediction_allow_set(entry, EINA_FALSE);
1023 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
1025 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
1026 PACKAGE, guide_txt);
1027 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0)) {
1028 elm_entry_entry_set(entry, entry_info->entry_txt);
1031 elm_entry_input_panel_layout_set(entry, panel_type);
1032 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
1034 limit_filter_data.max_char_count = 200;
1035 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
1037 Elm_Entry_Filter_Accept_Set digits_filter_data;
1038 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1039 digits_filter_data.accepted = accepted;
1040 elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digits_filter_data);
1042 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(entry);
1043 if (imf_ctxt && entry_info->input_panel_cb) {
1044 ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1045 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1046 entry_info->input_panel_cb,
1047 entry_info->input_panel_cb_data);
1048 DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1051 evas_object_smart_callback_add(entry, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1052 evas_object_smart_callback_add(entry, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1053 evas_object_smart_callback_add(entry, "changed", _gl_eap_entry_changed_cb, entry_info);
1054 evas_object_smart_callback_add(entry, "focused", _gl_eap_entry_focused_cb, entry_info);
1055 evas_object_smart_callback_add(entry, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1056 evas_object_smart_callback_add(entry, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1058 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD) {
1059 g_pwd_entry = entry;
1063 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1064 Evas_Object *btn = elm_button_add(obj);
1065 elm_object_style_set(btn, "editfield_clear");
1066 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1073 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1075 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1076 if (entry_info == NULL) {
1080 if (entry_info->entry_txt) {
1081 g_free(entry_info->entry_txt);
1087 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1089 if (obj == NULL || g_pwd_entry == NULL) {
1093 Eina_Bool state = elm_check_state_get(obj);
1095 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1097 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1101 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1104 char *str_pkg_name = (char *)data;
1106 if (!g_strcmp0(part, "elm.text.main.left")) {
1108 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1115 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1116 Evas_Object *obj, const char *part)
1118 Evas_Object *check = NULL;
1120 if(!g_strcmp0(part, "elm.icon.right")) {
1121 check = elm_check_add(obj);
1122 evas_object_propagate_events_set(check, EINA_FALSE);
1124 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1125 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1126 evas_object_smart_callback_add(check, "changed",
1127 _chk_changed_cb, NULL);
1129 elm_object_focus_allow_set(check, EINA_FALSE);
1136 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1138 Elm_Object_Item *item = NULL;
1140 item = (Elm_Object_Item *)ei;
1145 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1147 elm_genlist_item_selected_set(item, EINA_FALSE);
1149 Eina_Bool state = elm_check_state_get(ck);
1150 elm_check_state_set(ck, !state);
1152 _chk_changed_cb(NULL, ck, NULL);
1155 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1157 elm_genlist_realized_items_update(obj);
1160 static void __common_eap_connect_popup_init_item_class(void *data)
1162 g_eap_type_itc.item_style = "entry.main";
1163 g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1164 g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1165 g_eap_type_itc.func.state_get = NULL;
1166 g_eap_type_itc.func.del = NULL;
1168 g_eap_auth_itc.item_style = "entry.main";
1169 g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1170 g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1171 g_eap_auth_itc.func.state_get = NULL;
1172 g_eap_auth_itc.func.del = NULL;
1174 g_eap_user_cert_itc.item_style = "entry.main";
1175 g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1176 g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1177 g_eap_user_cert_itc.func.state_get = NULL;
1178 g_eap_user_cert_itc.func.del = NULL;
1180 g_eap_entry_itc.item_style = "entry.main";
1181 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1182 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1183 g_eap_entry_itc.func.state_get = NULL;
1184 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1186 g_eap_chkbox_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
1187 g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1188 g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1189 g_eap_chkbox_itc.func.state_get = NULL;
1190 g_eap_chkbox_itc.func.del = NULL;
1193 static gboolean __cert_extract_files(const char *cert_alias,
1194 eap_connect_data_t *eap_data)
1198 int cert_counts = 0;
1200 gchar *ca_cert_path = NULL;
1201 gchar *user_cert_path = NULL;
1202 gchar *privatekey_path = NULL;
1204 CertSvcInstance cert_instance;
1205 CertSvcString cert_alias_str;
1206 CertSvcCertificateList cert_list;
1207 CertSvcCertificate user_certificate;
1208 CertSvcCertificate ca_certificate;
1209 CertSvcCertificate *selected_certificate = NULL;
1211 EVP_PKEY *privatekey = NULL;
1213 ret = certsvc_instance_new(&cert_instance);
1214 if (ret != CERTSVC_SUCCESS) {
1215 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1218 ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1219 if (ret != CERTSVC_SUCCESS) {
1220 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1223 ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1224 if (ret != CERTSVC_SUCCESS) {
1225 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1228 ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1229 if (cert_counts < 1) {
1230 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1233 INFO_LOG(UG_NAME_NORMAL, "cert counts: %d", cert_counts);
1234 selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1235 if (selected_certificate == NULL) {
1236 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1239 ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1240 if (ret != CERTSVC_SUCCESS) {
1241 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1244 cert_index = cert_counts - 1;
1246 selected_certificate[0] = user_certificate;
1248 ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1250 user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1251 cert_alias, EAP_TLS_USER_CERT_PATH);
1252 if ((fp = fopen(user_cert_path, "w")) == NULL) {
1255 ret = PEM_write_X509(fp, x509);
1257 certsvc_certificate_free_x509(x509);
1258 INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1260 ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1261 EAP_TLS_CA_CERT_PATH);
1262 while (cert_index) {
1263 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1264 if (ret != CERTSVC_SUCCESS) {
1265 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1269 selected_certificate[cert_counts-cert_index] = ca_certificate;
1272 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1273 if ((fp = fopen(ca_cert_path, "a")) == NULL) {
1276 ret = PEM_write_X509(fp, x509);
1278 certsvc_certificate_free_x509(x509);
1280 INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1281 ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1282 if (ret != CERTSVC_SUCCESS) {
1283 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1286 if (validity == 0) {
1287 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1291 ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1293 privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1294 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1296 if ((fp = fopen(privatekey_path, "w")) == NULL) {
1299 ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1301 certsvc_pkcs12_free_evp_pkey(privatekey);
1302 INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1304 g_free(selected_certificate);
1305 certsvc_instance_free(cert_instance);
1307 eap_data->ca_cert_path = ca_cert_path;
1308 eap_data->user_cert_path = user_cert_path;
1309 eap_data->privatekey_path = privatekey_path;
1314 g_free(ca_cert_path);
1315 g_free(user_cert_path);
1316 g_free(privatekey_path);
1318 if (selected_certificate) {
1319 g_free(selected_certificate);
1322 certsvc_instance_free(cert_instance);
1326 /* This creates EAP type, Auth type, CA certificate, User certificate,
1327 * User Id, Anonymous Id and Password items.
1329 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1330 eap_connect_data_t *eap_data)
1332 __COMMON_FUNC_ENTER__;
1333 Evas_Object* view_list = eap_data->genlist;
1334 Elm_Object_Item *insert_after_item = NULL;
1335 Elm_Object_Item *prev_item = NULL;
1336 common_utils_entry_info_t *edit_box_details;
1337 Eina_Bool auth_reqd = EINA_FALSE;
1338 Eina_Bool user_cert_reqd = EINA_FALSE;
1339 Eina_Bool id_reqd = EINA_FALSE;
1340 Eina_Bool pw_reqd = EINA_FALSE;
1342 if (NULL == eap_data->eap_type_item) {
1343 /* Create EAP method/type */
1344 eap_data->eap_type_item = elm_genlist_item_append(
1345 view_list, &g_eap_type_itc,
1347 ELM_GENLIST_ITEM_NONE,
1348 _gl_eap_item_sel_cb, eap_data);
1352 case EAP_SEC_TYPE_PEAP:
1353 insert_after_item = eap_data->eap_type_item;
1354 auth_reqd = EINA_TRUE;
1355 user_cert_reqd = EINA_FALSE;
1356 id_reqd = EINA_TRUE;
1357 pw_reqd = EINA_TRUE;
1359 case EAP_SEC_TYPE_TLS:
1360 insert_after_item = eap_data->eap_type_item;
1361 auth_reqd = EINA_FALSE;
1362 user_cert_reqd = EINA_TRUE;
1363 id_reqd = EINA_TRUE;
1364 pw_reqd = EINA_FALSE;
1366 case EAP_SEC_TYPE_TTLS:
1367 insert_after_item = eap_data->eap_type_item;
1368 auth_reqd = EINA_TRUE;
1369 user_cert_reqd = EINA_FALSE;
1370 id_reqd = EINA_TRUE;
1371 pw_reqd = EINA_TRUE;
1373 case EAP_SEC_TYPE_SIM:
1374 case EAP_SEC_TYPE_AKA:
1375 _delete_eap_entry_items(eap_data);
1376 auth_reqd = EINA_FALSE;
1377 user_cert_reqd = EINA_FALSE;
1378 id_reqd = EINA_FALSE;
1379 pw_reqd = EINA_FALSE;
1385 if (auth_reqd == EINA_TRUE) {
1386 if (eap_data->eap_auth_item == NULL) {
1387 /* Add EAP phase2 authentication */
1388 eap_data->eap_auth_item = elm_genlist_item_insert_after(
1389 view_list, &g_eap_auth_itc, eap_data, NULL,
1390 insert_after_item, ELM_GENLIST_ITEM_NONE,
1391 _gl_eap_item_sel_cb, eap_data);
1394 _delete_eap_auth_item(eap_data);
1397 if (user_cert_reqd == EINA_TRUE) {
1398 if (eap_data->eap_user_cert_item == NULL) {
1399 prev_item = eap_data->eap_type_item;
1401 /* Add User certificate */
1402 eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1403 view_list, &g_eap_user_cert_itc, eap_data, NULL,
1404 prev_item, ELM_GENLIST_ITEM_NONE,
1405 _gl_eap_item_sel_cb, eap_data);
1408 _delete_eap_user_cert_item(eap_data);
1411 if (id_reqd == EINA_TRUE) {
1412 if (eap_data->eap_id_item == NULL) {
1413 if (new_type == EAP_SEC_TYPE_PEAP ||
1414 new_type == EAP_SEC_TYPE_TTLS) {
1415 prev_item = eap_data->eap_auth_item;
1417 prev_item = eap_data->eap_user_cert_item;
1421 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1422 if (edit_box_details == NULL) {
1426 edit_box_details->ap = eap_data->ap;
1427 edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1428 edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1429 edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1430 edit_box_details->item = elm_genlist_item_insert_after(
1431 view_list, &g_eap_entry_itc, edit_box_details,
1433 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1434 eap_data->eap_id_item = edit_box_details->item;
1437 _delete_eap_id_item(eap_data);
1440 if (pw_reqd == EINA_TRUE) {
1441 if (eap_data->eap_pw_item == NULL) {
1442 /* Add EAP Password */
1443 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1444 if (edit_box_details == NULL) {
1448 edit_box_details->ap = eap_data->ap;
1449 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1450 edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1451 edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1452 edit_box_details->item = elm_genlist_item_insert_after(
1453 view_list, &g_eap_entry_itc,
1454 edit_box_details, NULL,
1455 eap_data->eap_id_item,
1456 ELM_GENLIST_ITEM_NONE,
1457 _gl_editbox_sel_cb, NULL);
1458 eap_data->eap_pw_item = edit_box_details->item;
1460 _update_eap_id_item_enter_key(eap_data);
1463 if (eap_data->eap_chkbox_item == NULL) {
1464 /* Add Show Password checkbox */
1465 eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1466 view_list, &g_eap_chkbox_itc,
1467 eap_data->str_pkg_name, NULL,
1468 eap_data->eap_pw_item,
1469 ELM_GENLIST_ITEM_NONE,
1470 _gl_eap_chkbox_sel, NULL);
1473 _delete_eap_pw_items(eap_data);
1476 __COMMON_FUNC_EXIT__;
1480 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1482 if (eap_data->eap_id_item == NULL)
1485 Evas_Object *entry = NULL;
1486 eap_type_t eap_type;
1488 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1489 entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1492 if (eap_type == EAP_SEC_TYPE_TLS) {
1493 elm_entry_input_panel_return_key_type_set(entry,
1494 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1496 elm_entry_input_panel_return_key_type_set(entry,
1497 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1502 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1504 __COMMON_FUNC_ENTER__;
1506 if (eap_data->eap_auth_item != NULL) {
1507 elm_object_item_del(eap_data->eap_auth_item);
1508 eap_data->eap_auth_item = NULL;
1511 __COMMON_FUNC_EXIT__;
1515 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1517 __COMMON_FUNC_ENTER__;
1519 if (eap_data->eap_user_cert_item != NULL) {
1520 elm_object_item_del(eap_data->eap_user_cert_item);
1521 eap_data->eap_user_cert_item = NULL;
1524 __COMMON_FUNC_EXIT__;
1528 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1530 __COMMON_FUNC_ENTER__;
1532 if (eap_data->eap_id_item != NULL) {
1533 elm_object_item_del(eap_data->eap_id_item);
1534 eap_data->eap_id_item = NULL;
1537 __COMMON_FUNC_EXIT__;
1541 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1543 __COMMON_FUNC_ENTER__;
1545 _update_eap_id_item_enter_key(eap_data);
1547 if (eap_data->eap_pw_item != NULL) {
1548 elm_object_item_del(eap_data->eap_pw_item);
1549 eap_data->eap_pw_item = NULL;
1552 if (eap_data->eap_chkbox_item) {
1553 elm_object_item_del(eap_data->eap_chkbox_item);
1554 eap_data->eap_chkbox_item = NULL;
1557 __COMMON_FUNC_EXIT__;
1561 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1563 __COMMON_FUNC_ENTER__;
1565 if (eap_data->eap_auth_item != NULL) {
1566 elm_object_item_del(eap_data->eap_auth_item);
1567 eap_data->eap_auth_item = NULL;
1570 if (eap_data->eap_user_cert_item != NULL) {
1571 elm_object_item_del(eap_data->eap_user_cert_item);
1572 eap_data->eap_user_cert_item = NULL;
1575 if (eap_data->eap_id_item != NULL) {
1576 elm_object_item_del(eap_data->eap_id_item);
1577 eap_data->eap_id_item = NULL;
1580 if (eap_data->eap_pw_item != NULL) {
1581 elm_object_item_del(eap_data->eap_pw_item);
1582 eap_data->eap_pw_item = NULL;
1585 if (eap_data->eap_chkbox_item != NULL) {
1586 elm_object_item_del(eap_data->eap_chkbox_item);
1587 eap_data->eap_chkbox_item = NULL;
1590 __COMMON_FUNC_EXIT__;
1594 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1596 __COMMON_FUNC_ENTER__;
1597 assertm_if(NULL == parent, "NULL!!");
1599 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1600 Evas_Object* view_list = NULL;
1601 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1602 retvm_if(eap_data == NULL, NULL);
1604 __common_eap_connect_popup_init_item_class(eap_data);
1606 eap_data->eap_done_ok = FALSE;
1607 eap_data->genlist = view_list = elm_genlist_add(parent);
1608 elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1609 elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1611 evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1613 evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1615 /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1616 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1617 wifi_ap_set_eap_type(eap_data->ap,
1618 (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1619 WIFI_EAP_TYPE_PEAP :
1620 __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1622 wifi_ap_set_eap_auth_type(eap_data->ap,
1623 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
1627 /* Create the entry items */
1628 _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1630 evas_object_show(view_list);
1631 evas_object_smart_callback_add(view_list, "language,changed",
1632 gl_lang_changed, NULL);
1634 __COMMON_FUNC_EXIT__;
1638 static Eina_Bool _enable_scan_updates_cb(void *data)
1640 /* Lets enable the scan updates */
1641 wlan_manager_enable_scan_result_update();
1643 /* Reset the ecore timer handle */
1644 common_util_manager_ecore_scan_update_timer_reset();
1646 return ECORE_CALLBACK_CANCEL;
1649 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1651 if (eap_data == NULL) {
1655 if (eap_data->conf != NULL) {
1656 evas_object_smart_callback_del(eap_data->conf,
1657 "virtualkeypad,state,on",
1658 _eap_popup_keypad_on_cb);
1659 evas_object_smart_callback_del(eap_data->conf,
1660 "virtualkeypad,state,off",
1661 _eap_popup_keypad_off_cb);
1664 if (eap_data->ssid != NULL) {
1665 g_free(eap_data->ssid);
1666 eap_data->ssid = NULL;
1669 if (eap_data->cert_alias) {
1670 g_free(eap_data->cert_alias);
1671 eap_data->cert_alias = NULL;
1674 if (eap_data->ca_cert_path) {
1675 g_free(eap_data->ca_cert_path);
1676 eap_data->ca_cert_path = NULL;
1679 if (eap_data->user_cert_path) {
1680 g_free(eap_data->user_cert_path);
1681 eap_data->user_cert_path = NULL;
1684 if (eap_data->privatekey_path) {
1685 g_free(eap_data->privatekey_path);
1686 eap_data->privatekey_path = NULL;
1689 wifi_ap_destroy(eap_data->ap);
1690 eap_data->ap = NULL;
1692 if(eap_data->info_popup){
1693 evas_object_del(eap_data->info_popup);
1694 eap_data->info_popup = NULL;
1697 if (eap_data->popup != NULL) {
1698 evas_object_hide(eap_data->popup);
1699 evas_object_del(eap_data->popup);
1702 if(_eap_view_deref_cb != NULL) {
1703 _eap_view_deref_cb();
1704 _eap_view_deref_cb = NULL;
1707 /* A delay is needed to get the smooth Input panel closing animation effect */
1708 common_util_managed_ecore_scan_update_timer_add(0.1,
1709 _enable_scan_updates_cb, NULL);
1712 static void __common_eap_connect_destroy_cb(void *data, Evas_Object *obj,
1715 __common_eap_connect_cleanup((eap_connect_data_t *)data);
1718 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1720 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1722 if (eap_data->info_popup != NULL) {
1723 evas_object_del(eap_data->info_popup);
1724 eap_data->info_popup = NULL;
1728 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1731 char *str_id = NULL;
1732 char *str_pw = NULL;
1733 bool favorite = FALSE;
1734 wifi_eap_type_e eap_type;
1735 wifi_eap_auth_type_e eap_auth_type;
1736 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1737 popup_btn_info_t popup_data;
1739 __COMMON_FUNC_ENTER__;
1740 if (eap_data->eap_done_ok == TRUE) {
1741 __COMMON_FUNC_EXIT__;
1745 eap_data->eap_done_ok = TRUE;
1747 wifi_ap_get_eap_type(eap_data->ap, &eap_type);
1748 wifi_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1750 wifi_ap_is_favorite(eap_data->ap, &favorite);
1751 if (favorite == TRUE) {
1752 wlan_manager_forget(eap_data->ap);
1753 wifi_ap_refresh(eap_data->ap);
1755 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1756 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1759 wifi_ap_set_eap_ca_cert_file(eap_data->ap, "");
1760 wifi_ap_set_eap_client_cert_file(eap_data->ap, "");
1761 wifi_ap_set_eap_private_key_info(eap_data->ap, "", "");
1764 case WIFI_EAP_TYPE_PEAP:
1765 case WIFI_EAP_TYPE_TTLS:
1767 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1768 if (str_id == NULL || str_id[0] == '\0') {
1769 memset(&popup_data, 0, sizeof(popup_data));
1770 popup_data.title_txt = eap_data->ssid;
1771 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1772 popup_data.btn1_cb = _info_popup_ok_cb;
1773 popup_data.btn1_data = eap_data;
1774 popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1775 eap_data->eap_done_ok = FALSE;
1776 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1781 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1782 if (str_pw == NULL || str_pw[0] == '\0') {
1783 memset(&popup_data, 0, sizeof(popup_data));
1784 popup_data.title_txt = eap_data->ssid;
1785 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1786 popup_data.btn1_cb = _info_popup_ok_cb;
1787 popup_data.btn1_data = eap_data;
1788 popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1789 eap_data->eap_done_ok = FALSE;
1790 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1795 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1796 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1797 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1800 case WIFI_EAP_TYPE_TLS:
1801 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1802 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1804 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1805 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1806 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1807 wifi_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1808 wifi_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1809 wifi_ap_set_eap_private_key_info(eap_data->ap,
1810 eap_data->privatekey_path, NULL);
1813 case WIFI_EAP_TYPE_SIM:
1814 case WIFI_EAP_TYPE_AKA:
1818 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1822 if (eap_data->is_hidden) {
1823 wifi_ap_h hidden_ap;
1825 wifi_ap_get_essid(eap_data->ap, &ssid);
1826 wifi_ap_hidden_create(ssid, &hidden_ap);
1830 case WIFI_EAP_TYPE_PEAP:
1831 case WIFI_EAP_TYPE_TTLS:
1832 wifi_ap_set_eap_type(hidden_ap, eap_type);
1833 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1834 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1836 case WIFI_EAP_TYPE_TLS:
1837 wifi_ap_set_eap_type(hidden_ap, eap_type);
1838 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1839 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1840 wifi_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1841 wifi_ap_set_eap_client_cert_file(hidden_ap,eap_data->user_cert_path);
1842 wifi_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1844 case WIFI_EAP_TYPE_SIM:
1845 case WIFI_EAP_TYPE_AKA:
1848 wlan_manager_connect(hidden_ap);
1850 wlan_manager_connect(eap_data->ap);
1852 __common_eap_connect_cleanup(eap_data);
1854 __COMMON_FUNC_EXIT__;
1857 static gboolean delay_create_context_popup(gpointer data)
1859 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1861 if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1862 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1864 click.btn_click[EAP_CERT_BTN] = FALSE;
1865 click.btn_obj[EAP_CERT_BTN] = NULL;
1866 } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1867 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1869 click.btn_click[EAP_AUTH_BTN] = FALSE;
1870 click.btn_obj[EAP_AUTH_BTN] = NULL;
1871 } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1872 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1874 click.btn_click[EAP_TYPE_BTN] = FALSE;
1875 click.btn_obj[EAP_TYPE_BTN] = NULL;
1880 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1887 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1889 keypad_state = FALSE;
1891 common_util_managed_idle_add(delay_create_context_popup,
1892 (gpointer)eap_data);
1894 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
1897 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1904 keypad_state = TRUE;
1905 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
1908 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
1909 Evas_Object *conf, const char *pkg_name,
1910 wifi_device_info_t *device_info, void (*deref_func)(void))
1912 __COMMON_FUNC_ENTER__;
1914 Evas_Object *popup = NULL;
1915 Evas_Object *list = NULL;
1916 Evas_Object *box = NULL;
1918 if (layout_main == NULL || device_info == NULL || pkg_name == NULL) {
1922 eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
1923 if (eap_data == NULL) {
1927 eap_data->str_pkg_name = pkg_name;
1928 eap_data->win = win;
1929 eap_data->conf = conf;
1930 eap_data->ssid = g_strdup(device_info->ssid);
1932 if (device_info->is_hidden == true) {
1933 /* Hidden Wi-Fi network */
1936 wifi_ap_get_essid(device_info->ap, &ssid);
1940 wifi_ap_hidden_create(ssid, &(eap_data->ap));
1943 eap_data->is_hidden = TRUE;
1945 /* Clone the Wi-Fi AP handle */
1946 wifi_ap_clone(&(eap_data->ap), device_info->ap);
1949 /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
1950 wlan_manager_disable_scan_result_update();
1952 _eap_view_deref_cb = deref_func;
1953 click.btn_click[EAP_TYPE_BTN] = FALSE;
1954 click.btn_obj[EAP_TYPE_BTN] = NULL;
1955 click.btn_click[EAP_AUTH_BTN] = FALSE;
1956 click.btn_obj[EAP_AUTH_BTN] = NULL;
1957 click.btn_click[EAP_CERT_BTN] = FALSE;
1958 click.btn_obj[EAP_CERT_BTN] = NULL;
1959 keypad_state = FALSE;
1961 popup_btn_info_t popup_btn_data;
1962 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
1964 popup_btn_data.title_txt = device_info->ssid;
1965 popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
1966 popup_btn_data.btn1_data = eap_data;
1967 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
1968 popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
1969 popup_btn_data.btn2_data = eap_data;
1970 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
1972 popup = common_utils_show_info_popup(layout_main,
1974 eap_data->popup = popup;
1975 evas_object_show(popup);
1976 elm_object_focus_set(popup, EINA_TRUE);
1978 box = elm_box_add(popup);
1979 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1981 /* Create an EAP connect view list */
1982 list = _create_list(box, eap_data);
1983 elm_object_content_set(box, list);
1985 elm_box_pack_end(box, list);
1986 evas_object_size_hint_min_set(box, -1, ELM_SCALE_SIZE(300));
1987 elm_object_content_set(popup, box);
1989 evas_object_smart_callback_add(eap_data->conf,
1990 "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
1992 evas_object_smart_callback_add(eap_data->conf,
1993 "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
1996 __COMMON_FUNC_EXIT__;
2000 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
2002 wifi_eap_type_e wlan_eap_type = WLAN_SEC_EAP_TYPE_PEAP;
2004 case EAP_SEC_TYPE_PEAP:
2005 wlan_eap_type = WIFI_EAP_TYPE_PEAP;
2007 case EAP_SEC_TYPE_TLS:
2008 wlan_eap_type = WIFI_EAP_TYPE_TLS;
2010 case EAP_SEC_TYPE_TTLS:
2011 wlan_eap_type = WIFI_EAP_TYPE_TTLS;
2013 case EAP_SEC_TYPE_SIM:
2014 wlan_eap_type = WIFI_EAP_TYPE_SIM;
2016 case EAP_SEC_TYPE_AKA:
2017 wlan_eap_type = WIFI_EAP_TYPE_AKA;
2020 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2024 return wlan_eap_type;
2027 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2029 wifi_eap_auth_type_e wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2030 switch (auth_type) {
2031 case EAP_SEC_AUTH_NONE:
2032 wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2034 case EAP_SEC_AUTH_PAP:
2035 wlan_auth_type = WIFI_EAP_AUTH_TYPE_PAP;
2037 case EAP_SEC_AUTH_MSCHAP:
2038 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAP;
2040 case EAP_SEC_AUTH_MSCHAPV2:
2041 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
2043 case EAP_SEC_AUTH_GTC:
2044 wlan_auth_type = WIFI_EAP_AUTH_TYPE_GTC;
2046 case EAP_SEC_AUTH_MD5:
2047 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MD5;
2050 /* This case should never occur */
2051 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2054 return wlan_auth_type;
2057 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap)
2059 wifi_eap_type_e wlan_eap_type = 0;
2060 int ret = wifi_ap_get_eap_type(ap, &wlan_eap_type);
2061 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2062 ret = wifi_ap_set_eap_type(ap, WIFI_EAP_TYPE_PEAP);
2065 if (WIFI_ERROR_NONE != ret) {
2066 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2067 return EAP_SEC_TYPE_UNKNOWN;
2070 switch (wlan_eap_type) {
2071 case WIFI_EAP_TYPE_PEAP: /**< EAP PEAP type */
2072 return EAP_SEC_TYPE_PEAP;
2074 case WIFI_EAP_TYPE_TLS: /**< EAP TLS type */
2075 return EAP_SEC_TYPE_TLS;
2077 case WIFI_EAP_TYPE_TTLS: /**< EAP TTLS type */
2078 return EAP_SEC_TYPE_TTLS;
2080 case WIFI_EAP_TYPE_SIM: /**< EAP SIM type */
2081 return EAP_SEC_TYPE_SIM;
2083 case WIFI_EAP_TYPE_AKA: /**< EAP AKA type */
2084 return EAP_SEC_TYPE_AKA;
2087 return EAP_SEC_TYPE_PEAP;
2089 return EAP_SEC_TYPE_PEAP;
2092 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap)
2094 wifi_eap_auth_type_e wlan_auth_type = 0;
2095 int ret = wifi_ap_get_eap_auth_type(ap, &wlan_auth_type);
2096 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2097 ret = wifi_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2100 if (WIFI_ERROR_NONE != ret) {
2101 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2102 return EAP_SEC_AUTH_NONE;
2105 switch (wlan_auth_type) {
2106 case WIFI_EAP_AUTH_TYPE_NONE: /**< EAP phase2 authentication none */
2107 return EAP_SEC_AUTH_NONE;
2109 case WIFI_EAP_AUTH_TYPE_PAP: /**< EAP phase2 authentication PAP */
2110 return EAP_SEC_AUTH_PAP;
2112 case WIFI_EAP_AUTH_TYPE_MSCHAP: /**< EAP phase2 authentication MSCHAP */
2113 return EAP_SEC_AUTH_MSCHAP;
2115 case WIFI_EAP_AUTH_TYPE_MSCHAPV2: /**< EAP phase2 authentication MSCHAPv2 */
2116 return EAP_SEC_AUTH_MSCHAPV2;
2118 case WIFI_EAP_AUTH_TYPE_GTC: /**< EAP phase2 authentication GTC */
2119 return EAP_SEC_AUTH_GTC;
2121 case WIFI_EAP_AUTH_TYPE_MD5: /**< EAP phase2 authentication MD5 */
2122 return EAP_SEC_AUTH_MD5;
2125 return EAP_SEC_AUTH_NONE;
2127 return EAP_SEC_AUTH_NONE;
2130 static char *_eap_info_get_user_cert_alias(wifi_ap_h ap)
2134 char *filename = NULL;
2135 char *cert_name = NULL;
2137 int filename_len = 0;
2139 wifi_ap_get_eap_client_cert_file(ap, &path);
2143 filename = strrchr(path, '/');
2144 if (filename == NULL) {
2145 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2150 cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2151 if (cert_name == NULL) {
2152 /* For truncated path, available filename will be followed
2153 * with ellipsis(...) & excluding any remaining part of
2154 * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2155 filename_len = strlen(filename);
2156 alias = g_try_malloc0(filename_len - 10);
2157 if (alias == NULL) {
2158 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2161 g_strlcpy(alias, filename, filename_len - 13);
2162 g_strlcat(alias, "...", filename_len - 10);
2163 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2168 alias_len = cert_name - filename;
2170 alias = g_try_malloc0(alias_len + 1);
2171 if (alias == NULL) {
2172 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2176 g_strlcpy(alias, filename, alias_len + 1);
2177 INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2185 /* This creates Auth type, ID, Anonymous Id and Password items
2186 * This function should be called after creating the EAP type item
2188 eap_info_list_t *eap_info_append_items(wifi_ap_h ap, Evas_Object* view_list,
2189 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2190 void *input_panel_cb_data)
2192 __COMMON_FUNC_ENTER__;
2194 eap_type_t eap_type;
2195 eap_auth_t auth_type;
2196 char *temp_str = NULL;
2197 Eina_Bool append_continue = TRUE;
2198 eap_info_list_t *eap_info_list_data = NULL;
2199 Elm_Object_Item* item = NULL;
2200 if (!view_list || !str_pkg_name || !ap) {
2201 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2205 eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2206 if (eap_info_list_data == NULL) {
2210 eap_info_list_data->ap = ap;
2211 eap_type = __common_eap_connect_popup_get_eap_type(ap);
2212 auth_type = __common_eap_connect_popup_get_auth_type(ap);
2214 item = common_utils_add_2_line_txt_disabled_item(view_list,
2215 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2216 sc(str_pkg_name, I18N_TYPE_EAP_method),
2217 list_eap_type[eap_type].name);
2218 eap_info_list_data->eap_method_item = item;
2220 eap_info_list_data->eap_type = eap_type;
2223 case EAP_SEC_TYPE_UNKNOWN:
2224 case EAP_SEC_TYPE_PEAP:
2225 case EAP_SEC_TYPE_TLS:
2226 case EAP_SEC_TYPE_TTLS:
2228 case EAP_SEC_TYPE_SIM:
2229 case EAP_SEC_TYPE_AKA:
2231 append_continue = FALSE;
2235 if (append_continue) {
2236 if (eap_type == EAP_SEC_TYPE_PEAP ||
2237 eap_type == EAP_SEC_TYPE_TTLS) {
2238 /* Add EAP phase2 authentication */
2239 item = common_utils_add_2_line_txt_disabled_item(view_list,
2240 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2241 sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2242 list_eap_auth[auth_type].name);
2243 eap_info_list_data->eap_auth_item = item;
2246 if (eap_type == EAP_SEC_TYPE_TLS) {
2247 /* Add User certificate */
2248 temp_str = _eap_info_get_user_cert_alias(ap);
2250 if (temp_str == NULL || strlen(temp_str) == 0) {
2251 if (temp_str != NULL) {
2254 temp_str = g_strdup(sc(str_pkg_name,
2255 I18N_TYPE_Unspecified));
2258 item = common_utils_add_2_line_txt_disabled_item(view_list,
2259 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2260 sc(str_pkg_name, I18N_TYPE_User_Certificate),
2262 eap_info_list_data->user_cert_item = item;
2269 wifi_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set);
2270 item = common_utils_add_2_line_txt_disabled_item(view_list,
2271 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2272 sc(str_pkg_name, I18N_TYPE_Identity),
2274 eap_info_list_data->id_item = item;
2278 common_utils_entry_info_t *edit_box_details;
2280 /* Add EAP Password */
2281 g_eap_entry_itc.item_style = "entry.main";
2282 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2283 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2284 g_eap_entry_itc.func.state_get = NULL;
2285 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2287 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2288 if (edit_box_details == NULL) {
2289 g_free(eap_info_list_data);
2293 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2294 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2295 edit_box_details->entry_txt = NULL;
2296 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2297 edit_box_details->input_panel_cb = input_panel_cb;
2298 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2299 edit_box_details->item = elm_genlist_item_append(view_list,
2300 &g_eap_entry_itc, edit_box_details, NULL,
2301 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2302 elm_genlist_item_select_mode_set(edit_box_details->item,
2303 ELM_OBJECT_SELECT_MODE_NONE);
2304 eap_info_list_data->pswd_item = edit_box_details->item;
2308 __COMMON_FUNC_EXIT__;
2309 return eap_info_list_data;
2313 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2315 if (!eap_info_list_data) {
2316 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2319 char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2321 wifi_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2327 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2329 if (!eap_info_list_data) {
2330 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2334 g_free(eap_info_list_data);
2337 void eap_connect_data_free(eap_connect_data_t *eap_data)
2339 __common_eap_connect_cleanup(eap_data);