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 CertSvcInstance instance;
346 static CertSvcStoreCertList *certList = NULL;
348 static void _gl_eap_user_cert_sel(void *data, Evas_Object *obj,
351 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
352 const char *cert_alias = elm_object_item_text_get((Elm_Object_Item *) event_info);
357 if (eap_data->sub_popup != NULL) {
358 evas_object_del(eap_data->sub_popup);
359 eap_data->sub_popup = NULL;
362 if (eap_data->ca_cert_path) {
363 g_unlink(eap_data->ca_cert_path);
364 eap_data->ca_cert_path = NULL;
366 if (eap_data->user_cert_path) {
367 g_unlink(eap_data->user_cert_path);
368 eap_data->user_cert_path = NULL;
370 if (eap_data->privatekey_path) {
371 g_unlink(eap_data->privatekey_path);
372 eap_data->privatekey_path = NULL;
375 if (strcmp(cert_alias, sc(PACKAGE, I18N_TYPE_None)) == 0) {
376 if (eap_data->cert_alias != NULL) {
377 g_free(eap_data->cert_alias);
378 eap_data->cert_alias = NULL;
380 } else if (__cert_extract_files(cert_alias, eap_data)) {
381 if (eap_data->cert_alias != NULL) {
382 g_free(eap_data->cert_alias);
383 eap_data->cert_alias = NULL;
385 eap_data->cert_alias = g_strdup(cert_alias);
388 if(eap_data->eap_user_cert_item != NULL)
389 elm_genlist_item_update(eap_data->eap_user_cert_item);
391 if (eap_data->cert_candidates != NULL) {
392 g_slist_free_full(eap_data->cert_candidates, g_free);
393 eap_data->cert_candidates = NULL;
397 static void _create_eap_cert_list(eap_connect_data_t *eap_data,
400 size_t list_length = 0;
401 Evas_Object *ctxpopup;
402 Elm_Object_Item *it = NULL;
407 if (eap_data->sub_popup != NULL) {
408 evas_object_del(eap_data->sub_popup);
409 eap_data->sub_popup = NULL;
412 ctxpopup = elm_ctxpopup_add(eap_data->win);
413 eap_data->sub_popup = ctxpopup;
414 elm_object_style_set(ctxpopup, "dropdown/list");
415 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
416 cert_ctxpopup_dismissed_cb, NULL);
417 evas_object_smart_callback_add(ctxpopup,"dismissed",
418 cert_ctxpopup_dismissed_cb, eap_data);
419 elm_ctxpopup_direction_priority_set(ctxpopup,
420 ELM_CTXPOPUP_DIRECTION_DOWN,
421 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
422 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
423 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
425 if (certsvc_instance_new(&instance) == CERTSVC_FAIL) {
426 INFO_LOG(UG_NAME_ERR, "Failed to create new instance");
430 certsvc_pkcs12_get_certificate_list_from_store(instance, WIFI_STORE, DISABLED, &certList, &list_length);
432 if (eap_data->cert_candidates) {
433 g_slist_free_full(eap_data->cert_candidates, g_free);
434 eap_data->cert_candidates = NULL;
437 it = elm_ctxpopup_item_append(ctxpopup, "IDS_ST_BODY_NONE", NULL,
438 _gl_eap_user_cert_sel, eap_data);
439 elm_object_item_domain_text_translatable_set(it,
442 while(certList != NULL) {
443 char *char_buffer = NULL;
444 CertSvcString buffer;
446 buffer.privateHandler = (char *)certList->gname;
447 buffer.privateLength = strlen(certList->gname);
448 INFO_LOG(UG_NAME_NORMAL, "gname in processing : %s", certList->gname);
450 char_buffer = g_strndup(buffer.privateHandler, buffer.privateLength);
451 if (char_buffer == NULL)
454 elm_ctxpopup_item_append(ctxpopup, char_buffer, NULL,
455 _gl_eap_user_cert_sel, eap_data);
456 eap_data->cert_candidates =
457 g_slist_prepend(eap_data->cert_candidates, char_buffer);
459 certsvc_string_free(buffer);
460 certList = certList->next;
463 move_dropdown(eap_data, btn);
464 evas_object_show(ctxpopup);
467 certsvc_instance_free(instance);
470 static void _gl_eap_cert_list_btn_cb(void *data, Evas_Object *obj,
473 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
474 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
477 elm_genlist_item_selected_set(item, EINA_FALSE);
479 if (keypad_state == FALSE) {
480 _create_eap_cert_list(eap_data, obj);
482 click.btn_click[EAP_CERT_BTN] = FALSE;
483 click.btn_obj[EAP_CERT_BTN] = NULL;
485 click.btn_click[EAP_CERT_BTN] = TRUE;
486 click.btn_obj[EAP_CERT_BTN] = obj;
490 static char *_gl_eap_user_cert_text_get(void *data, Evas_Object *obj, const char *part)
492 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
494 if (!g_strcmp0(part, "elm.text.sub")) {
495 return g_strdup(sc(eap_data->str_pkg_name,
496 I18N_TYPE_User_Certificate));
502 static Evas_Object *_gl_eap_user_cert_content_get(void *data,
503 Evas_Object *obj, const char *part)
505 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
506 Evas_Object *btn = NULL;
507 Evas_Object *ly = NULL;
510 if (!strcmp(part, "elm.swallow.icon.0")) {
511 ly = elm_layout_add(obj);
512 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
513 "eap_dropdown_button");
514 btn = elm_button_add(obj);
516 if (eap_data->cert_alias == NULL) {
517 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
518 sc(eap_data->str_pkg_name, I18N_TYPE_None));
520 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
521 eap_data->cert_alias);
524 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
525 elm_object_style_set(btn, "dropdown/label");
526 evas_object_propagate_events_set(btn, EINA_FALSE);
527 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
529 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
531 evas_object_smart_callback_add(btn, "clicked",
532 _gl_eap_cert_list_btn_cb, eap_data);
534 elm_layout_content_set(ly, "btn", btn);
540 static void _gl_eap_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
542 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
545 elm_genlist_item_selected_set(item, EINA_FALSE);
549 static void _create_eap_type_list(eap_connect_data_t *eap_data,
552 Evas_Object *ctxpopup = NULL;
553 int i = EAP_SEC_TYPE_PEAP;
554 int sim_state = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
555 Elm_Object_Item *it = NULL;
557 sim_state = common_utils_get_sim_state();
559 if (eap_data->sub_popup != NULL) {
560 evas_object_del(eap_data->sub_popup);
563 ctxpopup = elm_ctxpopup_add(eap_data->win);
564 eap_data->sub_popup = ctxpopup;
565 elm_object_style_set(ctxpopup, "dropdown/list");
566 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
567 eext_ctxpopup_back_cb, NULL);
568 evas_object_smart_callback_add(ctxpopup,"dismissed",
569 ctxpopup_dismissed_cb, eap_data);
570 elm_ctxpopup_direction_priority_set(ctxpopup,
571 ELM_CTXPOPUP_DIRECTION_DOWN,
572 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
573 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
574 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
576 /* eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap); */
577 while (list_eap_type[i].name != NULL) {
578 it = elm_ctxpopup_item_append(ctxpopup, list_eap_type[i].name,
579 NULL, _gl_eap_type_sub_sel, eap_data);
581 if ((i == EAP_SEC_TYPE_SIM || i == EAP_SEC_TYPE_AKA) &&
582 sim_state != VCONFKEY_TELEPHONY_SIM_INSERTED) {
583 elm_object_item_disabled_set(it, EINA_TRUE);
588 move_dropdown(eap_data, btn);
589 evas_object_show(ctxpopup);
592 static void _gl_eap_type_btn_cb(void *data, Evas_Object *obj, void *event_info)
594 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
595 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
598 elm_genlist_item_selected_set(item, EINA_FALSE);
600 if (keypad_state == FALSE) {
601 _create_eap_type_list(eap_data, obj);
603 click.btn_click[EAP_TYPE_BTN] = FALSE;
604 click.btn_obj[EAP_TYPE_BTN] = NULL;
606 click.btn_click[EAP_TYPE_BTN] = TRUE;
607 click.btn_obj[EAP_TYPE_BTN] = obj;
611 static char *_gl_eap_type_text_get(void *data, Evas_Object *obj, const char *part)
613 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
615 if (!g_strcmp0(part, "elm.text.sub")) {
616 return g_strdup(sc(eap_data->str_pkg_name, I18N_TYPE_EAP_method));
622 static Evas_Object *_gl_eap_type_content_get(void *data,
623 Evas_Object *obj, const char *part)
625 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
626 eap_type_t sel_sub_item_id = __common_eap_connect_popup_get_eap_type(eap_data->ap);
627 Evas_Object *btn = NULL;
628 Evas_Object *ly = NULL;
631 if (!strcmp(part, "elm.swallow.icon.0")) {
632 ly = elm_layout_add(obj);
633 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
634 "eap_dropdown_button");
635 btn = elm_button_add(obj);
637 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
638 list_eap_type[sel_sub_item_id].name);
640 elm_object_text_set(btn, buf);
641 elm_object_style_set(btn, "dropdown/label");
642 evas_object_propagate_events_set(btn, EINA_FALSE);
643 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
645 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
647 evas_object_smart_callback_add(btn, "clicked",
648 _gl_eap_type_btn_cb, eap_data);
650 elm_layout_content_set(ly, "btn", btn);
656 static void _gl_eap_auth_sub_sel(void *data, Evas_Object *obj, void *event_info)
658 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
659 eap_auth_t sel_index = EAP_SEC_AUTH_NONE;
661 const char *label = elm_object_item_text_get((Elm_Object_Item *) event_info);
663 if (strcmp(label, sc(PACKAGE, I18N_TYPE_None)) == 0)
664 sel_index = EAP_SEC_AUTH_NONE;
665 else if (strcmp(label, EAP_AUTH_TYPE_PAP) == 0)
666 sel_index = EAP_SEC_AUTH_PAP;
667 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAP) == 0)
668 sel_index = EAP_SEC_AUTH_MSCHAP;
669 else if (strcmp(label, EAP_AUTH_TYPE_MSCHAPV2) == 0)
670 sel_index = EAP_SEC_AUTH_MSCHAPV2;
671 else if (strcmp(label, EAP_AUTH_TYPE_GTC) == 0)
672 sel_index = EAP_SEC_AUTH_GTC;
673 else if (strcmp(label, EAP_AUTH_TYPE_MD5) == 0)
674 sel_index = EAP_SEC_AUTH_MD5;
676 wifi_ap_set_eap_auth_type(eap_data->ap,
677 __common_eap_connect_popup_get_wlan_auth_type(sel_index));
679 if (eap_data->sub_popup != NULL) {
680 evas_object_del(eap_data->sub_popup);
681 eap_data->sub_popup = NULL;
684 if(eap_data->eap_auth_item != NULL)
685 elm_genlist_item_update(eap_data->eap_auth_item);
688 static void _create_eap_auth_list(eap_connect_data_t *eap_data,
691 Elm_Object_Item *it = NULL;
692 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
693 Evas_Object *ctxpopup;
696 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
698 if (eap_data->sub_popup != NULL) {
699 evas_object_del(eap_data->sub_popup);
702 ctxpopup = elm_ctxpopup_add(eap_data->win);
703 eap_data->sub_popup = ctxpopup;
704 elm_object_style_set(ctxpopup, "dropdown/list");
705 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, NULL);
706 evas_object_smart_callback_add(ctxpopup,"dismissed", ctxpopup_dismissed_cb, eap_data);
707 elm_ctxpopup_direction_priority_set(ctxpopup,
708 ELM_CTXPOPUP_DIRECTION_DOWN,
709 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
710 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
711 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
713 while (list_eap_auth[i].name != NULL) {
714 if ((eap_type != EAP_SEC_TYPE_PEAP) ||
715 (eap_type == EAP_SEC_TYPE_PEAP && i != 1 &&
717 it = elm_ctxpopup_item_append(ctxpopup, list_eap_auth[i].name,
718 NULL, _gl_eap_auth_sub_sel, eap_data);
720 elm_object_item_domain_text_translatable_set(it,
726 move_dropdown(eap_data, btn);
727 evas_object_show(ctxpopup);
730 static void _gl_eap_auth_btn_cb(void *data, Evas_Object *obj, void *event_info)
732 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
733 eap_connect_data_t *eap_data = (eap_connect_data_t *) data;
736 elm_genlist_item_selected_set(item, EINA_FALSE);
738 if (keypad_state == FALSE) {
739 _create_eap_auth_list(eap_data, obj);
741 click.btn_click[EAP_AUTH_BTN] = FALSE;
742 click.btn_obj[EAP_AUTH_BTN] = NULL;
744 click.btn_click[EAP_AUTH_BTN] = TRUE;
745 click.btn_obj[EAP_AUTH_BTN] = obj;
749 static char *_gl_eap_auth_text_get(void *data, Evas_Object *obj, const char *part)
751 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
753 if (!g_strcmp0(part, "elm.text.sub")) {
754 return g_strdup(sc(eap_data->str_pkg_name,
755 I18N_TYPE_Phase_2_authentication));
761 static Evas_Object *_gl_eap_auth_content_get(void *data,
762 Evas_Object *obj, const char *part)
764 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
765 eap_auth_t sel_sub_item_id = __common_eap_connect_popup_get_auth_type(eap_data->ap);
766 Evas_Object *btn = NULL;
767 Evas_Object *ly = NULL;
770 if (!strcmp(part, "elm.swallow.icon.0")) {
771 ly = elm_layout_add(obj);
772 elm_layout_file_set(ly, CUSTOM_EDITFIELD_PATH,
773 "eap_dropdown_button");
774 btn = elm_button_add(obj);
776 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
777 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
778 sc(PACKAGE, I18N_TYPE_None));
780 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
781 list_eap_auth[sel_sub_item_id].name);
784 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
785 elm_object_style_set(btn, "dropdown/label");
786 evas_object_propagate_events_set(btn, EINA_FALSE);
787 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
789 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
791 evas_object_smart_callback_add(btn, "clicked",
792 _gl_eap_auth_btn_cb, eap_data);
794 elm_layout_content_set(ly, "btn", btn);
800 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
802 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
807 Evas_Object *entry = NULL;
808 Elm_Object_Item *next_item = NULL;
811 switch (entry_info->entry_id) {
812 case ENTRY_TYPE_USER_ID:
813 eap_type = __common_eap_connect_popup_get_eap_type(
816 if (eap_type == EAP_SEC_TYPE_TLS) {
817 entry = elm_object_item_part_content_get(entry_info->item,
820 elm_object_focus_set(entry, EINA_FALSE);
823 next_item = elm_genlist_item_next_get(entry_info->item);
825 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
826 elm_genlist_item_select_mode_get(next_item) !=
827 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
828 entry = elm_object_item_part_content_get(
829 next_item, "elm.icon.entry");
831 elm_object_focus_set(entry, EINA_TRUE);
836 next_item = elm_genlist_item_next_get(next_item);
840 case ENTRY_TYPE_PASSWORD:
841 entry = elm_object_item_part_content_get(entry_info->item,
844 elm_object_focus_set(entry, EINA_FALSE);
852 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
854 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
859 if (elm_object_focus_get(obj)) {
860 if (elm_entry_is_empty(obj)) {
861 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
863 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
867 if (entry_info->entry_txt) {
868 g_free(entry_info->entry_txt);
869 entry_info->entry_txt = NULL;
872 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
874 if (entry_text != NULL && entry_text[0] != '\0') {
875 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
881 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
883 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
892 if (elm_object_focus_get(obj)) {
893 if (elm_entry_is_empty(obj)) {
894 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
896 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
901 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
903 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
908 if (!elm_entry_is_empty(obj)) {
909 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
912 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
915 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
917 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
922 if (entry_info->entry_txt) {
923 g_free(entry_info->entry_txt);
924 entry_info->entry_txt = NULL;
927 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
928 if (entry_text != NULL && entry_text[0] != '\0')
929 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
933 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
934 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
937 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
940 common_utils_send_message_to_net_popup("Password length",
941 "Lengthy Password", "notification", NULL);
944 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
946 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
951 Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
953 elm_object_focus_set(entry, EINA_TRUE);
954 elm_entry_entry_set(entry, "");
958 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
960 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
965 if (!g_strcmp0(part, "elm.text.sub")) {
966 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
972 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
974 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
979 if (g_strcmp0(part, "elm.swallow.icon.0") == 0) {
980 Evas_Object *entry = NULL;
981 char *guide_txt = NULL;
982 char *accepted = NULL;
983 Eina_Bool hide_entry_txt = EINA_FALSE;
984 Elm_Input_Panel_Layout panel_type;
988 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
990 static Elm_Entry_Filter_Limit_Size limit_filter_data;
992 switch (entry_info->entry_id)
994 case ENTRY_TYPE_USER_ID:
995 panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
996 guide_txt = entry_info->guide_txt;
998 if (eap_type == EAP_SEC_TYPE_TLS) {
999 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1001 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1004 case ENTRY_TYPE_PASSWORD:
1005 panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1006 guide_txt = entry_info->guide_txt;
1007 hide_entry_txt = EINA_TRUE;
1008 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1014 entry = elm_entry_add(obj);
1015 retvm_if(NULL == entry, NULL);
1017 elm_entry_single_line_set(entry, EINA_TRUE);
1018 elm_entry_scrollable_set(entry, EINA_TRUE);
1019 elm_entry_password_set(entry, hide_entry_txt);
1020 elm_entry_prediction_allow_set(entry, EINA_FALSE);
1021 elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_NONE);
1023 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
1024 PACKAGE, guide_txt);
1025 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0)) {
1026 elm_entry_entry_set(entry, entry_info->entry_txt);
1029 elm_entry_input_panel_layout_set(entry, panel_type);
1030 elm_entry_input_panel_return_key_type_set(entry, return_key_type);
1032 limit_filter_data.max_char_count = 200;
1033 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
1035 Elm_Entry_Filter_Accept_Set digits_filter_data;
1036 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1037 digits_filter_data.accepted = accepted;
1038 elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digits_filter_data);
1040 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(entry);
1041 if (imf_ctxt && entry_info->input_panel_cb) {
1042 ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1043 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1044 entry_info->input_panel_cb,
1045 entry_info->input_panel_cb_data);
1046 DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1049 evas_object_smart_callback_add(entry, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1050 evas_object_smart_callback_add(entry, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1051 evas_object_smart_callback_add(entry, "changed", _gl_eap_entry_changed_cb, entry_info);
1052 evas_object_smart_callback_add(entry, "focused", _gl_eap_entry_focused_cb, entry_info);
1053 evas_object_smart_callback_add(entry, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1054 evas_object_smart_callback_add(entry, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1056 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD) {
1057 g_pwd_entry = entry;
1061 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1062 Evas_Object *btn = elm_button_add(obj);
1063 elm_object_style_set(btn, "editfield_clear");
1064 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1071 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1073 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1074 if (entry_info == NULL) {
1078 if (entry_info->entry_txt) {
1079 g_free(entry_info->entry_txt);
1085 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1087 if (obj == NULL || g_pwd_entry == NULL) {
1091 Eina_Bool state = elm_check_state_get(obj);
1093 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1095 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1099 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1102 char *str_pkg_name = (char *)data;
1104 if (!strcmp("elm.text", part)) {
1106 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1113 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1114 Evas_Object *obj, const char *part)
1116 Evas_Object *check = NULL;
1118 if (!strcmp("elm.swallow.end", part)) {
1119 check = elm_check_add(obj);
1120 evas_object_propagate_events_set(check, EINA_FALSE);
1122 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1123 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1124 evas_object_smart_callback_add(check, "changed",
1125 _chk_changed_cb, NULL);
1127 elm_object_focus_allow_set(check, EINA_FALSE);
1134 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1136 Elm_Object_Item *item = NULL;
1138 item = (Elm_Object_Item *)ei;
1143 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1145 elm_genlist_item_selected_set(item, EINA_FALSE);
1147 Eina_Bool state = elm_check_state_get(ck);
1148 elm_check_state_set(ck, !state);
1150 _chk_changed_cb(NULL, ck, NULL);
1153 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1155 elm_genlist_realized_items_update(obj);
1158 static void __common_eap_connect_popup_init_item_class(void *data)
1160 g_eap_type_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1161 g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1162 g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1163 g_eap_type_itc.func.state_get = NULL;
1164 g_eap_type_itc.func.del = NULL;
1166 g_eap_auth_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1167 g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1168 g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1169 g_eap_auth_itc.func.state_get = NULL;
1170 g_eap_auth_itc.func.del = NULL;
1172 g_eap_user_cert_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1173 g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1174 g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1175 g_eap_user_cert_itc.func.state_get = NULL;
1176 g_eap_user_cert_itc.func.del = NULL;
1178 g_eap_entry_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1179 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1180 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1181 g_eap_entry_itc.func.state_get = NULL;
1182 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1184 g_eap_chkbox_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
1185 g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1186 g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1187 g_eap_chkbox_itc.func.state_get = NULL;
1188 g_eap_chkbox_itc.func.del = NULL;
1191 static gboolean __cert_extract_files(const char *cert_alias,
1192 eap_connect_data_t *eap_data)
1196 size_t cert_counts = 0;
1198 gchar *ca_cert_path = NULL;
1199 gchar *user_cert_path = NULL;
1200 gchar *privatekey_path = NULL;
1202 CertSvcInstance cert_instance;
1203 CertSvcString cert_alias_str;
1204 CertSvcCertificateList cert_list;
1205 CertSvcCertificate user_certificate;
1206 CertSvcCertificate ca_certificate;
1207 CertSvcCertificate *selected_certificate = NULL;
1209 EVP_PKEY *privatekey = NULL;
1211 ret = certsvc_instance_new(&cert_instance);
1212 if (ret != CERTSVC_SUCCESS) {
1213 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1216 ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1217 if (ret != CERTSVC_SUCCESS) {
1218 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1221 ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1222 if (ret != CERTSVC_SUCCESS) {
1223 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1226 ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1227 if (cert_counts < 1) {
1228 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1231 INFO_LOG(UG_NAME_NORMAL, "cert counts: %d", cert_counts);
1232 selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1233 if (selected_certificate == NULL) {
1234 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1237 ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1238 if (ret != CERTSVC_SUCCESS) {
1239 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1242 cert_index = cert_counts - 1;
1244 selected_certificate[0] = user_certificate;
1246 ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1248 user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1249 cert_alias, EAP_TLS_USER_CERT_PATH);
1250 if ((fp = fopen(user_cert_path, "w")) == NULL) {
1253 ret = PEM_write_X509(fp, x509);
1255 certsvc_certificate_free_x509(x509);
1256 INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1258 ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1259 EAP_TLS_CA_CERT_PATH);
1260 while (cert_index) {
1261 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1262 if (ret != CERTSVC_SUCCESS) {
1263 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1267 selected_certificate[cert_counts-cert_index] = ca_certificate;
1270 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1271 if ((fp = fopen(ca_cert_path, "a")) == NULL) {
1274 ret = PEM_write_X509(fp, x509);
1276 certsvc_certificate_free_x509(x509);
1278 INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1279 ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1280 if (ret != CERTSVC_SUCCESS) {
1281 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1284 if (validity == 0) {
1285 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1289 ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1291 privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1292 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1294 if ((fp = fopen(privatekey_path, "w")) == NULL) {
1297 ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1299 certsvc_pkcs12_free_evp_pkey(privatekey);
1300 INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1302 g_free(selected_certificate);
1303 certsvc_instance_free(cert_instance);
1305 eap_data->ca_cert_path = ca_cert_path;
1306 eap_data->user_cert_path = user_cert_path;
1307 eap_data->privatekey_path = privatekey_path;
1312 g_free(ca_cert_path);
1313 g_free(user_cert_path);
1314 g_free(privatekey_path);
1316 if (selected_certificate) {
1317 g_free(selected_certificate);
1320 certsvc_instance_free(cert_instance);
1324 /* This creates EAP type, Auth type, CA certificate, User certificate,
1325 * User Id, Anonymous Id and Password items.
1327 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1328 eap_connect_data_t *eap_data)
1330 __COMMON_FUNC_ENTER__;
1331 Evas_Object* view_list = eap_data->genlist;
1332 Elm_Object_Item *insert_after_item = NULL;
1333 Elm_Object_Item *prev_item = NULL;
1334 common_utils_entry_info_t *edit_box_details;
1335 Eina_Bool auth_reqd = EINA_FALSE;
1336 Eina_Bool user_cert_reqd = EINA_FALSE;
1337 Eina_Bool id_reqd = EINA_FALSE;
1338 Eina_Bool pw_reqd = EINA_FALSE;
1340 if (NULL == eap_data->eap_type_item) {
1341 /* Create EAP method/type */
1342 eap_data->eap_type_item = elm_genlist_item_append(
1343 view_list, &g_eap_type_itc,
1345 ELM_GENLIST_ITEM_NONE,
1346 _gl_eap_item_sel_cb, eap_data);
1350 case EAP_SEC_TYPE_PEAP:
1351 insert_after_item = eap_data->eap_type_item;
1352 auth_reqd = EINA_TRUE;
1353 user_cert_reqd = EINA_FALSE;
1354 id_reqd = EINA_TRUE;
1355 pw_reqd = EINA_TRUE;
1357 case EAP_SEC_TYPE_TLS:
1358 insert_after_item = eap_data->eap_type_item;
1359 auth_reqd = EINA_FALSE;
1360 user_cert_reqd = EINA_TRUE;
1361 id_reqd = EINA_TRUE;
1362 pw_reqd = EINA_FALSE;
1364 case EAP_SEC_TYPE_TTLS:
1365 insert_after_item = eap_data->eap_type_item;
1366 auth_reqd = EINA_TRUE;
1367 user_cert_reqd = EINA_FALSE;
1368 id_reqd = EINA_TRUE;
1369 pw_reqd = EINA_TRUE;
1371 case EAP_SEC_TYPE_SIM:
1372 case EAP_SEC_TYPE_AKA:
1373 _delete_eap_entry_items(eap_data);
1374 auth_reqd = EINA_FALSE;
1375 user_cert_reqd = EINA_FALSE;
1376 id_reqd = EINA_FALSE;
1377 pw_reqd = EINA_FALSE;
1383 if (auth_reqd == EINA_TRUE) {
1384 if (eap_data->eap_auth_item == NULL) {
1385 /* Add EAP phase2 authentication */
1386 eap_data->eap_auth_item = elm_genlist_item_insert_after(
1387 view_list, &g_eap_auth_itc, eap_data, NULL,
1388 insert_after_item, ELM_GENLIST_ITEM_NONE,
1389 _gl_eap_item_sel_cb, eap_data);
1392 _delete_eap_auth_item(eap_data);
1395 if (user_cert_reqd == EINA_TRUE) {
1396 if (eap_data->eap_user_cert_item == NULL) {
1397 prev_item = eap_data->eap_type_item;
1399 /* Add User certificate */
1400 eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1401 view_list, &g_eap_user_cert_itc, eap_data, NULL,
1402 prev_item, ELM_GENLIST_ITEM_NONE,
1403 _gl_eap_item_sel_cb, eap_data);
1406 _delete_eap_user_cert_item(eap_data);
1409 if (id_reqd == EINA_TRUE) {
1410 if (eap_data->eap_id_item == NULL) {
1411 if (new_type == EAP_SEC_TYPE_PEAP ||
1412 new_type == EAP_SEC_TYPE_TTLS) {
1413 prev_item = eap_data->eap_auth_item;
1415 prev_item = eap_data->eap_user_cert_item;
1419 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1420 if (edit_box_details == NULL) {
1424 edit_box_details->ap = eap_data->ap;
1425 edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1426 edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1427 edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1428 edit_box_details->item = elm_genlist_item_insert_after(
1429 view_list, &g_eap_entry_itc, edit_box_details,
1431 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1432 eap_data->eap_id_item = edit_box_details->item;
1435 _delete_eap_id_item(eap_data);
1438 if (pw_reqd == EINA_TRUE) {
1439 if (eap_data->eap_pw_item == NULL) {
1440 /* Add EAP Password */
1441 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1442 if (edit_box_details == NULL) {
1446 edit_box_details->ap = eap_data->ap;
1447 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1448 edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1449 edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1450 edit_box_details->item = elm_genlist_item_insert_after(
1451 view_list, &g_eap_entry_itc,
1452 edit_box_details, NULL,
1453 eap_data->eap_id_item,
1454 ELM_GENLIST_ITEM_NONE,
1455 _gl_editbox_sel_cb, NULL);
1456 eap_data->eap_pw_item = edit_box_details->item;
1458 _update_eap_id_item_enter_key(eap_data);
1461 if (eap_data->eap_chkbox_item == NULL) {
1462 /* Add Show Password checkbox */
1463 eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1464 view_list, &g_eap_chkbox_itc,
1465 eap_data->str_pkg_name, NULL,
1466 eap_data->eap_pw_item,
1467 ELM_GENLIST_ITEM_NONE,
1468 _gl_eap_chkbox_sel, NULL);
1471 _delete_eap_pw_items(eap_data);
1474 __COMMON_FUNC_EXIT__;
1478 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1480 if (eap_data->eap_id_item == NULL)
1483 Evas_Object *entry = NULL;
1484 eap_type_t eap_type;
1486 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1487 entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1490 if (eap_type == EAP_SEC_TYPE_TLS) {
1491 elm_entry_input_panel_return_key_type_set(entry,
1492 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1494 elm_entry_input_panel_return_key_type_set(entry,
1495 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1500 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1502 __COMMON_FUNC_ENTER__;
1504 if (eap_data->eap_auth_item != NULL) {
1505 elm_object_item_del(eap_data->eap_auth_item);
1506 eap_data->eap_auth_item = NULL;
1509 __COMMON_FUNC_EXIT__;
1513 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1515 __COMMON_FUNC_ENTER__;
1517 if (eap_data->eap_user_cert_item != NULL) {
1518 elm_object_item_del(eap_data->eap_user_cert_item);
1519 eap_data->eap_user_cert_item = NULL;
1522 __COMMON_FUNC_EXIT__;
1526 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1528 __COMMON_FUNC_ENTER__;
1530 if (eap_data->eap_id_item != NULL) {
1531 elm_object_item_del(eap_data->eap_id_item);
1532 eap_data->eap_id_item = NULL;
1535 __COMMON_FUNC_EXIT__;
1539 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1541 __COMMON_FUNC_ENTER__;
1543 _update_eap_id_item_enter_key(eap_data);
1545 if (eap_data->eap_pw_item != NULL) {
1546 elm_object_item_del(eap_data->eap_pw_item);
1547 eap_data->eap_pw_item = NULL;
1550 if (eap_data->eap_chkbox_item) {
1551 elm_object_item_del(eap_data->eap_chkbox_item);
1552 eap_data->eap_chkbox_item = NULL;
1555 __COMMON_FUNC_EXIT__;
1559 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1561 __COMMON_FUNC_ENTER__;
1563 if (eap_data->eap_auth_item != NULL) {
1564 elm_object_item_del(eap_data->eap_auth_item);
1565 eap_data->eap_auth_item = NULL;
1568 if (eap_data->eap_user_cert_item != NULL) {
1569 elm_object_item_del(eap_data->eap_user_cert_item);
1570 eap_data->eap_user_cert_item = NULL;
1573 if (eap_data->eap_id_item != NULL) {
1574 elm_object_item_del(eap_data->eap_id_item);
1575 eap_data->eap_id_item = NULL;
1578 if (eap_data->eap_pw_item != NULL) {
1579 elm_object_item_del(eap_data->eap_pw_item);
1580 eap_data->eap_pw_item = NULL;
1583 if (eap_data->eap_chkbox_item != NULL) {
1584 elm_object_item_del(eap_data->eap_chkbox_item);
1585 eap_data->eap_chkbox_item = NULL;
1588 __COMMON_FUNC_EXIT__;
1592 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1594 __COMMON_FUNC_ENTER__;
1595 assertm_if(NULL == parent, "NULL!!");
1597 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1598 Evas_Object* view_list = NULL;
1599 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1600 retvm_if(eap_data == NULL, NULL);
1602 __common_eap_connect_popup_init_item_class(eap_data);
1604 eap_data->eap_done_ok = FALSE;
1605 eap_data->genlist = view_list = elm_genlist_add(parent);
1606 //elm_genlist_realization_mode_set(view_list, EINA_TRUE);
1607 elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1608 elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1610 evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1612 evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1614 /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1615 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1616 wifi_ap_set_eap_type(eap_data->ap,
1617 (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1618 WIFI_EAP_TYPE_PEAP :
1619 __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1621 wifi_ap_set_eap_auth_type(eap_data->ap,
1622 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
1626 /* Create the entry items */
1627 _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1629 evas_object_smart_callback_add(view_list, "language,changed",
1630 gl_lang_changed, NULL);
1632 __COMMON_FUNC_EXIT__;
1636 static Eina_Bool _enable_scan_updates_cb(void *data)
1638 /* Lets enable the scan updates */
1639 wlan_manager_enable_scan_result_update();
1641 /* Reset the ecore timer handle */
1642 common_util_manager_ecore_scan_update_timer_reset();
1644 return ECORE_CALLBACK_CANCEL;
1647 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1649 if (eap_data == NULL) {
1653 if (eap_data->conf != NULL) {
1654 evas_object_smart_callback_del(eap_data->conf,
1655 "virtualkeypad,state,on",
1656 _eap_popup_keypad_on_cb);
1657 evas_object_smart_callback_del(eap_data->conf,
1658 "virtualkeypad,state,off",
1659 _eap_popup_keypad_off_cb);
1662 if (eap_data->ssid != NULL) {
1663 g_free(eap_data->ssid);
1664 eap_data->ssid = NULL;
1667 if (eap_data->cert_alias) {
1668 g_free(eap_data->cert_alias);
1669 eap_data->cert_alias = NULL;
1672 if (eap_data->ca_cert_path) {
1673 g_free(eap_data->ca_cert_path);
1674 eap_data->ca_cert_path = NULL;
1677 if (eap_data->user_cert_path) {
1678 g_free(eap_data->user_cert_path);
1679 eap_data->user_cert_path = NULL;
1682 if (eap_data->privatekey_path) {
1683 g_free(eap_data->privatekey_path);
1684 eap_data->privatekey_path = NULL;
1687 wifi_ap_destroy(eap_data->ap);
1688 eap_data->ap = NULL;
1690 if(eap_data->info_popup){
1691 evas_object_del(eap_data->info_popup);
1692 eap_data->info_popup = NULL;
1695 if (eap_data->popup != NULL) {
1696 evas_object_hide(eap_data->popup);
1697 evas_object_del(eap_data->popup);
1700 if(_eap_view_deref_cb != NULL) {
1701 _eap_view_deref_cb();
1702 _eap_view_deref_cb = NULL;
1705 /* A delay is needed to get the smooth Input panel closing animation effect */
1706 common_util_managed_ecore_scan_update_timer_add(0.1,
1707 _enable_scan_updates_cb, NULL);
1710 static void __common_eap_connect_destroy_cb(void *data, Evas_Object *obj,
1713 __common_eap_connect_cleanup((eap_connect_data_t *)data);
1716 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1718 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1720 if (eap_data->info_popup != NULL) {
1721 evas_object_del(eap_data->info_popup);
1722 eap_data->info_popup = NULL;
1726 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1729 char *str_id = NULL;
1730 char *str_pw = NULL;
1731 bool favorite = FALSE;
1732 wifi_eap_type_e eap_type;
1733 wifi_eap_auth_type_e eap_auth_type;
1734 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1735 popup_btn_info_t popup_data;
1737 __COMMON_FUNC_ENTER__;
1738 if (eap_data->eap_done_ok == TRUE) {
1739 __COMMON_FUNC_EXIT__;
1743 eap_data->eap_done_ok = TRUE;
1745 wifi_ap_get_eap_type(eap_data->ap, &eap_type);
1746 wifi_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1748 wifi_ap_is_favorite(eap_data->ap, &favorite);
1749 if (favorite == TRUE) {
1750 wlan_manager_forget(eap_data->ap);
1751 wifi_ap_refresh(eap_data->ap);
1753 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1754 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1757 wifi_ap_set_eap_ca_cert_file(eap_data->ap, "");
1758 wifi_ap_set_eap_client_cert_file(eap_data->ap, "");
1759 wifi_ap_set_eap_private_key_info(eap_data->ap, "", "");
1762 case WIFI_EAP_TYPE_PEAP:
1763 case WIFI_EAP_TYPE_TTLS:
1765 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1766 if (str_id == NULL || str_id[0] == '\0') {
1767 memset(&popup_data, 0, sizeof(popup_data));
1768 popup_data.title_txt = eap_data->ssid;
1769 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1770 popup_data.btn1_cb = _info_popup_ok_cb;
1771 popup_data.btn1_data = eap_data;
1772 popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1773 eap_data->eap_done_ok = FALSE;
1774 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1779 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1780 if (str_pw == NULL || str_pw[0] == '\0') {
1781 memset(&popup_data, 0, sizeof(popup_data));
1782 popup_data.title_txt = eap_data->ssid;
1783 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1784 popup_data.btn1_cb = _info_popup_ok_cb;
1785 popup_data.btn1_data = eap_data;
1786 popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1787 eap_data->eap_done_ok = FALSE;
1788 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1793 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1794 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1795 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1798 case WIFI_EAP_TYPE_TLS:
1799 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1800 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1802 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1803 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1804 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1805 wifi_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1806 wifi_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1807 wifi_ap_set_eap_private_key_info(eap_data->ap,
1808 eap_data->privatekey_path, NULL);
1811 case WIFI_EAP_TYPE_SIM:
1812 case WIFI_EAP_TYPE_AKA:
1816 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1820 if (eap_data->is_hidden) {
1821 wifi_ap_h hidden_ap;
1823 wifi_ap_get_essid(eap_data->ap, &ssid);
1824 wifi_ap_hidden_create(ssid, &hidden_ap);
1828 case WIFI_EAP_TYPE_PEAP:
1829 case WIFI_EAP_TYPE_TTLS:
1830 wifi_ap_set_eap_type(hidden_ap, eap_type);
1831 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1832 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1834 case WIFI_EAP_TYPE_TLS:
1835 wifi_ap_set_eap_type(hidden_ap, eap_type);
1836 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1837 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1838 wifi_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1839 wifi_ap_set_eap_client_cert_file(hidden_ap,eap_data->user_cert_path);
1840 wifi_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1842 case WIFI_EAP_TYPE_SIM:
1843 case WIFI_EAP_TYPE_AKA:
1846 wlan_manager_connect(hidden_ap);
1848 wlan_manager_connect(eap_data->ap);
1850 __common_eap_connect_cleanup(eap_data);
1852 __COMMON_FUNC_EXIT__;
1855 static gboolean delay_create_context_popup(gpointer data)
1857 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1859 if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1860 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1862 click.btn_click[EAP_CERT_BTN] = FALSE;
1863 click.btn_obj[EAP_CERT_BTN] = NULL;
1864 } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1865 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1867 click.btn_click[EAP_AUTH_BTN] = FALSE;
1868 click.btn_obj[EAP_AUTH_BTN] = NULL;
1869 } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1870 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1872 click.btn_click[EAP_TYPE_BTN] = FALSE;
1873 click.btn_obj[EAP_TYPE_BTN] = NULL;
1878 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1885 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1887 keypad_state = FALSE;
1889 common_util_managed_idle_add(delay_create_context_popup,
1890 (gpointer)eap_data);
1892 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
1895 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1902 keypad_state = TRUE;
1903 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
1906 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
1907 Evas_Object *conf, const char *pkg_name,
1908 wifi_device_info_t *device_info, void (*deref_func)(void))
1910 __COMMON_FUNC_ENTER__;
1912 Evas_Object *popup = NULL;
1913 Evas_Object *list = NULL;
1915 if (layout_main == NULL || device_info == NULL || pkg_name == NULL) {
1919 eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
1920 if (eap_data == NULL) {
1924 eap_data->str_pkg_name = pkg_name;
1925 eap_data->win = win;
1926 eap_data->conf = conf;
1927 eap_data->ssid = g_strdup(device_info->ssid);
1929 if (device_info->is_hidden == true) {
1930 /* Hidden Wi-Fi network */
1933 wifi_ap_get_essid(device_info->ap, &ssid);
1937 wifi_ap_hidden_create(ssid, &(eap_data->ap));
1940 eap_data->is_hidden = TRUE;
1942 /* Clone the Wi-Fi AP handle */
1943 wifi_ap_clone(&(eap_data->ap), device_info->ap);
1946 /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
1947 wlan_manager_disable_scan_result_update();
1949 _eap_view_deref_cb = deref_func;
1950 click.btn_click[EAP_TYPE_BTN] = FALSE;
1951 click.btn_obj[EAP_TYPE_BTN] = NULL;
1952 click.btn_click[EAP_AUTH_BTN] = FALSE;
1953 click.btn_obj[EAP_AUTH_BTN] = NULL;
1954 click.btn_click[EAP_CERT_BTN] = FALSE;
1955 click.btn_obj[EAP_CERT_BTN] = NULL;
1956 keypad_state = FALSE;
1958 popup_btn_info_t popup_btn_data;
1959 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
1961 popup_btn_data.title_txt = device_info->ssid;
1962 popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
1963 popup_btn_data.btn1_data = eap_data;
1964 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
1965 popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
1966 popup_btn_data.btn2_data = eap_data;
1967 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
1969 popup = common_utils_show_info_popup(layout_main,
1971 eap_data->popup = popup;
1972 evas_object_show(popup);
1973 elm_object_focus_set(popup, EINA_TRUE);
1975 /* Create an EAP connect view list */
1976 list = _create_list(popup, eap_data);
1977 elm_object_content_set(popup, list);
1979 evas_object_smart_callback_add(eap_data->conf,
1980 "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
1982 evas_object_smart_callback_add(eap_data->conf,
1983 "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
1986 __COMMON_FUNC_EXIT__;
1990 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
1992 wifi_eap_type_e wlan_eap_type = WLAN_SEC_EAP_TYPE_PEAP;
1994 case EAP_SEC_TYPE_PEAP:
1995 wlan_eap_type = WIFI_EAP_TYPE_PEAP;
1997 case EAP_SEC_TYPE_TLS:
1998 wlan_eap_type = WIFI_EAP_TYPE_TLS;
2000 case EAP_SEC_TYPE_TTLS:
2001 wlan_eap_type = WIFI_EAP_TYPE_TTLS;
2003 case EAP_SEC_TYPE_SIM:
2004 wlan_eap_type = WIFI_EAP_TYPE_SIM;
2006 case EAP_SEC_TYPE_AKA:
2007 wlan_eap_type = WIFI_EAP_TYPE_AKA;
2010 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2014 return wlan_eap_type;
2017 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2019 wifi_eap_auth_type_e wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2020 switch (auth_type) {
2021 case EAP_SEC_AUTH_NONE:
2022 wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2024 case EAP_SEC_AUTH_PAP:
2025 wlan_auth_type = WIFI_EAP_AUTH_TYPE_PAP;
2027 case EAP_SEC_AUTH_MSCHAP:
2028 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAP;
2030 case EAP_SEC_AUTH_MSCHAPV2:
2031 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
2033 case EAP_SEC_AUTH_GTC:
2034 wlan_auth_type = WIFI_EAP_AUTH_TYPE_GTC;
2036 case EAP_SEC_AUTH_MD5:
2037 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MD5;
2040 /* This case should never occur */
2041 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2044 return wlan_auth_type;
2047 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap)
2049 wifi_eap_type_e wlan_eap_type = 0;
2050 int ret = wifi_ap_get_eap_type(ap, &wlan_eap_type);
2051 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2052 ret = wifi_ap_set_eap_type(ap, WIFI_EAP_TYPE_PEAP);
2055 if (WIFI_ERROR_NONE != ret) {
2056 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2057 return EAP_SEC_TYPE_UNKNOWN;
2060 switch (wlan_eap_type) {
2061 case WIFI_EAP_TYPE_PEAP: /**< EAP PEAP type */
2062 return EAP_SEC_TYPE_PEAP;
2064 case WIFI_EAP_TYPE_TLS: /**< EAP TLS type */
2065 return EAP_SEC_TYPE_TLS;
2067 case WIFI_EAP_TYPE_TTLS: /**< EAP TTLS type */
2068 return EAP_SEC_TYPE_TTLS;
2070 case WIFI_EAP_TYPE_SIM: /**< EAP SIM type */
2071 return EAP_SEC_TYPE_SIM;
2073 case WIFI_EAP_TYPE_AKA: /**< EAP AKA type */
2074 return EAP_SEC_TYPE_AKA;
2077 return EAP_SEC_TYPE_PEAP;
2079 return EAP_SEC_TYPE_PEAP;
2082 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap)
2084 wifi_eap_auth_type_e wlan_auth_type = 0;
2085 int ret = wifi_ap_get_eap_auth_type(ap, &wlan_auth_type);
2086 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2087 ret = wifi_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2090 if (WIFI_ERROR_NONE != ret) {
2091 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2092 return EAP_SEC_AUTH_NONE;
2095 switch (wlan_auth_type) {
2096 case WIFI_EAP_AUTH_TYPE_NONE: /**< EAP phase2 authentication none */
2097 return EAP_SEC_AUTH_NONE;
2099 case WIFI_EAP_AUTH_TYPE_PAP: /**< EAP phase2 authentication PAP */
2100 return EAP_SEC_AUTH_PAP;
2102 case WIFI_EAP_AUTH_TYPE_MSCHAP: /**< EAP phase2 authentication MSCHAP */
2103 return EAP_SEC_AUTH_MSCHAP;
2105 case WIFI_EAP_AUTH_TYPE_MSCHAPV2: /**< EAP phase2 authentication MSCHAPv2 */
2106 return EAP_SEC_AUTH_MSCHAPV2;
2108 case WIFI_EAP_AUTH_TYPE_GTC: /**< EAP phase2 authentication GTC */
2109 return EAP_SEC_AUTH_GTC;
2111 case WIFI_EAP_AUTH_TYPE_MD5: /**< EAP phase2 authentication MD5 */
2112 return EAP_SEC_AUTH_MD5;
2115 return EAP_SEC_AUTH_NONE;
2117 return EAP_SEC_AUTH_NONE;
2120 static char *_eap_info_get_user_cert_alias(wifi_ap_h ap)
2124 char *filename = NULL;
2125 char *cert_name = NULL;
2127 int filename_len = 0;
2129 wifi_ap_get_eap_client_cert_file(ap, &path);
2133 filename = strrchr(path, '/');
2134 if (filename == NULL) {
2135 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2140 cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2141 if (cert_name == NULL) {
2142 /* For truncated path, available filename will be followed
2143 * with ellipsis(...) & excluding any remaining part of
2144 * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2145 filename_len = strlen(filename);
2146 alias = g_try_malloc0(filename_len - 10);
2147 if (alias == NULL) {
2148 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2151 g_strlcpy(alias, filename, filename_len - 13);
2152 g_strlcat(alias, "...", filename_len - 10);
2153 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2158 alias_len = cert_name - filename;
2160 alias = g_try_malloc0(alias_len + 1);
2161 if (alias == NULL) {
2162 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2166 g_strlcpy(alias, filename, alias_len + 1);
2167 INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2175 /* This creates Auth type, ID, Anonymous Id and Password items
2176 * This function should be called after creating the EAP type item
2178 eap_info_list_t *eap_info_append_items(wifi_ap_h ap, Evas_Object* view_list,
2179 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2180 void *input_panel_cb_data)
2182 __COMMON_FUNC_ENTER__;
2184 eap_type_t eap_type;
2185 eap_auth_t auth_type;
2186 char *temp_str = NULL;
2187 Eina_Bool append_continue = TRUE;
2188 eap_info_list_t *eap_info_list_data = NULL;
2189 Elm_Object_Item* item = NULL;
2190 if (!view_list || !str_pkg_name || !ap) {
2191 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2195 eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2196 if (eap_info_list_data == NULL) {
2200 eap_info_list_data->ap = ap;
2201 eap_type = __common_eap_connect_popup_get_eap_type(ap);
2202 auth_type = __common_eap_connect_popup_get_auth_type(ap);
2204 item = common_utils_add_2_line_txt_disabled_item(view_list,
2205 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2206 sc(str_pkg_name, I18N_TYPE_EAP_method),
2207 list_eap_type[eap_type].name);
2208 eap_info_list_data->eap_method_item = item;
2210 eap_info_list_data->eap_type = eap_type;
2213 case EAP_SEC_TYPE_UNKNOWN:
2214 case EAP_SEC_TYPE_PEAP:
2215 case EAP_SEC_TYPE_TLS:
2216 case EAP_SEC_TYPE_TTLS:
2218 case EAP_SEC_TYPE_SIM:
2219 case EAP_SEC_TYPE_AKA:
2221 append_continue = FALSE;
2225 if (append_continue) {
2226 if (eap_type == EAP_SEC_TYPE_PEAP ||
2227 eap_type == EAP_SEC_TYPE_TTLS) {
2228 /* Add EAP phase2 authentication */
2229 item = common_utils_add_2_line_txt_disabled_item(view_list,
2230 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2231 sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2232 list_eap_auth[auth_type].name);
2233 eap_info_list_data->eap_auth_item = item;
2236 if (eap_type == EAP_SEC_TYPE_TLS) {
2237 /* Add User certificate */
2238 temp_str = _eap_info_get_user_cert_alias(ap);
2240 if (temp_str == NULL || strlen(temp_str) == 0) {
2241 if (temp_str != NULL) {
2244 temp_str = g_strdup(sc(str_pkg_name,
2245 I18N_TYPE_Unspecified));
2248 item = common_utils_add_2_line_txt_disabled_item(view_list,
2249 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2250 sc(str_pkg_name, I18N_TYPE_User_Certificate),
2252 eap_info_list_data->user_cert_item = item;
2259 wifi_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set);
2260 item = common_utils_add_2_line_txt_disabled_item(view_list,
2261 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2262 sc(str_pkg_name, I18N_TYPE_Identity),
2264 eap_info_list_data->id_item = item;
2268 common_utils_entry_info_t *edit_box_details;
2270 /* Add EAP Password */
2271 g_eap_entry_itc.item_style = "entry.main";
2272 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2273 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2274 g_eap_entry_itc.func.state_get = NULL;
2275 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2277 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2278 if (edit_box_details == NULL) {
2279 g_free(eap_info_list_data);
2283 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2284 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2285 edit_box_details->entry_txt = NULL;
2286 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2287 edit_box_details->input_panel_cb = input_panel_cb;
2288 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2289 edit_box_details->item = elm_genlist_item_append(view_list,
2290 &g_eap_entry_itc, edit_box_details, NULL,
2291 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2292 elm_genlist_item_select_mode_set(edit_box_details->item,
2293 ELM_OBJECT_SELECT_MODE_NONE);
2294 eap_info_list_data->pswd_item = edit_box_details->item;
2298 __COMMON_FUNC_EXIT__;
2299 return eap_info_list_data;
2303 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2305 if (!eap_info_list_data) {
2306 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2309 char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2311 wifi_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2317 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2319 if (!eap_info_list_data) {
2320 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2324 g_free(eap_info_list_data);
2327 void eap_connect_data_free(eap_connect_data_t *eap_data)
2329 __common_eap_connect_cleanup(eap_data);