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