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 <vconf-keys.h>
26 #include <glib/gstdio.h>
27 #include <efl_extension.h>
31 #include "common_eap_connect.h"
32 #include "i18nmanager.h"
33 #include "common_utils.h"
34 #include "common_ip_info.h"
36 #define GENLIST_ITEM_HEIGHT 96
37 #define MAX_LABEL_LENGTH 512
39 #define EAP_TLS_PATH "/tmp/"
40 #define EAP_TLS_CA_CERT_PATH "ca_cert.pem"
41 #define EAP_TLS_USER_CERT_PATH "user_cert.pem"
42 #define EAP_TLS_PRIVATEKEY_PATH "privatekey.pem"
44 #define EAP_TYPE_UNKNOWN "UNKNOWN"
45 #define EAP_TYPE_PEAP "PEAP"
46 #define EAP_TYPE_TLS "TLS"
47 #define EAP_TYPE_TTLS "TTLS"
48 #define EAP_TYPE_SIM "SIM"
49 #define EAP_TYPE_AKA "AKA"
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, "eap_dropdown_button");
773 btn = elm_button_add(obj);
775 if (sel_sub_item_id == EAP_SEC_AUTH_NONE) {
776 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
777 sc(PACKAGE, I18N_TYPE_None));
779 g_snprintf(buf, sizeof(buf), "<align=left>%s</align>",
780 list_eap_auth[sel_sub_item_id].name);
783 elm_object_domain_translatable_text_set(btn, PACKAGE, buf);
784 elm_object_style_set(btn, "dropdown/label");
785 evas_object_propagate_events_set(btn, EINA_FALSE);
786 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
788 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
790 evas_object_smart_callback_add(btn, "clicked",
791 _gl_eap_auth_btn_cb, eap_data);
793 elm_layout_content_set(ly, "btn", btn);
799 static void _gl_eap_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
801 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
806 Evas_Object *entry = NULL;
807 Elm_Object_Item *next_item = NULL;
810 switch (entry_info->entry_id) {
811 case ENTRY_TYPE_USER_ID:
812 eap_type = __common_eap_connect_popup_get_eap_type(
815 if (eap_type == EAP_SEC_TYPE_TLS) {
816 entry = elm_object_item_part_content_get(entry_info->item,
819 elm_object_focus_set(entry, EINA_FALSE);
822 next_item = elm_genlist_item_next_get(entry_info->item);
824 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
825 elm_genlist_item_select_mode_get(next_item) !=
826 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
827 entry = elm_object_item_part_content_get(
828 next_item, "elm.icon.entry");
830 elm_object_focus_set(entry, EINA_TRUE);
835 next_item = elm_genlist_item_next_get(next_item);
839 case ENTRY_TYPE_PASSWORD:
840 entry = elm_object_item_part_content_get(entry_info->item,
843 elm_object_focus_set(entry, EINA_FALSE);
851 static void _gl_eap_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
853 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
858 if (elm_object_focus_get(obj)) {
859 if (elm_entry_is_empty(obj)) {
860 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
862 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
866 if (entry_info->entry_txt) {
867 g_free(entry_info->entry_txt);
868 entry_info->entry_txt = NULL;
871 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
873 if (entry_text != NULL && entry_text[0] != '\0') {
874 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
880 static void _gl_eap_entry_changed_cb(void* data, Evas_Object* obj, void* event_info)
882 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
891 if (elm_object_focus_get(obj)) {
892 if (elm_entry_is_empty(obj)) {
893 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
895 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
900 static void _gl_eap_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
902 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
907 if (!elm_entry_is_empty(obj)) {
908 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
911 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
914 static void _gl_eap_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
916 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
921 if (entry_info->entry_txt) {
922 g_free(entry_info->entry_txt);
923 entry_info->entry_txt = NULL;
926 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
927 if (entry_text != NULL && entry_text[0] != '\0')
928 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
932 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
933 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
936 static void _gl_eap_entry_maxlength_reached(void *data, Evas_Object *obj,
939 common_utils_send_message_to_net_popup("Password length",
940 "Lengthy Password", "notification", NULL);
943 static void _gl_eap_entry_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
945 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
950 Evas_Object *entry = elm_object_item_part_content_get(entry_info->item, "elm.icon.entry");
952 elm_object_focus_set(entry, EINA_TRUE);
953 elm_entry_entry_set(entry, "");
957 static char *_gl_eap_entry_item_text_get(void *data, Evas_Object *obj, const char *part)
959 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
964 if (!g_strcmp0(part, "elm.text.sub")) {
965 return g_strdup(dgettext(PACKAGE, entry_info->title_txt));
971 static Evas_Object *_gl_eap_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
973 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
978 if (g_strcmp0(part, "elm.swallow.content") == 0) {
979 Evas_Object *entry = NULL;
980 Evas_Object *box = NULL;
981 Evas_Object *tpad = NULL;
982 Evas_Object *lpad = NULL;
983 Evas_Object *label = NULL;
984 Evas_Object *layout = NULL;
985 Evas_Object *editfield = NULL;
986 char buf[MAX_LABEL_LENGTH] = {0, };
987 char *guide_txt = NULL;
988 char *accepted = NULL;
989 Eina_Bool hide_entry_txt = EINA_FALSE;
990 Elm_Input_Panel_Layout panel_type;
995 eap_type = __common_eap_connect_popup_get_eap_type(entry_info->ap);
997 static Elm_Entry_Filter_Limit_Size limit_filter_data;
999 switch (entry_info->entry_id)
1001 case ENTRY_TYPE_USER_ID:
1002 panel_type = ELM_INPUT_PANEL_LAYOUT_NORMAL;
1003 guide_txt = entry_info->guide_txt;
1005 if (eap_type == EAP_SEC_TYPE_TLS) {
1006 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1008 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
1011 case ENTRY_TYPE_PASSWORD:
1012 panel_type = ELM_INPUT_PANEL_LAYOUT_PASSWORD;
1013 guide_txt = entry_info->guide_txt;
1014 hide_entry_txt = EINA_TRUE;
1015 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
1021 entry = elm_box_add(obj);
1022 elm_box_align_set(entry, 0.0, 0.0);
1024 tpad = evas_object_rectangle_add(entry);
1025 evas_object_size_hint_min_set(tpad, 0, ELM_SCALE_SIZE(10));
1026 evas_object_show(tpad);
1027 elm_box_pack_end(entry, tpad);
1029 box = elm_box_add(entry);
1030 evas_object_size_hint_align_set(box, 0.0, 0.0);
1031 elm_box_horizontal_set(box, EINA_TRUE);
1032 elm_box_pack_end(entry, box);
1033 evas_object_show(box);
1035 lpad = evas_object_rectangle_add(box);
1036 evas_object_size_hint_min_set(lpad, ELM_SCALE_SIZE(15), 0);
1037 evas_object_show(lpad);
1038 elm_box_pack_end(box, lpad);
1039 evas_object_show(box);
1041 label = elm_label_add(box);
1042 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=30>%s</font_size>",
1043 dgettext(PACKAGE, entry_info->title_txt));
1044 elm_object_text_set(label, buf);
1045 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1046 evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
1047 elm_box_pack_end(box, label);
1048 evas_object_show(label);
1050 layout = elm_layout_add(entry);
1051 elm_layout_theme_set(layout, "layout", "editfield", "singleline");
1052 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1053 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1055 editfield = elm_entry_add(layout);
1056 elm_entry_single_line_set(editfield, EINA_TRUE);
1057 elm_entry_scrollable_set(editfield, EINA_TRUE);
1058 elm_entry_password_set(editfield, hide_entry_txt);
1059 elm_entry_prediction_allow_set(editfield, EINA_FALSE);
1060 elm_entry_autocapital_type_set(editfield, ELM_AUTOCAPITAL_TYPE_NONE);
1062 elm_object_domain_translatable_part_text_set(editfield, "elm.guide",
1063 PACKAGE, guide_txt);
1064 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0)) {
1065 elm_entry_entry_set(editfield, entry_info->entry_txt);
1068 elm_entry_input_panel_layout_set(editfield, panel_type);
1069 elm_entry_input_panel_return_key_type_set(editfield, return_key_type);
1071 limit_filter_data.max_char_count = 200;
1072 elm_entry_markup_filter_append(editfield, elm_entry_filter_limit_size, &limit_filter_data);
1074 Elm_Entry_Filter_Accept_Set digits_filter_data;
1075 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
1076 digits_filter_data.accepted = accepted;
1077 elm_entry_markup_filter_append(editfield, elm_entry_filter_accept_set, &digits_filter_data);
1079 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(editfield);
1080 if (imf_ctxt && entry_info->input_panel_cb) {
1081 ecore_imf_context_input_panel_event_callback_add(imf_ctxt,
1082 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1083 entry_info->input_panel_cb,
1084 entry_info->input_panel_cb_data);
1085 DEBUG_LOG(UG_NAME_NORMAL, "set the imf ctxt cbs");
1088 evas_object_smart_callback_add(editfield, "activated", _gl_eap_entry_key_enter_cb, entry_info);
1089 evas_object_smart_callback_add(editfield, "cursor,changed", _gl_eap_entry_cursor_changed_cb, entry_info);
1090 evas_object_smart_callback_add(editfield, "changed", _gl_eap_entry_changed_cb, entry_info);
1091 evas_object_smart_callback_add(editfield, "focused", _gl_eap_entry_focused_cb, entry_info);
1092 evas_object_smart_callback_add(editfield, "unfocused", _gl_eap_entry_unfocused_cb, entry_info);
1093 evas_object_smart_callback_add(editfield, "maxlength,reached", _gl_eap_entry_maxlength_reached, NULL);
1095 elm_object_part_content_set(layout, "elm.swallow.content", editfield);
1096 evas_object_show(layout);
1097 elm_box_pack_end(entry, layout);
1099 evas_object_size_hint_min_set(entry, 0, ELM_SCALE_SIZE(height));
1100 elm_object_focus_set(entry, EINA_FALSE);
1101 evas_object_show(entry);
1103 if (entry_info->entry_id == ENTRY_TYPE_PASSWORD) {
1104 g_pwd_entry = editfield;
1108 } else if (g_strcmp0(part, "elm.icon.eraser") == 0) {
1109 Evas_Object *btn = elm_button_add(obj);
1110 elm_object_style_set(btn, "editfield_clear");
1111 evas_object_smart_callback_add(btn, "clicked", _gl_eap_entry_eraser_clicked_cb, entry_info);
1118 static void _gl_eap_entry_item_del(void *data, Evas_Object *obj)
1120 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
1121 if (entry_info == NULL) {
1125 if (entry_info->entry_txt) {
1126 g_free(entry_info->entry_txt);
1132 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1134 if (obj == NULL || g_pwd_entry == NULL) {
1138 Eina_Bool state = elm_check_state_get(obj);
1140 elm_entry_password_set(g_pwd_entry, EINA_FALSE);
1142 elm_entry_password_set(g_pwd_entry, EINA_TRUE);
1146 static char *_gl_eap_chkbox_item_text_get(void *data, Evas_Object *obj,
1149 char *str_pkg_name = (char *)data;
1151 if (!strcmp("elm.text", part)) {
1153 snprintf(buf, 1023, "%s", sc(str_pkg_name, I18N_TYPE_Show_password));
1160 static Evas_Object *_gl_eap_chkbox_item_content_get(void *data,
1161 Evas_Object *obj, const char *part)
1163 Evas_Object *check = NULL;
1165 if (!strcmp("elm.swallow.end", part)) {
1166 check = elm_check_add(obj);
1167 evas_object_propagate_events_set(check, EINA_FALSE);
1169 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1170 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1171 evas_object_smart_callback_add(check, "changed",
1172 _chk_changed_cb, NULL);
1174 elm_object_focus_allow_set(check, EINA_FALSE);
1181 static void _gl_eap_chkbox_sel(void *data, Evas_Object *obj, void *ei)
1183 Elm_Object_Item *item = NULL;
1185 item = (Elm_Object_Item *)ei;
1190 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.right");
1192 elm_genlist_item_selected_set(item, EINA_FALSE);
1194 Eina_Bool state = elm_check_state_get(ck);
1195 elm_check_state_set(ck, !state);
1197 _chk_changed_cb(NULL, ck, NULL);
1200 static void gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
1202 elm_genlist_realized_items_update(obj);
1205 static void __common_eap_connect_popup_init_item_class(void *data)
1207 g_eap_type_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1208 g_eap_type_itc.func.text_get = _gl_eap_type_text_get;
1209 g_eap_type_itc.func.content_get = _gl_eap_type_content_get;
1210 g_eap_type_itc.func.state_get = NULL;
1211 g_eap_type_itc.func.del = NULL;
1213 g_eap_auth_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1214 g_eap_auth_itc.func.text_get = _gl_eap_auth_text_get;
1215 g_eap_auth_itc.func.content_get = _gl_eap_auth_content_get;
1216 g_eap_auth_itc.func.state_get = NULL;
1217 g_eap_auth_itc.func.del = NULL;
1219 g_eap_user_cert_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
1220 g_eap_user_cert_itc.func.text_get = _gl_eap_user_cert_text_get;
1221 g_eap_user_cert_itc.func.content_get = _gl_eap_user_cert_content_get;
1222 g_eap_user_cert_itc.func.state_get = NULL;
1223 g_eap_user_cert_itc.func.del = NULL;
1225 g_eap_entry_itc.item_style = WIFI_GENLIST_FULL_STYLE;
1226 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
1227 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
1228 g_eap_entry_itc.func.state_get = NULL;
1229 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
1231 g_eap_chkbox_itc.item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
1232 g_eap_chkbox_itc.func.text_get = _gl_eap_chkbox_item_text_get;
1233 g_eap_chkbox_itc.func.content_get = _gl_eap_chkbox_item_content_get;
1234 g_eap_chkbox_itc.func.state_get = NULL;
1235 g_eap_chkbox_itc.func.del = NULL;
1238 static gboolean __cert_extract_files(const char *cert_alias,
1239 eap_connect_data_t *eap_data)
1243 size_t cert_counts = 0;
1245 gchar *ca_cert_path = NULL;
1246 gchar *user_cert_path = NULL;
1247 gchar *privatekey_path = NULL;
1249 CertSvcInstance cert_instance;
1250 CertSvcString cert_alias_str;
1251 CertSvcCertificateList cert_list;
1252 CertSvcCertificate user_certificate;
1253 CertSvcCertificate ca_certificate;
1254 CertSvcCertificate *selected_certificate = NULL;
1256 EVP_PKEY *privatekey = NULL;
1258 ret = certsvc_instance_new(&cert_instance);
1259 if (ret != CERTSVC_SUCCESS) {
1260 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_instance_new");
1263 ret = certsvc_string_new(cert_instance, cert_alias, strlen(cert_alias), &cert_alias_str);
1264 if (ret != CERTSVC_SUCCESS) {
1265 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_string_new");
1268 ret = certsvc_pkcs12_load_certificate_list_from_store(cert_instance, WIFI_STORE, cert_alias_str, &cert_list);
1269 if (ret != CERTSVC_SUCCESS) {
1270 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_pkcs12_load_certificate_list_from_store");
1273 ret = certsvc_certificate_list_get_length(cert_list, &cert_counts);
1274 if (cert_counts < 1) {
1275 ERROR_LOG(UG_NAME_NORMAL, "there is no certificates");
1278 INFO_LOG(UG_NAME_NORMAL, "cert counts: %d", cert_counts);
1279 selected_certificate = g_try_new0(CertSvcCertificate, cert_counts);
1280 if (selected_certificate == NULL) {
1281 ERROR_LOG(UG_NAME_NORMAL, "failed to allocate memory");
1284 ret = certsvc_certificate_list_get_one(cert_list, 0, &user_certificate);
1285 if (ret != CERTSVC_SUCCESS) {
1286 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1289 cert_index = cert_counts - 1;
1291 selected_certificate[0] = user_certificate;
1293 ret = certsvc_certificate_dup_x509(user_certificate, &x509);
1295 user_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1296 cert_alias, EAP_TLS_USER_CERT_PATH);
1297 if ((fp = fopen(user_cert_path, "w")) == NULL) {
1300 ret = PEM_write_X509(fp, x509);
1302 certsvc_certificate_free_x509(x509);
1303 INFO_LOG(UG_NAME_NORMAL, "success to save user_cert file");
1305 ca_cert_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH, cert_alias,
1306 EAP_TLS_CA_CERT_PATH);
1307 while (cert_index) {
1308 ret = certsvc_certificate_list_get_one(cert_list, cert_index, &ca_certificate);
1309 if (ret != CERTSVC_SUCCESS) {
1310 ERROR_LOG(UG_NAME_NORMAL, "failed to certsvc_certificate_list_get_one");
1314 selected_certificate[cert_counts-cert_index] = ca_certificate;
1317 ret = certsvc_certificate_dup_x509(ca_certificate, &x509);
1318 if ((fp = fopen(ca_cert_path, "a")) == NULL) {
1321 ret = PEM_write_X509(fp, x509);
1323 certsvc_certificate_free_x509(x509);
1325 INFO_LOG(UG_NAME_NORMAL, "success to save ca_cert file");
1326 ret = certsvc_certificate_verify(selected_certificate[0], selected_certificate, cert_counts, NULL, 0, &validity);
1327 if (ret != CERTSVC_SUCCESS) {
1328 ERROR_LOG(UG_NAME_NORMAL, "failed to verify ca_certificate");
1331 if (validity == 0) {
1332 ERROR_LOG(UG_NAME_NORMAL, "Invalid certificate");
1336 ret = certsvc_pkcs12_dup_evp_pkey_from_store(cert_instance, WIFI_STORE, cert_alias_str, &privatekey);
1338 privatekey_path = g_strdup_printf("%s%s_%s", EAP_TLS_PATH,
1339 cert_alias, EAP_TLS_PRIVATEKEY_PATH);
1341 if ((fp = fopen(privatekey_path, "w")) == NULL) {
1344 ret = PEM_write_PrivateKey(fp, privatekey, NULL, NULL, 0, NULL, NULL);
1346 certsvc_pkcs12_free_evp_pkey(privatekey);
1347 INFO_LOG(UG_NAME_NORMAL, "success to save privatekey file");
1349 g_free(selected_certificate);
1350 certsvc_instance_free(cert_instance);
1352 eap_data->ca_cert_path = ca_cert_path;
1353 eap_data->user_cert_path = user_cert_path;
1354 eap_data->privatekey_path = privatekey_path;
1359 g_free(ca_cert_path);
1360 g_free(user_cert_path);
1361 g_free(privatekey_path);
1363 if (selected_certificate) {
1364 g_free(selected_certificate);
1367 certsvc_instance_free(cert_instance);
1371 /* This creates EAP type, Auth type, CA certificate, User certificate,
1372 * User Id, Anonymous Id and Password items.
1374 static void _create_and_update_list_items_based_on_rules(eap_type_t new_type,
1375 eap_connect_data_t *eap_data)
1377 __COMMON_FUNC_ENTER__;
1378 Evas_Object* view_list = eap_data->genlist;
1379 Elm_Object_Item *insert_after_item = NULL;
1380 Elm_Object_Item *prev_item = NULL;
1381 common_utils_entry_info_t *edit_box_details;
1382 Eina_Bool auth_reqd = EINA_FALSE;
1383 Eina_Bool user_cert_reqd = EINA_FALSE;
1384 Eina_Bool id_reqd = EINA_FALSE;
1385 Eina_Bool pw_reqd = EINA_FALSE;
1387 if (NULL == eap_data->eap_type_item) {
1388 /* Create EAP method/type */
1389 eap_data->eap_type_item = elm_genlist_item_append(
1390 view_list, &g_eap_type_itc,
1392 ELM_GENLIST_ITEM_NONE,
1393 _gl_eap_item_sel_cb, eap_data);
1397 case EAP_SEC_TYPE_PEAP:
1398 insert_after_item = eap_data->eap_type_item;
1399 auth_reqd = EINA_TRUE;
1400 user_cert_reqd = EINA_FALSE;
1401 id_reqd = EINA_TRUE;
1402 pw_reqd = EINA_TRUE;
1404 case EAP_SEC_TYPE_TLS:
1405 insert_after_item = eap_data->eap_type_item;
1406 auth_reqd = EINA_FALSE;
1407 user_cert_reqd = EINA_TRUE;
1408 id_reqd = EINA_TRUE;
1409 pw_reqd = EINA_FALSE;
1411 case EAP_SEC_TYPE_TTLS:
1412 insert_after_item = eap_data->eap_type_item;
1413 auth_reqd = EINA_TRUE;
1414 user_cert_reqd = EINA_FALSE;
1415 id_reqd = EINA_TRUE;
1416 pw_reqd = EINA_TRUE;
1418 case EAP_SEC_TYPE_SIM:
1419 case EAP_SEC_TYPE_AKA:
1420 _delete_eap_entry_items(eap_data);
1421 auth_reqd = EINA_FALSE;
1422 user_cert_reqd = EINA_FALSE;
1423 id_reqd = EINA_FALSE;
1424 pw_reqd = EINA_FALSE;
1430 if (auth_reqd == EINA_TRUE) {
1431 if (eap_data->eap_auth_item == NULL) {
1432 /* Add EAP phase2 authentication */
1433 eap_data->eap_auth_item = elm_genlist_item_insert_after(
1434 view_list, &g_eap_auth_itc, eap_data, NULL,
1435 insert_after_item, ELM_GENLIST_ITEM_NONE,
1436 _gl_eap_item_sel_cb, eap_data);
1439 _delete_eap_auth_item(eap_data);
1442 if (user_cert_reqd == EINA_TRUE) {
1443 if (eap_data->eap_user_cert_item == NULL) {
1444 prev_item = eap_data->eap_type_item;
1446 /* Add User certificate */
1447 eap_data->eap_user_cert_item = elm_genlist_item_insert_after(
1448 view_list, &g_eap_user_cert_itc, eap_data, NULL,
1449 prev_item, ELM_GENLIST_ITEM_NONE,
1450 _gl_eap_item_sel_cb, eap_data);
1453 _delete_eap_user_cert_item(eap_data);
1456 if (id_reqd == EINA_TRUE) {
1457 if (eap_data->eap_id_item == NULL) {
1458 if (new_type == EAP_SEC_TYPE_PEAP ||
1459 new_type == EAP_SEC_TYPE_TTLS) {
1460 prev_item = eap_data->eap_auth_item;
1462 prev_item = eap_data->eap_user_cert_item;
1466 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1467 if (edit_box_details == NULL) {
1471 edit_box_details->ap = eap_data->ap;
1472 edit_box_details->entry_id = ENTRY_TYPE_USER_ID;
1473 edit_box_details->title_txt = "IDS_WIFI_BODY_IDENTITY";
1474 edit_box_details->guide_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1475 edit_box_details->item = elm_genlist_item_insert_after(
1476 view_list, &g_eap_entry_itc, edit_box_details,
1478 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
1479 eap_data->eap_id_item = edit_box_details->item;
1482 _delete_eap_id_item(eap_data);
1485 if (pw_reqd == EINA_TRUE) {
1486 if (eap_data->eap_pw_item == NULL) {
1487 /* Add EAP Password */
1488 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
1489 if (edit_box_details == NULL) {
1493 edit_box_details->ap = eap_data->ap;
1494 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
1495 edit_box_details->title_txt = "IDS_WIFI_HEADER_PASSWORD";
1496 edit_box_details->guide_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1497 edit_box_details->item = elm_genlist_item_insert_after(
1498 view_list, &g_eap_entry_itc,
1499 edit_box_details, NULL,
1500 eap_data->eap_id_item,
1501 ELM_GENLIST_ITEM_NONE,
1502 _gl_editbox_sel_cb, NULL);
1503 eap_data->eap_pw_item = edit_box_details->item;
1505 _update_eap_id_item_enter_key(eap_data);
1508 if (eap_data->eap_chkbox_item == NULL) {
1509 /* Add Show Password checkbox */
1510 eap_data->eap_chkbox_item = elm_genlist_item_insert_after(
1511 view_list, &g_eap_chkbox_itc,
1512 eap_data->str_pkg_name, NULL,
1513 eap_data->eap_pw_item,
1514 ELM_GENLIST_ITEM_NONE,
1515 _gl_eap_chkbox_sel, NULL);
1518 _delete_eap_pw_items(eap_data);
1521 __COMMON_FUNC_EXIT__;
1525 static void _update_eap_id_item_enter_key(eap_connect_data_t *eap_data)
1527 if (eap_data->eap_id_item == NULL)
1530 Evas_Object *entry = NULL;
1531 eap_type_t eap_type;
1533 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1534 entry = elm_object_item_part_content_get(eap_data->eap_id_item,
1537 if (eap_type == EAP_SEC_TYPE_TLS) {
1538 elm_entry_input_panel_return_key_type_set(entry,
1539 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1541 elm_entry_input_panel_return_key_type_set(entry,
1542 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT);
1547 static void _delete_eap_auth_item(eap_connect_data_t *eap_data)
1549 __COMMON_FUNC_ENTER__;
1551 if (eap_data->eap_auth_item != NULL) {
1552 elm_object_item_del(eap_data->eap_auth_item);
1553 eap_data->eap_auth_item = NULL;
1556 __COMMON_FUNC_EXIT__;
1560 static void _delete_eap_user_cert_item(eap_connect_data_t *eap_data)
1562 __COMMON_FUNC_ENTER__;
1564 if (eap_data->eap_user_cert_item != NULL) {
1565 elm_object_item_del(eap_data->eap_user_cert_item);
1566 eap_data->eap_user_cert_item = NULL;
1569 __COMMON_FUNC_EXIT__;
1573 static void _delete_eap_id_item(eap_connect_data_t *eap_data)
1575 __COMMON_FUNC_ENTER__;
1577 if (eap_data->eap_id_item != NULL) {
1578 elm_object_item_del(eap_data->eap_id_item);
1579 eap_data->eap_id_item = NULL;
1582 __COMMON_FUNC_EXIT__;
1586 static void _delete_eap_pw_items(eap_connect_data_t *eap_data)
1588 __COMMON_FUNC_ENTER__;
1590 _update_eap_id_item_enter_key(eap_data);
1592 if (eap_data->eap_pw_item != NULL) {
1593 elm_object_item_del(eap_data->eap_pw_item);
1594 eap_data->eap_pw_item = NULL;
1597 if (eap_data->eap_chkbox_item) {
1598 elm_object_item_del(eap_data->eap_chkbox_item);
1599 eap_data->eap_chkbox_item = NULL;
1602 __COMMON_FUNC_EXIT__;
1606 void _delete_eap_entry_items(eap_connect_data_t *eap_data)
1608 __COMMON_FUNC_ENTER__;
1610 if (eap_data->eap_auth_item != NULL) {
1611 elm_object_item_del(eap_data->eap_auth_item);
1612 eap_data->eap_auth_item = NULL;
1615 if (eap_data->eap_user_cert_item != NULL) {
1616 elm_object_item_del(eap_data->eap_user_cert_item);
1617 eap_data->eap_user_cert_item = NULL;
1620 if (eap_data->eap_id_item != NULL) {
1621 elm_object_item_del(eap_data->eap_id_item);
1622 eap_data->eap_id_item = NULL;
1625 if (eap_data->eap_pw_item != NULL) {
1626 elm_object_item_del(eap_data->eap_pw_item);
1627 eap_data->eap_pw_item = NULL;
1630 if (eap_data->eap_chkbox_item != NULL) {
1631 elm_object_item_del(eap_data->eap_chkbox_item);
1632 eap_data->eap_chkbox_item = NULL;
1635 __COMMON_FUNC_EXIT__;
1639 static Evas_Object* _create_list(Evas_Object* parent, void *data)
1641 __COMMON_FUNC_ENTER__;
1642 assertm_if(NULL == parent, "NULL!!");
1644 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1645 Evas_Object* view_list = NULL;
1646 eap_type_t eap_type = EAP_SEC_TYPE_UNKNOWN;
1647 retvm_if(eap_data == NULL, NULL);
1649 __common_eap_connect_popup_init_item_class(eap_data);
1651 eap_data->eap_done_ok = FALSE;
1652 eap_data->genlist = view_list = elm_genlist_add(parent);
1653 //elm_genlist_realization_mode_set(view_list, EINA_TRUE);
1654 elm_genlist_mode_set(view_list, ELM_LIST_COMPRESS);
1655 elm_scroller_content_min_limit(view_list, EINA_FALSE, EINA_TRUE);
1657 evas_object_size_hint_weight_set(view_list, EVAS_HINT_EXPAND,
1659 evas_object_size_hint_align_set(view_list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1661 /* Set default values. eap type = PEAP, auth type = MSCHAPv2 */
1662 eap_type = __common_eap_connect_popup_get_eap_type(eap_data->ap);
1663 wifi_ap_set_eap_type(eap_data->ap,
1664 (eap_type == EAP_SEC_TYPE_UNKNOWN) ?
1665 WIFI_EAP_TYPE_PEAP :
1666 __common_eap_connect_popup_get_wlan_eap_type(eap_type));
1668 wifi_ap_set_eap_auth_type(eap_data->ap,
1669 WIFI_EAP_AUTH_TYPE_MSCHAPV2);
1673 /* Create the entry items */
1674 _create_and_update_list_items_based_on_rules(eap_type, eap_data);
1676 evas_object_smart_callback_add(view_list, "language,changed",
1677 gl_lang_changed, NULL);
1679 __COMMON_FUNC_EXIT__;
1683 static Eina_Bool _enable_scan_updates_cb(void *data)
1685 /* Lets enable the scan updates */
1686 wlan_manager_enable_scan_result_update();
1688 /* Reset the ecore timer handle */
1689 common_util_manager_ecore_scan_update_timer_reset();
1691 return ECORE_CALLBACK_CANCEL;
1694 static void __common_eap_connect_cleanup(eap_connect_data_t *eap_data)
1696 if (eap_data == NULL) {
1700 if (eap_data->conf != NULL) {
1701 evas_object_smart_callback_del(eap_data->conf,
1702 "virtualkeypad,state,on",
1703 _eap_popup_keypad_on_cb);
1704 evas_object_smart_callback_del(eap_data->conf,
1705 "virtualkeypad,state,off",
1706 _eap_popup_keypad_off_cb);
1709 if (eap_data->ssid != NULL) {
1710 g_free(eap_data->ssid);
1711 eap_data->ssid = NULL;
1714 if (eap_data->cert_alias) {
1715 g_free(eap_data->cert_alias);
1716 eap_data->cert_alias = NULL;
1719 if (eap_data->ca_cert_path) {
1720 g_free(eap_data->ca_cert_path);
1721 eap_data->ca_cert_path = NULL;
1724 if (eap_data->user_cert_path) {
1725 g_free(eap_data->user_cert_path);
1726 eap_data->user_cert_path = NULL;
1729 if (eap_data->privatekey_path) {
1730 g_free(eap_data->privatekey_path);
1731 eap_data->privatekey_path = NULL;
1734 wifi_ap_destroy(eap_data->ap);
1735 eap_data->ap = NULL;
1737 if(eap_data->info_popup){
1738 evas_object_del(eap_data->info_popup);
1739 eap_data->info_popup = NULL;
1742 if (eap_data->popup != NULL) {
1743 evas_object_hide(eap_data->popup);
1744 evas_object_del(eap_data->popup);
1747 if(_eap_view_deref_cb != NULL) {
1748 _eap_view_deref_cb();
1749 _eap_view_deref_cb = NULL;
1752 /* A delay is needed to get the smooth Input panel closing animation effect */
1753 common_util_managed_ecore_scan_update_timer_add(0.1,
1754 _enable_scan_updates_cb, NULL);
1757 static void __common_eap_connect_destroy_cb(void *data, Evas_Object *obj,
1760 __common_eap_connect_cleanup((eap_connect_data_t *)data);
1763 static void _info_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1765 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1767 if (eap_data->info_popup != NULL) {
1768 evas_object_del(eap_data->info_popup);
1769 eap_data->info_popup = NULL;
1773 static void __common_eap_connect_done_cb(void *data, Evas_Object *obj,
1776 char *str_id = NULL;
1777 char *str_pw = NULL;
1778 bool favorite = FALSE;
1779 wifi_eap_type_e eap_type;
1780 wifi_eap_auth_type_e eap_auth_type;
1781 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1782 popup_btn_info_t popup_data;
1784 __COMMON_FUNC_ENTER__;
1785 if (eap_data->eap_done_ok == TRUE) {
1786 __COMMON_FUNC_EXIT__;
1790 eap_data->eap_done_ok = TRUE;
1792 wifi_ap_get_eap_type(eap_data->ap, &eap_type);
1793 wifi_ap_get_eap_auth_type(eap_data->ap, &eap_auth_type);
1795 wifi_ap_is_favorite(eap_data->ap, &favorite);
1796 if (favorite == TRUE) {
1797 wlan_manager_forget(eap_data->ap);
1798 wifi_ap_refresh(eap_data->ap);
1800 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1801 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1804 wifi_ap_set_eap_ca_cert_file(eap_data->ap, "");
1805 wifi_ap_set_eap_client_cert_file(eap_data->ap, "");
1806 wifi_ap_set_eap_private_key_info(eap_data->ap, "", "");
1809 case WIFI_EAP_TYPE_PEAP:
1810 case WIFI_EAP_TYPE_TTLS:
1812 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1813 if (str_id == NULL || str_id[0] == '\0') {
1814 memset(&popup_data, 0, sizeof(popup_data));
1815 popup_data.title_txt = eap_data->ssid;
1816 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1817 popup_data.btn1_cb = _info_popup_ok_cb;
1818 popup_data.btn1_data = eap_data;
1819 popup_data.info_txt = "IDS_WIFI_BODY_ENTER_IDENTITY";
1820 eap_data->eap_done_ok = FALSE;
1821 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1829 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1830 if (str_pw == NULL || str_pw[0] == '\0') {
1831 memset(&popup_data, 0, sizeof(popup_data));
1832 popup_data.title_txt = eap_data->ssid;
1833 popup_data.btn1_txt = "IDS_WIFI_SK2_OK";
1834 popup_data.btn1_cb = _info_popup_ok_cb;
1835 popup_data.btn1_data = eap_data;
1836 popup_data.info_txt = "IDS_WIFI_HEADER_ENTER_PASSWORD";
1837 eap_data->eap_done_ok = FALSE;
1838 eap_data->info_popup = common_utils_show_info_popup(eap_data->win,
1847 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1848 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1849 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1852 case WIFI_EAP_TYPE_TLS:
1853 str_id = common_utils_get_list_item_entry_txt(eap_data->eap_id_item);
1854 str_pw = common_utils_get_list_item_entry_txt(eap_data->eap_pw_item);
1856 wifi_ap_set_eap_type(eap_data->ap, eap_type);
1857 wifi_ap_set_eap_auth_type(eap_data->ap, eap_auth_type);
1858 wifi_ap_set_eap_passphrase(eap_data->ap, str_id, str_pw);
1859 wifi_ap_set_eap_ca_cert_file(eap_data->ap, eap_data->ca_cert_path);
1860 wifi_ap_set_eap_client_cert_file(eap_data->ap, eap_data->user_cert_path);
1861 wifi_ap_set_eap_private_key_info(eap_data->ap,
1862 eap_data->privatekey_path, NULL);
1865 case WIFI_EAP_TYPE_SIM:
1866 case WIFI_EAP_TYPE_AKA:
1870 ERROR_LOG(UG_NAME_NORMAL, "Unknown EAP method %d", eap_type);
1874 if (eap_data->is_hidden) {
1875 wifi_ap_h hidden_ap;
1877 wifi_ap_get_essid(eap_data->ap, &ssid);
1878 wifi_ap_hidden_create(ssid, &hidden_ap);
1882 case WIFI_EAP_TYPE_PEAP:
1883 case WIFI_EAP_TYPE_TTLS:
1884 wifi_ap_set_eap_type(hidden_ap, eap_type);
1885 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1886 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1888 case WIFI_EAP_TYPE_TLS:
1889 wifi_ap_set_eap_type(hidden_ap, eap_type);
1890 wifi_ap_set_eap_auth_type(hidden_ap, eap_auth_type);
1891 wifi_ap_set_eap_passphrase(hidden_ap, str_id, str_pw);
1892 wifi_ap_set_eap_ca_cert_file(hidden_ap, eap_data->ca_cert_path);
1893 wifi_ap_set_eap_client_cert_file(hidden_ap,eap_data->user_cert_path);
1894 wifi_ap_set_eap_private_key_info(hidden_ap, eap_data->privatekey_path, NULL);
1896 case WIFI_EAP_TYPE_SIM:
1897 case WIFI_EAP_TYPE_AKA:
1900 wlan_manager_connect(hidden_ap);
1902 wlan_manager_connect(eap_data->ap);
1904 __common_eap_connect_cleanup(eap_data);
1906 __COMMON_FUNC_EXIT__;
1909 static gboolean delay_create_context_popup(gpointer data)
1911 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1913 if (click.btn_click[EAP_CERT_BTN] == TRUE) {
1914 _create_eap_cert_list(eap_data, click.btn_obj[EAP_CERT_BTN]);
1916 click.btn_click[EAP_CERT_BTN] = FALSE;
1917 click.btn_obj[EAP_CERT_BTN] = NULL;
1918 } else if (click.btn_click[EAP_AUTH_BTN] == TRUE) {
1919 _create_eap_auth_list(eap_data, click.btn_obj[EAP_AUTH_BTN]);
1921 click.btn_click[EAP_AUTH_BTN] = FALSE;
1922 click.btn_obj[EAP_AUTH_BTN] = NULL;
1923 } else if (click.btn_click[EAP_TYPE_BTN] == TRUE) {
1924 _create_eap_type_list(eap_data, click.btn_obj[EAP_TYPE_BTN]);
1926 click.btn_click[EAP_TYPE_BTN] = FALSE;
1927 click.btn_obj[EAP_TYPE_BTN] = NULL;
1932 static void _eap_popup_keypad_off_cb(void *data, Evas_Object *obj,
1939 eap_connect_data_t *eap_data = (eap_connect_data_t *)data;
1941 keypad_state = FALSE;
1943 common_util_managed_idle_add(delay_create_context_popup,
1944 (gpointer)eap_data);
1946 INFO_LOG(UG_NAME_NORMAL,"Keypad is down");
1949 static void _eap_popup_keypad_on_cb(void *data, Evas_Object *obj,
1956 keypad_state = TRUE;
1957 INFO_LOG(UG_NAME_NORMAL,"Keypad is up");
1960 eap_connect_data_t *create_eap_view(Evas_Object *layout_main, Evas_Object *win,
1961 Evas_Object *conf, const char *pkg_name,
1962 wifi_device_info_t *device_info, void (*deref_func)(void))
1964 __COMMON_FUNC_ENTER__;
1966 Evas_Object *popup = NULL;
1967 Evas_Object *list = NULL;
1969 if (layout_main == NULL || device_info == NULL || pkg_name == NULL) {
1973 eap_connect_data_t *eap_data = g_try_new0(eap_connect_data_t, 1);
1974 if (eap_data == NULL) {
1978 eap_data->str_pkg_name = pkg_name;
1979 eap_data->win = win;
1980 eap_data->conf = conf;
1981 eap_data->ssid = g_strdup(device_info->ssid);
1983 if (device_info->is_hidden == true) {
1984 /* Hidden Wi-Fi network */
1987 wifi_ap_get_essid(device_info->ap, &ssid);
1990 g_free(eap_data->ssid);
1994 wifi_ap_hidden_create(ssid, &(eap_data->ap));
1997 eap_data->is_hidden = TRUE;
1999 /* Clone the Wi-Fi AP handle */
2000 wifi_ap_clone(&(eap_data->ap), device_info->ap);
2003 /* Lets disable the scan updates so that the UI is not refreshed unnecessarily */
2004 wlan_manager_disable_scan_result_update();
2006 _eap_view_deref_cb = deref_func;
2007 click.btn_click[EAP_TYPE_BTN] = FALSE;
2008 click.btn_obj[EAP_TYPE_BTN] = NULL;
2009 click.btn_click[EAP_AUTH_BTN] = FALSE;
2010 click.btn_obj[EAP_AUTH_BTN] = NULL;
2011 click.btn_click[EAP_CERT_BTN] = FALSE;
2012 click.btn_obj[EAP_CERT_BTN] = NULL;
2013 keypad_state = FALSE;
2015 popup_btn_info_t popup_btn_data;
2016 memset(&popup_btn_data, 0, sizeof(popup_btn_data));
2018 popup_btn_data.title_txt = device_info->ssid;
2019 popup_btn_data.btn1_cb = __common_eap_connect_destroy_cb;
2020 popup_btn_data.btn1_data = eap_data;
2021 popup_btn_data.btn1_txt = "IDS_WIFI_SK_CANCEL";
2022 popup_btn_data.btn2_cb = __common_eap_connect_done_cb;
2023 popup_btn_data.btn2_data = eap_data;
2024 popup_btn_data.btn2_txt = "IDS_WIFI_BODY_CONNECT";
2026 popup = common_utils_show_info_popup(layout_main,
2028 eap_data->popup = popup;
2029 evas_object_show(popup);
2030 elm_object_focus_set(popup, EINA_TRUE);
2032 /* Create an EAP connect view list */
2033 list = _create_list(popup, eap_data);
2034 elm_object_content_set(popup, list);
2036 evas_object_smart_callback_add(eap_data->conf,
2037 "virtualkeypad,state,on", _eap_popup_keypad_on_cb,
2039 evas_object_smart_callback_add(eap_data->conf,
2040 "virtualkeypad,state,off", _eap_popup_keypad_off_cb,
2043 __COMMON_FUNC_EXIT__;
2047 static wifi_eap_type_e __common_eap_connect_popup_get_wlan_eap_type(eap_type_t eap_type)
2049 wifi_eap_type_e wlan_eap_type = WLAN_SEC_EAP_TYPE_PEAP;
2051 case EAP_SEC_TYPE_PEAP:
2052 wlan_eap_type = WIFI_EAP_TYPE_PEAP;
2054 case EAP_SEC_TYPE_TLS:
2055 wlan_eap_type = WIFI_EAP_TYPE_TLS;
2057 case EAP_SEC_TYPE_TTLS:
2058 wlan_eap_type = WIFI_EAP_TYPE_TTLS;
2060 case EAP_SEC_TYPE_SIM:
2061 wlan_eap_type = WIFI_EAP_TYPE_SIM;
2063 case EAP_SEC_TYPE_AKA:
2064 wlan_eap_type = WIFI_EAP_TYPE_AKA;
2067 ERROR_LOG(UG_NAME_NORMAL, "Err! This case should never occur");
2071 return wlan_eap_type;
2074 static wifi_eap_auth_type_e __common_eap_connect_popup_get_wlan_auth_type(eap_auth_t auth_type)
2076 wifi_eap_auth_type_e wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2077 switch (auth_type) {
2078 case EAP_SEC_AUTH_NONE:
2079 wlan_auth_type = WIFI_EAP_AUTH_TYPE_NONE;
2081 case EAP_SEC_AUTH_PAP:
2082 wlan_auth_type = WIFI_EAP_AUTH_TYPE_PAP;
2084 case EAP_SEC_AUTH_MSCHAP:
2085 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAP;
2087 case EAP_SEC_AUTH_MSCHAPV2:
2088 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
2090 case EAP_SEC_AUTH_GTC:
2091 wlan_auth_type = WIFI_EAP_AUTH_TYPE_GTC;
2093 case EAP_SEC_AUTH_MD5:
2094 wlan_auth_type = WIFI_EAP_AUTH_TYPE_MD5;
2097 /* This case should never occur */
2098 ERROR_LOG(UG_NAME_NORMAL, "Err!");
2101 return wlan_auth_type;
2104 static eap_type_t __common_eap_connect_popup_get_eap_type(wifi_ap_h ap)
2106 wifi_eap_type_e wlan_eap_type = 0;
2107 int ret = wifi_ap_get_eap_type(ap, &wlan_eap_type);
2108 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2109 ret = wifi_ap_set_eap_type(ap, WIFI_EAP_TYPE_PEAP);
2112 if (WIFI_ERROR_NONE != ret) {
2113 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap type. err = %d", ret);
2114 return EAP_SEC_TYPE_UNKNOWN;
2117 switch (wlan_eap_type) {
2118 case WIFI_EAP_TYPE_PEAP: /**< EAP PEAP type */
2119 return EAP_SEC_TYPE_PEAP;
2121 case WIFI_EAP_TYPE_TLS: /**< EAP TLS type */
2122 return EAP_SEC_TYPE_TLS;
2124 case WIFI_EAP_TYPE_TTLS: /**< EAP TTLS type */
2125 return EAP_SEC_TYPE_TTLS;
2127 case WIFI_EAP_TYPE_SIM: /**< EAP SIM type */
2128 return EAP_SEC_TYPE_SIM;
2130 case WIFI_EAP_TYPE_AKA: /**< EAP AKA type */
2131 return EAP_SEC_TYPE_AKA;
2134 return EAP_SEC_TYPE_PEAP;
2136 return EAP_SEC_TYPE_PEAP;
2139 static eap_auth_t __common_eap_connect_popup_get_auth_type(wifi_ap_h ap)
2141 wifi_eap_auth_type_e wlan_auth_type = 0;
2142 int ret = wifi_ap_get_eap_auth_type(ap, &wlan_auth_type);
2143 if (WIFI_ERROR_OPERATION_FAILED == ret) {
2144 ret = wifi_ap_set_eap_auth_type(ap, EAP_SEC_AUTH_NONE);
2147 if (WIFI_ERROR_NONE != ret) {
2148 ERROR_LOG(UG_NAME_ERR, "Unable to get the eap auth type. err = %d", ret);
2149 return EAP_SEC_AUTH_NONE;
2152 switch (wlan_auth_type) {
2153 case WIFI_EAP_AUTH_TYPE_NONE: /**< EAP phase2 authentication none */
2154 return EAP_SEC_AUTH_NONE;
2156 case WIFI_EAP_AUTH_TYPE_PAP: /**< EAP phase2 authentication PAP */
2157 return EAP_SEC_AUTH_PAP;
2159 case WIFI_EAP_AUTH_TYPE_MSCHAP: /**< EAP phase2 authentication MSCHAP */
2160 return EAP_SEC_AUTH_MSCHAP;
2162 case WIFI_EAP_AUTH_TYPE_MSCHAPV2: /**< EAP phase2 authentication MSCHAPv2 */
2163 return EAP_SEC_AUTH_MSCHAPV2;
2165 case WIFI_EAP_AUTH_TYPE_GTC: /**< EAP phase2 authentication GTC */
2166 return EAP_SEC_AUTH_GTC;
2168 case WIFI_EAP_AUTH_TYPE_MD5: /**< EAP phase2 authentication MD5 */
2169 return EAP_SEC_AUTH_MD5;
2172 return EAP_SEC_AUTH_NONE;
2174 return EAP_SEC_AUTH_NONE;
2177 static char *_eap_info_get_user_cert_alias(wifi_ap_h ap)
2181 char *filename = NULL;
2182 char *cert_name = NULL;
2184 int filename_len = 0;
2186 wifi_ap_get_eap_client_cert_file(ap, &path);
2190 filename = strrchr(path, '/');
2191 if (filename == NULL) {
2192 ERROR_LOG(UG_NAME_ERR, "Invalid file name");
2197 cert_name = strstr(filename, EAP_TLS_USER_CERT_PATH);
2198 if (cert_name == NULL) {
2199 /* For truncated path, available filename will be followed
2200 * with ellipsis(...) & excluding any remaining part of
2201 * "_user_cert.pem" - 14 chars (-14+3+1=10)*/
2202 filename_len = strlen(filename);
2203 alias = g_try_malloc0(filename_len - 10);
2204 if (alias == NULL) {
2205 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2208 g_strlcpy(alias, filename, filename_len - 13);
2209 g_strlcat(alias, "...", filename_len - 10);
2210 INFO_LOG(UG_NAME_NORMAL, "Truncated alias [%s]", alias);
2215 alias_len = cert_name - filename;
2217 alias = g_try_malloc0(alias_len + 1);
2218 if (alias == NULL) {
2219 ERROR_LOG(UG_NAME_ERR, "malloc fail");
2223 g_strlcpy(alias, filename, alias_len + 1);
2224 INFO_LOG(UG_NAME_NORMAL, "Alias [%s] length [%d]", alias, alias_len);
2232 /* This creates Auth type, ID, Anonymous Id and Password items
2233 * This function should be called after creating the EAP type item
2235 eap_info_list_t *eap_info_append_items(wifi_ap_h ap, Evas_Object* view_list,
2236 const char *str_pkg_name, imf_ctxt_panel_cb_t input_panel_cb,
2237 void *input_panel_cb_data)
2239 __COMMON_FUNC_ENTER__;
2241 eap_type_t eap_type;
2242 eap_auth_t auth_type;
2243 char *temp_str = NULL;
2244 Eina_Bool append_continue = TRUE;
2245 eap_info_list_t *eap_info_list_data = NULL;
2246 Elm_Object_Item* item = NULL;
2247 if (!view_list || !str_pkg_name || !ap) {
2248 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2252 eap_info_list_data = g_try_new0(eap_info_list_t, 1);
2253 if (eap_info_list_data == NULL) {
2257 eap_info_list_data->ap = ap;
2258 eap_type = __common_eap_connect_popup_get_eap_type(ap);
2259 auth_type = __common_eap_connect_popup_get_auth_type(ap);
2261 item = common_utils_add_2_line_txt_disabled_item(view_list,
2262 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2263 sc(str_pkg_name, I18N_TYPE_EAP_method),
2264 list_eap_type[eap_type].name);
2265 eap_info_list_data->eap_method_item = item;
2267 eap_info_list_data->eap_type = eap_type;
2270 case EAP_SEC_TYPE_UNKNOWN:
2271 case EAP_SEC_TYPE_PEAP:
2272 case EAP_SEC_TYPE_TLS:
2273 case EAP_SEC_TYPE_TTLS:
2275 case EAP_SEC_TYPE_SIM:
2276 case EAP_SEC_TYPE_AKA:
2278 append_continue = FALSE;
2282 if (append_continue) {
2283 if (eap_type == EAP_SEC_TYPE_PEAP ||
2284 eap_type == EAP_SEC_TYPE_TTLS) {
2285 /* Add EAP phase2 authentication */
2286 item = common_utils_add_2_line_txt_disabled_item(view_list,
2287 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2288 sc(str_pkg_name, I18N_TYPE_Phase_2_authentication),
2289 list_eap_auth[auth_type].name);
2290 eap_info_list_data->eap_auth_item = item;
2293 if (eap_type == EAP_SEC_TYPE_TLS) {
2294 /* Add User certificate */
2295 temp_str = _eap_info_get_user_cert_alias(ap);
2297 if (temp_str == NULL || strlen(temp_str) == 0) {
2298 if (temp_str != NULL) {
2301 temp_str = g_strdup(sc(str_pkg_name,
2302 I18N_TYPE_Unspecified));
2305 item = common_utils_add_2_line_txt_disabled_item(view_list,
2306 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2307 sc(str_pkg_name, I18N_TYPE_User_Certificate),
2309 eap_info_list_data->user_cert_item = item;
2316 wifi_ap_get_eap_passphrase(ap, &temp_str, &is_paswd_set);
2317 item = common_utils_add_2_line_txt_disabled_item(view_list,
2318 WIFI_GENLIST_2LINE_TOP_TEXT_STYLE,
2319 sc(str_pkg_name, I18N_TYPE_Identity),
2321 eap_info_list_data->id_item = item;
2325 common_utils_entry_info_t *edit_box_details;
2327 /* Add EAP Password */
2328 g_eap_entry_itc.item_style = "entry.main";
2329 g_eap_entry_itc.func.text_get = _gl_eap_entry_item_text_get;
2330 g_eap_entry_itc.func.content_get = _gl_eap_entry_item_content_get;
2331 g_eap_entry_itc.func.state_get = NULL;
2332 g_eap_entry_itc.func.del = _gl_eap_entry_item_del;
2334 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
2335 if (edit_box_details == NULL) {
2336 g_free(eap_info_list_data);
2340 edit_box_details->entry_id = ENTRY_TYPE_PASSWORD;
2341 edit_box_details->title_txt = sc(str_pkg_name, I18N_TYPE_Password);
2342 edit_box_details->entry_txt = NULL;
2343 edit_box_details->guide_txt = sc(str_pkg_name, I18N_TYPE_Enter_password);
2344 edit_box_details->input_panel_cb = input_panel_cb;
2345 edit_box_details->input_panel_cb_data = input_panel_cb_data;
2346 edit_box_details->item = elm_genlist_item_append(view_list,
2347 &g_eap_entry_itc, edit_box_details, NULL,
2348 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
2349 elm_genlist_item_select_mode_set(edit_box_details->item,
2350 ELM_OBJECT_SELECT_MODE_NONE);
2351 eap_info_list_data->pswd_item = edit_box_details->item;
2355 __COMMON_FUNC_EXIT__;
2356 return eap_info_list_data;
2360 void eap_info_save_data(eap_info_list_t *eap_info_list_data)
2362 if (!eap_info_list_data) {
2363 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2366 char *txt = common_utils_get_list_item_entry_txt(eap_info_list_data->pswd_item);
2368 wifi_ap_set_eap_passphrase(eap_info_list_data->ap, NULL, txt);
2374 void eap_info_remove(eap_info_list_t *eap_info_list_data)
2376 if (!eap_info_list_data) {
2377 ERROR_LOG(UG_NAME_ERR, "Invalid params passed!");
2381 g_free(eap_info_list_data);
2384 void eap_connect_data_free(eap_connect_data_t *eap_data)
2386 __common_eap_connect_cleanup(eap_data);