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