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 static Eina_Bool rotate_flag = EINA_FALSE;
38 void _genlist_update_device_item(mh_appdata_t *ad);
39 mh_appdata_t *g_ad = NULL;
40 #define UPDATE_INTERVAL 1
42 #ifdef TIZEN_FEATURE_EMULATOR
43 static tethering_type_e updated_type = TETHERING_TYPE_ALL;
44 static tethering_type_e selected_type = TETHERING_TYPE_ALL;
45 static Eina_Bool selected_state = EINA_FALSE;
47 tethering_type_e _get_updated_type(void)
52 tethering_type_e _get_selected_type(void)
57 Eina_Bool _get_selected_state(void)
59 return selected_state;
63 void _list_connected_dev(mh_appdata_t *ap)
65 __MOBILE_AP_FUNC_ENTER__;
68 ERR("data is NULL\n");
72 _add_connected_clients(ap);
73 __MOBILE_AP_FUNC_EXIT__;
76 static bool _connected_clients_cb(tethering_client_h client, void *user_data)
78 __MOBILE_AP_FUNC_ENTER__;
80 if (user_data == NULL) {
81 ERR("user_data is NULL\n");
85 mh_appdata_t *ad = (mh_appdata_t *)user_data;
87 _append_list_client_handle(ad, client);
89 __MOBILE_AP_FUNC_EXIT__;
93 void ap_update_data_device(mh_appdata_t *ad)
95 __MOBILE_AP_FUNC_ENTER__;
98 ERR("Invalid param\n");
102 _genlist_update_device_item(ad);
104 __MOBILE_AP_FUNC_EXIT__;
107 #ifdef TETHERING_DATA_USAGE_SUPPORT
108 Eina_Bool ap_update_data_packet_usage(mh_appdata_t *ad)
111 ERR("Invalid param\n");
115 if (ad->main.usage_item)
116 elm_genlist_item_update(ad->main.usage_item);
121 Eina_Bool ap_get_data_statistics(void *data)
124 ERR("The param is NULL\n");
125 return ECORE_CALLBACK_CANCEL;
127 mh_appdata_t *ad = (mh_appdata_t *)data;
129 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
130 ad->update_statistics_handle = NULL;
131 return ECORE_CALLBACK_CANCEL;
134 /* If previous data is not updated, new data is not required */
135 if (ad->data_statistics.is_updated == false)
136 return ECORE_CALLBACK_RENEW;
138 /* Because previous data is updated, new data is required.
139 It will be returned asynchronously. */
140 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
141 ad->data_statistics.is_updated = false;
143 return ECORE_CALLBACK_RENEW;
147 Eina_Bool ap_update_device_conn_time(void * data)
150 ERR("The param is NULL\n");
151 return ECORE_CALLBACK_CANCEL;
153 mh_appdata_t *ad = (mh_appdata_t *)data;
156 #ifdef TIZEN_FEATURE_EMULATOR
157 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
158 _stop_update_device_conn_time(ad);
159 return ECORE_CALLBACK_CANCEL;
162 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
163 updated_type = TETHERING_TYPE_WIFI;
164 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_WIFI],
165 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
168 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) {
169 updated_type = TETHERING_TYPE_BT;
170 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_BT],
171 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
174 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) {
175 updated_type = TETHERING_TYPE_USB;
176 elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_USB],
177 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
180 updated_type = TETHERING_TYPE_ALL;
182 return ECORE_CALLBACK_RENEW;
185 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
186 _stop_update_device_conn_time(ad);
187 __MOBILE_AP_FUNC_EXIT__;
188 return ECORE_CALLBACK_CANCEL;
191 while (count < ad->main.no_of_clients) {
192 if (ad->main.station_items[count])
193 elm_genlist_item_fields_update(ad->main.station_items[count++],
194 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
196 return ECORE_CALLBACK_RENEW;
199 void _start_update_device_conn_time(mh_appdata_t *ad)
201 __MOBILE_AP_FUNC_ENTER__;
204 ERR("Invalid param\n");
205 __MOBILE_AP_FUNC_EXIT__;
209 if (ad->update_conn_time_handle)
210 _stop_update_device_conn_time(ad);
212 ad->update_conn_time_handle = ecore_timer_add(UPDATE_INTERVAL,
213 ap_update_device_conn_time, (void *)ad);
215 __MOBILE_AP_FUNC_EXIT__;
218 void _stop_update_device_conn_time(mh_appdata_t *ad)
220 __MOBILE_AP_FUNC_ENTER__;
223 ERR("Invalid param\n");
227 if (ad->update_conn_time_handle) {
228 ecore_timer_del(ad->update_conn_time_handle);
229 ad->update_conn_time_handle = NULL;
231 __MOBILE_AP_FUNC_EXIT__;
234 #ifdef TETHERING_DATA_USAGE_SUPPORT
235 void _start_update_data_packet_usage(mh_appdata_t *ad)
237 __MOBILE_AP_FUNC_ENTER__;
240 ERR("Invalid param\n");
244 if (ad->update_statistics_handle)
245 _stop_update_data_packet_usage(ad);
247 ad->data_statistics.is_updated = false;
248 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
249 ad->update_statistics_handle = ecore_timer_add(MH_UPDATE_INTERVAL,
250 ap_get_data_statistics, (void *)ad);
252 __MOBILE_AP_FUNC_EXIT__;
256 void _stop_update_data_packet_usage(mh_appdata_t *ad)
258 __MOBILE_AP_FUNC_ENTER__;
261 ERR("Invalid param\n");
265 if (ad->update_statistics_handle) {
266 ecore_timer_del(ad->update_statistics_handle);
267 ad->data_statistics.is_updated = false;
268 ad->update_statistics_handle = NULL;
271 __MOBILE_AP_FUNC_EXIT__;
276 static void __read_setting(mh_appdata_t *ad)
278 __MOBILE_AP_FUNC_ENTER__;
281 ERR("Invalid param\n");
287 char *passphrase = NULL;
289 tethering_wifi_security_type_e type;
291 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
293 #ifdef TETHERING_DATA_USAGE_SUPPORT
294 ad->data_statistics.pdp_total_sent = 0;
295 ad->data_statistics.pdp_total_receive = 0;
296 if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
297 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
300 ret = tethering_wifi_get_ssid(ad->handle, &ssid);
301 if (ret != TETHERING_ERROR_NONE || ssid == NULL) {
302 ERR("tethering_wifi_get_ssid is failed : %d\n", ret);
305 g_strlcpy(ad->setup.device_name, ssid, sizeof(ad->setup.device_name));
308 ret = tethering_wifi_get_passphrase(ad->handle, &passphrase);
309 if (ret != TETHERING_ERROR_NONE || passphrase == NULL) {
310 ERR("tethering_wifi_get_passphrase is failed : %d\n", ret);
314 g_strlcpy(ad->setup.wifi_passphrase, passphrase,
315 sizeof(ad->setup.wifi_passphrase));
316 g_strlcpy(ad->setup.wifi_passphrase_new, passphrase,
317 sizeof(ad->setup.wifi_passphrase_new));
320 ret = tethering_wifi_get_ssid_visibility(ad->handle, &visibility);
321 if (ret != TETHERING_ERROR_NONE)
322 ERR("tethering_wifi_get_ssid_visibility is failed\n");
324 ad->setup.visibility = visibility;
325 ad->setup.visibility_new = visibility;
327 ret = tethering_wifi_get_security_type(ad->handle, &type);
328 if (ret != TETHERING_ERROR_NONE)
329 ERR("tethering_wifi_get_security_type is failed\n");
331 ad->setup.security_type = type;
332 ad->setup.security_type_new = type;
334 __MOBILE_AP_FUNC_EXIT__;
337 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
339 __MOBILE_AP_FUNC_ENTER__;
341 if (ad->main.wifi_state == wifi_state)
344 if (ad->main.wifi_state == MH_STATE_PROCESS) {
345 ad->main.wifi_state = MH_STATE_NONE;
346 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
347 } else if (ad->main.wifi_state == MH_STATE_NONE) {
348 ad->main.wifi_state = MH_STATE_PROCESS;
349 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
352 if (ad->main.wifi_item)
353 elm_genlist_item_update(ad->main.wifi_item);
355 if (ad->main.setup_item)
356 elm_object_item_signal_emit(ad->main.setup_item, "elm,state,bottom", "");
358 __MOBILE_AP_FUNC_EXIT__;
363 void _update_bt_item(mh_appdata_t *ad, int bt_state)
365 __MOBILE_AP_FUNC_ENTER__;
367 if (ad->main.bt_state == bt_state)
370 if (ad->main.bt_state == MH_STATE_PROCESS) {
371 ad->main.bt_state = MH_STATE_NONE;
372 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
373 } else if (ad->main.bt_state == MH_STATE_NONE) {
374 ad->main.bt_state = MH_STATE_PROCESS;
375 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
378 if (ad->main.bt_item)
379 elm_genlist_item_update(ad->main.bt_item);
381 __MOBILE_AP_FUNC_EXIT__;
386 void _update_usb_item(mh_appdata_t *ad, int usb_state)
388 __MOBILE_AP_FUNC_ENTER__;
390 if (ad->main.usb_state == usb_state)
393 if (ad->main.usb_state == MH_STATE_PROCESS) {
394 ad->main.usb_state = MH_STATE_NONE;
395 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
396 } else if (ad->main.usb_state == MH_STATE_NONE) {
397 ad->main.usb_state = MH_STATE_PROCESS;
398 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
401 elm_genlist_item_update(ad->main.usb_item);
403 __MOBILE_AP_FUNC_EXIT__;
408 void _genlist_update_device_item(mh_appdata_t *ad)
410 __MOBILE_AP_FUNC_ENTER__;
413 ERR("Invalid param\n");
416 unsigned int no_of_dev = 0;
417 no_of_dev = _get_list_clients_count(ad);
418 Elm_Object_Item *item = NULL;
420 if (no_of_dev == 0) {
421 if (ad->main.device_item) {
422 elm_object_item_del(ad->main.device_item);
423 ad->main.device_item = NULL;
424 _update_conn_clients(ad);
427 if (ad->main.device_item) {
428 _update_conn_clients(ad);
430 item = elm_genlist_item_append(ad->main.genlist,
431 ad->main.device_itc, ad, NULL,
432 ELM_GENLIST_ITEM_NONE, NULL, NULL);
433 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
434 ad->main.device_item = item;
435 _list_connected_dev(ad);
440 __MOBILE_AP_FUNC_EXIT__;
444 void _update_main_view(mh_appdata_t *ad, tethering_type_e type)
446 __MOBILE_AP_FUNC_ENTER__;
449 ERR("Invalid param\n");
453 int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
454 Eina_Bool wifi_state = EINA_FALSE;
455 Eina_Bool bt_state = EINA_FALSE;
456 Eina_Bool usb_state = EINA_FALSE;
457 Eina_Bool wifi_ap_state = EINA_FALSE;
458 Elm_Object_Item *item = NULL;
462 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
463 state = ad->main.hotspot_mode;
465 wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
466 bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
467 usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
468 wifi_ap_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP);
471 if (ad->main.wifi_item)
472 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
473 if (ad->main.setup_item)
474 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
475 if (ad->main.bt_item)
476 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
477 if (ad->main.usb_item)
478 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
480 if (ad->main.setup_item)
481 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
482 if (ad->main.bt_item)
483 elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE);
484 if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) {
485 if (ad->main.usb_item)
486 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
488 if (ad->main.usb_item)
489 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
493 if (wifi_state || bt_state || usb_state) {
494 #ifdef TETHERING_DATA_USAGE_SUPPORT
495 if (ad->main.usage_item == NULL) {
496 item = elm_genlist_item_insert_before(ad->main.genlist,
497 ad->main.usage_itc, ad, NULL,
499 ELM_GENLIST_ITEM_NONE, NULL, NULL);
500 elm_genlist_item_select_mode_set(item,
501 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
502 ad->main.usage_item = item;
506 no_of_dev = _get_list_clients_count(ad);
507 if (ad->main.device_item == NULL) {
508 if (no_of_dev != 0) {
509 item = elm_genlist_item_append(ad->main.genlist,
510 ad->main.device_itc, ad, NULL,
511 ELM_GENLIST_ITEM_NONE, NULL, NULL);
512 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
513 _list_connected_dev(ad);
514 _update_conn_clients(ad);
516 ad->main.device_item = item;
519 if (ad->main.device_item) {
520 elm_object_item_del(ad->main.device_item);
521 ad->main.device_item = NULL;
523 #ifdef TETHERING_DATA_USAGE_SUPPORT
524 if (ad->main.usage_item) {
525 elm_object_item_del(ad->main.usage_item);
526 ad->main.usage_item = NULL;
532 if (ad->main.help_item) {
533 elm_genlist_item_update(ad->main.help_item);
535 item = elm_genlist_item_insert_after(ad->main.genlist,
536 ad->main.help_itc, ad, NULL,
538 ELM_GENLIST_ITEM_NONE, NULL,
541 ERR("elm_genlist_item_insert_after NULL\n");
543 elm_genlist_item_select_mode_set(item,
544 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
545 ad->main.help_item = item;
549 if (ad->main.help_item) {
550 elm_object_item_del(ad->main.help_item);
551 ad->main.help_item = NULL;
556 case TETHERING_TYPE_WIFI:
557 /* Update Wi-Fi tethering on / off button */
558 if (ad->main.wifi_state != MH_STATE_NONE) {
559 _update_wifi_item(ad, MH_STATE_NONE);
561 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
563 elm_check_state_set(obj, wifi_state);
565 if (ad->main.wifi_item)
566 elm_genlist_item_update(ad->main.wifi_item);
570 case TETHERING_TYPE_BT:
571 /* Update BT tethering on / off button */
572 if (ad->main.bt_state != MH_STATE_NONE) {
573 _update_bt_item(ad, MH_STATE_NONE);
575 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
577 elm_check_state_set(obj, bt_state);
579 if (ad->main.bt_item)
580 elm_genlist_item_update(ad->main.bt_item);
584 case TETHERING_TYPE_USB:
585 /* Update USB tethering on / off button */
586 if (ad->main.usb_state != MH_STATE_NONE) {
587 _update_usb_item(ad, MH_STATE_NONE);
589 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
591 elm_check_state_set(obj, usb_state);
593 if (ad->main.usb_item)
594 elm_genlist_item_update(ad->main.usb_item);
599 DBG("Unknown tethering type : %d\n", type);
603 __MOBILE_AP_FUNC_EXIT__;
608 #ifdef TIZEN_FEATURE_EMULATOR
609 void _update_emul_main_view(mh_appdata_t *ad, tethering_type_e type, Eina_Bool state)
611 __MOBILE_AP_FUNC_ENTER__;
614 ERR("Invalid param\n");
618 Elm_Object_Item *item = NULL;
621 case TETHERING_TYPE_WIFI:
622 /* Update Wi-Fi tethering on / off button */
623 _update_wifi_item(ad, MH_STATE_NONE);
625 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
626 if (ad->main.help_item) {
627 elm_genlist_item_update(ad->main.help_item);
629 item = elm_genlist_item_insert_after(ad->main.genlist,
630 ad->main.help_itc, ad, NULL,
632 ELM_GENLIST_ITEM_NONE, NULL,
635 ERR("elm_genlist_item_insert_after NULL\n");
637 elm_genlist_item_select_mode_set(item,
638 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
639 ad->main.help_item = item;
643 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
644 if (ad->main.help_item) {
645 elm_object_item_del(ad->main.help_item);
646 ad->main.help_item = NULL;
650 if (ad->main.wifi_item)
651 elm_genlist_item_update(ad->main.wifi_item);
654 case TETHERING_TYPE_BT:
655 /* Update BT tethering on / off button */
656 _update_bt_item(ad, MH_STATE_NONE);
658 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
660 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_BT;
662 if (ad->main.bt_item)
663 elm_genlist_item_update(ad->main.bt_item);
666 case TETHERING_TYPE_USB:
667 /* Update USB tethering on / off button */
668 _update_usb_item(ad, MH_STATE_NONE);
670 ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_USB;
672 ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_USB;
674 if (ad->main.usb_item)
675 elm_genlist_item_update(ad->main.usb_item);
679 DBG("Unknown tethering type : %d\n", type);
683 if (ad->main.hotspot_mode && ad->main.device_item == NULL) {
684 item = elm_genlist_item_append(ad->main.genlist,
685 ad->main.device_itc, ad, NULL,
686 ELM_GENLIST_ITEM_NONE, NULL, NULL);
687 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
688 ad->main.device_item = item;
689 } else if (ad->main.hotspot_mode == 0 && ad->main.device_item) {
690 elm_object_item_del(ad->main.device_item);
691 ad->main.device_item = NULL;
694 __update_emul_clients_genlist(ad);
696 __MOBILE_AP_FUNC_EXIT__;
701 static int __is_allowed(tethering_type_e type)
704 device_policy_manager_h dpm = NULL;
706 dpm = dpm_manager_create();
708 ERR("Failed to create device policy manager!!");
713 case TETHERING_TYPE_WIFI:
714 dpm_restriction_get_wifi_hotspot_state(dpm, &state);
716 case TETHERING_TYPE_USB:
717 dpm_restriction_get_usb_tethering_state(dpm, &state);
719 case TETHERING_TYPE_BT:
720 dpm_restriction_get_bluetooth_tethering_state(dpm, &state);
726 dpm_manager_destroy(dpm);
731 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
734 __MOBILE_AP_FUNC_ENTER__;
736 if (!__is_allowed(TETHERING_TYPE_WIFI)) {
737 ERR("Wi-Fi tethering is restricted!!");
738 elm_check_state_set(obj, EINA_FALSE);
739 _create_security_restriction_noti(TETHERING_TYPE_WIFI);
744 ERR("The param is NULL\n");
748 mh_appdata_t *ad = (mh_appdata_t *)data;
750 _update_wifi_item(ad, MH_STATE_PROCESS);
751 ad->type = TETHERING_TYPE_WIFI;
752 ad->is_wifi_teth_enabling = true;
754 #ifdef TIZEN_FEATURE_EMULATOR
755 selected_type = TETHERING_TYPE_WIFI;
756 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? EINA_FALSE : EINA_TRUE;
757 DBG("type [%d] state[%d]", selected_type, selected_state);
760 if (_handle_wifi_onoff_change(ad) != 0) {
761 ERR("_handle_wifi_onoff_change is failed\n");
762 _update_wifi_item(ad, MH_STATE_NONE);
763 ad->is_wifi_teth_enabling = false;
766 #ifdef TIZEN_FEATURE_EMULATOR
767 if (_get_checkbox_status(selected_type) || !selected_state)
768 _update_emul_main_view(ad, selected_type, selected_state);
771 __MOBILE_AP_FUNC_EXIT__;
776 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
778 __MOBILE_AP_FUNC_ENTER__;
780 Evas_Object *content;
781 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
784 ERR("The param is NULL\n");
788 elm_genlist_item_selected_set(item, EINA_FALSE);
790 content = elm_object_item_part_content_get(item, "elm.icon");
791 __wifi_onoff_changed_cb(data, content, NULL);
793 __MOBILE_AP_FUNC_EXIT__;
798 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
800 __MOBILE_AP_FUNC_ENTER__;
802 if (!__is_allowed(TETHERING_TYPE_BT)) {
803 ERR("BT tethering is restricted!!");
804 elm_check_state_set(obj, EINA_FALSE);
805 _create_security_restriction_noti(TETHERING_TYPE_BT);
810 ERR("The param is NULL\n");
814 mh_appdata_t *ad = (mh_appdata_t *)data;
816 _update_bt_item(ad, MH_STATE_PROCESS);
817 ad->type = TETHERING_TYPE_BT;
818 ad->is_bt_teth_enabling = true;
820 #ifdef TIZEN_FEATURE_EMULATOR
821 selected_type = TETHERING_TYPE_BT;
822 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? EINA_FALSE : EINA_TRUE;
823 DBG("type [%d] state[%d]", selected_type, selected_state);
826 if (_handle_bt_onoff_change(ad) != 0) {
827 ERR("_handle_bt_onoff_change is failed\n");
828 _update_bt_item(ad, MH_STATE_NONE);
829 ad->is_bt_teth_enabling = false;
832 #ifdef TIZEN_FEATURE_EMULATOR
833 if (_get_checkbox_status(selected_type) || !selected_state)
834 _update_emul_main_view(ad, selected_type, selected_state);
837 __MOBILE_AP_FUNC_EXIT__;
842 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
844 __MOBILE_AP_FUNC_ENTER__;
846 Evas_Object *content;
847 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
850 ERR("The param is NULL\n");
854 elm_genlist_item_selected_set(item, EINA_FALSE);
856 content = elm_object_item_part_content_get(item, "elm.icon");
857 __bt_onoff_changed_cb(data, content, NULL);
859 __MOBILE_AP_FUNC_EXIT__;
864 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
866 __MOBILE_AP_FUNC_ENTER__;
868 if (!__is_allowed(TETHERING_TYPE_USB)) {
869 ERR("USB tethering is restricted!!");
870 elm_check_state_set(obj, EINA_FALSE);
871 _create_security_restriction_noti(TETHERING_TYPE_USB);
876 ERR("The param is NULL\n");
880 mh_appdata_t *ad = (mh_appdata_t *)data;
881 _update_usb_item(ad, MH_STATE_PROCESS);
882 ad->type = TETHERING_TYPE_USB;
883 ad->is_usb_teth_enabling = true;
885 #ifdef TIZEN_FEATURE_EMULATOR
886 selected_type = TETHERING_TYPE_USB;
887 selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? EINA_FALSE : EINA_TRUE;
890 if (_handle_usb_onoff_change(ad) != 0) {
891 ERR("_handle_usb_onoff_change is failed\n");
892 _update_usb_item(ad, MH_STATE_NONE);
893 ad->is_usb_teth_enabling = false;
896 #ifdef TIZEN_FEATURE_EMULATOR
897 if (_get_checkbox_status(selected_type) || !selected_state)
898 _update_emul_main_view(ad, selected_type, selected_state);
901 __MOBILE_AP_FUNC_EXIT__;
906 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
908 __MOBILE_AP_FUNC_ENTER__;
910 Evas_Object *content;
911 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
914 ERR("The param is NULL\n");
918 elm_genlist_item_selected_set(item, EINA_FALSE);
920 content = elm_object_item_part_content_get(item, "elm.icon");
921 __usb_onoff_changed_cb(data, content, NULL);
923 __MOBILE_AP_FUNC_EXIT__;
928 static void __back_btn_cb(void *data, Elm_Object_Item *navi_item)
933 ERR("The param is NULL\n");
937 mh_appdata_t *ad = (mh_appdata_t*)data;
939 _release_list_client_handle(ad);
940 _main_callback_del(ad);
942 ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
948 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
950 if (!strcmp("elm.text", part))
951 return strdup(STR_MOBILE_HOTSPOT);
956 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
959 mh_appdata_t *ad = (mh_appdata_t*)data;
960 Evas_Object *btn = NULL;
963 ERR("The param is NULL\n");
967 if (!strcmp("elm.swallow.end", part)) {
968 if (ad->main.wifi_state == MH_STATE_PROCESS) {
969 btn = _create_progressbar(obj, "process_medium");
971 btn = elm_check_add(obj);
972 elm_object_style_set(btn, "on&off");
974 evas_object_propagate_events_set(btn, EINA_FALSE);
975 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
976 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
977 elm_check_state_set(btn, ad->main.hotspot_mode &
978 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
980 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb, ad);
981 evas_object_show(btn);
988 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
990 if (!strcmp("elm.text", part))
991 return strdup(STR_BLUETOOTH_TETH);
996 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
998 mh_appdata_t *ad = (mh_appdata_t *)data;
999 Evas_Object *btn = NULL;
1002 ERR("The param is NULL\n");
1006 if (!strcmp("elm.swallow.end", part)) {
1007 if (ad->main.bt_state == MH_STATE_PROCESS) {
1008 btn = _create_progressbar(obj, "process_medium");
1010 btn = elm_check_add(obj);
1012 ERR("btn is NULL\n");
1015 elm_object_style_set(btn, "on&off");
1016 evas_object_pass_events_set(btn, EINA_TRUE);
1017 evas_object_propagate_events_set(btn, EINA_FALSE);
1018 elm_check_state_set(btn, ad->main.hotspot_mode &
1019 VCONFKEY_MOBILE_HOTSPOT_MODE_BT ? EINA_TRUE : EINA_FALSE);
1020 evas_object_show(btn);
1021 evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb, ad);
1028 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
1030 if (!strcmp("elm.text", part))
1031 return strdup(STR_USB_TETH);
1036 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
1039 mh_appdata_t *ad = (mh_appdata_t *)data;
1040 Evas_Object *btn = NULL;
1043 ERR("The param is NULL\n");
1047 if (!strcmp("elm.swallow.end", part)) {
1048 if (ad->main.usb_state == MH_STATE_PROCESS) {
1049 btn = _create_progressbar(obj, "process_medium");
1051 btn = elm_check_add(obj);
1053 ERR("btn is NULL\n");
1056 elm_object_style_set(btn, "on&off");
1057 evas_object_pass_events_set(btn, EINA_TRUE);
1058 evas_object_propagate_events_set(btn, EINA_FALSE);
1059 elm_check_state_set(btn, ad->main.hotspot_mode &
1060 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
1061 evas_object_show(btn);
1062 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb, ad);
1069 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
1071 mh_appdata_t *ad = (mh_appdata_t *)data;
1072 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1073 char device_name[MH_LABEL_LENGTH_MAX] = {0, };
1074 char passphrase[MH_LABEL_LENGTH_MAX] = {0, };
1075 char security_type[MH_LABEL_LENGTH_MAX] = {0, };
1076 char *fmt = STR_SECURITY_TYPE_PS;
1079 char *device_name_utf = NULL;
1080 int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
1083 ERR("The param is NULL\n");
1087 if (!strcmp("elm.text.multiline", part)) {
1088 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
1089 if (device_name_utf == NULL) {
1090 ERR("vconf_get_str failed \n");
1094 ptr = elm_entry_utf8_to_markup(device_name_utf);
1096 g_free(device_name_utf);
1097 ERR("elm_entry_utf8_to_markup is failed\n");
1101 g_strlcpy(ad->setup.device_name, ptr,
1102 sizeof(ad->setup.device_name));
1103 g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
1104 g_free(device_name_utf);
1108 if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
1109 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
1111 ERR("elm_entry_utf8_to_markup is failed\n");
1114 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
1117 snprintf(security_type, sizeof(security_type),
1121 wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
1123 if (wifi_state && ad->setup.visibility == false)
1124 hidden = STR_MOBILE_HOTSPOT_IS_HIDDEN;
1126 if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
1127 snprintf(buf, MH_LABEL_LENGTH_MAX,
1140 STR_ENTER_THE_PASSWORD_ON_THE_OTHER_DEVICE,
1141 hidden[0] != '\0' ? "<br>" : "",
1144 snprintf(buf, MH_LABEL_LENGTH_MAX,
1151 hidden[0] != '\0' ? "<br>" : "",
1161 static char *__get_device_label(void *data, Evas_Object *obj,
1164 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1167 ERR("The param is NULL\n");
1171 if (!strcmp("elm.text", part)) {
1172 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s</font_size>", STR_CONNECTED_DEV);
1179 #ifdef TETHERING_DATA_USAGE_SUPPORT
1180 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
1182 mh_appdata_t *ad = (mh_appdata_t*)data;
1183 unsigned long long total = 0;
1184 unsigned long long sent = 0;
1185 unsigned long long received = 0;
1187 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1188 char label[MH_LABEL_LENGTH_MAX] = {0, };
1191 ERR("The param is NULL\n");
1195 if (!strcmp("elm.text", part)) {
1196 g_strlcpy(label, STR_DATA_USAGE, sizeof(label));
1197 return strdup(label);
1198 } else if (!strcmp("elm.text.multiline", part)) {
1199 sent = ad->data_statistics.pdp_total_sent;
1200 received = ad->data_statistics.pdp_total_receive;
1202 if (sent >= MH_MB || received >= MH_MB) {
1206 total = sent + received;
1208 } else if (sent + received >= MH_MB) {
1209 total = (sent + received) / MH_MB;
1211 } else if (sent >= MH_KB || received >= MH_KB) {
1215 total = sent + received;
1217 } else if (sent + received >= MH_KB) {
1218 total = (sent + received) / MH_KB;
1221 total = sent + received;
1225 if (total > INT_MAX) {
1226 ERR("data usage overflow\n");
1229 snprintf(label, MH_LABEL_LENGTH_MAX, fmt_str, (int)total);
1230 return strdup(label);
1237 static void __set_genlist_itc(mh_appdata_t *ad)
1239 /* On, Off view's item class for genlist */
1240 ad->main.wifi_itc = elm_genlist_item_class_new();
1241 if (ad->main.wifi_itc == NULL) {
1242 ERR("elm_genlist_item_class_new failed\n");
1246 ad->main.wifi_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1247 ad->main.wifi_itc->func.text_get = __get_wifi_label;
1248 ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1249 ad->main.wifi_itc->func.state_get = NULL;
1250 ad->main.wifi_itc->func.del = NULL;
1252 /* End of On, Off view's item class for genlist */
1254 /* Off view's item class for genlist */
1255 ad->main.bt_itc = elm_genlist_item_class_new();
1256 if (ad->main.bt_itc == NULL) {
1257 ERR("elm_genlist_item_class_new failed\n");
1261 ad->main.bt_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1262 ad->main.bt_itc->func.text_get = __get_bt_label;
1263 ad->main.bt_itc->func.content_get = __get_bt_icon;
1264 ad->main.bt_itc->func.state_get = NULL;
1265 ad->main.bt_itc->func.del = NULL;
1267 ad->main.usb_itc = elm_genlist_item_class_new();
1268 if (ad->main.usb_itc == NULL) {
1269 ERR("elm_genlist_item_class_new failed\n");
1273 ad->main.usb_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1274 ad->main.usb_itc->func.text_get = __get_usb_label;
1275 ad->main.usb_itc->func.content_get = __get_usb_icon;
1276 ad->main.usb_itc->func.state_get = NULL;
1277 ad->main.usb_itc->func.del = NULL;
1279 ad->main.help_itc = elm_genlist_item_class_new();
1280 if (ad->main.help_itc == NULL) {
1281 ERR("elm_genlist_item_class_new failed\n");
1285 ad->main.help_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1286 ad->main.help_itc->func.text_get = __get_help_label;
1287 ad->main.help_itc->func.content_get = NULL;
1288 ad->main.help_itc->func.state_get = NULL;
1289 ad->main.help_itc->func.del = NULL;
1291 /* End of Off view's item class for genlist */
1294 ad->main.device_itc = elm_genlist_item_class_new();
1295 if (ad->main.device_itc == NULL) {
1296 ERR("elm_genlist_item_class_new failed\n");
1300 ad->main.device_itc->item_style = MH_GENLIST_GROUP_INDEX_STYLE;
1301 ad->main.device_itc->func.text_get = __get_device_label;
1302 ad->main.device_itc->func.content_get = NULL;
1303 ad->main.device_itc->func.state_get = NULL;
1304 ad->main.device_itc->func.del = NULL;
1306 #ifdef TETHERING_DATA_USAGE_SUPPORT
1307 ad->main.usage_itc = elm_genlist_item_class_new();
1308 if (ad->main.usage_itc == NULL) {
1309 ERR("elm_genlist_item_class_new failed\n");
1313 ad->main.usage_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1314 ad->main.usage_itc->func.text_get = __get_usage_label;
1315 ad->main.usage_itc->func.content_get = NULL;
1316 ad->main.usage_itc->func.state_get = NULL;
1317 ad->main.usage_itc->func.del = NULL;
1319 /* End of On view's item class for genlist */
1323 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
1325 if (data == NULL || event_info == NULL) {
1326 ERR("Invalid param\n");
1330 mh_appdata_t *ad = (mh_appdata_t *)data;
1331 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1334 char str[MH_LABEL_LENGTH_MAX] = {0, };
1337 if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.usb_item) {
1338 ao = elm_object_item_access_object_get(item);
1339 btn = elm_object_item_part_content_get(item, "on&off");
1340 snprintf(str, sizeof(str), "%s, %s", "On/off button",
1341 (elm_check_state_get(btn) ? "On" : "Off"));
1342 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1344 if (item == ad->main.wifi_item || item == ad->main.bt_item) {
1345 DBG("Wi-Fi or BT item : %p\n", item);
1346 elm_object_item_signal_emit(item, "elm,state,top", "");
1347 } else if (item == ad->main.usb_item) {
1349 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1351 } else if (item == ad->main.setup_item) {
1352 DBG("setup_item\n");
1353 ao = elm_object_item_access_object_get(item);
1354 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Item");
1356 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1357 } else if (item == ad->main.device_item) {
1358 DBG("device_item\n");
1359 ao = elm_object_item_access_object_get(item);
1360 snprintf(str, sizeof(str), "%s, %s", "Expandable list",
1361 "Double tap to open list");
1362 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1364 elm_object_item_signal_emit(item, "elm,state,top", "");
1365 } else if (ad->main.device_item != NULL &&
1366 ad->main.device_item == elm_genlist_item_parent_get(item)) {
1367 DBG("device_item's child\n");
1368 elm_object_item_signal_emit(item, "elm,state,center", "");
1370 for (i = 0; i < 4; i++) {
1371 if (item == ad->main.sp_item[i])
1372 elm_object_item_access_unregister(item);
1375 #ifdef TETHERING_DATA_USAGE_SUPPORT
1376 if (item == ad->main.usage_item) {
1377 DBG("usage_item\n");
1378 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1384 static void __create_inner_contents(mh_appdata_t *ad)
1386 __MOBILE_AP_FUNC_ENTER__;
1388 Elm_Object_Item *item = NULL;
1392 ad->main.genlist = elm_genlist_add(ad->naviframe);
1393 elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1394 evas_object_smart_callback_add(ad->main.genlist, "realized", __gl_realized, ad);
1396 __set_genlist_itc(ad);
1398 item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1399 ad, NULL, ELM_GENLIST_ITEM_NONE,
1400 __select_wifi_item, ad);
1401 ad->main.wifi_item = item;
1403 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
1404 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1405 ad, NULL, ELM_GENLIST_ITEM_NONE,
1407 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1408 ad->main.help_item = item;
1411 item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1412 ad, NULL, ELM_GENLIST_ITEM_NONE,
1413 __select_bt_item, ad);
1414 ad->main.bt_item = item;
1416 item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1417 ad, NULL, ELM_GENLIST_ITEM_NONE,
1418 __select_usb_item, ad);
1419 ad->main.usb_item = item;
1420 if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) {
1421 if (ad->main.usb_item)
1422 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1424 if (ad->main.usb_item)
1425 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
1427 if (ad->main.hotspot_mode & (VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI |
1428 VCONFKEY_MOBILE_HOTSPOT_MODE_USB |
1429 VCONFKEY_MOBILE_HOTSPOT_MODE_BT)) {
1430 #ifdef TETHERING_DATA_USAGE_SUPPORT
1431 item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1432 ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1433 elm_genlist_item_select_mode_set(item,
1434 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1435 ad->main.usage_item = item;
1437 /* Insert "Connected devices" item */
1438 tethering_foreach_connected_clients(ad->handle, TETHERING_TYPE_ALL,
1439 _connected_clients_cb, (void *)ad);
1441 no_of_dev = _get_list_clients_count(ad);
1442 if (no_of_dev != 0) {
1443 item = elm_genlist_item_append(ad->main.genlist,
1444 ad->main.device_itc, ad, NULL,
1445 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1446 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1447 _list_connected_dev(ad);
1448 _update_conn_clients(ad);
1450 ad->main.device_item = item;
1453 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP) {
1454 if (ad->main.wifi_item)
1455 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
1456 if (ad->main.setup_item)
1457 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
1458 if (ad->main.bt_item)
1459 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
1460 if (ad->main.usb_item)
1461 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1464 __MOBILE_AP_FUNC_EXIT__;
1468 void _main_free_genlist_itc(mh_appdata_t *ad)
1470 __MOBILE_AP_FUNC_ENTER__;
1475 mh_main_view_t *mv = &ad->main;
1477 #ifdef TETHERING_DATA_USAGE_SUPPORT
1478 _free_genlist_itc(&mv->usage_itc);
1480 _free_genlist_itc(&mv->device_itc);
1481 _free_genlist_itc(&mv->device0_itc);
1482 _free_genlist_itc(&mv->help_itc);
1483 _free_genlist_itc(&mv->usb_itc);
1484 _free_genlist_itc(&mv->bt_itc);
1485 _free_genlist_itc(&mv->setup_itc);
1486 _free_genlist_itc(&mv->wifi_itc);
1487 __MOBILE_AP_FUNC_EXIT__;
1491 void _main_callback_del(mh_appdata_t *ad)
1493 __MOBILE_AP_FUNC_ENTER__;
1496 ERR("ad is NULL\n");
1502 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
1504 evas_object_smart_callback_del(obj, "changed", __wifi_onoff_changed_cb);
1506 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
1508 evas_object_smart_callback_del(obj, "changed", __bt_onoff_changed_cb);
1510 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
1512 evas_object_smart_callback_del(obj, "changed", __usb_onoff_changed_cb);
1514 evas_object_smart_callback_del(ad->main.genlist, "realized", __gl_realized);
1516 __MOBILE_AP_FUNC_EXIT__;
1519 void _ctxpopup_more_button_callback_add(mh_appdata_t *ad)
1521 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE,
1522 __create_ctxpopup_more_button, ad);
1525 void _ctxpopup_more_button_callback_del(mh_appdata_t *ad)
1527 eext_object_event_callback_del(ad->naviframe, EEXT_CALLBACK_MORE,
1528 __create_ctxpopup_more_button);
1531 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad)
1536 __MOBILE_AP_FUNC_ENTER__;
1538 elm_win_screen_size_get(ad->win, NULL, NULL, &w, &h);
1539 pos = elm_win_rotation_get(ad->win);
1544 evas_object_move(ctx, w/2, h);
1547 evas_object_move(ctx, h/2, w);
1550 evas_object_move(ctx, h/2, w);
1553 __MOBILE_AP_FUNC_EXIT__;
1556 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
1558 __MOBILE_AP_FUNC_ENTER__;
1560 mh_appdata_t *ad = (mh_appdata_t *)data;
1561 Evas_Object *ctx = ad->ctxpopup;
1563 __ctx_move_more_ctxpopup(ctx, ad);
1564 evas_object_show(ctx);
1566 __MOBILE_AP_FUNC_EXIT__;
1569 static void __dismissed_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event)
1571 __MOBILE_AP_FUNC_ENTER__;
1573 mh_appdata_t *ad = (mh_appdata_t *)data;
1574 Evas_Object *ctx = ad->ctxpopup;
1577 evas_object_del(ctx);
1580 __ctx_move_more_ctxpopup(ctx, ad);
1581 evas_object_show(ctx);
1582 rotate_flag = EINA_FALSE;
1584 __MOBILE_AP_FUNC_EXIT__;
1587 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj,
1590 Evas_Object *navi = (Evas_Object *)data;
1591 Evas_Object *ctx = obj;
1594 ERR("data is null\n");
1597 __MOBILE_AP_FUNC_ENTER__;
1599 evas_object_smart_callback_del(ctx, "dismissed",
1600 __dismissed_more_ctxpopup_cb);
1601 evas_object_smart_callback_del(elm_object_top_widget_get(ctx),
1602 "rotation,changed", __rotate_more_ctxpopup_cb);
1603 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
1604 __ctx_delete_more_ctxpopup_cb, navi);
1605 __MOBILE_AP_FUNC_EXIT__;
1608 static void __gl_configure_wifi_tethering(void *data, Evas_Object *obj, void *event_info)
1610 __MOBILE_AP_FUNC_ENTER__;
1613 ERR("The param is NULL\n");
1616 mh_appdata_t *ad = (mh_appdata_t *)data;
1618 evas_object_del(ad->ctxpopup);
1619 ad->ctxpopup = NULL;
1621 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1622 _ctxpopup_more_button_callback_del(ad);
1623 mh_draw_wifi_setup_view(ad);
1625 __MOBILE_AP_FUNC_EXIT__;
1630 static void __create_ctxpopup_more_button(void *data, Evas_Object *obj,
1633 mh_appdata_t *ad = (mh_appdata_t *)data;
1634 Evas_Object *ctxpopup = NULL;
1637 ERR("ad is null\n");
1640 __MOBILE_AP_FUNC_ENTER__;
1642 ctxpopup = elm_ctxpopup_add(ad->win);
1643 elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
1645 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
1646 eext_ctxpopup_back_cb, ad);
1647 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE,
1648 eext_ctxpopup_back_cb, ad);
1649 elm_object_style_set(ctxpopup, "more/default");
1650 evas_object_smart_callback_add(ctxpopup, "dismissed",
1651 __dismissed_more_ctxpopup_cb, ad);
1652 evas_object_smart_callback_add(elm_object_top_widget_get(ctxpopup), "rotation,changed",
1653 __rotate_more_ctxpopup_cb, ad);
1654 evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL,
1655 __ctx_delete_more_ctxpopup_cb, ad->naviframe);
1657 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
1658 ELM_CTXPOPUP_DIRECTION_DOWN,
1659 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
1660 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
1662 __ctx_move_more_ctxpopup(ctxpopup, ad);
1663 elm_ctxpopup_item_append(ctxpopup, STR_CONFIGURE_MOBILE_HOTSPOT,
1664 NULL, __gl_configure_wifi_tethering, ad);
1666 evas_object_show(ctxpopup);
1668 ad->ctxpopup = ctxpopup;
1670 __MOBILE_AP_FUNC_EXIT__;
1674 void _main_draw_contents(mh_appdata_t *ad)
1678 Elm_Object_Item *navi_item;
1680 __create_inner_contents(ad);
1682 ad->main.back_btn = elm_button_add(ad->naviframe);
1683 if (ad->main.back_btn == NULL) {
1684 ERR("elm_button_add is failed\n");
1685 if (ad->main.genlist) {
1686 evas_object_del(ad->main.genlist);
1687 ad->main.genlist = NULL;
1691 elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1693 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_BACK,
1694 eext_naviframe_back_cb, NULL);
1695 _ctxpopup_more_button_callback_add(ad);
1696 evas_object_smart_callback_add(ad->main.back_btn, "clicked", (Evas_Smart_Cb)__back_btn_cb, (void *)ad);
1697 elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1699 navi_item = elm_naviframe_item_push(ad->naviframe, IDS_TETH,
1700 ad->main.back_btn, NULL, ad->main.genlist, NULL);
1701 elm_object_item_domain_text_translatable_set(navi_item, PKGNAME, EINA_TRUE);
1703 elm_naviframe_item_pop_cb_set(navi_item, (Elm_Naviframe_Item_Pop_Cb)__back_btn_cb, (void *)ad);
1704 ad->navi_item = navi_item;