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