Merge branch 'master' into tizen_2.1
[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\n", ret);
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_passphrase is failed : %d\n", ret);
298                 return;
299         }
300         g_strlcpy(ad->setup.wifi_passphrase, passphrase,
301                         sizeof(ad->setup.wifi_passphrase));
302         g_strlcpy(ad->setup.wifi_passphrase_new, passphrase,
303                         sizeof(ad->setup.wifi_passphrase_new));
304         free(passphrase);
305
306         ret = tethering_wifi_get_ssid_visibility(ad->handle, &ad->setup.visibility);
307         if (ret != TETHERING_ERROR_NONE) {
308                 ERR("tethering_wifi_get_ssid_visibility is failed\n");
309         }
310
311         ret = tethering_wifi_get_security_type(ad->handle, &ad->setup.security_type);
312         if (ret != TETHERING_ERROR_NONE) {
313                 ERR("tethering_wifi_get_security_type is failed\n");
314         }
315         DBG("End of Load setting value \n");
316
317         __MOBILE_AP_FUNC_EXIT__;
318 }
319
320 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
321 {
322         __MOBILE_AP_FUNC_ENTER__;
323
324         if (ad->main.wifi_state == wifi_state) {
325                 DBG("aready updated\n");
326                 return;
327         }
328
329         if (ad->main.wifi_state == MH_STATE_PROCESS) {
330                 ad->main.wifi_state = MH_STATE_NONE;
331                 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
332                 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
333         } else if (ad->main.wifi_state == MH_STATE_NONE) {
334                 ad->main.wifi_state = MH_STATE_PROCESS;
335                 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
336                 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
337         }
338
339         elm_genlist_item_update(ad->main.wifi_item);
340         elm_object_item_signal_emit(ad->main.setup_item, "elm,state,bottom", "");
341
342         __MOBILE_AP_FUNC_EXIT__;
343
344         return;
345 }
346
347 void _update_bt_item(mh_appdata_t *ad, int bt_state)
348 {
349         __MOBILE_AP_FUNC_ENTER__;
350
351         if (ad->main.bt_state == bt_state) {
352                 DBG("aready updated\n");
353                 return;
354         }
355
356         if (ad->main.bt_state == MH_STATE_PROCESS) {
357                 ad->main.bt_state = MH_STATE_NONE;
358                 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
359         } else if (ad->main.bt_state == MH_STATE_NONE) {
360                 ad->main.bt_state = MH_STATE_PROCESS;
361                 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
362         }
363
364         elm_genlist_item_update(ad->main.bt_item);
365
366         __MOBILE_AP_FUNC_EXIT__;
367
368         return;
369 }
370
371 void _update_usb_item(mh_appdata_t *ad, int usb_state)
372 {
373         __MOBILE_AP_FUNC_ENTER__;
374
375         if (ad->main.usb_state == usb_state) {
376                 DBG("aready updated\n");
377                 return;
378         }
379
380         if (ad->main.usb_state == MH_STATE_PROCESS) {
381                 ad->main.usb_state = MH_STATE_NONE;
382                 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
383         } else if (ad->main.usb_state == MH_STATE_NONE) {
384                 ad->main.usb_state = MH_STATE_PROCESS;
385                 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
386         }
387
388         elm_genlist_item_update(ad->main.usb_item);
389
390         __MOBILE_AP_FUNC_EXIT__;
391
392         return;
393 }
394
395 void _update_main_view(mh_appdata_t *ad)
396 {
397         __MOBILE_AP_FUNC_ENTER__;
398
399         if (ad == NULL) {
400                 ERR("Invalid param\n");
401                 return;
402         }
403
404         int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
405         Eina_Bool wifi_state = EINA_FALSE;
406         Eina_Bool bt_state = EINA_FALSE;
407         Eina_Bool usb_state = EINA_FALSE;
408         Elm_Object_Item *item = NULL;
409
410         ad->main.hotspot_mode = _get_vconf_hotspot_mode();
411         state = ad->main.hotspot_mode;
412
413         ap_update_data_device(ad);
414
415         wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
416         bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
417         usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
418         DBG("wifi_state : %d, bt_state : %d, usb_state : %d\n",
419                         wifi_state, bt_state, usb_state);
420
421         /* Update Wi-Fi tethering on / off button */
422         if (ad->main.wifi_state != MH_STATE_NONE) {
423                 _update_wifi_item(ad, MH_STATE_NONE);
424         } else {
425                 elm_check_state_set(ad->main.wifi_btn, wifi_state);
426         }
427
428         /* Update BT tethering on / off button */
429         if (ad->main.bt_state != MH_STATE_NONE) {
430                 _update_bt_item(ad, MH_STATE_NONE);
431         } else {
432                 elm_check_state_set(ad->main.bt_btn, bt_state);
433         }
434
435         /* Update USB tethering on / off button */
436         if (ad->main.usb_state != MH_STATE_NONE) {
437                 _update_usb_item(ad, MH_STATE_NONE);
438         } else {
439                 elm_check_state_set(ad->main.usb_btn, usb_state);
440         }
441
442         if (wifi_state || bt_state || usb_state) {
443                 _start_update_data_packet_usage(ad);
444         }
445
446         if (wifi_state || bt_state) {
447                 if (ad->main.help_item) {
448                         DBG("Just update help label item\n");
449                         elm_genlist_item_update(ad->main.help_item);
450                         return;
451                 } else {
452                         DBG("Add help item\n");
453                         item = elm_genlist_item_insert_after(ad->main.genlist,
454                                         ad->main.help_itc, ad, NULL,
455                                         ad->main.usb_item,
456                                         ELM_GENLIST_ITEM_NONE, NULL,
457                                         NULL);
458                         if (item == NULL) {
459                                 ERR("elm_genlist_item_insert_after NULL\n");
460                                 return;
461                         }
462                         elm_genlist_item_select_mode_set(item,
463                                         ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
464                         ad->main.help_item = item;
465                 }
466         } else {
467                 if (ad->main.help_item) {
468                         DBG("Remove help item\n");
469                         elm_object_item_del(ad->main.help_item);
470                         ad->main.help_item = NULL;
471                 }
472         }
473
474         __MOBILE_AP_FUNC_EXIT__;
475 }
476
477 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
478                                                         void *event_info)
479 {
480         __MOBILE_AP_FUNC_ENTER__;
481
482         if (data == NULL) {
483                 ERR("The param is NULL\n");
484                 return;
485         }
486
487         mh_appdata_t *ad = (mh_appdata_t *)data;
488
489         _update_wifi_item(ad, MH_STATE_PROCESS);
490
491         if (_handle_wifi_onoff_change(ad) != 0) {
492                 ERR("_handle_wifi_onoff_change is failed\n");
493                 _update_wifi_item(ad, MH_STATE_NONE);
494         }
495
496         __MOBILE_AP_FUNC_EXIT__;
497
498         return;
499 }
500
501 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
502 {
503         __MOBILE_AP_FUNC_ENTER__;
504
505         if (data == NULL) {
506                 ERR("The param is NULL\n");
507                 return;
508         }
509
510         mh_appdata_t *ad = (mh_appdata_t *)data;
511
512         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
513
514         __wifi_onoff_changed_cb(data, ad->main.wifi_btn, NULL);
515
516         __MOBILE_AP_FUNC_EXIT__;
517
518         return;
519 }
520
521 static void __select_setup_item(void *data, Evas_Object *obj, void *event_info)
522 {
523         __MOBILE_AP_FUNC_ENTER__;
524
525         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
526         mh_appdata_t *ad = (mh_appdata_t *)data;
527         int connected_wifi_clients = 0;
528         int ret = 0;
529
530         if (data == NULL) {
531                 ERR("The param is NULL\n");
532                 return;
533         }
534
535         elm_genlist_item_selected_set(item, EINA_FALSE);
536
537         if (tethering_is_enabled(ad->handle, TETHERING_TYPE_WIFI) == false) {
538                 mh_draw_wifi_setup_view(ad);
539                 return;
540         }
541
542         DBG("Wi-Fi tethering is on\n");
543         if (_get_no_of_connected_device(ad->handle, &connected_wifi_clients,
544                                 TETHERING_TYPE_WIFI) == FALSE) {
545                 ERR("Getting the number of connected device is failed\n");
546         }
547
548         if (connected_wifi_clients > 0) {
549                 _prepare_popup(MH_POP_ENTER_TO_WIFI_SETUP_CONF,
550                                 _("IDS_MOBILEAP_POP_CONNECTED_DEVICE_WILL_BE_DISCONNECTED"));
551                 _create_popup(ad);
552         } else {
553                 _update_wifi_item(ad, MH_STATE_PROCESS);
554                 ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI);
555                 if (ret != TETHERING_ERROR_NONE) {
556                         ERR("Wi-Fi tethering off is failed : %d\n", ret);
557                         _update_wifi_item(ad, MH_STATE_NONE);
558                 } else
559                         ad->main.need_recover_wifi_tethering = true;
560
561                 mh_draw_wifi_setup_view(ad);
562         }
563
564         __MOBILE_AP_FUNC_EXIT__;
565
566         return;
567 }
568
569 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
570 {
571         __MOBILE_AP_FUNC_ENTER__;
572
573         if (data == NULL) {
574                 ERR("The param is NULL\n");
575                 return;
576         }
577
578         mh_appdata_t *ad = (mh_appdata_t *)data;
579
580         _update_bt_item(ad, MH_STATE_PROCESS);
581
582         if (_handle_bt_onoff_change(ad) != 0) {
583                 ERR("_handle_bt_onoff_change is failed\n");
584                 _update_bt_item(ad, MH_STATE_NONE);
585         }
586
587         __MOBILE_AP_FUNC_EXIT__;
588
589         return;
590 }
591
592 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
593 {
594         __MOBILE_AP_FUNC_ENTER__;
595
596         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
597         mh_appdata_t *ad = (mh_appdata_t *)data;
598
599         if (data == NULL) {
600                 ERR("The param is NULL\n");
601                 return;
602         }
603
604         elm_genlist_item_selected_set(item, EINA_FALSE);
605
606         __bt_onoff_changed_cb(data, ad->main.bt_btn, NULL);
607
608         __MOBILE_AP_FUNC_EXIT__;
609
610         return;
611 }
612
613 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
614 {
615         __MOBILE_AP_FUNC_ENTER__;
616
617         if (data == NULL) {
618                 ERR("The param is NULL\n");
619                 return;
620         }
621
622         mh_appdata_t *ad = (mh_appdata_t *)data;
623
624         _update_usb_item(ad, MH_STATE_PROCESS);
625         if (_handle_usb_onoff_change(ad) != 0) {
626                 ERR("_handle_usb_onoff_change is failed\n");
627                 _update_usb_item(ad, MH_STATE_NONE);
628         }
629
630         __MOBILE_AP_FUNC_EXIT__;
631
632         return;
633 }
634
635 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
636 {
637         __MOBILE_AP_FUNC_ENTER__;
638
639         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
640         mh_appdata_t *ad = (mh_appdata_t *)data;
641
642         if (data == NULL) {
643                 ERR("The param is NULL\n");
644                 return;
645         }
646
647         elm_genlist_item_selected_set(item, EINA_FALSE);
648
649         __usb_onoff_changed_cb(data, ad->main.usb_btn, NULL);
650
651         __MOBILE_AP_FUNC_EXIT__;
652
653         return;
654 }
655
656 static void __back_btn_cb(void *data, Evas_Object *obj, void *event_info)
657 {
658         __MOBILE_AP_FUNC_ENTER__;
659
660         if (data == NULL) {
661                 ERR("The param is NULL\n");
662                 return;
663         }
664
665         mh_appdata_t *ad = (mh_appdata_t*)data;
666
667         ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
668
669         __MOBILE_AP_FUNC_EXIT__;
670 }
671
672 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
673 {
674         if (strcmp(part, "elm.text") != 0) {
675                 ERR("Invalid param\n");
676                 return NULL;
677         }
678
679         return strdup(_("IDS_MOBILEAP_MBODY_WI_FI_TETHERING"));
680 }
681
682 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
683                 const char *part)
684 {
685         __MOBILE_AP_FUNC_ENTER__;
686
687         if (data == NULL) {
688                 ERR("The param is NULL\n");
689                 return NULL;
690         }
691
692         if (strcmp(part, "elm.icon") != 0) {
693                 ERR("Invalid param\n");
694                 return NULL;
695         }
696
697         mh_appdata_t *ad = (mh_appdata_t*)data;
698         Evas_Object *btn = NULL;
699         Evas_Object *progressbar = NULL;
700
701         if (ad->main.wifi_state == MH_STATE_PROCESS) {
702                 progressbar = elm_progressbar_add(obj);
703                 if (progressbar == NULL) {
704                         ERR("progressbar is NULL\n");
705                         return NULL;
706                 }
707                 elm_object_style_set(progressbar, "list_process");
708                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
709                 elm_progressbar_pulse(progressbar, EINA_TRUE);
710                 evas_object_show(progressbar);
711                 ad->main.wifi_btn = progressbar;
712         } else {
713                 btn = elm_check_add(obj);
714                 elm_object_style_set(btn, "on&off");
715                 evas_object_show(btn);
716
717                 evas_object_pass_events_set(btn, EINA_TRUE);
718                 evas_object_propagate_events_set(btn, EINA_FALSE);
719                 elm_check_state_set(btn, ad->main.hotspot_mode &
720                                 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
721
722                 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb,
723                                 ad);
724                 ad->main.wifi_btn = btn;
725         }
726
727         __MOBILE_AP_FUNC_EXIT__;
728         return ad->main.wifi_btn;
729 }
730
731 static char *__get_setup_label(void *data, Evas_Object *obj, const char *part)
732 {
733         if (data == NULL) {
734
735                 ERR("The param is NULL\n");
736                 return NULL;
737         }
738
739         if (strcmp(part, "elm.text") != 0) {
740                 ERR("Invalid param\n");
741                 return NULL;
742         }
743
744         return strdup(_("IDS_MOBILEAP_MBODY_WI_FI_TETHERING_SETTINGS"));
745 }
746
747 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
748 {
749         if (strcmp(part, "elm.text") != 0) {
750                 ERR("Invalid param\n");
751                 return NULL;
752         }
753
754         return strdup(_("IDS_MOBILEAP_BODY_BLUETOOTH_TETHERING"));
755 }
756
757 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
758 {
759         __MOBILE_AP_FUNC_ENTER__;
760
761         mh_appdata_t *ad = (mh_appdata_t *)data;
762         Evas_Object *btn = NULL;
763         Evas_Object *progressbar = NULL;
764
765         if (strcmp(part, "elm.icon") != 0) {
766                 ERR("Invalid param\n");
767                 return NULL;
768         }
769
770         if (data == NULL) {
771                 ERR("The param is NULL\n");
772                 return NULL;
773         }
774
775         ad->main.bt_btn = NULL;
776         if (ad->main.bt_state == MH_STATE_PROCESS) {
777                 progressbar = elm_progressbar_add(obj);
778                 if (progressbar == NULL) {
779                         ERR("progressbar is NULL\n");
780                         return NULL;
781                 }
782                 elm_object_style_set(progressbar, "list_process");
783                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
784                 elm_progressbar_pulse(progressbar, EINA_TRUE);
785                 evas_object_show(progressbar);
786                 ad->main.bt_btn = progressbar;
787         } else {
788                 btn = elm_check_add(obj);
789                 if (btn == NULL) {
790                         ERR("btn is NULL\n");
791                         return NULL;
792                 }
793                 elm_object_style_set(btn, "on&off");
794                 evas_object_pass_events_set(btn, EINA_TRUE);
795                 evas_object_propagate_events_set(btn, EINA_FALSE);
796                 elm_check_state_set(btn, ad->main.hotspot_mode &
797                                 VCONFKEY_MOBILE_HOTSPOT_MODE_BT ? EINA_TRUE : EINA_FALSE);
798                 evas_object_show(btn);
799                 evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb,
800                                 ad);
801                 ad->main.bt_btn = btn;
802         }
803
804         __MOBILE_AP_FUNC_EXIT__;
805
806         return ad->main.bt_btn;
807 }
808
809 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
810 {
811         if (strcmp(part, "elm.text") != 0) {
812                 ERR("Invalid param\n");
813                 return NULL;
814         }
815
816         return strdup(_("IDS_MOBILEAP_MBODY_USB_TETHERING"));
817 }
818
819 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
820                                                         const char *part)
821 {
822         __MOBILE_AP_FUNC_ENTER__;
823
824         mh_appdata_t *ad = (mh_appdata_t *)data;
825         Evas_Object *btn = NULL;
826         Evas_Object *progressbar = NULL;
827
828         if (strcmp(part, "elm.icon") != 0) {
829                 ERR("Invalid param\n");
830                 return NULL;
831         }
832
833         if (data == NULL) {
834                 ERR("The param is NULL\n");
835                 return NULL;
836         }
837
838         ad->main.usb_btn = NULL;
839         if (ad->main.usb_state == MH_STATE_PROCESS) {
840                 progressbar = elm_progressbar_add(obj);
841                 if (progressbar == NULL) {
842                         ERR("progressbar is NULL\n");
843                         return NULL;
844                 }
845                 elm_object_style_set(progressbar, "list_process");
846                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
847                 elm_progressbar_pulse(progressbar, EINA_TRUE);
848                 evas_object_show(progressbar);
849                 ad->main.usb_btn = progressbar;
850         } else {
851                 btn = elm_check_add(obj);
852                 if (btn == NULL) {
853                         ERR("btn is NULL\n");
854                         return NULL;
855                 }
856                 elm_object_style_set(btn, "on&off");
857                 evas_object_pass_events_set(btn, EINA_TRUE);
858                 evas_object_propagate_events_set(btn, EINA_FALSE);
859                 elm_check_state_set(btn, ad->main.hotspot_mode &
860                                 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
861                 evas_object_show(btn);
862                 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb,
863                                 ad);
864                 ad->main.usb_btn = btn;
865         }
866
867         __MOBILE_AP_FUNC_EXIT__;
868
869         return ad->main.usb_btn;
870 }
871
872 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
873 {
874         __MOBILE_AP_FUNC_ENTER__;
875
876         mh_appdata_t *ad = (mh_appdata_t *)data;
877         char buf[MH_LABEL_LENGTH_MAX] = {0, };
878         char device_name[MH_LABEL_LENGTH_MAX] = {0, };
879         char passphrase[MH_LABEL_LENGTH_MAX] = {0, };
880         char *hidden = "";
881         char *ptr = NULL;
882         int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
883
884         if (strcmp(part, "elm.text") != 0) {
885                 ERR("Invalid param : %s\n", part);
886                 return NULL;
887         }
888
889         if (data == NULL) {
890                 ERR("The param is NULL\n");
891                 return NULL;
892         }
893
894         ptr = elm_entry_utf8_to_markup(ad->setup.device_name);
895         if (ptr == NULL) {
896                 ERR("elm_entry_utf8_to_markup is failed\n");
897                 return NULL;
898         }
899         g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
900         free(ptr);
901
902         if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
903                 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
904                 if (ptr == NULL) {
905                         ERR("elm_entry_utf8_to_markup is failed\n");
906                         return NULL;
907                 }
908                 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
909                 free(ptr);
910         }
911
912         wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
913
914         if (wifi_state && ad->setup.visibility == false)
915                 hidden = _("IDS_MOBILEAP_BODY_WI_FI_TETHERING_HIDDEN");
916
917         if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
918                 snprintf(buf, MH_LABEL_LENGTH_MAX,
919                                 "%s: %s<br>"
920                                 "%s: %s<br><br>"
921                                 "%s"
922                                 "%s"
923                                 "%s",
924                                 _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
925                                 device_name,
926                                 _("IDS_MOBILEAP_BODY_PASSWORD"),
927                                 passphrase,
928                                 _("IDS_MOBILEAP_BODY_THIS_PASSWORD_IS_ONLY_FOR_WI_FI_TETHERING"),
929                                 hidden[0] != '\0' ? "<br>" : "",
930                                 hidden);
931
932         } else {
933                 snprintf(buf, MH_LABEL_LENGTH_MAX,
934                                 "%s : %s%s%s",
935                                 _("IDS_MOBILEAP_BODY_DEVICE_NAME"),
936                                 device_name,
937                                 hidden[0] != '\0' ? "<br>" : "",
938                                 hidden);
939         }
940
941         __MOBILE_AP_FUNC_EXIT__;
942
943         return strdup(buf);
944 }
945
946 static char *__get_connected_device_label(void *data, Evas_Object *obj,
947                                                         const char *part)
948 {
949         if (strcmp(part, "elm.text.1") != 0 && strcmp(part, "elm.text.2") != 0) {
950                 ERR("Invalid param\n");
951                 return NULL;
952         }
953
954         if (data == NULL) {
955                 ERR("The param is NULL\n");
956                 return NULL;
957         }
958
959         mh_appdata_t *ad = (mh_appdata_t*)data;
960         char buf[MH_LABEL_LENGTH_MAX] = {0, };
961
962         if (strcmp(part, "elm.text.1") != 0)
963                 snprintf(buf, MH_LABEL_LENGTH_MAX, "%d",
964                                 ad->clients.number);
965         else if (strcmp(part, "elm.text.2") != 0)
966                 g_strlcpy(buf, _("IDS_MOBILEAP_BODY_CONNECTED_DEVICE"),
967                                 sizeof(buf));
968
969         return strdup(buf);
970 }
971
972 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
973 {
974         if (data == NULL) {
975                 ERR("The param is NULL\n");
976                 return NULL;
977         }
978
979         if (strcmp(part, "elm.text.1") != 0 && strcmp(part, "elm.text.2") != 0) {
980                 ERR("Invalid param\n");
981                 return NULL;
982         }
983
984         mh_appdata_t *ad = (mh_appdata_t*)data;
985         int sent = 0;
986         int received = 0;
987         char *sent_str = NULL;
988         char *received_str = NULL;
989         char fmt[MH_LABEL_LENGTH_MAX] = {0, };
990         char label[MH_LABEL_LENGTH_MAX] = {0, };
991
992         if (strcmp(part, "elm.text.1") != 0 ) {
993                 sent = ad->data_statistics.pdp_total_sent;
994                 received = ad->data_statistics.pdp_total_receive;
995
996                 if (sent >= MH_MB) {
997                         sent /= MH_MB;
998                         sent_str =  _("IDS_MOBILEAP_BODY_PD_MB");
999                 } else if (sent >= MH_KB) {
1000                         sent /= MH_KB;
1001                         sent_str =  _("IDS_MOBILEAP_BODY_PD_KB");
1002                 } else {
1003                         sent_str =  _("IDS_MOBILEAP_BODY_PD_BYTES");
1004                 }
1005
1006                 if (received >= MH_MB) {
1007                         received /= MH_MB;
1008                         received_str =  _("IDS_MOBILEAP_BODY_PD_MB");
1009                 } else if (received >= MH_KB) {
1010                         received /= MH_KB;
1011                         received_str =  _("IDS_MOBILEAP_BODY_PD_KB");
1012                 } else {
1013                         received_str =  _("IDS_MOBILEAP_BODY_PD_BYTES");
1014                 }
1015
1016                 snprintf(fmt, sizeof(fmt), "%s %s / %s %s",
1017                                 _("IDS_MOBILEAP_BODY_SENT_C"),
1018                                 sent_str,
1019                                 _("IDS_MOBILEAP_BODY_RECEIVED_C"),
1020                                 received_str);
1021                 snprintf(label, sizeof(label), fmt, sent, received);
1022         } else if (strcmp(part, "elm.text.2") != 0)
1023                 g_strlcpy(label, _("IDS_MOBILEAP_MBODY_DATA_USAGE"),
1024                                 sizeof(label));
1025
1026         return strdup(label);
1027 }
1028
1029 static char *__gl_get_dev_label(void *data, Evas_Object *obj, const char *part)
1030 {
1031         if (data == NULL || part == NULL) {
1032                 ERR("Invalid param\n");
1033                 return NULL;
1034         }
1035
1036         tethering_client_h client = (tethering_client_h)data;
1037         char *name = NULL;
1038
1039         if (!strcmp(part, "elm.text")) {
1040                 tethering_client_get_name(client, &name);
1041                 DBG("Device name : %s\n", name);
1042
1043                 if (!strcmp(name, "UNKNOWN")) {
1044                         return strdup(S_("IDS_COM_BODY_NO_NAME"));
1045                 }
1046
1047                 return name;
1048         }
1049
1050         return NULL;
1051 }
1052
1053 static Evas_Object *__gl_get_dev_wifi_icon(void *data, Evas_Object *obj,
1054                                                         const char *part)
1055 {
1056         Evas_Object *icon;
1057
1058         if (!strncmp(part, "elm.icon", 8)) {
1059                 icon = elm_icon_add(obj);
1060                 elm_image_file_set(icon, EDJDIR"/"TETHERING_IMAGES_EDJ, WIFI_ICON);
1061                 evas_object_size_hint_aspect_set(icon,
1062                                 EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1063                 return icon;
1064         }
1065         return NULL;
1066 }
1067
1068 static Evas_Object *__gl_get_dev_usb_icon(void *data, Evas_Object *obj,
1069                                                         const char *part)
1070 {
1071         Evas_Object *icon;
1072
1073         if (!strncmp(part, "elm.icon", 8)) {
1074                 icon = elm_icon_add(obj);
1075                 elm_image_file_set(icon, EDJDIR"/"TETHERING_IMAGES_EDJ, USB_ICON);
1076                 evas_object_size_hint_aspect_set(icon,
1077                                 EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1078                 return icon;
1079         }
1080         return NULL;
1081 }
1082
1083 static Evas_Object *__gl_get_dev_bt_icon(void *data, Evas_Object *obj,
1084                                                         const char *part)
1085 {
1086         Evas_Object *icon;
1087
1088         if (!strncmp(part, "elm.icon", 8)) {
1089                 icon = elm_icon_add(obj);
1090                 elm_image_file_set(icon, EDJDIR"/"TETHERING_IMAGES_EDJ, BT_ICON);
1091                 evas_object_size_hint_aspect_set(icon,
1092                                         EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
1093                 return icon;
1094         }
1095         return NULL;
1096 }
1097
1098 static void _gl_exp(void *data, Evas_Object *obj, void *event_info)
1099 {
1100         __MOBILE_AP_FUNC_ENTER__;
1101
1102         if (data == NULL) {
1103                 ERR("Invalid param\n");
1104                 return;
1105         }
1106
1107         mh_appdata_t *ad = (mh_appdata_t *)data;
1108
1109         ap_update_data_device(ad);
1110
1111         __MOBILE_AP_FUNC_EXIT__;
1112 }
1113
1114 static void _gl_con(void *data, Evas_Object *obj, void *event_info)
1115 {
1116         __MOBILE_AP_FUNC_ENTER__;
1117
1118         if (event_info == NULL) {
1119                 ERR("Invalid param\n");
1120                 return;
1121         }
1122
1123         mh_appdata_t *ad = (mh_appdata_t *)data;
1124
1125         elm_genlist_item_subitems_clear(ad->main.device_item);
1126
1127         __MOBILE_AP_FUNC_EXIT__;
1128 }
1129
1130 static void _gl_device_item_sel(void *data, Evas_Object *obj, void *event_info)
1131 {
1132         __MOBILE_AP_FUNC_ENTER__;
1133
1134         Elm_Object_Item *item = (Elm_Object_Item*)event_info;
1135
1136         elm_genlist_item_selected_set(item, EINA_FALSE);
1137
1138         Eina_Bool status = elm_genlist_item_expanded_get(item);
1139         DBG("+ expand status:%d\n", status);
1140
1141         elm_genlist_item_expanded_set(item, !status);
1142
1143         __MOBILE_AP_FUNC_EXIT__;
1144
1145         return;
1146 }
1147
1148 static void __free_genlist_itc(mh_appdata_t *ad)
1149 {
1150         elm_genlist_item_class_free(ad->main.sp_itc);
1151         elm_genlist_item_class_free(ad->main.wifi_itc);
1152         elm_genlist_item_class_free(ad->main.setup_itc);
1153         elm_genlist_item_class_free(ad->main.bt_itc);
1154         elm_genlist_item_class_free(ad->main.usb_itc);
1155         elm_genlist_item_class_free(ad->main.help_itc);
1156         elm_genlist_item_class_free(ad->main.device_itc);
1157         elm_genlist_item_class_free(ad->main.device0_itc);
1158         elm_genlist_item_class_free(ad->main.usage_itc);
1159         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_WIFI]);
1160         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_USB]);
1161         elm_genlist_item_class_free(ad->main.dev_itc[TETHERING_TYPE_BT]);
1162         return;
1163 }
1164
1165 static void __set_genlist_itc(mh_appdata_t *ad)
1166 {
1167         /* On, Off view's item class for genlist */
1168         ad->main.sp_itc = elm_genlist_item_class_new();
1169         ad->main.sp_itc->item_style = "dialogue/separator";
1170         ad->main.sp_itc->func.text_get = NULL;
1171         ad->main.sp_itc->func.content_get = NULL;
1172         ad->main.sp_itc->func.state_get = NULL;
1173         ad->main.sp_itc->func.del = NULL;
1174
1175         ad->main.wifi_itc = elm_genlist_item_class_new();
1176         ad->main.wifi_itc->item_style = "dialogue/1text.1icon";
1177         ad->main.wifi_itc->func.text_get = __get_wifi_label;
1178         ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1179         ad->main.wifi_itc->func.state_get = NULL;
1180         ad->main.wifi_itc->func.del = NULL;
1181
1182         ad->main.end_sp_itc = elm_genlist_item_class_new();
1183         ad->main.end_sp_itc->item_style = "dialogue/separator";
1184         ad->main.end_sp_itc->func.text_get = NULL;
1185         ad->main.end_sp_itc->func.content_get = NULL;
1186         ad->main.end_sp_itc->func.state_get = NULL;
1187         ad->main.end_sp_itc->func.del = NULL;
1188         /* End of On, Off view's item class for genlist */
1189
1190         /* Off view's item class for genlist */
1191         ad->main.setup_itc = elm_genlist_item_class_new();
1192         ad->main.setup_itc->item_style = "dialogue/1text";
1193         ad->main.setup_itc->func.text_get = __get_setup_label;
1194         ad->main.setup_itc->func.content_get = NULL;
1195         ad->main.setup_itc->func.state_get = NULL;
1196         ad->main.setup_itc->func.del = NULL;
1197
1198         ad->main.bt_itc = elm_genlist_item_class_new();
1199         ad->main.bt_itc->item_style = "dialogue/1text.1icon";
1200         ad->main.bt_itc->func.text_get = __get_bt_label;
1201         ad->main.bt_itc->func.content_get = __get_bt_icon;
1202         ad->main.bt_itc->func.state_get = NULL;
1203         ad->main.bt_itc->func.del = NULL;
1204
1205         ad->main.usb_itc = elm_genlist_item_class_new();
1206         ad->main.usb_itc->item_style = "dialogue/1text.1icon";
1207         ad->main.usb_itc->func.text_get = __get_usb_label;
1208         ad->main.usb_itc->func.content_get = __get_usb_icon;
1209         ad->main.usb_itc->func.state_get = NULL;
1210         ad->main.usb_itc->func.del = NULL;
1211
1212         ad->main.help_itc = elm_genlist_item_class_new();
1213         ad->main.help_itc->item_style = "multiline/1text";
1214         ad->main.help_itc->func.text_get = __get_help_label;
1215         ad->main.help_itc->func.content_get = NULL;
1216         ad->main.help_itc->func.state_get = NULL;
1217         ad->main.help_itc->func.del = NULL;
1218
1219         /* End of Off view's item class for genlist */
1220
1221         /* On view's item class for genlist */
1222         ad->main.device_itc = elm_genlist_item_class_new();
1223         ad->main.device_itc->item_style = "dialogue/2text.3/expandable";
1224         ad->main.device_itc->func.text_get = __get_connected_device_label;
1225         ad->main.device_itc->func.content_get = NULL;
1226         ad->main.device_itc->func.state_get = NULL;
1227         ad->main.device_itc->func.del = NULL;
1228
1229         ad->main.device0_itc = elm_genlist_item_class_new();
1230         ad->main.device0_itc->item_style = "dialogue/2text.3";
1231         ad->main.device0_itc->func.text_get = __get_connected_device_label;
1232         ad->main.device0_itc->func.content_get = NULL;
1233         ad->main.device0_itc->func.state_get = NULL;
1234         ad->main.device0_itc->func.del = NULL;
1235
1236         ad->main.usage_itc = elm_genlist_item_class_new();
1237         ad->main.usage_itc->item_style = "dialogue/2text.3";
1238         ad->main.usage_itc->func.text_get = __get_usage_label;
1239         ad->main.usage_itc->func.content_get = NULL;
1240         ad->main.usage_itc->func.state_get = NULL;
1241         ad->main.usage_itc->func.del = NULL;
1242
1243         ad->main.dev_itc[TETHERING_TYPE_WIFI] = elm_genlist_item_class_new();
1244         ad->main.dev_itc[TETHERING_TYPE_WIFI]->item_style =
1245                 "dialogue/1text.1icon/expandable2";
1246         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.text_get = __gl_get_dev_label;
1247         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.content_get = __gl_get_dev_wifi_icon;
1248         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.state_get = NULL;
1249         ad->main.dev_itc[TETHERING_TYPE_WIFI]->func.del = NULL;
1250
1251         ad->main.dev_itc[TETHERING_TYPE_USB] = elm_genlist_item_class_new();
1252         ad->main.dev_itc[TETHERING_TYPE_USB]->item_style =
1253                 "dialogue/1text.1icon/expandable2";
1254         ad->main.dev_itc[TETHERING_TYPE_USB]->func.text_get = __gl_get_dev_label;
1255         ad->main.dev_itc[TETHERING_TYPE_USB]->func.content_get = __gl_get_dev_usb_icon;
1256         ad->main.dev_itc[TETHERING_TYPE_USB]->func.state_get = NULL;
1257         ad->main.dev_itc[TETHERING_TYPE_USB]->func.del = NULL;
1258
1259         ad->main.dev_itc[TETHERING_TYPE_BT] = elm_genlist_item_class_new();
1260         ad->main.dev_itc[TETHERING_TYPE_BT]->item_style =
1261                 "dialogue/1text.1icon/expandable2";
1262         ad->main.dev_itc[TETHERING_TYPE_BT]->func.text_get = __gl_get_dev_label;
1263         ad->main.dev_itc[TETHERING_TYPE_BT]->func.content_get = __gl_get_dev_bt_icon;
1264         ad->main.dev_itc[TETHERING_TYPE_BT]->func.state_get = NULL;
1265         ad->main.dev_itc[TETHERING_TYPE_BT]->func.del = NULL;
1266         /* End of On view's item class for genlist */
1267
1268         return;
1269 }
1270
1271 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
1272 {
1273         mh_appdata_t *ad = (mh_appdata_t *)data;
1274         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1275         Evas_Object *ao;
1276         Evas_Object *btn;
1277         char str[MH_LABEL_LENGTH_MAX] = {0, };
1278         int i = 0;
1279
1280         if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.device_item)
1281                 elm_object_item_signal_emit(item, "elm,state,top", "");
1282         else if (item == ad->main.setup_item || item == ad->main.usage_item || item == ad->main.usb_item)
1283                 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1284
1285         for (i = 0; i < 4; i++) {
1286                 if (item == ad->main.sp_item[i])
1287                         elm_object_item_access_unregister(item);
1288         }
1289
1290         if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.usb_item) {
1291                 ao = elm_object_item_access_object_get(item);
1292                 btn = elm_object_item_part_content_get(item, "on&off");
1293                 snprintf(str, sizeof(str), "%s, %s", "On/off button",
1294                                 (elm_check_state_get(btn) ? "On" : "Off"));
1295                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1296         } else if (item == ad->main.setup_item) {
1297                 ao = elm_object_item_access_object_get(item);
1298                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Item");
1299         } else if (item == ad->main.device_item) {
1300                 ao = elm_object_item_access_object_get(item);
1301                 snprintf(str, sizeof(str), "%s, %s", "Expandable list",
1302                                 "Double tap to open list");
1303                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1304         }
1305
1306         if (ad->main.device_item == elm_genlist_item_parent_get(item)) {
1307                 if (ad->clients.number == elm_genlist_item_index_get(item) - 9)
1308                         elm_object_item_signal_emit(item, "elm,state,bottom", "");
1309                 else
1310                         elm_object_item_signal_emit(item, "elm,state,center", "");
1311         }
1312
1313         return;
1314 }
1315
1316 static void __create_inner_contents(mh_appdata_t *ad)
1317 {
1318         __MOBILE_AP_FUNC_ENTER__;
1319
1320         Elm_Object_Item *item = NULL;
1321         int i = 0;
1322
1323         __read_setting(ad);
1324         if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
1325                 _start_update_data_packet_usage(ad);
1326
1327         ad->main.genlist = elm_genlist_add(ad->naviframe);
1328         elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1329         evas_object_smart_callback_add(ad->main.genlist, "realized", __gl_realized, ad);
1330
1331         __set_genlist_itc(ad);
1332
1333         /* separator */
1334         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, NULL,
1335                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1336         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1337         ad->main.sp_item[i++] = item;
1338
1339         item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1340                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1341                         __select_wifi_item, ad);
1342         ad->main.wifi_item = item;
1343
1344         item = elm_genlist_item_append(ad->main.genlist, ad->main.setup_itc,
1345                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1346                         __select_setup_item, ad);
1347         ad->main.setup_item = item;
1348
1349         /* separator */
1350         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, NULL,
1351                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1352         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1353         ad->main.sp_item[i++] = item;
1354
1355         item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1356                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1357                         __select_bt_item, ad);
1358         ad->main.bt_item = item;
1359
1360         item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1361                         ad, NULL, ELM_GENLIST_ITEM_NONE,
1362                         __select_usb_item, ad);
1363         ad->main.usb_item = item;
1364
1365         if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ||
1366                         ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) {
1367                 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1368                                 ad, NULL, ELM_GENLIST_ITEM_NONE,
1369                                 NULL, NULL);
1370                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1371                 DBG("elm_genlist_item_append for help_itc : %x\n", item);
1372                 ad->main.help_item = item;
1373         }
1374
1375         /* separator */
1376         item = elm_genlist_item_append(ad->main.genlist, ad->main.sp_itc, ad,
1377                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1378         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1379         ad->main.sp_item[i++] = item;
1380
1381         item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1382                         ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1383         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1384         ad->main.usage_item = item;
1385
1386         /* Insert "Connected devices" item */
1387         ap_update_data_device(ad);
1388
1389         item = elm_genlist_item_append(ad->main.genlist, ad->main.end_sp_itc, NULL,
1390                         NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1391         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1392         ad->main.sp_item[i++] = item;
1393
1394         __MOBILE_AP_FUNC_EXIT__;
1395         return;
1396 }
1397
1398 void ap_callback_del(mh_appdata_t *ad)
1399 {
1400         __MOBILE_AP_FUNC_ENTER__;
1401
1402         if (ad == NULL) {
1403                 ERR("ad is NULL\n");
1404                 return;
1405         }
1406
1407         evas_object_smart_callback_del(ad->main.back_btn, "clicked",
1408                         __back_btn_cb);
1409         evas_object_smart_callback_del(ad->main.wifi_btn, "changed",
1410                         __wifi_onoff_changed_cb);
1411         evas_object_smart_callback_del(ad->main.bt_btn, "changed",
1412                         __bt_onoff_changed_cb);
1413         evas_object_smart_callback_del(ad->main.usb_btn, "changed",
1414                         __usb_onoff_changed_cb);
1415
1416         evas_object_smart_callback_del(ad->main.genlist, "expanded", _gl_exp);
1417         evas_object_smart_callback_del(ad->main.genlist, "contracted", _gl_con);
1418         evas_object_smart_callback_del(ad->main.genlist, "realized", __gl_realized);
1419
1420         __MOBILE_AP_FUNC_EXIT__;
1421 }
1422
1423 void ap_update_data_onoff(void* data)
1424 {
1425         __MOBILE_AP_FUNC_ENTER__;
1426
1427         __MOBILE_AP_FUNC_EXIT__;
1428 }
1429
1430 void ap_draw_contents(mh_appdata_t *ad)
1431 {
1432         __MOBILE_AP_FUNC_ENTER__;
1433
1434         __create_inner_contents(ad);
1435
1436         ad->main.back_btn = elm_button_add(ad->naviframe);
1437         if (ad->main.back_btn == NULL) {
1438                 ERR("elm_button_add is failed\n");
1439                 if (ad->main.genlist) {
1440                         evas_object_del(ad->main.genlist);
1441                         ad->main.genlist = NULL;
1442                 }
1443                 return;
1444         }
1445
1446         elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1447         evas_object_smart_callback_add(ad->main.back_btn, "clicked",
1448                         __back_btn_cb, ad);
1449         elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1450
1451         elm_naviframe_item_push(ad->naviframe,
1452                         _("IDS_MOBILEAP_BODY_TETHERING"),
1453                         ad->main.back_btn, NULL, ad->main.genlist, NULL);
1454
1455         __MOBILE_AP_FUNC_EXIT__;
1456         return;
1457 }