4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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
10 * http://www.tizenopensource.org/license
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.
22 #include <efl_extension.h>
23 #include <dpm/restriction.h>
25 #include "mh_view_main.h"
26 #include "mh_common_utility.h"
28 #include "mh_string.h"
30 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad);
31 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj,
33 static void __create_ctxpopup_more_button(void *data, Evas_Object *obj,
36 void _genlist_update_device_item(mh_appdata_t *ad);
37 mh_appdata_t *g_ad = NULL;
38 #define UPDATE_INTERVAL 1
40 #ifdef TIZEN_FEATURE_EMULATOR
41 static tethering_type_e updated_type = TETHERING_TYPE_ALL;
42 static tethering_type_e selected_type = TETHERING_TYPE_ALL;
43 static Eina_Bool selected_state = EINA_FALSE;
45 tethering_type_e _get_updated_type(void)
50 tethering_type_e _get_selected_type(void)
55 Eina_Bool _get_selected_state(void)
57 return selected_state;
61 void _list_connected_dev(mh_appdata_t *ap)
63 __MOBILE_AP_FUNC_ENTER__;
66 ERR("data is NULL\n");
70 _add_connected_clients(ap);
71 __MOBILE_AP_FUNC_EXIT__;
74 static bool _connected_clients_cb(tethering_client_h client, void *user_data)
76 __MOBILE_AP_FUNC_ENTER__;
78 if (user_data == NULL) {
79 ERR("user_data is NULL\n");
83 mh_appdata_t *ad = (mh_appdata_t *)user_data;
85 _append_list_client_handle(ad, client);
87 __MOBILE_AP_FUNC_EXIT__;
91 void ap_update_data_device(mh_appdata_t *ad)
93 __MOBILE_AP_FUNC_ENTER__;
96 ERR("Invalid param\n");
100 _genlist_update_device_item(ad);
102 __MOBILE_AP_FUNC_EXIT__;
105 #ifdef TETHERING_DATA_USAGE_SUPPORT
106 Eina_Bool ap_update_data_packet_usage(mh_appdata_t *ad)
109 ERR("Invalid param\n");
113 if (ad->main.usage_item)
114 elm_genlist_item_update(ad->main.usage_item);
119 Eina_Bool ap_get_data_statistics(void *data)
122 ERR("The param is NULL\n");
123 return ECORE_CALLBACK_CANCEL;
125 mh_appdata_t *ad = (mh_appdata_t *)data;
127 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
128 ad->update_statistics_handle = NULL;
129 return ECORE_CALLBACK_CANCEL;
132 /* If previous data is not updated, new data is not required */
133 if (ad->data_statistics.is_updated == false)
134 return ECORE_CALLBACK_RENEW;
136 /* Because previous data is updated, new data is required.
137 It will be returned asynchronously. */
138 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
139 ad->data_statistics.is_updated = false;
141 return ECORE_CALLBACK_RENEW;
145 Eina_Bool ap_update_device_conn_time(void * data)
148 ERR("The param is NULL\n");
149 return ECORE_CALLBACK_CANCEL;
151 mh_appdata_t *ad = (mh_appdata_t *)data;
154 #ifdef TIZEN_FEATURE_EMULATOR
155 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
156 _stop_update_device_conn_time(ad);
157 return ECORE_CALLBACK_CANCEL;
160 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
161 updated_type = TETHERING_TYPE_WIFI;
162 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_WIFI],
163 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
166 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) {
167 updated_type = TETHERING_TYPE_BT;
168 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_BT],
169 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
172 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) {
173 updated_type = TETHERING_TYPE_USB;
174 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_USB],
175 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
178 updated_type = TETHERING_TYPE_ALL;
180 return ECORE_CALLBACK_RENEW;
183 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
184 _stop_update_device_conn_time(ad);
185 __MOBILE_AP_FUNC_EXIT__;
186 return ECORE_CALLBACK_CANCEL;
189 while (count < ad->main.no_of_clients) {
190 if (ad->main.station_items[count])
191 elm_genlist_item_fields_update(ad->main.station_items[count++],
192 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
194 return ECORE_CALLBACK_RENEW;
197 void _start_update_device_conn_time(mh_appdata_t *ad)
199 __MOBILE_AP_FUNC_ENTER__;
202 ERR("Invalid param\n");
203 __MOBILE_AP_FUNC_EXIT__;
207 if (ad->update_conn_time_handle)
208 _stop_update_device_conn_time(ad);
210 ad->update_conn_time_handle = ecore_timer_add(UPDATE_INTERVAL,
211 ap_update_device_conn_time, (void *)ad);
213 __MOBILE_AP_FUNC_EXIT__;
216 void _stop_update_device_conn_time(mh_appdata_t *ad)
218 __MOBILE_AP_FUNC_ENTER__;
221 ERR("Invalid param\n");
225 if (ad->update_conn_time_handle) {
226 ecore_timer_del(ad->update_conn_time_handle);
227 ad->update_conn_time_handle = NULL;
229 __MOBILE_AP_FUNC_EXIT__;
232 #ifdef TETHERING_DATA_USAGE_SUPPORT
233 void _start_update_data_packet_usage(mh_appdata_t *ad)
235 __MOBILE_AP_FUNC_ENTER__;
238 ERR("Invalid param\n");
242 if (ad->update_statistics_handle)
243 _stop_update_data_packet_usage(ad);
245 ad->data_statistics.is_updated = false;
246 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
247 ad->update_statistics_handle = ecore_timer_add(MH_UPDATE_INTERVAL,
248 ap_get_data_statistics, (void *)ad);
250 __MOBILE_AP_FUNC_EXIT__;
254 void _stop_update_data_packet_usage(mh_appdata_t *ad)
256 __MOBILE_AP_FUNC_ENTER__;
259 ERR("Invalid param\n");
263 if (ad->update_statistics_handle) {
264 ecore_timer_del(ad->update_statistics_handle);
265 ad->data_statistics.is_updated = false;
266 ad->update_statistics_handle = NULL;
269 __MOBILE_AP_FUNC_EXIT__;
274 static void __read_setting(mh_appdata_t *ad)
276 __MOBILE_AP_FUNC_ENTER__;
279 ERR("Invalid param\n");
285 char *passphrase = NULL;
287 tethering_wifi_security_type_e type;
289 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
291 #ifdef TETHERING_DATA_USAGE_SUPPORT
292 ad->data_statistics.pdp_total_sent = 0;
293 ad->data_statistics.pdp_total_receive = 0;
294 if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
295 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
298 ret = tethering_wifi_get_ssid(ad->handle, &ssid);
299 if (ret != TETHERING_ERROR_NONE || ssid == NULL) {
300 ERR("tethering_wifi_get_ssid is failed : %d\n", ret);
303 g_strlcpy(ad->setup.device_name, ssid, sizeof(ad->setup.device_name));
306 ret = tethering_wifi_get_passphrase(ad->handle, &passphrase);
307 if (ret != TETHERING_ERROR_NONE || passphrase == NULL) {
308 ERR("tethering_wifi_get_passphrase is failed : %d\n", ret);
312 g_strlcpy(ad->setup.wifi_passphrase, passphrase,
313 sizeof(ad->setup.wifi_passphrase));
314 g_strlcpy(ad->setup.wifi_passphrase_new, passphrase,
315 sizeof(ad->setup.wifi_passphrase_new));
318 ret = tethering_wifi_get_ssid_visibility(ad->handle, &visibility);
319 if (ret != TETHERING_ERROR_NONE)
320 ERR("tethering_wifi_get_ssid_visibility is failed\n");
322 ad->setup.visibility = visibility;
323 ad->setup.visibility_new = visibility;
325 ret = tethering_wifi_get_security_type(ad->handle, &type);
326 if (ret != TETHERING_ERROR_NONE)
327 ERR("tethering_wifi_get_security_type is failed\n");
329 ad->setup.security_type = type;
330 ad->setup.security_type_new = type;
332 __MOBILE_AP_FUNC_EXIT__;
335 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
337 __MOBILE_AP_FUNC_ENTER__;
339 if (ad->main.wifi_state == wifi_state)
342 if (ad->main.wifi_state == MH_STATE_PROCESS) {
343 ad->main.wifi_state = MH_STATE_NONE;
344 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
345 } else if (ad->main.wifi_state == MH_STATE_NONE) {
346 ad->main.wifi_state = MH_STATE_PROCESS;
347 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
350 if (ad->main.wifi_item)
351 elm_genlist_item_update(ad->main.wifi_item);
353 if (ad->main.setup_item)
354 elm_object_item_signal_emit(ad->main.setup_item, "elm,state,bottom", "");
356 __MOBILE_AP_FUNC_EXIT__;
361 void _update_bt_item(mh_appdata_t *ad, int bt_state)
363 __MOBILE_AP_FUNC_ENTER__;
365 if (ad->main.bt_state == bt_state)
368 if (ad->main.bt_state == MH_STATE_PROCESS) {
369 ad->main.bt_state = MH_STATE_NONE;
370 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
371 } else if (ad->main.bt_state == MH_STATE_NONE) {
372 ad->main.bt_state = MH_STATE_PROCESS;
373 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
376 if (ad->main.bt_item)
377 elm_genlist_item_update(ad->main.bt_item);
379 __MOBILE_AP_FUNC_EXIT__;
384 void _update_usb_item(mh_appdata_t *ad, int usb_state)
386 __MOBILE_AP_FUNC_ENTER__;
388 if (ad->main.usb_state == usb_state)
391 if (ad->main.usb_state == MH_STATE_PROCESS) {
392 ad->main.usb_state = MH_STATE_NONE;
393 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
394 } else if (ad->main.usb_state == MH_STATE_NONE) {
395 ad->main.usb_state = MH_STATE_PROCESS;
396 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
399 elm_genlist_item_update(ad->main.usb_item);
401 __MOBILE_AP_FUNC_EXIT__;
406 void _genlist_update_device_item(mh_appdata_t *ad)
408 __MOBILE_AP_FUNC_ENTER__;
411 ERR("Invalid param\n");
414 unsigned int no_of_dev = 0;
415 no_of_dev = _get_list_clients_count(ad);
416 Elm_Object_Item *item = NULL;
418 if (no_of_dev == 0) {
419 if (ad->main.device_item) {
420 elm_object_item_del(ad->main.device_item);
421 ad->main.device_item = NULL;
422 _update_conn_clients(ad);
425 if (ad->main.device_item) {
426 _update_conn_clients(ad);
428 item = elm_genlist_item_append(ad->main.genlist,
429 ad->main.device_itc, ad, NULL,
430 ELM_GENLIST_ITEM_NONE, NULL, NULL);
431 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
432 ad->main.device_item = item;
433 _list_connected_dev(ad);
438 __MOBILE_AP_FUNC_EXIT__;
442 void _update_main_view(mh_appdata_t *ad, tethering_type_e type)
444 __MOBILE_AP_FUNC_ENTER__;
447 ERR("Invalid param\n");
451 int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
452 Eina_Bool wifi_state = EINA_FALSE;
453 Eina_Bool bt_state = EINA_FALSE;
454 Eina_Bool usb_state = EINA_FALSE;
455 Eina_Bool wifi_ap_state = EINA_FALSE;
456 Elm_Object_Item *item = NULL;
460 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
461 state = ad->main.hotspot_mode;
463 wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
464 bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
465 usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
466 wifi_ap_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP);
469 if (ad->main.wifi_item)
470 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
471 if (ad->main.setup_item)
472 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
473 if (ad->main.bt_item)
474 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
475 if (ad->main.usb_item)
476 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
478 if (ad->main.setup_item)
479 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
480 if (ad->main.bt_item)
481 elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE);
482 if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) {
483 if (ad->main.usb_item)
484 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
486 if (ad->main.usb_item)
487 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
491 if (wifi_state || bt_state || usb_state) {
492 #ifdef TETHERING_DATA_USAGE_SUPPORT
493 if (ad->main.usage_item == NULL) {
494 item = elm_genlist_item_insert_before(ad->main.genlist,
495 ad->main.usage_itc, ad, NULL,
497 ELM_GENLIST_ITEM_NONE, NULL, NULL);
498 elm_genlist_item_select_mode_set(item,
499 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
500 ad->main.usage_item = item;
504 no_of_dev = _get_list_clients_count(ad);
505 if (ad->main.device_item == NULL) {
506 if (no_of_dev != 0) {
507 item = elm_genlist_item_append(ad->main.genlist,
508 ad->main.device_itc, ad, NULL,
509 ELM_GENLIST_ITEM_NONE, NULL, NULL);
510 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
511 _list_connected_dev(ad);
512 _update_conn_clients(ad);
514 ad->main.device_item = item;
517 if (ad->main.device_item) {
518 elm_object_item_del(ad->main.device_item);
519 ad->main.device_item = NULL;
521 #ifdef TETHERING_DATA_USAGE_SUPPORT
522 if (ad->main.usage_item) {
523 elm_object_item_del(ad->main.usage_item);
524 ad->main.usage_item = NULL;
530 if (ad->main.help_item) {
531 elm_genlist_item_update(ad->main.help_item);
533 item = elm_genlist_item_insert_after(ad->main.genlist,
534 ad->main.help_itc, ad, NULL,
536 ELM_GENLIST_ITEM_NONE, NULL,
539 ERR("elm_genlist_item_insert_after NULL\n");
541 elm_genlist_item_select_mode_set(item,
542 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
543 ad->main.help_item = item;
547 if (ad->main.help_item) {
548 elm_object_item_del(ad->main.help_item);
549 ad->main.help_item = NULL;
554 case TETHERING_TYPE_WIFI:
555 /* Update Wi-Fi tethering on / off button */
556 if (ad->main.wifi_state != MH_STATE_NONE) {
557 _update_wifi_item(ad, MH_STATE_NONE);
559 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
561 elm_check_state_set(obj, wifi_state);
563 if (ad->main.wifi_item)
564 elm_genlist_item_update(ad->main.wifi_item);
568 case TETHERING_TYPE_BT:
569 /* Update BT tethering on / off button */
570 if (ad->main.bt_state != MH_STATE_NONE) {
571 _update_bt_item(ad, MH_STATE_NONE);
573 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
575 elm_check_state_set(obj, bt_state);
577 if (ad->main.bt_item)
578 elm_genlist_item_update(ad->main.bt_item);
582 case TETHERING_TYPE_USB:
583 /* Update USB tethering on / off button */
584 if (ad->main.usb_state != MH_STATE_NONE) {
585 _update_usb_item(ad, MH_STATE_NONE);
587 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
589 elm_check_state_set(obj, usb_state);
591 if (ad->main.usb_item)
592 elm_genlist_item_update(ad->main.usb_item);
597 DBG("Unknown tethering type : %d\n", type);
601 __MOBILE_AP_FUNC_EXIT__;
606 #ifdef TIZEN_FEATURE_EMULATOR
607 void _update_emul_main_view(mh_appdata_t *ad, tethering_type_e type, Eina_Bool state)
609 __MOBILE_AP_FUNC_ENTER__;
612 ERR("Invalid param\n");
616 Elm_Object_Item *item = NULL;
619 case TETHERING_TYPE_WIFI:
620 /* Update Wi-Fi tethering on / off button */
621 _update_wifi_item(ad, MH_STATE_NONE);
623 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
624 if (ad->main.help_item) {
625 elm_genlist_item_update(ad->main.help_item);
627 item = elm_genlist_item_insert_after(ad->main.genlist,
628 ad->main.help_itc, ad, NULL,
630 ELM_GENLIST_ITEM_NONE, NULL,
633 ERR("elm_genlist_item_insert_after NULL\n");
635 elm_genlist_item_select_mode_set(item,
636 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
637 ad->main.help_item = item;
641 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
642 if (ad->main.help_item) {
643 elm_object_item_del(ad->main.help_item);
644 ad->main.help_item = NULL;
648 if (ad->main.wifi_item)
649 elm_genlist_item_update(ad->main.wifi_item);
652 case TETHERING_TYPE_BT:
653 /* Update BT tethering on / off button */
654 _update_bt_item(ad, MH_STATE_NONE);
656 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
658 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
660 if (ad->main.bt_item)
661 elm_genlist_item_update(ad->main.bt_item);
664 case TETHERING_TYPE_USB:
665 /* Update USB tethering on / off button */
666 _update_usb_item(ad, MH_STATE_NONE);
668 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_USB;
670 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_USB;
672 if (ad->main.usb_item)
673 elm_genlist_item_update(ad->main.usb_item);
677 DBG("Unknown tethering type : %d\n", type);
681 if (ad->main.hotspot_mode && ad->main.device_item == NULL) {
682 item = elm_genlist_item_append(ad->main.genlist,
683 ad->main.device_itc, ad, NULL,
684 ELM_GENLIST_ITEM_NONE, NULL, NULL);
685 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
686 ad->main.device_item = item;
687 } else if (ad->main.hotspot_mode == 0 && ad->main.device_item) {
688 elm_object_item_del(ad->main.device_item);
689 ad->main.device_item = NULL;
692 __update_emul_clients_genlist(ad);
694 __MOBILE_AP_FUNC_EXIT__;
699 static int __is_allowed(tethering_type_e type)
702 device_policy_manager_h dpm = NULL;
704 dpm = dpm_manager_create();
706 ERR("Failed to create device policy manager!!");
711 case TETHERING_TYPE_WIFI:
712 dpm_restriction_get_wifi_hotspot_state(dpm, &state);
714 case TETHERING_TYPE_USB:
715 dpm_restriction_get_usb_tethering_state(dpm, &state);
717 case TETHERING_TYPE_BT:
718 dpm_restriction_get_bluetooth_tethering_state(dpm, &state);
724 dpm_manager_destroy(dpm);
729 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
732 __MOBILE_AP_FUNC_ENTER__;
734 if (!__is_allowed(TETHERING_TYPE_WIFI)) {
735 ERR("Wi-Fi tethering is restricted!!");
736 elm_check_state_set(obj, EINA_FALSE);
737 _create_security_restriction_noti(TETHERING_TYPE_WIFI);
742 ERR("The param is NULL\n");
746 mh_appdata_t *ad = (mh_appdata_t *)data;
748 _update_wifi_item(ad, MH_STATE_PROCESS);
749 ad->type = TETHERING_TYPE_WIFI;
750 ad->is_wifi_teth_enabling = true;
752 #ifdef TIZEN_FEATURE_EMULATOR
753 selected_type = TETHERING_TYPE_WIFI;
754 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? EINA_FALSE : EINA_TRUE;
755 DBG("type [%d] state[%d]", selected_type, selected_state);
758 if (_handle_wifi_onoff_change(ad) != 0) {
759 ERR("_handle_wifi_onoff_change is failed\n");
760 _update_wifi_item(ad, MH_STATE_NONE);
761 ad->is_wifi_teth_enabling = false;
764 #ifdef TIZEN_FEATURE_EMULATOR
765 if (_get_checkbox_status(selected_type) || !selected_state)
766 _update_emul_main_view(ad, selected_type, selected_state);
769 __MOBILE_AP_FUNC_EXIT__;
774 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
776 __MOBILE_AP_FUNC_ENTER__;
778 Evas_Object *content;
779 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
782 ERR("The param is NULL\n");
786 elm_genlist_item_selected_set(item, EINA_FALSE);
788 content = elm_object_item_part_content_get(item, "elm.icon");
789 __wifi_onoff_changed_cb(data, content, NULL);
791 __MOBILE_AP_FUNC_EXIT__;
796 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
798 __MOBILE_AP_FUNC_ENTER__;
800 if (!__is_allowed(TETHERING_TYPE_BT)) {
801 ERR("BT tethering is restricted!!");
802 elm_check_state_set(obj, EINA_FALSE);
803 _create_security_restriction_noti(TETHERING_TYPE_BT);
808 ERR("The param is NULL\n");
812 mh_appdata_t *ad = (mh_appdata_t *)data;
814 _update_bt_item(ad, MH_STATE_PROCESS);
815 ad->type = TETHERING_TYPE_BT;
816 ad->is_bt_teth_enabling = true;
818 #ifdef TIZEN_FEATURE_EMULATOR
819 selected_type = TETHERING_TYPE_BT;
820 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? EINA_FALSE : EINA_TRUE;
821 DBG("type [%d] state[%d]", selected_type, selected_state);
824 if (_handle_bt_onoff_change(ad) != 0) {
825 ERR("_handle_bt_onoff_change is failed\n");
826 _update_bt_item(ad, MH_STATE_NONE);
827 ad->is_bt_teth_enabling = false;
830 #ifdef TIZEN_FEATURE_EMULATOR
831 if (_get_checkbox_status(selected_type) || !selected_state)
832 _update_emul_main_view(ad, selected_type, selected_state);
835 __MOBILE_AP_FUNC_EXIT__;
840 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
842 __MOBILE_AP_FUNC_ENTER__;
844 Evas_Object *content;
845 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
848 ERR("The param is NULL\n");
852 elm_genlist_item_selected_set(item, EINA_FALSE);
854 content = elm_object_item_part_content_get(item, "elm.icon");
855 __bt_onoff_changed_cb(data, content, NULL);
857 __MOBILE_AP_FUNC_EXIT__;
862 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
864 __MOBILE_AP_FUNC_ENTER__;
866 if (!__is_allowed(TETHERING_TYPE_USB)) {
867 ERR("USB tethering is restricted!!");
868 elm_check_state_set(obj, EINA_FALSE);
869 _create_security_restriction_noti(TETHERING_TYPE_USB);
874 ERR("The param is NULL\n");
878 mh_appdata_t *ad = (mh_appdata_t *)data;
879 _update_usb_item(ad, MH_STATE_PROCESS);
880 ad->type = TETHERING_TYPE_USB;
881 ad->is_usb_teth_enabling = true;
883 #ifdef TIZEN_FEATURE_EMULATOR
884 selected_type = TETHERING_TYPE_USB;
885 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? EINA_FALSE : EINA_TRUE;
888 if (_handle_usb_onoff_change(ad) != 0) {
889 ERR("_handle_usb_onoff_change is failed\n");
890 _update_usb_item(ad, MH_STATE_NONE);
891 ad->is_usb_teth_enabling = false;
894 #ifdef TIZEN_FEATURE_EMULATOR
895 if (_get_checkbox_status(selected_type) || !selected_state)
896 _update_emul_main_view(ad, selected_type, selected_state);
899 __MOBILE_AP_FUNC_EXIT__;
904 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
906 __MOBILE_AP_FUNC_ENTER__;
908 Evas_Object *content;
909 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
912 ERR("The param is NULL\n");
916 elm_genlist_item_selected_set(item, EINA_FALSE);
918 content = elm_object_item_part_content_get(item, "elm.icon");
919 __usb_onoff_changed_cb(data, content, NULL);
921 __MOBILE_AP_FUNC_EXIT__;
926 static void __back_btn_cb(void *data, Elm_Object_Item *navi_item)
931 ERR("The param is NULL\n");
935 mh_appdata_t *ad = (mh_appdata_t*)data;
937 _release_list_client_handle(ad);
938 _main_callback_del(ad);
940 ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
946 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
948 if (!strcmp("elm.text", part))
949 return strdup(STR_MOBILE_HOTSPOT);
954 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
957 mh_appdata_t *ad = (mh_appdata_t*)data;
958 Evas_Object *btn = NULL;
961 ERR("The param is NULL\n");
965 if (!strcmp("elm.swallow.end", part)) {
966 if (ad->main.wifi_state == MH_STATE_PROCESS) {
967 btn = _create_progressbar(obj, "process_medium");
969 btn = elm_check_add(obj);
970 elm_object_style_set(btn, "on&off");
972 evas_object_propagate_events_set(btn, EINA_FALSE);
973 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
974 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
975 elm_check_state_set(btn, ad->main.hotspot_mode &
976 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
978 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb, ad);
979 evas_object_show(btn);
986 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
988 if (!strcmp("elm.text", part))
989 return strdup(STR_BLUETOOTH_TETH);
994 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
996 mh_appdata_t *ad = (mh_appdata_t *)data;
997 Evas_Object *btn = NULL;
1000 ERR("The param is NULL\n");
1004 if (!strcmp("elm.swallow.end", part)) {
1005 if (ad->main.bt_state == MH_STATE_PROCESS) {
1006 btn = _create_progressbar(obj, "process_medium");
1008 btn = elm_check_add(obj);
1010 ERR("btn is NULL\n");
1013 elm_object_style_set(btn, "on&off");
1014 evas_object_pass_events_set(btn, EINA_TRUE);
1015 evas_object_propagate_events_set(btn, EINA_FALSE);
1016 elm_check_state_set(btn, ad->main.hotspot_mode &
1017 VCONFKEY_MOBILE_HOTSPOT_MODE_BT ? EINA_TRUE : EINA_FALSE);
1018 evas_object_show(btn);
1019 evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb, ad);
1026 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
1028 if (!strcmp("elm.text", part))
1029 return strdup(STR_USB_TETH);
1034 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
1037 mh_appdata_t *ad = (mh_appdata_t *)data;
1038 Evas_Object *btn = NULL;
1041 ERR("The param is NULL\n");
1045 if (!strcmp("elm.swallow.end", part)) {
1046 if (ad->main.usb_state == MH_STATE_PROCESS) {
1047 btn = _create_progressbar(obj, "process_medium");
1049 btn = elm_check_add(obj);
1051 ERR("btn is NULL\n");
1054 elm_object_style_set(btn, "on&off");
1055 evas_object_pass_events_set(btn, EINA_TRUE);
1056 evas_object_propagate_events_set(btn, EINA_FALSE);
1057 elm_check_state_set(btn, ad->main.hotspot_mode &
1058 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
1059 evas_object_show(btn);
1060 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb, ad);
1067 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
1069 mh_appdata_t *ad = (mh_appdata_t *)data;
1070 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1071 char device_name[DEVICE_NAME_LENGTH_MAX] = {0, };
1072 char passphrase[WIFI_PASSPHRASE_LENGTH_MAX] = {0, };
1073 char security_type[SECURITY_TYPE_LENGTH_MAX] = {0, };
1074 char *fmt = STR_SECURITY_TYPE_PS;
1077 char *device_name_utf = NULL;
1078 int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
1081 ERR("The param is NULL\n");
1085 if (!strcmp("elm.text.multiline", part)) {
1086 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
1087 if (device_name_utf == NULL) {
1088 ERR("vconf_get_str failed \n");
1092 ptr = elm_entry_utf8_to_markup(device_name_utf);
1094 g_free(device_name_utf);
1095 ERR("elm_entry_utf8_to_markup is failed\n");
1099 g_strlcpy(ad->setup.device_name, ptr,
1100 sizeof(ad->setup.device_name));
1101 g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
1102 g_free(device_name_utf);
1106 if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
1107 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
1109 ERR("elm_entry_utf8_to_markup is failed\n");
1112 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
1115 snprintf(security_type, sizeof(security_type),
1119 wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
1121 if (wifi_state && ad->setup.visibility == false)
1122 hidden = STR_MOBILE_HOTSPOT_IS_HIDDEN;
1124 if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
1125 snprintf(buf, MH_LABEL_LENGTH_MAX,
1138 STR_ENTER_THE_PASSWORD_ON_THE_OTHER_DEVICE,
1139 hidden && hidden[0] != '\0' ? "<br>" : "",
1142 snprintf(buf, MH_LABEL_LENGTH_MAX,
1149 hidden && hidden[0] != '\0' ? "<br>" : "",
1159 static char *__get_device_label(void *data, Evas_Object *obj,
1162 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1165 ERR("The param is NULL\n");
1169 if (!strcmp("elm.text", part)) {
1170 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size>", STR_CONNECTED_DEV);
1177 #ifdef TETHERING_DATA_USAGE_SUPPORT
1178 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
1180 mh_appdata_t *ad = (mh_appdata_t*)data;
1181 unsigned long long total = 0;
1182 unsigned long long sent = 0;
1183 unsigned long long received = 0;
1185 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1186 char label[MH_LABEL_LENGTH_MAX] = {0, };
1189 ERR("The param is NULL\n");
1193 if (!strcmp("elm.text", part)) {
1194 g_strlcpy(label, STR_DATA_USAGE, sizeof(label));
1195 return strdup(label);
1196 } else if (!strcmp("elm.text.multiline", part)) {
1197 sent = ad->data_statistics.pdp_total_sent;
1198 received = ad->data_statistics.pdp_total_receive;
1200 if (sent >= MH_MB || received >= MH_MB) {
1204 total = sent + received;
1206 } else if (sent + received >= MH_MB) {
1207 total = (sent + received) / MH_MB;
1209 } else if (sent >= MH_KB || received >= MH_KB) {
1213 total = sent + received;
1215 } else if (sent + received >= MH_KB) {
1216 total = (sent + received) / MH_KB;
1219 total = sent + received;
1223 if (total > INT_MAX) {
1224 ERR("data usage overflow\n");
1227 snprintf(label, MH_LABEL_LENGTH_MAX, fmt_str, (int)total);
1228 return strdup(label);
1235 static void __set_genlist_itc(mh_appdata_t *ad)
1237 /* On, Off view's item class for genlist */
1238 ad->main.wifi_itc = elm_genlist_item_class_new();
1239 if (ad->main.wifi_itc == NULL) {
1240 ERR("elm_genlist_item_class_new failed\n");
1244 ad->main.wifi_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1245 ad->main.wifi_itc->func.text_get = __get_wifi_label;
1246 ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1247 ad->main.wifi_itc->func.state_get = NULL;
1248 ad->main.wifi_itc->func.del = NULL;
1250 /* End of On, Off view's item class for genlist */
1252 /* Off view's item class for genlist */
1253 ad->main.bt_itc = elm_genlist_item_class_new();
1254 if (ad->main.bt_itc == NULL) {
1255 ERR("elm_genlist_item_class_new failed\n");
1259 ad->main.bt_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1260 ad->main.bt_itc->func.text_get = __get_bt_label;
1261 ad->main.bt_itc->func.content_get = __get_bt_icon;
1262 ad->main.bt_itc->func.state_get = NULL;
1263 ad->main.bt_itc->func.del = NULL;
1265 ad->main.usb_itc = elm_genlist_item_class_new();
1266 if (ad->main.usb_itc == NULL) {
1267 ERR("elm_genlist_item_class_new failed\n");
1271 ad->main.usb_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1272 ad->main.usb_itc->func.text_get = __get_usb_label;
1273 ad->main.usb_itc->func.content_get = __get_usb_icon;
1274 ad->main.usb_itc->func.state_get = NULL;
1275 ad->main.usb_itc->func.del = NULL;
1277 ad->main.help_itc = elm_genlist_item_class_new();
1278 if (ad->main.help_itc == NULL) {
1279 ERR("elm_genlist_item_class_new failed\n");
1283 ad->main.help_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1284 ad->main.help_itc->func.text_get = __get_help_label;
1285 ad->main.help_itc->func.content_get = NULL;
1286 ad->main.help_itc->func.state_get = NULL;
1287 ad->main.help_itc->func.del = NULL;
1289 /* End of Off view's item class for genlist */
1292 ad->main.device_itc = elm_genlist_item_class_new();
1293 if (ad->main.device_itc == NULL) {
1294 ERR("elm_genlist_item_class_new failed\n");
1298 ad->main.device_itc->item_style = MH_GENLIST_GROUP_INDEX_STYLE;
1299 ad->main.device_itc->func.text_get = __get_device_label;
1300 ad->main.device_itc->func.content_get = NULL;
1301 ad->main.device_itc->func.state_get = NULL;
1302 ad->main.device_itc->func.del = NULL;
1304 #ifdef TETHERING_DATA_USAGE_SUPPORT
1305 ad->main.usage_itc = elm_genlist_item_class_new();
1306 if (ad->main.usage_itc == NULL) {
1307 ERR("elm_genlist_item_class_new failed\n");
1311 ad->main.usage_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1312 ad->main.usage_itc->func.text_get = __get_usage_label;
1313 ad->main.usage_itc->func.content_get = NULL;
1314 ad->main.usage_itc->func.state_get = NULL;
1315 ad->main.usage_itc->func.del = NULL;
1317 /* End of On view's item class for genlist */
1321 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
1323 if (data == NULL || event_info == NULL) {
1324 ERR("Invalid param\n");
1328 mh_appdata_t *ad = (mh_appdata_t *)data;
1329 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1332 char str[MH_LABEL_LENGTH_MAX] = {0, };
1335 if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.usb_item) {
1336 ao = elm_object_item_access_object_get(item);
1337 btn = elm_object_item_part_content_get(item, "on&off");
1338 snprintf(str, sizeof(str), "%s, %s", "On/off button",
1339 (elm_check_state_get(btn) ? "On" : "Off"));
1340 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1342 if (item == ad->main.wifi_item || item == ad->main.bt_item) {
1343 DBG("Wi-Fi or BT item : %p\n", item);
1344 elm_object_item_signal_emit(item, "elm,state,top", "");
1345 } else if (item == ad->main.usb_item) {
1347 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1349 } else if (item == ad->main.setup_item) {
1350 DBG("setup_item\n");
1351 ao = elm_object_item_access_object_get(item);
1352 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Item");
1354 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1355 } else if (item == ad->main.device_item) {
1356 DBG("device_item\n");
1357 ao = elm_object_item_access_object_get(item);
1358 snprintf(str, sizeof(str), "%s, %s", "Expandable list",
1359 "Double tap to open list");
1360 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1362 elm_object_item_signal_emit(item, "elm,state,top", "");
1363 } else if (ad->main.device_item != NULL &&
1364 ad->main.device_item == elm_genlist_item_parent_get(item)) {
1365 DBG("device_item's child\n");
1366 elm_object_item_signal_emit(item, "elm,state,center", "");
1368 for (i = 0; i < 4; i++) {
1369 if (item == ad->main.sp_item[i])
1370 elm_object_item_access_unregister(item);
1373 #ifdef TETHERING_DATA_USAGE_SUPPORT
1374 if (item == ad->main.usage_item) {
1375 DBG("usage_item\n");
1376 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1382 static void __create_inner_contents(mh_appdata_t *ad)
1384 __MOBILE_AP_FUNC_ENTER__;
1386 Elm_Object_Item *item = NULL;
1390 ad->main.genlist = elm_genlist_add(ad->naviframe);
1391 elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1392 evas_object_smart_callback_add(ad->main.genlist, "realized", __gl_realized, ad);
1394 __set_genlist_itc(ad);
1396 item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1397 ad, NULL, ELM_GENLIST_ITEM_NONE,
1398 __select_wifi_item, ad);
1399 ad->main.wifi_item = item;
1401 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
1402 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1403 ad, NULL, ELM_GENLIST_ITEM_NONE,
1405 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1406 ad->main.help_item = item;
1409 item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1410 ad, NULL, ELM_GENLIST_ITEM_NONE,
1411 __select_bt_item, ad);
1412 ad->main.bt_item = item;
1414 item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1415 ad, NULL, ELM_GENLIST_ITEM_NONE,
1416 __select_usb_item, ad);
1417 ad->main.usb_item = item;
1418 if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) {
1419 if (ad->main.usb_item)
1420 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1422 if (ad->main.usb_item)
1423 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
1425 if (ad->main.hotspot_mode & (VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI |
1426 VCONFKEY_MOBILE_HOTSPOT_MODE_USB |
1427 VCONFKEY_MOBILE_HOTSPOT_MODE_BT)) {
1428 #ifdef TETHERING_DATA_USAGE_SUPPORT
1429 item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1430 ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1431 elm_genlist_item_select_mode_set(item,
1432 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1433 ad->main.usage_item = item;
1435 /* Insert "Connected devices" item */
1436 tethering_foreach_connected_clients(ad->handle, TETHERING_TYPE_ALL,
1437 _connected_clients_cb, (void *)ad);
1439 no_of_dev = _get_list_clients_count(ad);
1440 if (no_of_dev != 0) {
1441 item = elm_genlist_item_append(ad->main.genlist,
1442 ad->main.device_itc, ad, NULL,
1443 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1444 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1445 _list_connected_dev(ad);
1446 _update_conn_clients(ad);
1448 ad->main.device_item = item;
1451 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP) {
1452 if (ad->main.wifi_item)
1453 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
1454 if (ad->main.setup_item)
1455 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
1456 if (ad->main.bt_item)
1457 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
1458 if (ad->main.usb_item)
1459 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1462 __MOBILE_AP_FUNC_EXIT__;
1466 void _main_free_genlist_itc(mh_appdata_t *ad)
1468 __MOBILE_AP_FUNC_ENTER__;
1473 mh_main_view_t *mv = &ad->main;
1475 #ifdef TETHERING_DATA_USAGE_SUPPORT
1476 _free_genlist_itc(&mv->usage_itc);
1478 _free_genlist_itc(&mv->device_itc);
1479 _free_genlist_itc(&mv->device0_itc);
1480 _free_genlist_itc(&mv->help_itc);
1481 _free_genlist_itc(&mv->usb_itc);
1482 _free_genlist_itc(&mv->bt_itc);
1483 _free_genlist_itc(&mv->setup_itc);
1484 _free_genlist_itc(&mv->wifi_itc);
1485 __MOBILE_AP_FUNC_EXIT__;
1489 void _main_callback_del(mh_appdata_t *ad)
1491 __MOBILE_AP_FUNC_ENTER__;
1494 ERR("ad is NULL\n");
1500 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
1502 evas_object_smart_callback_del(obj, "changed", __wifi_onoff_changed_cb);
1504 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
1506 evas_object_smart_callback_del(obj, "changed", __bt_onoff_changed_cb);
1508 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
1510 evas_object_smart_callback_del(obj, "changed", __usb_onoff_changed_cb);
1512 evas_object_smart_callback_del(ad->main.genlist, "realized", __gl_realized);
1514 __MOBILE_AP_FUNC_EXIT__;
1517 void _ctxpopup_more_button_callback_add(mh_appdata_t *ad)
1519 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE,
1520 __create_ctxpopup_more_button, ad);
1523 void _ctxpopup_more_button_callback_del(mh_appdata_t *ad)
1525 eext_object_event_callback_del(ad->naviframe, EEXT_CALLBACK_MORE,
1526 __create_ctxpopup_more_button);
1529 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad)
1534 __MOBILE_AP_FUNC_ENTER__;
1536 elm_win_screen_size_get(ad->win, NULL, NULL, &w, &h);
1537 pos = elm_win_rotation_get(ad->win);
1542 evas_object_move(ctx, w/2, h);
1545 evas_object_move(ctx, h/2, w);
1548 evas_object_move(ctx, h/2, w);
1551 __MOBILE_AP_FUNC_EXIT__;
1554 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
1556 __MOBILE_AP_FUNC_ENTER__;
1558 mh_appdata_t *ad = (mh_appdata_t *)data;
1559 Evas_Object *ctx = ad->ctxpopup;
1561 __ctx_move_more_ctxpopup(ctx, ad);
1562 evas_object_show(ctx);
1564 __MOBILE_AP_FUNC_EXIT__;
1567 static void __dismissed_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event)
1569 __MOBILE_AP_FUNC_ENTER__;
1571 mh_appdata_t *ad = (mh_appdata_t *)data;
1572 Evas_Object *ctx = ad->ctxpopup;
1573 evas_object_del(ctx);
1576 __MOBILE_AP_FUNC_EXIT__;
1579 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj,
1582 Evas_Object *navi = (Evas_Object *)data;
1583 Evas_Object *ctx = obj;
1586 ERR("data is null\n");
1589 __MOBILE_AP_FUNC_ENTER__;
1591 evas_object_smart_callback_del(ctx, "dismissed",
1592 __dismissed_more_ctxpopup_cb);
1593 evas_object_smart_callback_del(elm_object_top_widget_get(ctx),
1594 "rotation,changed", __rotate_more_ctxpopup_cb);
1595 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
1596 __ctx_delete_more_ctxpopup_cb, navi);
1597 __MOBILE_AP_FUNC_EXIT__;
1600 static void __gl_configure_wifi_tethering(void *data, Evas_Object *obj, void *event_info)
1602 __MOBILE_AP_FUNC_ENTER__;
1605 ERR("The param is NULL\n");
1608 mh_appdata_t *ad = (mh_appdata_t *)data;
1610 evas_object_del(ad->ctxpopup);
1611 ad->ctxpopup = NULL;
1613 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1614 _ctxpopup_more_button_callback_del(ad);
1615 mh_draw_wifi_setup_view(ad);
1617 __MOBILE_AP_FUNC_EXIT__;
1622 static void __create_ctxpopup_more_button(void *data, Evas_Object *obj,
1625 mh_appdata_t *ad = (mh_appdata_t *)data;
1626 Evas_Object *ctxpopup = NULL;
1629 ERR("ad is null\n");
1632 __MOBILE_AP_FUNC_ENTER__;
1634 ctxpopup = elm_ctxpopup_add(ad->win);
1635 elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
1637 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
1638 eext_ctxpopup_back_cb, ad);
1639 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE,
1640 eext_ctxpopup_back_cb, ad);
1641 elm_object_style_set(ctxpopup, "more/default");
1642 evas_object_smart_callback_add(ctxpopup, "dismissed",
1643 __dismissed_more_ctxpopup_cb, ad);
1644 evas_object_smart_callback_add(elm_object_top_widget_get(ctxpopup), "rotation,changed",
1645 __rotate_more_ctxpopup_cb, ad);
1646 evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL,
1647 __ctx_delete_more_ctxpopup_cb, ad->naviframe);
1649 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
1650 ELM_CTXPOPUP_DIRECTION_DOWN,
1651 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
1652 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
1654 __ctx_move_more_ctxpopup(ctxpopup, ad);
1655 elm_ctxpopup_item_append(ctxpopup, STR_CONFIGURE_MOBILE_HOTSPOT,
1656 NULL, __gl_configure_wifi_tethering, ad);
1658 evas_object_show(ctxpopup);
1660 ad->ctxpopup = ctxpopup;
1662 __MOBILE_AP_FUNC_EXIT__;
1666 void _main_draw_contents(mh_appdata_t *ad)
1670 Elm_Object_Item *navi_item;
1672 __create_inner_contents(ad);
1674 ad->main.back_btn = elm_button_add(ad->naviframe);
1675 if (ad->main.back_btn == NULL) {
1676 ERR("elm_button_add is failed\n");
1677 if (ad->main.genlist) {
1678 evas_object_del(ad->main.genlist);
1679 ad->main.genlist = NULL;
1683 elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1685 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_BACK,
1686 eext_naviframe_back_cb, NULL);
1687 _ctxpopup_more_button_callback_add(ad);
1688 evas_object_smart_callback_add(ad->main.back_btn, "clicked", (Evas_Smart_Cb)__back_btn_cb, (void *)ad);
1689 elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1691 navi_item = elm_naviframe_item_push(ad->naviframe, IDS_TETH,
1692 ad->main.back_btn, NULL, ad->main.genlist, NULL);
1693 elm_object_item_domain_text_translatable_set(navi_item, PKGNAME, EINA_TRUE);
1695 elm_naviframe_item_pop_cb_set(navi_item, (Elm_Naviframe_Item_Pop_Cb)__back_btn_cb, (void *)ad);
1696 ad->navi_item = navi_item;