4 * Copyright 2012 Samsung Electronics Co., Ltd
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
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"
27 #include "mh_string.h"
29 #if 0 /* device rename not supported */
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, void *event_info);
32 static Eina_Bool rotate_flag = EINA_FALSE;
34 void _genlist_update_device_item(mh_appdata_t *ad);
35 mh_appdata_t *g_ad = NULL;
36 #define UPDATE_INTERVAL 1
38 #if 0 /* device rename not supported */
39 void _rotate_adjust_rename_popup(void)
41 __MOBILE_AP_FUNC_ENTER__;
45 change_ang = elm_win_rotation_get(g_ad->win);
46 if (change_ang == 0 || change_ang == 180)
47 _hadnle_rename_popup_rotation(EINA_TRUE);
49 _hadnle_rename_popup_rotation(EINA_FALSE);
51 __MOBILE_AP_FUNC_EXIT__;
55 void _select_connected_dev(void *data, Evas_Object *obj, void *event_info)
57 __MOBILE_AP_FUNC_ENTER__;
60 ERR("data is NULL\n");
64 mh_appdata_t *ad = (mh_appdata_t *)data;
66 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
67 _create_connected_client_view(ad);
68 __MOBILE_AP_FUNC_EXIT__;
71 static bool _connected_clients_cb(tethering_client_h client, void *user_data)
73 __MOBILE_AP_FUNC_ENTER__;
75 if (user_data == NULL) {
76 ERR("user_data is NULL\n");
80 mh_appdata_t *ad = (mh_appdata_t *)user_data;
82 _append_list_client_handle(ad, client);
84 __MOBILE_AP_FUNC_EXIT__;
88 void ap_update_data_device(mh_appdata_t *ad)
90 __MOBILE_AP_FUNC_ENTER__;
93 ERR("Invalid param\n");
97 _genlist_update_device_item(ad);
99 __MOBILE_AP_FUNC_EXIT__;
102 #ifdef TETHERING_DATA_USAGE_SUPPORT
103 Eina_Bool ap_update_data_packet_usage(mh_appdata_t *ad)
106 ERR("Invalid param\n");
110 if (ad->main.usage_item)
111 elm_genlist_item_update(ad->main.usage_item);
116 Eina_Bool ap_get_data_statistics(void *data)
119 ERR("The param is NULL\n");
120 return ECORE_CALLBACK_CANCEL;
122 mh_appdata_t *ad = (mh_appdata_t *)data;
124 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
125 ad->update_statistics_handle = NULL;
126 return ECORE_CALLBACK_CANCEL;
129 /* If previous data is not updated, new data is not required */
130 if (ad->data_statistics.is_updated == false)
131 return ECORE_CALLBACK_RENEW;
133 /* Because previous data is updated, new data is required.
134 It will be returned asynchronously. */
135 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
136 ad->data_statistics.is_updated = false;
138 return ECORE_CALLBACK_RENEW;
142 Eina_Bool ap_update_device_conn_time(void * data)
145 ERR("The param is NULL\n");
146 return ECORE_CALLBACK_CANCEL;
148 mh_appdata_t *ad = (mh_appdata_t *)data;
151 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
152 _stop_update_device_conn_time(ad);
153 __MOBILE_AP_FUNC_EXIT__;
154 return ECORE_CALLBACK_CANCEL;
157 while (count < ad->connected_device.no_of_clients) {
158 if (ad->connected_device.station_items[count])
159 elm_genlist_item_fields_update(ad->connected_device.station_items[count++],
160 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
162 return ECORE_CALLBACK_RENEW;
165 void _start_update_device_conn_time(mh_appdata_t *ad)
167 __MOBILE_AP_FUNC_ENTER__;
170 ERR("Invalid param\n");
171 __MOBILE_AP_FUNC_EXIT__;
175 if (ad->update_conn_time_handle)
176 _stop_update_device_conn_time(ad);
178 ad->update_conn_time_handle = ecore_timer_add(UPDATE_INTERVAL,
179 ap_update_device_conn_time, (void *)ad);
181 __MOBILE_AP_FUNC_EXIT__;
184 void _stop_update_device_conn_time(mh_appdata_t *ad)
186 __MOBILE_AP_FUNC_ENTER__;
189 ERR("Invalid param\n");
193 if (ad->update_conn_time_handle) {
194 ecore_timer_del(ad->update_conn_time_handle);
195 ad->update_conn_time_handle = NULL;
197 __MOBILE_AP_FUNC_EXIT__;
200 #ifdef TETHERING_DATA_USAGE_SUPPORT
201 void _start_update_data_packet_usage(mh_appdata_t *ad)
203 __MOBILE_AP_FUNC_ENTER__;
206 ERR("Invalid param\n");
210 if (ad->update_statistics_handle)
211 _stop_update_data_packet_usage(ad);
213 ad->data_statistics.is_updated = false;
214 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
215 ad->update_statistics_handle = ecore_timer_add(MH_UPDATE_INTERVAL,
216 ap_get_data_statistics, (void *)ad);
218 __MOBILE_AP_FUNC_EXIT__;
222 void _stop_update_data_packet_usage(mh_appdata_t *ad)
224 __MOBILE_AP_FUNC_ENTER__;
227 ERR("Invalid param\n");
231 if (ad->update_statistics_handle) {
232 ecore_timer_del(ad->update_statistics_handle);
233 ad->data_statistics.is_updated = false;
234 ad->update_statistics_handle = NULL;
237 __MOBILE_AP_FUNC_EXIT__;
242 static void __read_setting(mh_appdata_t *ad)
244 __MOBILE_AP_FUNC_ENTER__;
247 ERR("Invalid param\n");
253 char *passphrase = NULL;
255 tethering_wifi_security_type_e type;
257 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
259 #ifdef TETHERING_DATA_USAGE_SUPPORT
260 ad->data_statistics.pdp_total_sent = 0;
261 ad->data_statistics.pdp_total_receive = 0;
262 if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
263 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
266 ret = tethering_wifi_get_ssid(ad->handle, &ssid);
267 if (ret != TETHERING_ERROR_NONE || ssid == NULL) {
268 ERR("tethering_wifi_get_ssid is failed : %d\n", ret);
271 g_strlcpy(ad->setup.device_name, ssid, sizeof(ad->setup.device_name));
274 ret = tethering_wifi_get_passphrase(ad->handle, &passphrase);
275 if (ret != TETHERING_ERROR_NONE || passphrase == NULL) {
276 ERR("tethering_wifi_get_passphrase is failed : %d\n", ret);
280 g_strlcpy(ad->setup.wifi_passphrase, passphrase,
281 sizeof(ad->setup.wifi_passphrase));
282 g_strlcpy(ad->setup.wifi_passphrase_new, passphrase,
283 sizeof(ad->setup.wifi_passphrase_new));
286 ret = tethering_wifi_get_ssid_visibility(ad->handle, &visibility);
287 if (ret != TETHERING_ERROR_NONE)
288 ERR("tethering_wifi_get_ssid_visibility is failed\n");
290 ad->setup.visibility = visibility;
291 ad->setup.visibility_new = visibility;
293 ret = tethering_wifi_get_security_type(ad->handle, &type);
294 if (ret != TETHERING_ERROR_NONE)
295 ERR("tethering_wifi_get_security_type is failed\n");
297 ad->setup.security_type = type;
298 ad->setup.security_type_new = type;
300 __MOBILE_AP_FUNC_EXIT__;
303 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
305 __MOBILE_AP_FUNC_ENTER__;
307 if (ad->main.wifi_state == wifi_state)
310 if (ad->main.wifi_state == MH_STATE_PROCESS) {
311 ad->main.wifi_state = MH_STATE_NONE;
312 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
313 } else if (ad->main.wifi_state == MH_STATE_NONE) {
314 ad->main.wifi_state = MH_STATE_PROCESS;
315 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
318 if (ad->main.wifi_item)
319 elm_genlist_item_update(ad->main.wifi_item);
321 if (ad->main.setup_item)
322 elm_object_item_signal_emit(ad->main.setup_item, "elm,state,bottom", "");
324 __MOBILE_AP_FUNC_EXIT__;
329 void _update_bt_item(mh_appdata_t *ad, int bt_state)
331 __MOBILE_AP_FUNC_ENTER__;
333 if (ad->main.bt_state == bt_state)
336 if (ad->main.bt_state == MH_STATE_PROCESS) {
337 ad->main.bt_state = MH_STATE_NONE;
338 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
339 } else if (ad->main.bt_state == MH_STATE_NONE) {
340 ad->main.bt_state = MH_STATE_PROCESS;
341 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
344 if (ad->main.bt_item)
345 elm_genlist_item_update(ad->main.bt_item);
347 __MOBILE_AP_FUNC_EXIT__;
352 void _update_usb_item(mh_appdata_t *ad, int usb_state)
354 __MOBILE_AP_FUNC_ENTER__;
356 if (ad->main.usb_state == usb_state)
359 if (ad->main.usb_state == MH_STATE_PROCESS) {
360 ad->main.usb_state = MH_STATE_NONE;
361 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
362 } else if (ad->main.usb_state == MH_STATE_NONE) {
363 ad->main.usb_state = MH_STATE_PROCESS;
364 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
367 elm_genlist_item_update(ad->main.usb_item);
369 __MOBILE_AP_FUNC_EXIT__;
374 void _genlist_update_device_item(mh_appdata_t *ad)
376 __MOBILE_AP_FUNC_ENTER__;
379 ERR("Invalid param\n");
382 unsigned int no_of_dev = 0;
383 no_of_dev = _get_list_clients_count(ad);
384 Elm_Object_Item *item = NULL;
386 if (ad->main.device_item) {
387 elm_object_item_del(ad->main.device_item);
388 ad->main.device_item = NULL;
389 if (no_of_dev == 0) {
390 item = elm_genlist_item_append(ad->main.genlist,
391 ad->main.device0_itc, ad, NULL,
392 ELM_GENLIST_ITEM_NONE, NULL, NULL);
393 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
395 item = elm_genlist_item_append(ad->main.genlist,
396 ad->main.device_itc, ad, NULL,
397 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
398 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
400 ad->main.device_item = item;
403 if (ad->connected_device.navi_it)
404 _update_conn_clients(ad);
406 __MOBILE_AP_FUNC_EXIT__;
410 void _update_main_view(mh_appdata_t *ad, tethering_type_e type)
412 __MOBILE_AP_FUNC_ENTER__;
415 ERR("Invalid param\n");
419 int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
420 Eina_Bool wifi_state = EINA_FALSE;
421 Eina_Bool bt_state = EINA_FALSE;
422 Eina_Bool usb_state = EINA_FALSE;
423 Eina_Bool wifi_ap_state = EINA_FALSE;
424 Elm_Object_Item *item = NULL;
428 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
429 state = ad->main.hotspot_mode;
431 wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
432 bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
433 usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
434 wifi_ap_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP);
437 if (ad->main.wifi_item)
438 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
439 if (ad->main.setup_item)
440 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
441 if (ad->main.bt_item)
442 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
443 if (ad->main.usb_item)
444 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
446 if (ad->main.setup_item)
447 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
448 if (ad->main.bt_item)
449 elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE);
450 if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) {
451 if (ad->main.usb_item)
452 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
454 if (ad->main.usb_item)
455 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
459 if (wifi_state || bt_state || usb_state) {
460 #ifdef TETHERING_DATA_USAGE_SUPPORT
461 if (ad->main.usage_item == NULL) {
462 item = elm_genlist_item_insert_before(ad->main.genlist,
463 ad->main.usage_itc, ad, NULL,
465 ELM_GENLIST_ITEM_NONE, NULL, NULL);
466 elm_genlist_item_select_mode_set(item,
467 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
468 ad->main.usage_item = item;
472 no_of_dev = _get_list_clients_count(ad);
473 if (ad->main.device_item == NULL) {
474 if (no_of_dev == 0) {
475 item = elm_genlist_item_append(ad->main.genlist,
476 ad->main.device0_itc, ad, NULL,
477 ELM_GENLIST_ITEM_NONE, NULL, NULL);
478 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
480 item = elm_genlist_item_append(ad->main.genlist,
481 ad->main.device_itc, ad, NULL,
482 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
483 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
485 ad->main.device_item = item;
488 if (ad->main.device_item) {
489 elm_object_item_del(ad->main.device_item);
490 ad->main.device_item = NULL;
492 #ifdef TETHERING_DATA_USAGE_SUPPORT
493 if (ad->main.usage_item) {
494 elm_object_item_del(ad->main.usage_item);
495 ad->main.usage_item = NULL;
501 if (ad->main.help_item) {
502 elm_genlist_item_update(ad->main.help_item);
504 item = elm_genlist_item_insert_after(ad->main.genlist,
505 ad->main.help_itc, ad, NULL,
507 ELM_GENLIST_ITEM_NONE, NULL,
510 ERR("elm_genlist_item_insert_after NULL\n");
512 elm_genlist_item_select_mode_set(item,
513 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
514 ad->main.help_item = item;
518 if (ad->main.help_item) {
519 elm_object_item_del(ad->main.help_item);
520 ad->main.help_item = NULL;
525 case TETHERING_TYPE_WIFI:
526 /* Update Wi-Fi tethering on / off button */
527 if (ad->main.wifi_state != MH_STATE_NONE) {
528 _update_wifi_item(ad, MH_STATE_NONE);
530 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
532 elm_check_state_set(obj, wifi_state);
534 if (ad->main.wifi_item)
535 elm_genlist_item_update(ad->main.wifi_item);
539 case TETHERING_TYPE_BT:
540 /* Update BT tethering on / off button */
541 if (ad->main.bt_state != MH_STATE_NONE) {
542 _update_bt_item(ad, MH_STATE_NONE);
544 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
546 elm_check_state_set(obj, bt_state);
548 if (ad->main.bt_item)
549 elm_genlist_item_update(ad->main.bt_item);
553 case TETHERING_TYPE_USB:
554 /* Update USB tethering on / off button */
555 if (ad->main.usb_state != MH_STATE_NONE) {
556 _update_usb_item(ad, MH_STATE_NONE);
558 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
560 elm_check_state_set(obj, usb_state);
562 if (ad->main.usb_item)
563 elm_genlist_item_update(ad->main.usb_item);
568 DBG("Unknown tethering type : %d\n", type);
572 __MOBILE_AP_FUNC_EXIT__;
577 static int __is_allowed(tethering_type_e type)
580 dpm_context_h context = NULL;
581 dpm_restriction_policy_h policy = NULL;
583 context = dpm_context_create();
584 if (context == NULL) {
585 ERR("Failed to create dpm context!!");
589 policy = dpm_context_acquire_restriction_policy(context);
590 if (policy == NULL) {
591 ERR("Failed to create policy handle");
592 dpm_context_destroy(context);
597 case TETHERING_TYPE_WIFI:
598 dpm_restriction_get_wifi_hotspot_state(policy, &state);
600 case TETHERING_TYPE_USB:
601 dpm_restriction_get_usb_tethering_state(policy, &state);
603 case TETHERING_TYPE_BT:
604 dpm_restriction_get_bluetooth_tethering_state(policy, &state);
610 dpm_context_release_restriction_policy(context, policy);
611 dpm_context_destroy(context);
616 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
619 __MOBILE_AP_FUNC_ENTER__;
621 if (!__is_allowed(TETHERING_TYPE_WIFI)) {
622 ERR("Wi-Fi tethering is restricted!!");
623 elm_check_state_set(obj, EINA_FALSE);
624 _create_security_restriction_noti(TETHERING_TYPE_WIFI);
629 ERR("The param is NULL\n");
633 mh_appdata_t *ad = (mh_appdata_t *)data;
635 _update_wifi_item(ad, MH_STATE_PROCESS);
636 ad->type = TETHERING_TYPE_WIFI;
637 ad->is_wifi_teth_enabling = true;
638 if (_handle_wifi_onoff_change(ad) != 0) {
639 ERR("_handle_wifi_onoff_change is failed\n");
640 _update_wifi_item(ad, MH_STATE_NONE);
641 ad->is_wifi_teth_enabling = false;
644 __MOBILE_AP_FUNC_EXIT__;
649 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
651 __MOBILE_AP_FUNC_ENTER__;
654 ERR("The param is NULL\n");
657 mh_appdata_t *ad = (mh_appdata_t *)data;
659 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
660 mh_draw_wifi_setup_view(ad);
662 __MOBILE_AP_FUNC_EXIT__;
667 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
669 __MOBILE_AP_FUNC_ENTER__;
671 if (!__is_allowed(TETHERING_TYPE_BT)) {
672 ERR("BT tethering is restricted!!");
673 elm_check_state_set(obj, EINA_FALSE);
674 _create_security_restriction_noti(TETHERING_TYPE_BT);
679 ERR("The param is NULL\n");
683 mh_appdata_t *ad = (mh_appdata_t *)data;
685 _update_bt_item(ad, MH_STATE_PROCESS);
686 ad->type = TETHERING_TYPE_BT;
687 ad->is_bt_teth_enabling = true;
689 if (_handle_bt_onoff_change(ad) != 0) {
690 ERR("_handle_bt_onoff_change is failed\n");
691 _update_bt_item(ad, MH_STATE_NONE);
692 ad->is_bt_teth_enabling = false;
695 __MOBILE_AP_FUNC_EXIT__;
700 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
702 __MOBILE_AP_FUNC_ENTER__;
704 Evas_Object *content;
705 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
708 ERR("The param is NULL\n");
712 elm_genlist_item_selected_set(item, EINA_FALSE);
714 content = elm_object_item_part_content_get(item, "elm.icon");
715 __bt_onoff_changed_cb(data, content, NULL);
717 __MOBILE_AP_FUNC_EXIT__;
722 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
724 __MOBILE_AP_FUNC_ENTER__;
726 if (!__is_allowed(TETHERING_TYPE_USB)) {
727 ERR("USB tethering is restricted!!");
728 elm_check_state_set(obj, EINA_FALSE);
729 _create_security_restriction_noti(TETHERING_TYPE_USB);
734 ERR("The param is NULL\n");
738 mh_appdata_t *ad = (mh_appdata_t *)data;
739 _update_usb_item(ad, MH_STATE_PROCESS);
740 ad->type = TETHERING_TYPE_USB;
741 ad->is_usb_teth_enabling = true;
742 if (_handle_usb_onoff_change(ad) != 0) {
743 ERR("_handle_usb_onoff_change is failed\n");
744 _update_usb_item(ad, MH_STATE_NONE);
745 ad->is_usb_teth_enabling = false;
748 __MOBILE_AP_FUNC_EXIT__;
753 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
755 __MOBILE_AP_FUNC_ENTER__;
757 Evas_Object *content;
758 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
761 ERR("The param is NULL\n");
765 elm_genlist_item_selected_set(item, EINA_FALSE);
767 content = elm_object_item_part_content_get(item, "elm.icon");
768 __usb_onoff_changed_cb(data, content, NULL);
770 __MOBILE_AP_FUNC_EXIT__;
775 static void __back_btn_cb(void *data, Elm_Object_Item *navi_item)
780 ERR("The param is NULL\n");
784 mh_appdata_t *ad = (mh_appdata_t*)data;
786 _release_list_client_handle(ad);
787 _main_callback_del(ad);
789 ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
795 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
797 if (!strcmp("elm.text", part))
798 return strdup(STR_WIFI_TETH);
803 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
806 mh_appdata_t *ad = (mh_appdata_t*)data;
807 Evas_Object *btn = NULL;
810 ERR("The param is NULL\n");
814 if (!strcmp("elm.swallow.end", part)) {
815 if (ad->main.wifi_state == MH_STATE_PROCESS) {
816 btn = _create_progressbar(obj, "process_medium");
818 btn = elm_check_add(obj);
819 elm_object_style_set(btn, "on&off");
821 evas_object_propagate_events_set(btn, EINA_FALSE);
822 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
823 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
824 elm_check_state_set(btn, ad->main.hotspot_mode &
825 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
827 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb, ad);
828 evas_object_show(btn);
835 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
837 if (!strcmp("elm.text", part))
838 return strdup(STR_BLUETOOTH_TETH);
843 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
845 mh_appdata_t *ad = (mh_appdata_t *)data;
846 Evas_Object *btn = NULL;
849 ERR("The param is NULL\n");
853 if (!strcmp("elm.swallow.end", part)) {
854 if (ad->main.bt_state == MH_STATE_PROCESS) {
855 btn = _create_progressbar(obj, "process_medium");
857 btn = elm_check_add(obj);
859 ERR("btn is NULL\n");
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_BT ? EINA_TRUE : EINA_FALSE);
867 evas_object_show(btn);
868 evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb, ad);
875 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
877 if (!strcmp("elm.text", part))
878 return strdup(STR_USB_TETH);
883 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
886 mh_appdata_t *ad = (mh_appdata_t *)data;
887 Evas_Object *btn = NULL;
890 ERR("The param is NULL\n");
894 if (!strcmp("elm.swallow.end", part)) {
895 if (ad->main.usb_state == MH_STATE_PROCESS) {
896 btn = _create_progressbar(obj, "process_medium");
898 btn = elm_check_add(obj);
900 ERR("btn is NULL\n");
903 elm_object_style_set(btn, "on&off");
904 evas_object_pass_events_set(btn, EINA_TRUE);
905 evas_object_propagate_events_set(btn, EINA_FALSE);
906 elm_check_state_set(btn, ad->main.hotspot_mode &
907 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
908 evas_object_show(btn);
909 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb, ad);
916 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
918 mh_appdata_t *ad = (mh_appdata_t *)data;
919 char buf[MH_LABEL_LENGTH_MAX] = {0, };
920 char device_name[MH_LABEL_LENGTH_MAX] = {0, };
921 char passphrase[MH_LABEL_LENGTH_MAX] = {0, };
922 char security_type[MH_LABEL_LENGTH_MAX] = {0, };
923 char *fmt = STR_SECURITY_TYPE_PS;
926 char *device_name_utf = NULL;
927 int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
930 ERR("The param is NULL\n");
934 if (!strcmp("elm.text.multiline", part)) {
935 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
936 if (device_name_utf == NULL) {
937 ERR("vconf_get_str failed \n");
941 ptr = elm_entry_utf8_to_markup(device_name_utf);
943 g_free(device_name_utf);
944 ERR("elm_entry_utf8_to_markup is failed\n");
948 g_strlcpy(ad->setup.device_name, ptr,
949 sizeof(ad->setup.device_name));
950 g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
951 g_free(device_name_utf);
955 if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
956 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
958 ERR("elm_entry_utf8_to_markup is failed\n");
961 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
964 snprintf(security_type, sizeof(security_type),
968 wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
970 if (wifi_state && ad->setup.visibility == false)
971 hidden = STR_WIFI_TETH_HIDDEN;
973 if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
974 snprintf(buf, MH_LABEL_LENGTH_MAX,
987 STR_PASSWORD_FOR_WIFI_TETH,
988 hidden[0] != '\0' ? "<br>" : "",
991 snprintf(buf, MH_LABEL_LENGTH_MAX,
998 hidden[0] != '\0' ? "<br>" : "",
1008 static char *__get_no_connected_device_label(void *data, Evas_Object *obj,
1011 mh_appdata_t *ad = (mh_appdata_t*)data;
1012 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1016 ERR("The param is NULL\n");
1020 if (!strcmp("elm.text.multiline", part)) {
1021 no_of_dev = _get_list_clients_count(ad);
1022 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s<br>%d</font_size>", STR_CONNECTED_DEV, no_of_dev);
1029 static char *__get_connected_device_label(void *data, Evas_Object *obj,
1032 mh_appdata_t *ad = (mh_appdata_t*)data;
1033 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1037 ERR("The param is NULL\n");
1041 if (!strcmp("elm.text.sub", part)) {
1042 g_strlcpy(buf, STR_CONNECTED_DEV, sizeof(buf));
1044 } else if (!strcmp("elm.text", part)) {
1045 no_of_dev = _get_list_clients_count(ad);
1046 snprintf(buf, MH_LABEL_LENGTH_MAX, "%d", no_of_dev);
1053 #ifdef TETHERING_DATA_USAGE_SUPPORT
1054 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
1056 mh_appdata_t *ad = (mh_appdata_t*)data;
1057 unsigned long long total = 0;
1058 unsigned long long sent = 0;
1059 unsigned long long received = 0;
1061 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1062 char label[MH_LABEL_LENGTH_MAX] = {0, };
1065 ERR("The param is NULL\n");
1069 if (!strcmp("elm.text", part)) {
1070 g_strlcpy(label, STR_DATA_USAGE, sizeof(label));
1071 return strdup(label);
1072 } else if (!strcmp("elm.text.multiline", part)) {
1073 sent = ad->data_statistics.pdp_total_sent;
1074 received = ad->data_statistics.pdp_total_receive;
1076 if (sent >= MH_MB || received >= MH_MB) {
1080 total = sent + received;
1082 } else if (sent + received >= MH_MB) {
1083 total = (sent + received) / MH_MB;
1085 } else if (sent >= MH_KB || received >= MH_KB) {
1089 total = sent + received;
1091 } else if (sent + received >= MH_KB) {
1092 total = (sent + received) / MH_KB;
1095 total = sent + received;
1099 if (total > INT_MAX) {
1100 ERR("data usage overflow\n");
1103 snprintf(label, MH_LABEL_LENGTH_MAX, fmt_str, (int)total);
1104 return strdup(label);
1111 static void __set_genlist_itc(mh_appdata_t *ad)
1113 /* On, Off view's item class for genlist */
1114 #if 0 /* not used */
1115 ad->main.sp_itc = elm_genlist_item_class_new();
1116 if (ad->main.sp_itc == NULL) {
1117 ERR("elm_genlist_item_class_new failed\n");
1121 ad->main.sp_itc->item_style = "dialogue/separator";
1122 ad->main.sp_itc->func.text_get = NULL;
1123 ad->main.sp_itc->func.content_get = NULL;
1124 ad->main.sp_itc->func.state_get = NULL;
1125 ad->main.sp_itc->func.del = NULL;
1127 ad->main.wifi_itc = elm_genlist_item_class_new();
1128 if (ad->main.wifi_itc == NULL) {
1129 ERR("elm_genlist_item_class_new failed\n");
1133 ad->main.wifi_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1134 ad->main.wifi_itc->func.text_get = __get_wifi_label;
1135 ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1136 ad->main.wifi_itc->func.state_get = NULL;
1137 ad->main.wifi_itc->func.del = NULL;
1139 #if 0 /* not used */
1140 ad->main.sp2_itc = elm_genlist_item_class_new();
1141 if (ad->main.sp2_itc == NULL) {
1142 ERR("elm_genlist_item_class_new failed\n");
1146 ad->main.sp2_itc->item_style = "dialogue/separator.2";
1147 ad->main.sp2_itc->func.text_get = NULL;
1148 ad->main.sp2_itc->func.content_get = NULL;
1149 ad->main.sp2_itc->func.state_get = NULL;
1150 ad->main.sp2_itc->func.del = NULL;
1152 /* End of On, Off view's item class for genlist */
1154 /* Off view's item class for genlist */
1155 ad->main.bt_itc = elm_genlist_item_class_new();
1156 if (ad->main.bt_itc == NULL) {
1157 ERR("elm_genlist_item_class_new failed\n");
1161 ad->main.bt_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1162 ad->main.bt_itc->func.text_get = __get_bt_label;
1163 ad->main.bt_itc->func.content_get = __get_bt_icon;
1164 ad->main.bt_itc->func.state_get = NULL;
1165 ad->main.bt_itc->func.del = NULL;
1167 ad->main.usb_itc = elm_genlist_item_class_new();
1168 if (ad->main.usb_itc == NULL) {
1169 ERR("elm_genlist_item_class_new failed\n");
1173 ad->main.usb_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1174 ad->main.usb_itc->func.text_get = __get_usb_label;
1175 ad->main.usb_itc->func.content_get = __get_usb_icon;
1176 ad->main.usb_itc->func.state_get = NULL;
1177 ad->main.usb_itc->func.del = NULL;
1179 ad->main.help_itc = elm_genlist_item_class_new();
1180 if (ad->main.help_itc == NULL) {
1181 ERR("elm_genlist_item_class_new failed\n");
1185 ad->main.help_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1186 ad->main.help_itc->func.text_get = __get_help_label;
1187 ad->main.help_itc->func.content_get = NULL;
1188 ad->main.help_itc->func.state_get = NULL;
1189 ad->main.help_itc->func.del = NULL;
1191 /* End of Off view's item class for genlist */
1193 /* On view's item class for genlist */
1194 ad->main.device0_itc = elm_genlist_item_class_new();
1195 if (ad->main.device0_itc == NULL) {
1196 ERR("elm_genlist_item_class_new failed\n");
1200 ad->main.device0_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1201 ad->main.device0_itc->func.text_get = __get_no_connected_device_label;
1202 ad->main.device0_itc->func.content_get = NULL;
1203 ad->main.device0_itc->func.state_get = NULL;
1204 ad->main.device0_itc->func.del = NULL;
1206 ad->main.device_itc = elm_genlist_item_class_new();
1207 if (ad->main.device_itc == NULL) {
1208 ERR("elm_genlist_item_class_new failed\n");
1212 ad->main.device_itc->item_style = MH_GENLIST_2LINE_BOTTOM_TEXT_STYLE;
1213 ad->main.device_itc->func.text_get = __get_connected_device_label;
1214 ad->main.device_itc->func.content_get = NULL;
1215 ad->main.device_itc->func.state_get = NULL;
1216 ad->main.device_itc->func.del = NULL;
1218 #ifdef TETHERING_DATA_USAGE_SUPPORT
1219 ad->main.usage_itc = elm_genlist_item_class_new();
1220 if (ad->main.usage_itc == NULL) {
1221 ERR("elm_genlist_item_class_new failed\n");
1225 ad->main.usage_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1226 ad->main.usage_itc->func.text_get = __get_usage_label;
1227 ad->main.usage_itc->func.content_get = NULL;
1228 ad->main.usage_itc->func.state_get = NULL;
1229 ad->main.usage_itc->func.del = NULL;
1231 /* End of On view's item class for genlist */
1235 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
1237 if (data == NULL || event_info == NULL) {
1238 ERR("Invalid param\n");
1242 mh_appdata_t *ad = (mh_appdata_t *)data;
1243 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1246 char str[MH_LABEL_LENGTH_MAX] = {0, };
1249 if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.usb_item) {
1250 ao = elm_object_item_access_object_get(item);
1251 btn = elm_object_item_part_content_get(item, "on&off");
1252 snprintf(str, sizeof(str), "%s, %s", "On/off button",
1253 (elm_check_state_get(btn) ? "On" : "Off"));
1254 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1256 if (item == ad->main.wifi_item || item == ad->main.bt_item) {
1257 DBG("Wi-Fi or BT item : %p\n", item);
1258 elm_object_item_signal_emit(item, "elm,state,top", "");
1259 } else if (item == ad->main.usb_item) {
1261 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1263 } else if (item == ad->main.setup_item) {
1264 DBG("setup_item\n");
1265 ao = elm_object_item_access_object_get(item);
1266 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Item");
1268 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1269 } else if (item == ad->main.device_item) {
1270 DBG("device_item\n");
1271 ao = elm_object_item_access_object_get(item);
1272 snprintf(str, sizeof(str), "%s, %s", "Expandable list",
1273 "Double tap to open list");
1274 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1276 elm_object_item_signal_emit(item, "elm,state,top", "");
1277 } else if (ad->main.device_item != NULL &&
1278 ad->main.device_item == elm_genlist_item_parent_get(item)) {
1279 DBG("device_item's child\n");
1280 elm_object_item_signal_emit(item, "elm,state,center", "");
1282 for (i = 0; i < 4; i++) {
1283 if (item == ad->main.sp_item[i])
1284 elm_object_item_access_unregister(item);
1287 #ifdef TETHERING_DATA_USAGE_SUPPORT
1288 if (item == ad->main.usage_item) {
1289 DBG("usage_item\n");
1290 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1296 static void __create_inner_contents(mh_appdata_t *ad)
1298 __MOBILE_AP_FUNC_ENTER__;
1300 Elm_Object_Item *item = NULL;
1304 ad->main.genlist = elm_genlist_add(ad->naviframe);
1305 elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1306 evas_object_smart_callback_add(ad->main.genlist, "realized", __gl_realized, ad);
1308 __set_genlist_itc(ad);
1310 item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1311 ad, NULL, ELM_GENLIST_ITEM_NONE,
1312 __select_wifi_item, ad);
1313 ad->main.wifi_item = item;
1315 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
1316 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1317 ad, NULL, ELM_GENLIST_ITEM_NONE,
1319 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1320 ad->main.help_item = item;
1323 item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1324 ad, NULL, ELM_GENLIST_ITEM_NONE,
1325 __select_bt_item, ad);
1326 ad->main.bt_item = item;
1328 item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1329 ad, NULL, ELM_GENLIST_ITEM_NONE,
1330 __select_usb_item, ad);
1331 ad->main.usb_item = item;
1332 if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) {
1333 if (ad->main.usb_item)
1334 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1336 if (ad->main.usb_item)
1337 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
1339 if (ad->main.hotspot_mode & (VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI |
1340 VCONFKEY_MOBILE_HOTSPOT_MODE_USB |
1341 VCONFKEY_MOBILE_HOTSPOT_MODE_BT)) {
1342 #ifdef TETHERING_DATA_USAGE_SUPPORT
1343 item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1344 ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1345 elm_genlist_item_select_mode_set(item,
1346 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1347 ad->main.usage_item = item;
1349 /* Insert "Connected devices" item */
1350 tethering_foreach_connected_clients(ad->handle, TETHERING_TYPE_ALL,
1351 _connected_clients_cb, (void *)ad);
1353 no_of_dev = _get_list_clients_count(ad);
1354 if (no_of_dev == 0) {
1355 item = elm_genlist_item_append(ad->main.genlist,
1356 ad->main.device0_itc, ad, NULL,
1357 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1358 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1360 item = elm_genlist_item_append(ad->main.genlist,
1361 ad->main.device_itc, ad, NULL,
1362 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
1363 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1365 ad->main.device_item = item;
1368 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP) {
1369 if (ad->main.wifi_item)
1370 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
1371 if (ad->main.setup_item)
1372 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
1373 if (ad->main.bt_item)
1374 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
1375 if (ad->main.usb_item)
1376 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1379 __MOBILE_AP_FUNC_EXIT__;
1383 void _main_free_genlist_itc(mh_appdata_t *ad)
1385 __MOBILE_AP_FUNC_ENTER__;
1390 mh_main_view_t *mv = &ad->main;
1392 #ifdef TETHERING_DATA_USAGE_SUPPORT
1393 _free_genlist_itc(&mv->usage_itc);
1395 _free_genlist_itc(&mv->device_itc);
1396 _free_genlist_itc(&mv->device0_itc);
1397 _free_genlist_itc(&mv->help_itc);
1398 _free_genlist_itc(&mv->usb_itc);
1399 _free_genlist_itc(&mv->bt_itc);
1400 _free_genlist_itc(&mv->setup_itc);
1401 _free_genlist_itc(&mv->wifi_itc);
1402 #if 0 /* not used */
1403 _free_genlist_itc(&mv->sp_itc);
1404 _free_genlist_itc(&mv->sp2_itc);
1406 __MOBILE_AP_FUNC_EXIT__;
1410 void _main_callback_del(mh_appdata_t *ad)
1412 __MOBILE_AP_FUNC_ENTER__;
1415 ERR("ad is NULL\n");
1421 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
1423 evas_object_smart_callback_del(obj, "changed", __wifi_onoff_changed_cb);
1425 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
1427 evas_object_smart_callback_del(obj, "changed", __bt_onoff_changed_cb);
1429 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
1431 evas_object_smart_callback_del(obj, "changed", __usb_onoff_changed_cb);
1433 evas_object_smart_callback_del(ad->main.genlist, "realized", __gl_realized);
1435 __MOBILE_AP_FUNC_EXIT__;
1438 #if 0 /* device rename not supported */
1439 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad)
1444 __MOBILE_AP_FUNC_ENTER__;
1446 elm_win_screen_size_get(ad->win, NULL, NULL, &w, &h);
1447 pos = elm_win_rotation_get(ad->win);
1452 evas_object_move(ctx, w/2, h);
1455 evas_object_move(ctx, h/2, w);
1458 evas_object_move(ctx, h/2, w);
1461 __MOBILE_AP_FUNC_EXIT__;
1464 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
1466 __MOBILE_AP_FUNC_ENTER__;
1468 mh_appdata_t *ad = (mh_appdata_t *)data;
1469 Evas_Object *ctx = ad->ctxpopup;
1471 __ctx_move_more_ctxpopup(ctx, ad);
1472 evas_object_show(ctx);
1474 __MOBILE_AP_FUNC_EXIT__;
1477 static void __dismissed_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event)
1479 __MOBILE_AP_FUNC_ENTER__;
1481 mh_appdata_t *ad = (mh_appdata_t *)data;
1482 Evas_Object *ctx = ad->ctxpopup;
1485 evas_object_del(ctx);
1488 __ctx_move_more_ctxpopup(ctx, ad);
1489 evas_object_show(ctx);
1490 rotate_flag = EINA_FALSE;
1492 __MOBILE_AP_FUNC_EXIT__;
1495 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj,
1498 Evas_Object *navi = (Evas_Object *)data;
1499 Evas_Object *ctx = obj;
1502 ERR("data is null\n");
1505 __MOBILE_AP_FUNC_ENTER__;
1507 evas_object_smart_callback_del(ctx, "dismissed",
1508 __dismissed_more_ctxpopup_cb);
1509 evas_object_smart_callback_del(elm_object_top_widget_get(ctx),
1510 "rotation,changed", __rotate_more_ctxpopup_cb);
1511 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
1512 __ctx_delete_more_ctxpopup_cb, navi);
1513 __MOBILE_AP_FUNC_EXIT__;
1516 static void _gl_rename_device_sel(void *data, Evas_Object *obj, void *event_info)
1518 __MOBILE_AP_FUNC_ENTER__;
1520 mh_appdata_t *ad = (mh_appdata_t *)data;
1523 ERR("ad is null\n");
1526 evas_object_del(ad->ctxpopup);
1527 ad->ctxpopup = NULL;
1529 _create_rename_device_popup((void *)ad);
1530 __MOBILE_AP_FUNC_EXIT__;
1533 static void __create_ctxpopup_more_button(void *data, Evas_Object *obj,
1536 mh_appdata_t *ad = (mh_appdata_t *)data;
1537 Evas_Object *ctxpopup = NULL;
1540 ERR("ad is null\n");
1543 __MOBILE_AP_FUNC_ENTER__;
1545 if (ad->setup.navi_it == NULL)
1548 elm_naviframe_item_pop_cb_set(ad->setup.navi_it, _setting_back_btn_cb, (void *)ad);
1549 ctxpopup = elm_ctxpopup_add(ad->naviframe);
1550 elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
1552 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
1553 eext_ctxpopup_back_cb, ad);
1554 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE,
1555 eext_ctxpopup_back_cb, ad);
1556 elm_object_style_set(ctxpopup, "more/default");
1557 evas_object_smart_callback_add(ctxpopup, "dismissed",
1558 __dismissed_more_ctxpopup_cb, ad);
1559 evas_object_smart_callback_add(elm_object_top_widget_get(ctxpopup), "rotation,changed",
1560 __rotate_more_ctxpopup_cb, ad);
1561 evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL,
1562 __ctx_delete_more_ctxpopup_cb, ad->naviframe);
1564 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
1565 ELM_CTXPOPUP_DIRECTION_DOWN,
1566 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
1567 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
1569 __ctx_move_more_ctxpopup(ctxpopup, ad);
1570 elm_ctxpopup_item_append(ctxpopup, STR_RENAME_DEVICE_HEADER,
1571 NULL, _gl_rename_device_sel, ad);
1573 evas_object_show(ctxpopup);
1575 ad->ctxpopup = ctxpopup;
1577 __MOBILE_AP_FUNC_EXIT__;
1581 void _main_draw_contents(mh_appdata_t *ad)
1585 Elm_Object_Item *navi_item;
1587 __create_inner_contents(ad);
1589 ad->main.back_btn = elm_button_add(ad->naviframe);
1590 if (ad->main.back_btn == NULL) {
1591 ERR("elm_button_add is failed\n");
1592 if (ad->main.genlist) {
1593 evas_object_del(ad->main.genlist);
1594 ad->main.genlist = NULL;
1598 elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1600 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_BACK,
1601 eext_naviframe_back_cb, NULL);
1602 #if 0 /* device rename not supported */
1603 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE,
1604 __create_ctxpopup_more_button, ad);
1607 evas_object_smart_callback_add(ad->main.back_btn, "clicked", (Evas_Smart_Cb)__back_btn_cb, (void *)ad);
1608 elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1610 navi_item = elm_naviframe_item_push(ad->naviframe, IDS_TETH,
1611 ad->main.back_btn, NULL, ad->main.genlist, NULL);
1612 elm_object_item_domain_text_translatable_set(navi_item, PKGNAME, EINA_TRUE);
1614 elm_naviframe_item_pop_cb_set(navi_item, (Elm_Naviframe_Item_Pop_Cb)__back_btn_cb, (void *)ad);
1615 ad->navi_item = navi_item;