Initial code
[apps/native/ug-mobile-ap.git] / src / mh_view_wifi_setup.c
1 /*
2 * ug-mobile-ap
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
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
9
10 * http://www.tizenopensource.org/license
11
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.
17 *
18 */
19
20 #include "mh_view_wifi_setup.h"
21
22 static void __back_btn_cb(void *data, Evas_Object *obj, void *event_info);
23
24 static void __hide_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
25 {
26         __MOBILE_AP_FUNC_ENTER__;
27
28         if (data == NULL || obj == NULL) {
29                 ERR("Invalid param\n");
30                 return;
31         }
32
33         mh_appdata_t *ad = (mh_appdata_t *)data;
34         int ret = 0;
35
36         ret = tethering_wifi_set_ssid_visibility(ad->handle,
37                         !ad->setup.visibility);
38         if (ret != TETHERING_ERROR_NONE) {
39                 ERR("tethering_wifi_set_ssid_visibility is failed : %d\n", ret);
40                 return;
41         }
42
43         ad->setup.visibility = !ad->setup.visibility;
44
45         __MOBILE_AP_FUNC_EXIT__;
46 }
47
48 static void __security_btn_changed_cb(void *data, Evas_Object *obj, void *event_info)
49 {
50         __MOBILE_AP_FUNC_ENTER__;
51
52         if (data == NULL || obj == NULL) {
53                 ERR("Invalid param\n");
54                 return;
55         }
56
57         mh_appdata_t *ad = (mh_appdata_t *)data;
58         Eina_Bool pw_disabled = EINA_FALSE;
59         tethering_wifi_security_type_e temp_security_type;
60         int ret = 0;
61
62         if (ad->setup.security_type == TETHERING_WIFI_SECURITY_TYPE_NONE)
63                 temp_security_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
64         else
65                 temp_security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
66
67         ret = tethering_wifi_set_security_type(ad->handle, temp_security_type);
68         if (ret != TETHERING_ERROR_NONE) {
69                 ERR("tethering_wifi_set_security_type is failed : %d\n", ret);
70                 return;
71         }
72         ad->setup.security_type = temp_security_type;
73
74         pw_disabled = ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE ?
75                 EINA_FALSE : EINA_TRUE;
76         DBG("security_type : %d, pw_disabled : %d\n", ad->setup.security_type, pw_disabled);
77
78         elm_object_item_disabled_set(ad->setup.pw_item, pw_disabled);
79         elm_genlist_item_update(ad->setup.pw_item);
80
81         __MOBILE_AP_FUNC_EXIT__;
82 }
83
84 static char *__gl_hide_label_get(void *data, Evas_Object *obj, const char *part)
85 {
86         __MOBILE_AP_FUNC_ENTER__;
87
88         if (data == NULL || obj == NULL || part == NULL) {
89                 ERR("Invalid param\n");
90                 return NULL;
91         }
92
93         if (strcmp(part, "elm.text") != 0) {
94                 ERR("Invalid param\n");
95                 return NULL;
96         }
97
98         __MOBILE_AP_FUNC_EXIT__;
99         return strdup(_("IDS_MOBILEAP_BODY_HIDE_MY_DEVICE"));
100 }
101
102 static char *__gl_security_label_get(void *data, Evas_Object *obj, const char *part)
103 {
104         __MOBILE_AP_FUNC_ENTER__;
105
106         if (data == NULL || obj == NULL || part == NULL) {
107                 ERR("Invalid param\n");
108                 return NULL;
109         }
110
111         if (strcmp(part, "elm.text") != 0) {
112                 ERR("Invalid param\n");
113                 return NULL;
114         }
115
116         __MOBILE_AP_FUNC_EXIT__;
117         return strdup(_("IDS_MOBILEAP_BODY_SECURITY"));
118 }
119
120 static char *__gl_name_label_get(void *data, Evas_Object *obj, const char *part)
121 {
122         __MOBILE_AP_FUNC_ENTER__;
123
124         if (data == NULL || obj == NULL || part == NULL) {
125                 ERR("Invalid param\n");
126                 return NULL;
127         }
128
129         if (strcmp(part, "elm.text.1") != 0) {
130                 ERR("Invalid param\n");
131                 return NULL;
132         }
133
134         mh_appdata_t *ad = (mh_appdata_t *)data;
135         char label[MH_LABEL_LENGTH_MAX] = {0, };
136         char name_change_label[MH_LABEL_LENGTH_MAX] = {0, };
137         char path[MH_LABEL_LENGTH_MAX] = {0, };
138         char *device_name = NULL;
139
140         DBG("Device name : %s\n", ad->setup.device_name);
141
142         device_name = elm_entry_utf8_to_markup(ad->setup.device_name);
143         if (device_name == NULL) {
144                 ERR("elm_entry_utf8_to_markup is failed\n");
145                 return NULL;
146         }
147
148         snprintf(path, sizeof(path), "%s > %s",
149                         S_("IDS_COM_BODY_SETTINGS"),
150                         _("IDS_ST_BODY_ABOUT_PHONE"));
151         snprintf(name_change_label, sizeof(name_change_label),
152                         _("IDS_MOBILEAP_BODY_DEVICE_NAME_CAN_BE_CHANGED_IN_PS"),
153                         path);
154         snprintf(label, sizeof(label), "%s: %s<br>%s",
155                         _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
156                         device_name,
157                         name_change_label);
158         free(device_name);
159
160         __MOBILE_AP_FUNC_EXIT__;
161
162         return strdup(label);
163 }
164
165 static Evas_Object *__gl_hide_icon_get(void *data, Evas_Object *obj,
166                 const char *part)
167 {
168         __MOBILE_AP_FUNC_ENTER__;
169
170         if (data == NULL || obj == NULL || part == NULL) {
171                 ERR("Invalid param\n");
172                 return NULL;
173         }
174
175         if (strcmp(part, "elm.icon") != 0) {
176                 ERR("Invalid param\n");
177                 return NULL;
178         }
179
180         mh_appdata_t *ad = (mh_appdata_t *)data;
181         Evas_Object *btn = NULL;
182
183         btn = elm_check_add(obj);
184         if (btn == NULL) {
185                 ERR("btn is NULL\n");
186                 return NULL;
187         }
188         elm_object_style_set(btn, "on&off");
189         evas_object_show(btn);
190         evas_object_pass_events_set(btn, EINA_TRUE);
191         evas_object_propagate_events_set(btn, EINA_FALSE);
192         elm_check_state_set(btn, ad->setup.visibility ? EINA_FALSE : EINA_TRUE);
193         evas_object_smart_callback_add(btn, "changed",
194                         __hide_btn_changed_cb, (void *)ad);
195
196         ad->setup.hide_btn = btn;
197
198         __MOBILE_AP_FUNC_EXIT__;
199         return btn;
200 }
201
202 static Evas_Object *__gl_security_icon_get(void *data, Evas_Object *obj,
203                 const char *part)
204 {
205         __MOBILE_AP_FUNC_ENTER__;
206
207         if (data == NULL || obj == NULL || part == NULL) {
208                 ERR("Invalid param\n");
209                 return NULL;
210         }
211
212         if (strcmp(part, "elm.icon") != 0) {
213                 ERR("Invalid param\n");
214                 return NULL;
215         }
216
217         mh_appdata_t *ad = (mh_appdata_t *)data;
218         Evas_Object *btn = NULL;
219
220         btn = elm_check_add(obj);
221
222         elm_object_style_set(btn, "on&off");
223         evas_object_show(btn);
224         evas_object_pass_events_set(btn, EINA_TRUE);
225         evas_object_propagate_events_set(btn, EINA_FALSE);
226         elm_check_state_set(btn, ad->setup.security_type ==
227                         TETHERING_WIFI_SECURITY_TYPE_NONE ?
228                         EINA_FALSE : EINA_TRUE);
229         evas_object_smart_callback_add(btn, "changed",
230                         __security_btn_changed_cb, (void *)ad);
231
232         ad->setup.security_btn = btn;
233
234         __MOBILE_AP_FUNC_EXIT__;
235         return btn;
236 }
237
238 static Eina_Bool __save_wifi_passphrase(mh_appdata_t *ad)
239 {
240         __MOBILE_AP_FUNC_ENTER__;
241
242         if (ad == NULL) {
243                 ERR("Invalid param\n");
244                 return EINA_FALSE;
245         }
246
247         mh_wifi_setting_view_t *st = &ad->setup;
248         int ret = 0;
249         const char *entry_string = NULL;
250         char *utf8_string = NULL;
251         char wifi_passphrase[WIFI_PASSPHRASE_LENGTH_MAX + 1] = {0, };
252
253         entry_string = elm_entry_entry_get(st->pw_entry);
254         if (entry_string == NULL) {
255                 ERR("elm_entry_entry_get() Failed!!!\n");
256                 return EINA_FALSE;
257         }
258
259         utf8_string = elm_entry_markup_to_utf8(entry_string);
260         if (utf8_string == NULL) {
261                 ERR("elm_entry_markup_to_utf8() Failed!!!\n");
262                 return EINA_FALSE;
263         }
264         g_strlcpy(wifi_passphrase, utf8_string, sizeof(wifi_passphrase));
265         free(utf8_string);
266
267         if (g_strcmp0(st->wifi_passphrase, wifi_passphrase) == 0) {
268                 DBG("Password is not changed\n");
269                 return EINA_TRUE;
270         }
271
272         if (strlen(wifi_passphrase) < WIFI_PASSPHRASE_LENGTH_MIN) {
273                 DBG("Password is shorter than %d\n", WIFI_PASSPHRASE_LENGTH_MIN);
274                 _prepare_popup(ad, MH_POP_WIFI_PASSWORD_SHORT,
275                                 _("IDS_ST_BODY_ENTER_PASSWORD_OF_AT_LEAST_8_CHARACTERS"));
276                 _create_popup(ad);
277                 return EINA_FALSE;
278         }
279
280         ret = tethering_wifi_set_passphrase(ad->handle, wifi_passphrase);
281         if (ret != TETHERING_ERROR_NONE) {
282                 ERR("tethering_wifi_set_passphrase is failed : %d\n", ret);
283                 return EINA_FALSE;
284         }
285
286         DBG("SUCCESS : setting up VCONFKEY_MOBILE_HOTSPOT_WIFI_KEY\n");
287         g_strlcpy(st->wifi_passphrase, wifi_passphrase, sizeof(st->wifi_passphrase));
288
289         __MOBILE_AP_FUNC_EXIT__;
290
291         return EINA_TRUE;
292 }
293
294 static void __passphrase_maxlength_reached_cb(void *data, Evas_Object *obj,
295                 void *event_info)
296 {
297         __MOBILE_AP_FUNC_ENTER__;
298
299         if (data == NULL || obj == NULL) {
300                 ERR("The param is NULL\n");
301                 return;
302         }
303
304         mh_appdata_t *ad = (mh_appdata_t *)data;
305         char buf[MH_LABEL_LENGTH_MAX] = {0, };
306
307         if (ad->popup != NULL) {
308                 ERR("Popup already exists\n");
309                 return;
310         }
311
312         if (_hide_imf(ad->setup.pw_entry) == EINA_FALSE) {
313                 ERR("_hide_imf is failed\n");
314         }
315
316         if (__save_wifi_passphrase(ad) == EINA_FALSE) {
317                 ERR("__save_wifi_passphrase is failed\n");
318                 return;
319         }
320
321         snprintf(buf, sizeof(buf),
322                         _("IDS_MOBILEAP_POP_PASSWORD_MUST_CONTAIN_AT_LEAST_PD_CHARACTERS_AND_NOT_EXCEED_PD_CHARACTERS"),
323                         WIFI_PASSPHRASE_LENGTH_MIN, WIFI_PASSPHRASE_LENGTH_MAX);
324
325         _prepare_popup(ad, MH_POP_INFORMATION_WO_BUTTON, buf);
326         _create_popup(ad);
327
328         __MOBILE_AP_FUNC_EXIT__;
329 }
330
331 static void __passphrase_activated_cb(void *data, Evas_Object *obj,
332                 void *event_info)
333 {
334         __MOBILE_AP_FUNC_ENTER__;
335
336         if (data == NULL || obj == NULL) {
337                 ERR("Invalid param\n");
338                 return;
339         }
340
341         mh_appdata_t *ad = (mh_appdata_t *)data;
342
343         if (_hide_imf(ad->setup.pw_entry) == EINA_FALSE) {
344                 ERR("_hide_imf is failed\n");
345         }
346
347         if (__save_wifi_passphrase(ad) == EINA_FALSE) {
348                 ERR("__save_wifi_passphrase is failed\n");
349                 return;
350         }
351
352         __MOBILE_AP_FUNC_EXIT__;
353
354         return;
355 }
356
357 static void __pw_entry_changed_cb(void *data, Evas_Object *obj,
358                 void *event_info)
359 {
360         __MOBILE_AP_FUNC_ENTER__;
361
362         if (data == NULL || obj == NULL) {
363                 ERR("Invalid param\n");
364                 return;
365         }
366
367         mh_appdata_t *ad = (mh_appdata_t *)data;
368         mh_wifi_setting_view_t *st = &ad->setup;
369
370         if (!elm_object_focus_get(st->pw_layout))
371                 return;
372
373         if (elm_entry_is_empty(st->pw_entry)) {
374                 elm_object_signal_emit(st->pw_layout,
375                                 "elm,state,eraser,hide", "elm");
376         } else {
377                 elm_object_signal_emit(st->pw_layout,
378                                 "elm,state,eraser,show", "elm");
379         }
380
381         __MOBILE_AP_FUNC_EXIT__;
382
383         return;
384
385 }
386
387 static void __pw_entry_focused_cb(void *data, Evas_Object *obj,
388                 void *event_info)
389 {
390         __MOBILE_AP_FUNC_ENTER__;
391
392         if (data == NULL || obj == NULL) {
393                 ERR("Invalid param\n");
394                 return;
395         }
396
397         mh_appdata_t *ad = (mh_appdata_t *)data;
398         mh_wifi_setting_view_t *st = &ad->setup;
399
400         if (!elm_entry_is_empty(st->pw_entry))
401                 elm_object_signal_emit(st->pw_layout,
402                                 "elm,state,eraser,show", "elm");
403
404         elm_object_signal_emit(st->pw_layout,
405                         "elm,state,guidetext,hide", "elm");
406
407         __MOBILE_AP_FUNC_EXIT__;
408
409         return;
410
411 }
412
413 static void __pw_entry_unfocused_cb(void *data, Evas_Object *obj,
414                 void *event_info)
415 {
416         __MOBILE_AP_FUNC_ENTER__;
417
418         if (data == NULL || obj == NULL) {
419                 ERR("Invalid param\n");
420                 return;
421         }
422
423         mh_appdata_t *ad = (mh_appdata_t *)data;
424         mh_wifi_setting_view_t *st = &ad->setup;
425
426         if (elm_entry_is_empty(st->pw_entry))
427                 elm_object_signal_emit(st->pw_layout,
428                                 "elm,state,guidetext,show", "elm");
429
430         elm_object_signal_emit(st->pw_layout,
431                         "elm,state,eraser,hide", "elm");
432
433         __MOBILE_AP_FUNC_EXIT__;
434
435         return;
436
437 }
438
439 static void __pw_layout_eraser_clicked_cb(void *data, Evas_Object *obj,
440                 const char *emission, const char *source)
441 {
442         __MOBILE_AP_FUNC_ENTER__;
443
444         if (data == NULL || obj == NULL) {
445                 ERR("Invalid param\n");
446                 return;
447         }
448
449         mh_appdata_t *ad = (mh_appdata_t *)data;
450         mh_wifi_setting_view_t *st = &ad->setup;
451
452         elm_entry_entry_set(st->pw_entry, "");
453
454         __MOBILE_AP_FUNC_EXIT__;
455
456         return;
457
458 }
459
460 static Evas_Object *__gl_pw_icon_get(void *data, Evas_Object *obj,
461                 const char *part)
462 {
463         __MOBILE_AP_FUNC_ENTER__;
464
465         if (data == NULL || obj == NULL || part == NULL) {
466                 ERR("Invalid param\n");
467                 return NULL;
468         }
469
470         if (strcmp(part, "elm.icon") != 0) {
471                 ERR("Invalid part\n");
472                 return NULL;
473         }
474
475         static Elm_Entry_Filter_Limit_Size limit_filter_data;
476
477         mh_appdata_t *ad = (mh_appdata_t *)data;
478         mh_wifi_setting_view_t *st = &ad->setup;
479         Evas_Object *entry = NULL;
480         char *ptr = NULL;
481
482         st->pw_layout = elm_layout_add(obj);
483         if (st->pw_layout == NULL) {
484                 ERR("elm_layout_add returns NULL\n");
485                 return NULL;
486         }
487         elm_layout_theme_set(st->pw_layout, "layout", "editfield", "title");
488
489         entry = elm_entry_add(st->pw_layout);
490         if (entry == NULL) {
491                 ERR("elm_entry_add returns NULL\n");
492                 evas_object_del(st->pw_layout);
493                 st->pw_layout = NULL;
494                 return NULL;
495         }
496         st->pw_entry = entry;
497
498         elm_object_part_content_set(st->pw_layout, "elm.swallow.content", entry);
499         elm_object_part_text_set(st->pw_layout, "elm.text",
500                         _("IDS_MOBILEAP_BODY_PASSWORD"));
501         elm_object_part_text_set(st->pw_layout, "elm.guidetext",
502                         _("IDS_ST_BODY_ENTER_PASSWORD_OF_AT_LEAST_8_CHARACTERS"));
503
504         /* Set editable mode */
505         DBG("security_type : %d\n", st->security_type);
506         elm_entry_input_panel_enabled_set(entry, st->security_type ==
507                         TETHERING_WIFI_SECURITY_TYPE_NONE ?
508                         EINA_FALSE : EINA_TRUE);
509
510         /* Set single line of entry */
511         elm_entry_scrollable_set(entry, EINA_TRUE);
512         elm_entry_single_line_set(entry, EINA_TRUE);
513         elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PASSWORD);
514
515         /* Set the maximum length filter for passphrase entry */
516         limit_filter_data.max_char_count = 0;
517         limit_filter_data.max_byte_count = WIFI_PASSPHRASE_LENGTH_MAX;
518         elm_entry_markup_filter_append(entry,
519                         elm_entry_filter_limit_size, &limit_filter_data);
520
521         ptr = elm_entry_utf8_to_markup(st->wifi_passphrase);
522         if (ptr != NULL) {
523                 elm_entry_entry_set(entry, ptr);
524                 free(ptr);
525         } else {
526                 ERR("elm_entry_utf8_to_markup is failed\n");
527         }
528
529         if (!elm_entry_is_empty(entry))
530                 elm_object_signal_emit(st->pw_layout,
531                                 "elm,state,guidetext,hide", "elm");
532
533         evas_object_smart_callback_add(entry, "maxlength,reached",
534                         __passphrase_maxlength_reached_cb, data);
535         evas_object_smart_callback_add(entry, "activated",
536                         __passphrase_activated_cb, data);
537         evas_object_smart_callback_add(entry, "changed",
538                         __pw_entry_changed_cb, data);
539         evas_object_smart_callback_add(entry, "focused",
540                         __pw_entry_focused_cb, data);
541         evas_object_smart_callback_add(entry, "unfocused",
542                         __pw_entry_unfocused_cb, data);
543         elm_object_signal_callback_add(st->pw_layout, "elm,eraser,clicked", "elm",
544                         __pw_layout_eraser_clicked_cb, data);
545
546         __MOBILE_AP_FUNC_EXIT__;
547
548         return st->pw_layout;
549 }
550
551 static void __gl_hide_item_sel(void *data, Evas_Object *obj, void *event_info)
552 {
553         __MOBILE_AP_FUNC_ENTER__;
554
555         if (data == NULL || obj == NULL || event_info == NULL) {
556                 ERR("param is NULL\n");
557                 return;
558         }
559
560         mh_appdata_t *ad = (mh_appdata_t *)data;
561
562         elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
563
564         __hide_btn_changed_cb(data, obj, NULL);
565         elm_check_state_set(ad->setup.hide_btn, ad->setup.visibility ?
566                         EINA_FALSE : EINA_TRUE);
567
568         __MOBILE_AP_FUNC_EXIT__;
569 }
570
571 static void __gl_security_item_sel(void *data, Evas_Object *obj, void *event_info)
572 {
573         __MOBILE_AP_FUNC_ENTER__;
574
575         if (data == NULL || obj == NULL || event_info == NULL) {
576                 ERR("param is NULL\n");
577                 return;
578         }
579
580         mh_appdata_t *ad = (mh_appdata_t *)data;
581
582         elm_genlist_item_selected_set((Elm_Object_Item*)event_info, EINA_FALSE);
583
584         __security_btn_changed_cb(data, obj, NULL);
585         elm_check_state_set(ad->setup.security_btn, ad->setup.security_type ==
586                         TETHERING_WIFI_SECURITY_TYPE_NONE ? EINA_FALSE : EINA_TRUE);
587
588         __MOBILE_AP_FUNC_EXIT__;
589 }
590
591 static void __free_genlist_itc(mh_appdata_t *ad)
592 {
593         __MOBILE_AP_FUNC_ENTER__;
594
595         elm_genlist_item_class_free(ad->setup.sp_itc);
596         elm_genlist_item_class_free(ad->setup.hide_itc);
597         elm_genlist_item_class_free(ad->setup.security_itc);
598         elm_genlist_item_class_free(ad->setup.pw_itc);
599         elm_genlist_item_class_free(ad->setup.name_itc);
600
601         __MOBILE_AP_FUNC_EXIT__;
602         return;
603 }
604
605 static void __set_genlist_itc(mh_appdata_t *ad)
606 {
607         __MOBILE_AP_FUNC_ENTER__;
608
609         ad->setup.sp_itc = elm_genlist_item_class_new();
610         ad->setup.sp_itc->item_style = "dialogue/separator/21/with_line";
611         ad->setup.sp_itc->func.text_get = NULL;
612         ad->setup.sp_itc->func.content_get = NULL;
613         ad->setup.sp_itc->func.state_get = NULL;
614         ad->setup.sp_itc->func.del = NULL;
615
616         ad->setup.hide_itc = elm_genlist_item_class_new();
617         ad->setup.hide_itc->item_style = "dialogue/1text.1icon";
618         ad->setup.hide_itc->func.text_get = __gl_hide_label_get;
619         ad->setup.hide_itc->func.content_get = __gl_hide_icon_get;
620         ad->setup.hide_itc->func.state_get = NULL;
621         ad->setup.hide_itc->func.del = NULL;
622
623         ad->setup.security_itc = elm_genlist_item_class_new();
624         ad->setup.security_itc->item_style = "dialogue/1text.1icon";
625         ad->setup.security_itc->func.text_get = __gl_security_label_get;
626         ad->setup.security_itc->func.content_get = __gl_security_icon_get;
627         ad->setup.security_itc->func.state_get = NULL;
628         ad->setup.security_itc->func.del = NULL;
629
630         ad->setup.pw_itc = elm_genlist_item_class_new();
631         ad->setup.pw_itc->item_style = "dialogue/1icon";
632         ad->setup.pw_itc->func.text_get = NULL;
633         ad->setup.pw_itc->func.content_get = __gl_pw_icon_get;
634         ad->setup.pw_itc->func.state_get = NULL;
635         ad->setup.pw_itc->func.del = NULL;
636
637         ad->setup.name_itc = elm_genlist_item_class_new();
638         ad->setup.name_itc->item_style = "multiline/1text";
639         ad->setup.name_itc->func.text_get = __gl_name_label_get;
640         ad->setup.name_itc->func.content_get = NULL;
641         ad->setup.name_itc->func.state_get = NULL;
642         ad->setup.name_itc->func.del = NULL;
643
644         ad->setup.end_sp_itc = elm_genlist_item_class_new();
645         ad->setup.end_sp_itc->item_style = "dialogue/separator/end";
646         ad->setup.end_sp_itc->func.text_get = NULL;
647         ad->setup.end_sp_itc->func.content_get = NULL;
648         ad->setup.end_sp_itc->func.state_get = NULL;
649         ad->setup.end_sp_itc->func.del = NULL;
650
651         __MOBILE_AP_FUNC_EXIT__;
652         return;
653 }
654
655 static void __deconstruct_wifi_setup_view(mh_wifi_setting_view_t *st)
656 {
657         __MOBILE_AP_FUNC_ENTER__;
658
659         if (st == NULL) {
660                 ERR("st is NULL\n");
661                 return;
662         }
663
664         if (st->pw_entry == NULL) {
665                 ERR("pw_entry is NULL");
666                 return;
667         }
668
669         evas_object_smart_callback_del(st->hide_btn, "changed",
670                         __hide_btn_changed_cb);
671         evas_object_smart_callback_del(st->security_btn, "changed",
672                         __security_btn_changed_cb);
673         if (st->pw_entry) {
674                 evas_object_smart_callback_del(st->pw_entry,
675                                 "maxlength,reached",
676                                 __passphrase_maxlength_reached_cb);
677                 evas_object_smart_callback_del(st->pw_entry,
678                                 "activated",
679                                 __passphrase_activated_cb);
680         }
681         evas_object_smart_callback_del(st->back_btn, "clicked",
682                         __back_btn_cb);
683
684         st->hide_btn = NULL;
685         st->security_btn = NULL;
686         st->pw_layout = NULL;
687         st->pw_entry = NULL;
688         st->back_btn = NULL;
689         st->genlist = NULL;
690         st->conform = NULL;
691
692         __MOBILE_AP_FUNC_EXIT__;
693 }
694
695 static void __back_btn_cb(void *data, Evas_Object *obj, void *event_info)
696 {
697         __MOBILE_AP_FUNC_ENTER__;
698
699         if (data == NULL) {
700                 ERR("The param is NULL\n");
701                 return;
702         }
703
704         mh_appdata_t *ad = (mh_appdata_t *)data;
705         mh_wifi_setting_view_t *st = &ad->setup;
706
707         if (_hide_imf(st->pw_entry) == EINA_FALSE) {
708                 ERR("_hide_imf is failed\n");
709         }
710
711         if (__save_wifi_passphrase(ad) == EINA_FALSE) {
712                 ERR("__save_wifi_passphrase is failed\n");
713                 return;
714         }
715
716         __deconstruct_wifi_setup_view(st);
717
718         evas_object_del(ad->setup.genlist);
719         __free_genlist_itc(ad);
720
721         elm_naviframe_item_pop(ad->naviframe);
722
723         __MOBILE_AP_FUNC_EXIT__;
724 }
725
726 Evas_Object *__create_genlist(mh_appdata_t *ad)
727 {
728         __MOBILE_AP_FUNC_ENTER__;
729
730         if (ad == NULL) {
731                 ERR("ad is NULL\n");
732                 return NULL;
733         }
734
735         void *data = (void *)ad;
736         mh_wifi_setting_view_t *st = &ad->setup;
737         Evas_Object *genlist = NULL;
738         Elm_Object_Item *item = NULL;
739
740         genlist = elm_genlist_add(ad->naviframe);
741         if (genlist == NULL) {
742                 ERR("genlist is NULL\n");
743                 return NULL;
744         }
745         elm_object_style_set(genlist, "dialogue");
746         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
747
748         __set_genlist_itc(ad);
749         item = elm_genlist_item_append(genlist, st->sp_itc, NULL, NULL,
750                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
751         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
752
753         st->hide_item = elm_genlist_item_append(genlist, st->hide_itc, data, NULL,
754                         ELM_GENLIST_ITEM_NONE, __gl_hide_item_sel, data);
755
756         st->security_item = elm_genlist_item_append(genlist, st->security_itc, data, NULL,
757                         ELM_GENLIST_ITEM_NONE, __gl_security_item_sel, data);
758
759         DBG("security_type : %d\n", st->security_type);
760         st->pw_item = elm_genlist_item_append(genlist, st->pw_itc, data, NULL,
761                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
762         elm_object_item_disabled_set(st->pw_item, st->security_type ==
763                         TETHERING_WIFI_SECURITY_TYPE_NONE ?
764                         EINA_TRUE : EINA_FALSE);
765         elm_genlist_item_update(st->pw_item);
766
767         st->name_item = elm_genlist_item_append(genlist, st->name_itc, data, NULL,
768                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
769         elm_genlist_item_select_mode_set(st->name_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
770
771         item = elm_genlist_item_append(genlist, st->end_sp_itc, NULL, NULL,
772                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
773         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
774
775
776         __MOBILE_AP_FUNC_EXIT__;
777
778         return genlist;
779 }
780
781 void mh_draw_wifi_setup_view(mh_appdata_t *ad)
782 {
783         __MOBILE_AP_FUNC_ENTER__;
784
785         if (ad == NULL) {
786                 ERR("ad is NULL\n");
787                 return;
788         }
789
790         mh_wifi_setting_view_t *st = &ad->setup;
791
792         if (st->conform != NULL) {
793                 ERR("Wi-Fi setup view already exists\n");
794                 return;
795         }
796
797         st->conform = elm_conformant_add(ad->naviframe);
798         if (st->conform == NULL) {
799                 ERR("elm_conformant_add returns NULL\n");
800                 goto FAIL;
801         }
802         elm_object_style_set(st->conform, "internal_layout");
803         evas_object_show(st->conform);
804
805         st->genlist = __create_genlist(ad);
806         if (st->genlist == NULL) {
807                 ERR("__create_genlist returns NULL\n");
808                 goto FAIL;
809         }
810         elm_object_content_set(st->conform, st->genlist);
811
812         st->back_btn = elm_button_add(ad->naviframe);
813         if (st->back_btn == NULL) {
814                 ERR("elm_button_add returns NULL\n");
815                 goto FAIL;
816         }
817         elm_naviframe_item_push(ad->naviframe,
818                         _("IDS_MOBILEAP_MBODY_WI_FI_TETHERING_SETTINGS"),
819                         st->back_btn, NULL, st->conform, NULL);
820
821         /* Style set should be called after elm_naviframe_item_push(). */
822         elm_object_style_set(st->back_btn, "naviframe/back_btn/default");
823         evas_object_smart_callback_add(st->back_btn, "clicked",
824                         __back_btn_cb, ad);
825         elm_object_focus_allow_set(st->back_btn, EINA_FALSE);
826
827         __MOBILE_AP_FUNC_EXIT__;
828
829         return;
830
831 FAIL:
832         if (st->back_btn)
833                 evas_object_del(st->back_btn);
834         if (st->genlist)
835                 evas_object_del(st->genlist);
836         if (st->conform)
837                 evas_object_del(st->conform);
838
839         st->back_btn = NULL;
840         st->genlist = NULL;
841         st->conform = NULL;
842 }