Initial code
[apps/native/ug-mobile-ap.git] / src / mh_view_main.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_main.h"
21
22 static void _gl_device_item_sel(void *data, Evas_Object *obj, void *event_info);
23 static void _gl_exp(void *data, Evas_Object *obj, void *event_info);
24 static void _gl_con(void *data, Evas_Object *obj, void *event_info);
25
26 static bool _connected_clients_cb(tethering_client_h client, void *user_data)
27 {
28         if (user_data == NULL) {
29                 ERR("user_data is NULL\n");
30                 return true;
31         }
32
33         mh_appdata_t *ad = (mh_appdata_t *)user_data;
34         int i = ad->clients.number++;
35
36         tethering_client_clone(&(ad->clients.handle[i]), client);
37
38         return true;
39 }
40
41 static void __genlist_update_device_subitem(mh_appdata_t *ad)
42 {
43         __MOBILE_AP_FUNC_ENTER__;
44
45         if (ad == NULL) {
46                 ERR("Invalid param\n");
47                 return;
48         }
49
50         Elm_Object_Item *item = NULL;
51         tethering_type_e connection_type = 0;
52         int i;
53
54         for (i = 0; i < ad->clients.number; i++) {
55                 tethering_client_get_tethering_type(ad->clients.handle[i], &connection_type);
56
57                 item = elm_genlist_item_append(ad->main.genlist,
58                                 ad->main.dev_itc[connection_type],
59                                 (void *)ad->clients.handle[i],
60                                 ad->main.device_item, ELM_GENLIST_ITEM_NONE,
61                                 NULL, NULL);
62                 if (item == NULL) {
63                         ERR("elm_genlist_item_append is failed\n");
64                         continue;
65                 }
66
67                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
68         }
69
70         __MOBILE_AP_FUNC_EXIT__;
71
72         return;
73 }
74
75 static void __genlist_update_device_item(mh_appdata_t *ad, int no_of_dev)
76 {
77         __MOBILE_AP_FUNC_ENTER__;
78
79         if (ad == NULL) {
80                 ERR("Invalid param\n");
81                 return;
82         }
83
84         Elm_Object_Item *item = NULL;
85         const Elm_Genlist_Item_Class *itc = NULL;
86         Elm_Genlist_Item_Type item_flags = ELM_GENLIST_ITEM_NONE;
87         Eina_Bool expanded = EINA_FALSE;
88
89         if (ad->main.device_item != NULL) {
90                 itc = elm_genlist_item_item_class_get(ad->main.device_item);
91                 if (itc == NULL) {
92                         ERR("itc is NULL\n");
93                         return;
94                 }
95
96                 if ((itc == ad->main.device0_itc && no_of_dev == 0) ||
97                                 (itc == ad->main.device_itc && no_of_dev > 0)) {
98                         DBG("No need to change genlist item flags\n");
99                         elm_genlist_item_update(ad->main.device_item);
100
101                         expanded = elm_genlist_item_expanded_get(ad->main.device_item);
102                         if (expanded == EINA_TRUE) {
103                                 elm_genlist_item_subitems_clear(ad->main.device_item);
104                                 __genlist_update_device_subitem(ad);
105                         }
106
107                         return;
108                 }
109
110                 elm_genlist_item_subitems_clear(ad->main.device_item);
111                 elm_object_item_del(ad->main.device_item);
112                 ad->main.device_item = NULL;
113         }
114
115         if (no_of_dev == 0) {
116                 itc = ad->main.device0_itc;
117                 item_flags = ELM_GENLIST_ITEM_NONE;
118         } else if (no_of_dev > 0) {
119                 itc = ad->main.device_itc;
120                 item_flags = ELM_GENLIST_ITEM_TREE;
121         }
122
123         item = elm_genlist_item_insert_before(ad->main.genlist,
124                         itc, ad, NULL, ad->main.usage_item, item_flags,
125                         _gl_device_item_sel, NULL);
126         if (item == NULL) {
127                 ERR("elm_genlist_item_insert_before is failed\n");
128                 return;
129         }
130         ad->main.device_item = item;
131
132         if (no_of_dev == 0) {
133                 elm_genlist_item_select_mode_set(item,
134                                 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
135                 evas_object_smart_callback_del(ad->main.genlist, "expanded",
136                                 _gl_exp);
137                 evas_object_smart_callback_del(ad->main.genlist, "contracted",
138                                 _gl_con);
139         } else if (no_of_dev > 0) {
140                 evas_object_smart_callback_add(ad->main.genlist, "expanded",
141                                 _gl_exp, ad);
142                 evas_object_smart_callback_add(ad->main.genlist, "contracted",
143                                 _gl_con, ad);
144         }
145
146         __MOBILE_AP_FUNC_EXIT__;
147
148         return;
149 }
150
151 void ap_update_data_device(mh_appdata_t *ad)
152 {
153         __MOBILE_AP_FUNC_ENTER__;
154
155         if (ad == NULL) {
156                 ERR("Invalid param\n");
157                 return;
158         }
159
160         int i;
161
162         if (ad->clients.number > 0) {
163                 for (i = 0; i < ad->clients.number; i++) {
164                         if (!ad->clients.handle[i])
165                                 continue;
166
167                         tethering_client_destroy(ad->clients.handle[i]);
168                         ad->clients.handle[i] = NULL;
169                 }
170         }
171         ad->clients.number = 0;
172
173         tethering_foreach_connected_clients(ad->handle, TETHERING_TYPE_ALL,
174                         _connected_clients_cb, (void *)ad);
175         __genlist_update_device_item(ad, ad->clients.number);
176
177         __MOBILE_AP_FUNC_EXIT__;
178 }
179
180 Eina_Bool ap_update_data_packet_usage(mh_appdata_t *ad)
181 {
182         if (ad == NULL) {
183                 ERR("Invalid param\n");
184                 return EINA_FALSE;
185         }
186
187         elm_genlist_item_update(ad->main.usage_item);
188
189         return EINA_TRUE;
190 }
191
192 Eina_Bool ap_get_data_statistics(void *data)
193 {
194         if (!data) {
195                 ERR("The param is NULL\n");
196                 return ECORE_CALLBACK_CANCEL;
197         }
198         mh_appdata_t *ad = (mh_appdata_t *)data;
199
200         if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
201                 DBG("Mobile hotspot is turned off.\n");
202                 ad->update_statistics_handle = NULL;
203                 return ECORE_CALLBACK_CANCEL;
204         }
205
206         /* If previous data is not updated, new data is not required */
207         if (ad->data_statistics.is_updated == false)
208                 return ECORE_CALLBACK_RENEW;
209
210         /* Because previous data is updated, new data is required.
211            It will be returned asynchronously. */
212         tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
213         ad->data_statistics.is_updated = false;
214
215         return ECORE_CALLBACK_RENEW;
216 }
217
218 void _start_update_data_packet_usage(mh_appdata_t *ad)
219 {
220         __MOBILE_AP_FUNC_ENTER__;
221
222         if (ad == NULL) {
223                 ERR("Invalid param\n");
224                 return;
225         }
226
227         if (ad->update_statistics_handle) {
228                 DBG("update_statistics_handle is not NULL.\n");
229                 _stop_update_data_packet_usage(ad);
230         }
231
232         ad->data_statistics.is_updated = false;
233         tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
234         ad->update_statistics_handle = ecore_timer_add(MH_UPDATE_INTERVAL,
235                         ap_get_data_statistics, (void *)ad);
236
237         __MOBILE_AP_FUNC_EXIT__;
238         return;
239 }
240
241 void _stop_update_data_packet_usage(mh_appdata_t *ad)
242 {
243         __MOBILE_AP_FUNC_ENTER__;
244
245         if (ad == NULL) {
246                 ERR("Invalid param\n");
247                 return;
248         }
249
250         if (ad->update_statistics_handle) {
251                 ecore_timer_del(ad->update_statistics_handle);
252                 ad->data_statistics.is_updated = false;
253                 ad->update_statistics_handle = NULL;
254         }
255
256         __MOBILE_AP_FUNC_EXIT__;
257         return;
258 }
259
260 static void __read_setting(mh_appdata_t *ad)
261 {
262         __MOBILE_AP_FUNC_ENTER__;
263
264         if (ad == NULL) {
265                 ERR("Invalid param\n");
266                 return;
267         }
268
269         int ret = 0;
270         char *ssid = NULL;
271         char *passphrase = NULL;
272
273         ad->main.hotspot_mode = _get_vconf_hotspot_mode();
274
275         ret = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_CONNECTED_DEVICE,
276                         &ad->clients.number);
277         if (ret != 0) {
278                 ERR("vconf_get_int is failed\n");
279                 ad->clients.number = 0;
280         }
281
282         ad->data_statistics.pdp_total_sent = 0;
283         ad->data_statistics.pdp_total_receive = 0;
284         if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
285                 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
286
287         ret = tethering_wifi_get_ssid(ad->handle, &ssid);
288         if (ret != TETHERING_ERROR_NONE || ssid == NULL) {
289                 ERR("tethering_wifi_get_ssid is failed : %d %s\n", ret, ssid);
290                 return;
291         }
292         g_strlcpy(ad->setup.device_name, ssid, sizeof(ad->setup.device_name));
293         free(ssid);
294
295         ret = tethering_wifi_get_passphrase(ad->handle, &passphrase);
296         if (ret != TETHERING_ERROR_NONE || passphrase == NULL) {
297                 ERR("tethering_wifi_get_ssid is failed : %d %s\n", ret, ssid);
298                 return;
299         }
300         g_strlcpy(ad->setup.wifi_passphrase, passphrase,
301                         sizeof(ad->setup.wifi_passphrase));
302         free(passphrase);
303
304         ret = tethering_wifi_get_ssid_visibility(ad->handle, &ad->setup.visibility);
305         if (ret != TETHERING_ERROR_NONE) {
306                 ERR("tethering_wifi_get_ssid_visibility is failed\n");
307         }
308
309         ret = tethering_wifi_get_security_type(ad->handle, &ad->setup.security_type);
310         if (ret != TETHERING_ERROR_NONE) {
311                 ERR("tethering_wifi_get_security_type is failed\n");
312         }
313
314         DBG("VCONFKEY_MOBILE_HOTSPOT_MODE : %d\n", ad->main.hotspot_mode);
315         DBG("Device name - %s\n", ad->setup.device_name);
316         DBG("Wifi passphrase- %s\n", ad->setup.wifi_passphrase);
317         DBG("Connected device : %d\n", ad->clients.number);
318         DBG("Visibility: %d\n", ad->setup.visibility);
319         DBG("Security: %d\n", ad->setup.security_type);
320         DBG("End of Load setting value \n");
321
322         __MOBILE_AP_FUNC_EXIT__;
323 }
324
325 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
326 {
327         __MOBILE_AP_FUNC_ENTER__;
328
329         if (ad->main.wifi_state == wifi_state) {
330                 DBG("aready updated\n");
331                 return;
332         }
333
334         if (ad->main.wifi_state == MH_STATE_PROCESS) {
335                 ad->main.wifi_state = MH_STATE_NONE;
336                 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
337                 elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE);
338                 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
339         } else if (ad->main.wifi_state == MH_STATE_NONE) {
340                 ad->main.wifi_state = MH_STATE_PROCESS;
341                 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
342                 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
343                 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
344         }
345
346         elm_genlist_item_update(ad->main.wifi_item);
347
348         __MOBILE_AP_FUNC_EXIT__;
349
350         return;
351 }
352
353 void _update_usb_item(mh_appdata_t *ad, int usb_state)
354 {
355         __MOBILE_AP_FUNC_ENTER__;
356
357         if (ad->main.usb_state == usb_state) {
358                 DBG("aready updated\n");
359                 return;
360         }
361
362         if (ad->main.usb_state == MH_STATE_PROCESS) {
363                 ad->main.usb_state = MH_STATE_NONE;
364                 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
365         } else if (ad->main.usb_state == MH_STATE_NONE) {
366                 ad->main.usb_state = MH_STATE_PROCESS;
367                 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
368         }
369
370         elm_genlist_item_update(ad->main.usb_item);
371
372         __MOBILE_AP_FUNC_EXIT__;
373
374         return;
375 }
376
377 void _update_main_view(mh_appdata_t *ad)
378 {
379         __MOBILE_AP_FUNC_ENTER__;
380
381         if (ad == NULL) {
382                 ERR("Invalid param\n");
383                 return;
384         }
385
386         int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
387         Eina_Bool wifi_state = EINA_FALSE;
388         Eina_Bool bt_state = EINA_FALSE;
389         Eina_Bool usb_state = EINA_FALSE;
390         Elm_Object_Item *item = NULL;
391
392         ad->main.hotspot_mode = _get_vconf_hotspot_mode();
393         state = ad->main.hotspot_mode;
394
395         ap_update_data_device(ad);
396
397         wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
398         bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
399         usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
400         DBG("wifi_state : %d, bt_state : %d, usb_state : %d\n",
401                         wifi_state, bt_state, usb_state);
402
403         /* Update Wi-Fi tethering on / off button */
404         if (ad->main.wifi_state != MH_STATE_NONE) {
405                 _update_wifi_item(ad, MH_STATE_NONE);
406         } else {
407                 elm_check_state_set(ad->main.wifi_btn, wifi_state);
408         }
409         elm_object_item_disabled_set(ad->main.setup_item, wifi_state);
410
411         /* Update BT tethering on / off button */
412         elm_check_state_set(ad->main.bt_btn, bt_state);
413
414         /* Update USB tethering on / off button */
415         if (ad->main.usb_state != MH_STATE_NONE) {
416                 _update_usb_item(ad, MH_STATE_NONE);
417         } else {
418                 elm_check_state_set(ad->main.usb_btn, usb_state);
419         }
420
421         if (wifi_state || bt_state || usb_state) {
422                 _start_update_data_packet_usage(ad);
423         }
424
425         if (wifi_state || bt_state) {
426                 if (ad->main.help_item) {
427                         DBG("Just update genlist\n");
428                         elm_genlist_item_update(ad->main.help_item);
429                         return;
430                 } else {
431                         DBG("Add help item\n");
432                         item = elm_genlist_item_insert_after(ad->main.genlist,
433                                         ad->main.help_itc, ad, NULL,
434                                         ad->main.usb_item,
435                                         ELM_GENLIST_ITEM_NONE, NULL,
436                                         NULL);
437                         if (item == NULL) {
438                                 ERR("elm_genlist_item_insert_after NULL\n");
439                                 return;
440                         }
441                         ad->main.help_item = item;
442                 }
443         } else {
444                 if (!ad->main.help_item) {
445                         DBG("No need to update\n");
446                         return;
447                 } else {
448                         DBG("Remove help item\n");
449                         elm_object_item_del(ad->main.help_item);
450                         ad->main.help_item = NULL;
451                 }
452         }
453
454         __MOBILE_AP_FUNC_EXIT__;
455 }
456
457 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
458                                                         void *event_info)
459 {
460         __MOBILE_AP_FUNC_ENTER__;
461
462         if (data == NULL) {
463                 ERR("The param is NULL\n");
464                 return;
465         }
466
467         mh_appdata_t *ad = (mh_appdata_t *)data;
468         Eina_Bool wifi_state = EINA_FALSE;
469
470         wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ?
471                 EINA_TRUE : EINA_FALSE;
472
473         _update_wifi_item(ad, MH_STATE_PROCESS);
474         elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
475
476         if (_handle_wifi_onoff_change(ad) != 0) {
477                 ERR("_handle_wifi_onoff_change is failed\n");
478                 _update_wifi_item(ad, MH_STATE_NONE);
479                 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
480         } else
481                 wifi_state = !wifi_state;
482
483         __MOBILE_AP_FUNC_EXIT__;
484
485         return;
486 }
487
488 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
489 {
490         __MOBILE_AP_FUNC_ENTER__;
491
492         if (data == NULL) {
493                 ERR("The param is NULL\n");
494                 return;
495         }
496
497         mh_appdata_t *ad = (mh_appdata_t *)data;
498
499         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
500
501         __wifi_onoff_changed_cb(data, ad->main.wifi_btn, NULL);
502
503         __MOBILE_AP_FUNC_EXIT__;
504
505         return;
506 }
507
508 static void __select_setup_item(void *data, Evas_Object *obj, void *event_info)
509 {
510         __MOBILE_AP_FUNC_ENTER__;
511
512         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
513         mh_appdata_t *ad = (mh_appdata_t *)data;
514
515         if (data == NULL) {
516                 ERR("The param is NULL\n");
517                 return;
518         }
519
520         elm_genlist_item_selected_set(item, EINA_FALSE);
521         mh_draw_wifi_setup_view(ad);
522
523         __MOBILE_AP_FUNC_EXIT__;
524
525         return;
526 }
527
528 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
529 {
530         __MOBILE_AP_FUNC_ENTER__;
531
532         if (data == NULL) {
533                 ERR("The param is NULL\n");
534                 return;
535         }
536
537         mh_appdata_t *ad = (mh_appdata_t *)data;
538         Eina_Bool bt_state;
539
540         bt_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT ?
541                 EINA_TRUE : EINA_FALSE;
542
543         if (_handle_bt_onoff_change(ad) == 0)
544                 bt_state = !bt_state;
545
546         elm_check_state_set(ad->main.bt_btn, bt_state);
547
548         __MOBILE_AP_FUNC_EXIT__;
549
550         return;
551 }
552
553 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
554 {
555         __MOBILE_AP_FUNC_ENTER__;
556
557         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
558         mh_appdata_t *ad = (mh_appdata_t *)data;
559
560         if (data == NULL) {
561                 ERR("The param is NULL\n");
562                 return;
563         }
564
565         elm_genlist_item_selected_set(item, EINA_FALSE);
566
567         __bt_onoff_changed_cb(data, ad->main.bt_btn, NULL);
568
569         __MOBILE_AP_FUNC_EXIT__;
570
571         return;
572 }
573
574 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
575 {
576         __MOBILE_AP_FUNC_ENTER__;
577
578         if (data == NULL) {
579                 ERR("The param is NULL\n");
580                 return;
581         }
582
583         mh_appdata_t *ad = (mh_appdata_t *)data;
584
585         _update_usb_item(ad, MH_STATE_PROCESS);
586         if (_handle_usb_onoff_change(ad) != 0) {
587                 ERR("_handle_usb_onoff_change is failed\n");
588                 _update_usb_item(ad, MH_STATE_NONE);
589         }
590
591         __MOBILE_AP_FUNC_EXIT__;
592
593         return;
594 }
595
596 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
597 {
598         __MOBILE_AP_FUNC_ENTER__;
599
600         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
601         mh_appdata_t *ad = (mh_appdata_t *)data;
602
603         if (data == NULL) {
604                 ERR("The param is NULL\n");
605                 return;
606         }
607
608         elm_genlist_item_selected_set(item, EINA_FALSE);
609
610         __usb_onoff_changed_cb(data, ad->main.usb_btn, NULL);
611
612         __MOBILE_AP_FUNC_EXIT__;
613
614         return;
615 }
616
617 static void __quit_btn_cb(void *data, Evas_Object *obj, void *event_info)
618 {
619         __MOBILE_AP_FUNC_ENTER__;
620
621         if (data == NULL) {
622                 ERR("The param is NULL\n");
623                 return;
624         }
625
626         mh_appdata_t *ad = (mh_appdata_t*)data;
627
628         ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
629
630         __MOBILE_AP_FUNC_EXIT__;
631 }
632
633 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
634 {
635         if (strcmp(part, "elm.text") != 0) {
636                 ERR("Invalid param\n");
637                 return NULL;
638         }
639
640         return strdup(_("IDS_MOBILEAP_MBODY_WI_FI_TETHERING"));
641 }
642
643 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
644                 const char *part)
645 {
646         __MOBILE_AP_FUNC_ENTER__;
647
648         if (data == NULL) {
649                 ERR("The param is NULL\n");
650                 return NULL;
651         }
652
653         if (strcmp(part, "elm.icon") != 0) {
654                 ERR("Invalid param\n");
655                 return NULL;
656         }
657
658         mh_appdata_t *ad = (mh_appdata_t*)data;
659         Evas_Object *btn = NULL;
660         Evas_Object *progressbar = NULL;
661
662         if (ad->main.wifi_state == MH_STATE_PROCESS) {
663                 progressbar = elm_progressbar_add(obj);
664                 if (progressbar == NULL) {
665                         ERR("progressbar is NULL\n");
666                         return NULL;
667                 }
668                 elm_object_style_set(progressbar, "list_process");
669                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
670                 elm_progressbar_pulse(progressbar, EINA_TRUE);
671                 evas_object_show(progressbar);
672                 ad->main.wifi_btn = progressbar;
673         } else {
674                 btn = elm_check_add(obj);
675                 elm_object_style_set(btn, "on&off");
676                 evas_object_show(btn);
677
678                 evas_object_pass_events_set(btn, EINA_TRUE);
679                 evas_object_propagate_events_set(btn, EINA_FALSE);
680                 elm_check_state_set(btn, ad->main.hotspot_mode &
681                                 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
682
683                 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb,
684                                 ad);
685                 ad->main.wifi_btn = btn;
686         }
687
688         __MOBILE_AP_FUNC_EXIT__;
689         return ad->main.wifi_btn;
690 }
691
692 static char *__get_setup_label(void *data, Evas_Object *obj, const char *part)
693 {
694         if (data == NULL) {
695
696                 ERR("The param is NULL\n");
697                 return NULL;
698         }
699
700         mh_appdata_t *ad = (mh_appdata_t *)data;
701
702         if (strcmp(part, "elm.text") != 0) {
703                 ERR("Invalid param\n");
704                 return NULL;
705         }
706
707         elm_object_item_disabled_set(ad->main.setup_item,
708                         ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
709
710         return strdup(_("IDS_MOBILEAP_MBODY_WI_FI_TETHERING_SETTINGS"));
711 }
712
713 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
714 {
715         if (strcmp(part, "elm.text") != 0) {
716                 ERR("Invalid param\n");
717                 return NULL;
718         }
719
720         return strdup(_("IDS_MOBILEAP_BODY_BLUETOOTH_TETHERING"));
721 }
722
723 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
724 {
725         __MOBILE_AP_FUNC_ENTER__;
726
727         mh_appdata_t *ad = (mh_appdata_t *)data;
728         Evas_Object *btn = NULL;
729
730         if (strcmp(part, "elm.icon") != 0) {
731                 ERR("Invalid param\n");
732                 return NULL;
733         }
734
735         if (data == NULL) {
736                 ERR("The param is NULL\n");
737                 return NULL;
738         }
739
740         btn = elm_check_add(obj);
741         elm_object_style_set(btn, "on&off");
742         evas_object_show(btn);
743
744         evas_object_pass_events_set(btn, EINA_TRUE);
745         evas_object_propagate_events_set(btn, EINA_FALSE);
746         elm_check_state_set(btn, ad->main.hotspot_mode &
747                         VCONFKEY_MOBILE_HOTSPOT_MODE_BT ? EINA_TRUE : EINA_FALSE);
748
749         evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb,
750                         ad);
751         ad->main.bt_btn = btn;
752
753         __MOBILE_AP_FUNC_EXIT__;
754
755         return btn;
756 }
757
758 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
759 {
760         if (strcmp(part, "elm.text") != 0) {
761                 ERR("Invalid param\n");
762                 return NULL;
763         }
764
765         return strdup(_("IDS_MOBILEAP_MBODY_USB_TETHERING"));
766 }
767
768 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
769                                                         const char *part)
770 {
771         __MOBILE_AP_FUNC_ENTER__;
772
773         mh_appdata_t *ad = (mh_appdata_t *)data;
774         Evas_Object *btn = NULL;
775         Evas_Object *progressbar = NULL;
776
777         if (strcmp(part, "elm.icon") != 0) {
778                 ERR("Invalid param\n");
779                 return NULL;
780         }
781
782         if (data == NULL) {
783                 ERR("The param is NULL\n");
784                 return NULL;
785         }
786
787         ad->main.usb_btn = NULL;
788         if (ad->main.usb_state == MH_STATE_PROCESS) {
789                 progressbar = elm_progressbar_add(obj);
790                 if (progressbar == NULL) {
791                         ERR("progressbar is NULL\n");
792                         return NULL;
793                 }
794                 elm_object_style_set(progressbar, "list_process");
795                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
796                 elm_progressbar_pulse(progressbar, EINA_TRUE);
797                 evas_object_show(progressbar);
798                 ad->main.usb_btn = progressbar;
799         } else {
800                 btn = elm_check_add(obj);
801                 if (btn == NULL) {
802                         ERR("btn is NULL\n");
803                         return NULL;
804                 }
805                 elm_object_style_set(btn, "on&off");
806                 evas_object_pass_events_set(btn, EINA_TRUE);
807                 evas_object_propagate_events_set(btn, EINA_FALSE);
808                 elm_check_state_set(btn, ad->main.hotspot_mode &
809                                 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
810                 evas_object_show(btn);
811                 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb,
812                                 ad);
813                 ad->main.usb_btn = btn;
814         }
815
816         __MOBILE_AP_FUNC_EXIT__;
817
818         return ad->main.usb_btn;
819 }
820
821 static char *__get_setup_help_label(void *data, Evas_Object *obj,
822                                                         const char *part)
823 {
824         __MOBILE_AP_FUNC_ENTER__;
825
826         if (strcmp(part, "elm.text.1") != 0) {
827                 ERR("Invalid param\n");
828                 return NULL;
829         }
830
831         __MOBILE_AP_FUNC_EXIT__;
832
833         return strdup(_("IDS_MOBILEAP_BODY_WI_FI_TETHERING_SETTINGS_ARE_ONLY_AVAILABLE_WHEN_WI_FI_TETHERING_IS_DISABLED"));
834 }
835
836 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
837 {
838         __MOBILE_AP_FUNC_ENTER__;
839
840         mh_appdata_t *ad = (mh_appdata_t *)data;
841         char buf[MH_LABEL_LENGTH_MAX] = {0, };
842         char device_name[MH_LABEL_LENGTH_MAX] = {0, };
843         char passphrase[MH_LABEL_LENGTH_MAX] = {0, };
844         char *hidden = "";
845         char *ptr = NULL;
846         int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
847
848         if (strcmp(part, "elm.text.1") != 0) {
849                 ERR("Invalid param\n");
850                 return NULL;
851         }
852
853         if (data == NULL) {
854                 ERR("The param is NULL\n");
855                 return NULL;
856         }
857
858         ptr = elm_entry_utf8_to_markup(ad->setup.device_name);
859         if (ptr == NULL) {
860                 ERR("elm_entry_utf8_to_markup is failed\n");
861                 return NULL;
862         }
863         g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
864         free(ptr);
865
866         if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
867                 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
868                 if (ptr == NULL) {
869                         ERR("elm_entry_utf8_to_markup is failed\n");
870                         return NULL;
871                 }
872                 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
873                 free(ptr);
874         }
875
876         wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
877
878         if (wifi_state && ad->setup.visibility == false)
879                 hidden = _("IDS_MOBILEAP_BODY_WI_FI_TETHERING_HIDDEN");
880
881         if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
882                 snprintf(buf, MH_LABEL_LENGTH_MAX,
883                                 "%s: %s<br>"
884                                 "%s: %s<br><br>"
885                                 "%s"
886                                 "%s"
887                                 "%s",
888                                 _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
889                                 device_name,
890                                 _("IDS_MOBILEAP_BODY_PASSWORD"),
891                                 passphrase,
892                                 _("IDS_MOBILEAP_BODY_THIS_PASSWORD_IS_ONLY_FOR_WI_FI_TETHERING"),
893                                 hidden[0] != '\0' ? "<br>" : "",
894                                 hidden);
895
896         } else {
897                 snprintf(buf, MH_LABEL_LENGTH_MAX,
898                                 "%s : %s%s%s",
899                                 _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
900                                 device_name,
901                                 hidden[0] != '\0' ? "<br>" : "",
902                                 hidden);
903         }
904
905         __MOBILE_AP_FUNC_EXIT__;
906
907         return strdup(buf);
908 }
909
910 static char *__get_connected_device_label(void *data, Evas_Object *obj,
911                                                         const char *part)
912 {
913         if (strcmp(part, "elm.text.1") != 0 && strcmp(part, "elm.text.2") != 0) {
914                 ERR("Invalid param\n");
915                 return NULL;
916         }
917
918         if (data == NULL) {
919                 ERR("The param is NULL\n");
920                 return NULL;
921         }
922
923         mh_appdata_t *ad = (mh_appdata_t*)data;
924         char buf[MH_LABEL_LENGTH_MAX] = {0, };
925
926         if (strcmp(part, "elm.text.1") != 0)
927                 snprintf(buf, MH_LABEL_LENGTH_MAX, "%d",
928                                 ad->clients.number);
929         else if (strcmp(part, "elm.text.2") != 0)
930                 g_strlcpy(buf, _("IDS_MOBILEAP_BODY_CONNECTED_DEVICE"),
931                                 sizeof(buf));
932
933         return strdup(buf);
934 }
935
936 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
937 {
938         if (data == NULL) {
939                 ERR("The param is NULL\n");
940                 return NULL;
941         }
942
943         if (strcmp(part, "elm.text.1") != 0 && strcmp(part, "elm.text.2") != 0) {
944                 ERR("Invalid param\n");
945                 return NULL;
946         }
947
948         mh_appdata_t *ad = (mh_appdata_t*)data;
949         int sent = 0;
950         int received = 0;
951         char *sent_str = NULL;
952         char *received_str = NULL;
953         char fmt[MH_LABEL_LENGTH_MAX] = {0, };
954         char label[MH_LABEL_LENGTH_MAX] = {0, };
955
956         if (strcmp(part, "elm.text.1") != 0 ) {
957                 sent = ad->data_statistics.pdp_total_sent;
958                 received = ad->data_statistics.pdp_total_receive;
959
960                 if (sent >= MH_MB) {
961                         sent /= MH_MB;
962                         sent_str =  _("IDS_MOBILEAP_BODY_PD_MB");
963                 } else if (sent >= MH_KB) {
964                         sent /= MH_KB;
965                         sent_str =  _("IDS_MOBILEAP_BODY_PD_KB");
966                 } else {
967                         sent_str =  _("IDS_MOBILEAP_BODY_PD_BYTES");
968                 }
969
970                 if (received >= MH_MB) {
971                         received /= MH_MB;
972                         received_str =  _("IDS_MOBILEAP_BODY_PD_MB");
973                 } else if (received >= MH_KB) {
974                         received /= MH_KB;
975                         received_str =  _("IDS_MOBILEAP_BODY_PD_KB");
976                 } else {
977                         received_str =  _("IDS_MOBILEAP_BODY_PD_BYTES");
978                 }
979
980                 snprintf(fmt, sizeof(fmt), "%s %s / %s %s",
981                                 _("IDS_MOBILEAP_BODY_SENT_C"),
982                                 sent_str,
983                                 _("IDS_MOBILEAP_BODY_RECEIVED_C"),
984                                 received_str);
985                 snprintf(label, sizeof(label), fmt, sent, received);
986         } else if (strcmp(part, "elm.text.2") != 0)
987                 g_strlcpy(label, _("IDS_MOBILEAP_MBODY_DATA_USAGE"),
988                                 sizeof(label));
989
990         return strdup(label);
991 }
992
993 static char *__gl_get_dev_label(void *data, Evas_Object *obj, const char *part)
994 {
995         if (data == NULL || part == NULL) {
996                 ERR("Invalid param\n");
997                 return NULL;
998         }
999
1000         tethering_client_h client = (tethering_client_h)data;
1001         char *name = NULL;
1002
1003         if (!strcmp(part, "elm.text")) {
1004                 tethering_client_get_name(client, &name);
1005                 DBG("Device name : %s\n", name);
1006
1007                 if (!strcmp(name, "UNKNOWN")) {
1008                         return strdup(_(MH_DEVICE_LIST_NO_NAME));
1009                 }
1010
1011                 return name;
1012         }
1013
1014         return NULL;
1015 }
1016
1017 static Evas_Object *__gl_get_dev_wifi_icon(void *data, Evas_Object *obj,
1018                                                         const char *part)
1019 {
1020         Evas_Object *icon;
1021
1022         if (!strncmp(part, "elm.icon", 8)) {
1023                 icon = elm_icon_add(obj);
1024                 elm_icon_file_set(icon, MOBILE_AP_IMG_DIR"/Wifi.png", NULL);
1025                 evas_object_size_hint_aspect_set(icon,
1026                                 EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1027                 return icon;
1028         }
1029         return NULL;
1030 }
1031
1032 static Evas_Object *__gl_get_dev_usb_icon(void *data, Evas_Object *obj,
1033                                                         const char *part)
1034 {
1035         Evas_Object *icon;
1036
1037         if (!strncmp(part, "elm.icon", 8)) {
1038                 icon = elm_icon_add(obj);
1039                 elm_icon_file_set(icon, MOBILE_AP_IMG_DIR"/USB.png", NULL);
1040                 evas_object_size_hint_aspect_set(icon,
1041                                 EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1042                 return icon;
1043         }
1044         return NULL;
1045 }
1046
1047 static Evas_Object *__gl_get_dev_bt_icon(void *data, Evas_Object *obj,
1048                                                         const char *part)
1049 {
1050         Evas_Object *icon;
1051
1052         if (!strncmp(part, "elm.icon", 8)) {
1053                 icon = elm_icon_add(obj);
1054                 elm_icon_file_set(icon, MOBILE_AP_IMG_DIR"/Bluetooth.png", NULL);
1055                 evas_object_size_hint_aspect_set(icon,
1056                                         EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1057                 return icon;
1058         }
1059         return NULL;
1060 }
1061
1062 static void _gl_exp(void *data, Evas_Object *obj, void *event_info)
1063 {
1064         __MOBILE_AP_FUNC_ENTER__;
1065
1066         if (data == NULL) {
1067                 ERR("Invalid param\n");
1068                 return;
1069         }
1070
1071         mh_appdata_t *ad = (mh_appdata_t *)data;
1072
1073         ap_update_data_device(ad);
1074
1075         __MOBILE_AP_FUNC_EXIT__;
1076 }
1077
1078 static void _gl_con(void *data, Evas_Object *obj, void *event_info)
1079 {
1080         __MOBILE_AP_FUNC_ENTER__;
1081
1082         if (event_info == NULL) {
1083                 ERR("Invalid param\n");
1084                 return;
1085         }
1086
1087         mh_appdata_t *ad = (mh_appdata_t *)data;
1088
1089         elm_genlist_item_subitems_clear(ad->main.device_item);
1090
1091         __MOBILE_AP_FUNC_EXIT__;
1092 }
1093
1094 static void _gl_device_item_sel(void *data, Evas_Object *obj, void *event_info)
1095 {
1096         __MOBILE_AP_FUNC_ENTER__;
1097
1098         Elm_Object_Item *item = (Elm_Object_Item*)event_info;
1099
1100         elm_genlist_item_selected_set(item, EINA_FALSE);
1101
1102         Eina_Bool status = elm_genlist_item_expanded_get(item);
1103         DBG("+ expand status:%d\n", status);
1104
1105         elm_genlist_item_expanded_set(item, !status);
1106
1107         __MOBILE_AP_FUNC_EXIT__;
1108
1109         return;
1110 }
1111
1112 static void __free_genlist_itc(mh_appdata_t *ad)
1113 {
1114         elm_genlist_item_class_free(ad->main.sp_itc);
1115         elm_genlist_item_class_free(ad->main.wifi_itc);
1116         elm_genlist_item_class_free(ad->main.setup_itc);
1117         elm_genlist_item_class_free(ad->main.bt_itc);
1118         elm_genlist_item_class_free(ad->main.usb_itc);
1119         elm_genlist_item_class_free(ad->main.setup_help_itc);
1120         elm_genlist_item_class_free(ad->main.help_itc);
1121         elm_genlist_item_class_free(ad->main.device_itc);
1122         elm_genlist_item_class_free(ad->main.device0_itc);
1123         elm_genlist_item_class_free(ad->main.usage_itc);
1124         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_WIFI]);
1125         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_USB]);
1126         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_BT]);
1127         return;
1128 }
1129
1130 static void __set_genlist_itc(mh_appdata_t *ad)
1131 {
1132         /* On, Off view's item class for genlist */
1133         ad->main.sp_itc = elm_genlist_item_class_new();
1134         ad->main.sp_itc->item_style = "dialogue/separator/21/with_line";
1135         ad->main.sp_itc->func.text_get = NULL;
1136         ad->main.sp_itc->func.content_get = NULL;
1137         ad->main.sp_itc->func.state_get = NULL;
1138         ad->main.sp_itc->func.del = NULL;
1139
1140         ad->main.wifi_itc = elm_genlist_item_class_new();
1141         ad->main.wifi_itc->item_style = "dialogue/1text.1icon";
1142         ad->main.wifi_itc->func.text_get = __get_wifi_label;
1143         ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1144         ad->main.wifi_itc->func.state_get = NULL;
1145         ad->main.wifi_itc->func.del = NULL;
1146
1147         ad->main.end_sp_itc = elm_genlist_item_class_new();
1148         ad->main.end_sp_itc->item_style = "dialogue/separator/end";
1149         ad->main.end_sp_itc->func.text_get = NULL;
1150         ad->main.end_sp_itc->func.content_get = NULL;
1151         ad->main.end_sp_itc->func.state_get = NULL;
1152         ad->main.end_sp_itc->func.del = NULL;
1153         /* End of On, Off view's item class for genlist */
1154
1155         /* Off view's item class for genlist */
1156         ad->main.setup_itc = elm_genlist_item_class_new();
1157         ad->main.setup_itc->item_style = "dialogue/1text";
1158         ad->main.setup_itc->func.text_get = __get_setup_label;
1159         ad->main.setup_itc->func.content_get = NULL;
1160         ad->main.setup_itc->func.state_get = NULL;
1161         ad->main.setup_itc->func.del = NULL;
1162
1163         ad->main.bt_itc = elm_genlist_item_class_new();
1164         ad->main.bt_itc->item_style = "dialogue/1text.1icon";
1165         ad->main.bt_itc->func.text_get = __get_bt_label;
1166         ad->main.bt_itc->func.content_get = __get_bt_icon;
1167         ad->main.bt_itc->func.state_get = NULL;
1168         ad->main.bt_itc->func.del = NULL;
1169
1170         ad->main.usb_itc = elm_genlist_item_class_new();
1171         ad->main.usb_itc->item_style = "dialogue/1text.1icon";
1172         ad->main.usb_itc->func.text_get = __get_usb_label;
1173         ad->main.usb_itc->func.content_get = __get_usb_icon;
1174         ad->main.usb_itc->func.state_get = NULL;
1175         ad->main.usb_itc->func.del = NULL;
1176
1177         ad->main.setup_help_itc = elm_genlist_item_class_new();
1178         ad->main.setup_help_itc->item_style = "multiline/1text";
1179         ad->main.setup_help_itc->func.text_get = __get_setup_help_label;
1180         ad->main.setup_help_itc->func.content_get = NULL;
1181         ad->main.setup_help_itc->func.state_get = NULL;
1182         ad->main.setup_help_itc->func.del = NULL;
1183
1184         ad->main.help_itc = elm_genlist_item_class_new();
1185         ad->main.help_itc->item_style = "multiline/1text";
1186         ad->main.help_itc->func.text_get = __get_help_label;
1187         ad->main.help_itc->func.content_get = NULL;
1188         ad->main.help_itc->func.state_get = NULL;
1189         ad->main.help_itc->func.del = NULL;
1190
1191         /* End of Off view's item class for genlist */
1192
1193         /* On view's item class for genlist */
1194         ad->main.device_itc = elm_genlist_item_class_new();
1195         ad->main.device_itc->item_style = "dialogue/2text.3/expandable";
1196         ad->main.device_itc->func.text_get = __get_connected_device_label;
1197         ad->main.device_itc->func.content_get = NULL;
1198         ad->main.device_itc->func.state_get = NULL;
1199         ad->main.device_itc->func.del = NULL;
1200
1201         ad->main.device0_itc = elm_genlist_item_class_new();
1202         ad->main.device0_itc->item_style = "dialogue/2text.3";
1203         ad->main.device0_itc->func.text_get = __get_connected_device_label;
1204         ad->main.device0_itc->func.content_get = NULL;
1205         ad->main.device0_itc->func.state_get = NULL;
1206         ad->main.device0_itc->func.del = NULL;
1207
1208         ad->main.usage_itc = elm_genlist_item_class_new();
1209         ad->main.usage_itc->item_style = "dialogue/2text.3";
1210         ad->main.usage_itc->func.text_get = __get_usage_label;
1211         ad->main.usage_itc->func.content_get = NULL;
1212         ad->main.usage_itc->func.state_get = NULL;
1213         ad->main.usage_itc->func.del = NULL;
1214
1215         ad->main.dev_itc[TETHERING_TYPE_WIFI] = elm_genlist_item_class_new();
1216         ad->main.dev_itc[TETHERING_TYPE_WIFI]->item_style =
1217                 "dialogue/1text.1icon/expandable2";
1218         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.text_get = __gl_get_dev_label;
1219         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.content_get = __gl_get_dev_wifi_icon;
1220         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.state_get = NULL;
1221         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.del = NULL;
1222
1223         ad->main.dev_itc[TETHERING_TYPE_USB] = elm_genlist_item_class_new();
1224         ad->main.dev_itc[TETHERING_TYPE_USB]->item_style =
1225                 "dialogue/1text.1icon/expandable2";
1226         ad->main.dev_itc[TETHERING_TYPE_USB]->func.text_get = __gl_get_dev_label;
1227         ad->main.dev_itc[TETHERING_TYPE_USB]->func.content_get = __gl_get_dev_usb_icon;
1228         ad->main.dev_itc[TETHERING_TYPE_USB]->func.state_get = NULL;
1229         ad->main.dev_itc[TETHERING_TYPE_USB]->func.del = NULL;
1230
1231         ad->main.dev_itc[TETHERING_TYPE_BT] = elm_genlist_item_class_new();
1232         ad->main.dev_itc[TETHERING_TYPE_BT]->item_style =
1233                 "dialogue/1text.1icon/expandable2";
1234         ad->main.dev_itc[TETHERING_TYPE_BT]->func.text_get = __gl_get_dev_label;
1235         ad->main.dev_itc[TETHERING_TYPE_BT]->func.content_get = __gl_get_dev_bt_icon;
1236         ad->main.dev_itc[TETHERING_TYPE_BT]->func.state_get = NULL;
1237         ad->main.dev_itc[TETHERING_TYPE_BT]->func.del = NULL;
1238         /* End of On view's item class for genlist */
1239
1240         return;
1241 }
1242
1243 static void _ap_inner_contents(mh_appdata_t *ad)
1244 {
1245         __MOBILE_AP_FUNC_ENTER__;
1246
1247         Elm_Object_Item *item = NULL;
1248
1249         __read_setting(ad);
1250         if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
1251                 _start_update_data_packet_usage(ad);
1252
1253         ad->main.genlist = elm_genlist_add(ad->naviframe);
1254         elm_object_style_set(ad->main.genlist, "dialogue");
1255         elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1256         elm_object_content_set(ad->main.conform, ad->main.genlist);
1257         __set_genlist_itc(ad);
1258
1259         /* separator */
1260         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, ad,
1261                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1262         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1263
1264         item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1265                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1266                         __select_wifi_item, ad);
1267         ad->main.wifi_item = item;
1268
1269         item = elm_genlist_item_append(ad->main.genlist, ad->main.setup_itc,
1270                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1271                         __select_setup_item, ad);
1272         ad->main.setup_item = item;
1273
1274         item = elm_genlist_item_append(ad->main.genlist, ad->main.setup_help_itc,
1275                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1276                         NULL, NULL);
1277         ad->main.setup_help_item = item;
1278
1279         /* separator */
1280         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, ad,
1281                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1282         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1283
1284         item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1285                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1286                         __select_bt_item, ad);
1287         ad->main.bt_item = item;
1288
1289         item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1290                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1291                         __select_usb_item, ad);
1292         ad->main.usb_item = item;
1293
1294         if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ||
1295                         ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) {
1296                 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1297                                 ad, NULL, ELM_GENLIST_ITEM_NONE,
1298                                 NULL, NULL);
1299                 DBG("elm_genlist_item_append for help_itc : %x\n", item);
1300                 ad->main.help_item = item;
1301         }
1302
1303         /* separator */
1304         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, ad,
1305                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1306         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1307
1308         item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1309                         ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1310         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1311         ad->main.usage_item = item;
1312
1313         /* Insert "Connected devices" item */
1314         ap_update_data_device(ad);
1315
1316         item = elm_genlist_item_append(ad->main.genlist, ad->main.end_sp_itc, ad,
1317                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1318         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1319
1320         __MOBILE_AP_FUNC_EXIT__;
1321 }
1322
1323 void ap_callback_del(void *data)
1324 {
1325         __MOBILE_AP_FUNC_ENTER__;
1326
1327         if (data == NULL) {
1328                 ERR("The param is NULL\n");
1329                 return;
1330         }
1331         mh_appdata_t *ad = (mh_appdata_t*)data;
1332
1333         evas_object_smart_callback_del(ad->main.back_btn, "clicked",
1334                         __quit_btn_cb);
1335         evas_object_smart_callback_del(ad->main.wifi_btn, "changed",
1336                         __wifi_onoff_changed_cb);
1337         evas_object_smart_callback_del(ad->main.bt_btn, "changed",
1338                         __bt_onoff_changed_cb);
1339         evas_object_smart_callback_del(ad->main.usb_btn, "changed",
1340                         __usb_onoff_changed_cb);
1341
1342         evas_object_smart_callback_del(ad->main.genlist, "expanded", _gl_exp);
1343         evas_object_smart_callback_del(ad->main.genlist, "contracted", _gl_con);
1344
1345         __MOBILE_AP_FUNC_EXIT__;
1346 }
1347
1348 void ap_update_data_onoff(void* data)
1349 {
1350         __MOBILE_AP_FUNC_ENTER__;
1351
1352         __MOBILE_AP_FUNC_EXIT__;
1353 }
1354
1355 void ap_draw_contents(mh_appdata_t *ad)
1356 {
1357         __MOBILE_AP_FUNC_ENTER__;
1358
1359         elm_win_conformant_set(ad->win, 1);
1360         ad->main.conform = elm_conformant_add(ad->naviframe);
1361         elm_object_style_set(ad->main.conform, "internal_layout");
1362         evas_object_show(ad->main.conform);
1363
1364         _ap_inner_contents(ad);
1365
1366         ad->main.back_btn = elm_button_add(ad->naviframe);
1367
1368         elm_naviframe_item_push(ad->naviframe,
1369                         _("IDS_MOBILEAP_BODY_TETHERING"),
1370                         ad->main.back_btn, NULL, ad->main.conform, NULL);
1371
1372         /* Style set should be called after elm_naviframe_item_push(). */
1373         elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1374         evas_object_smart_callback_add(ad->main.back_btn, "clicked",
1375                         __quit_btn_cb, ad);
1376         elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1377
1378         __MOBILE_AP_FUNC_EXIT__;
1379 }