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>
24 #include "mh_view_main.h"
26 #include "mh_string.h"
28 #if 0 /* device rename not supported */
29 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad);
30 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
31 static Eina_Bool rotate_flag = EINA_FALSE;
33 void _genlist_update_device_item(mh_appdata_t *ad);
34 mh_appdata_t *g_ad = NULL;
35 #define UPDATE_INTERVAL 1
37 #if 0 /* device rename not supported */
38 void _rotate_adjust_rename_popup(void)
40 __MOBILE_AP_FUNC_ENTER__;
44 change_ang = elm_win_rotation_get(g_ad->win);
45 if (change_ang == 0 || change_ang == 180) {
46 _hadnle_rename_popup_rotation(EINA_TRUE);
48 _hadnle_rename_popup_rotation(EINA_FALSE);
50 __MOBILE_AP_FUNC_EXIT__;
54 void _select_connected_dev(void *data, Evas_Object *obj, void *event_info)
56 __MOBILE_AP_FUNC_ENTER__;
59 ERR("data is NULL\n");
63 mh_appdata_t *ad = (mh_appdata_t *)data;
65 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
66 _create_connected_client_view(ad);
67 __MOBILE_AP_FUNC_EXIT__;
70 static bool _connected_clients_cb(tethering_client_h client, void *user_data)
72 __MOBILE_AP_FUNC_ENTER__;
74 if (user_data == NULL) {
75 ERR("user_data is NULL\n");
79 mh_appdata_t *ad = (mh_appdata_t *)user_data;
81 _append_list_client_handle(ad, client);
83 __MOBILE_AP_FUNC_EXIT__;
87 void ap_update_data_device(mh_appdata_t *ad)
89 __MOBILE_AP_FUNC_ENTER__;
92 ERR("Invalid param\n");
96 _genlist_update_device_item(ad);
98 __MOBILE_AP_FUNC_EXIT__;
101 #ifdef TETHERING_DATA_USAGE_SUPPORT
102 Eina_Bool ap_update_data_packet_usage(mh_appdata_t *ad)
105 ERR("Invalid param\n");
108 if (ad->main.usage_item == NULL) {
112 if (ad->main.usage_item)
113 elm_genlist_item_update(ad->main.usage_item);
118 Eina_Bool ap_get_data_statistics(void *data)
121 ERR("The param is NULL\n");
122 return ECORE_CALLBACK_CANCEL;
124 mh_appdata_t *ad = (mh_appdata_t *)data;
126 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
127 ad->update_statistics_handle = NULL;
128 return ECORE_CALLBACK_CANCEL;
131 /* If previous data is not updated, new data is not required */
132 if (ad->data_statistics.is_updated == false) {
133 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 if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) {
155 _stop_update_device_conn_time(ad);
156 __MOBILE_AP_FUNC_EXIT__;
157 return ECORE_CALLBACK_CANCEL;
160 while (count < ad->connected_device.no_of_clients) {
161 if (ad->connected_device.station_items[count])
162 elm_genlist_item_fields_update(ad->connected_device.station_items[count++],
163 "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT);
165 return ECORE_CALLBACK_RENEW;
168 void _start_update_device_conn_time(mh_appdata_t *ad)
170 __MOBILE_AP_FUNC_ENTER__;
173 ERR("Invalid param\n");
174 __MOBILE_AP_FUNC_EXIT__;
178 if (ad->update_conn_time_handle) {
179 _stop_update_device_conn_time(ad);
181 ad->update_conn_time_handle = ecore_timer_add(UPDATE_INTERVAL,
182 ap_update_device_conn_time, (void *)ad);
184 __MOBILE_AP_FUNC_EXIT__;
187 void _stop_update_device_conn_time(mh_appdata_t *ad)
189 __MOBILE_AP_FUNC_ENTER__;
192 ERR("Invalid param\n");
196 if (ad->update_conn_time_handle) {
197 ecore_timer_del(ad->update_conn_time_handle);
198 ad->update_conn_time_handle = NULL;
200 __MOBILE_AP_FUNC_EXIT__;
203 #ifdef TETHERING_DATA_USAGE_SUPPORT
204 void _start_update_data_packet_usage(mh_appdata_t *ad)
206 __MOBILE_AP_FUNC_ENTER__;
209 ERR("Invalid param\n");
213 if (ad->update_statistics_handle) {
214 _stop_update_data_packet_usage(ad);
217 ad->data_statistics.is_updated = false;
218 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
219 ad->update_statistics_handle = ecore_timer_add(MH_UPDATE_INTERVAL,
220 ap_get_data_statistics, (void *)ad);
222 __MOBILE_AP_FUNC_EXIT__;
226 void _stop_update_data_packet_usage(mh_appdata_t *ad)
228 __MOBILE_AP_FUNC_ENTER__;
231 ERR("Invalid param\n");
235 if (ad->update_statistics_handle) {
236 ecore_timer_del(ad->update_statistics_handle);
237 ad->data_statistics.is_updated = false;
238 ad->update_statistics_handle = NULL;
241 __MOBILE_AP_FUNC_EXIT__;
246 static void __read_setting(mh_appdata_t *ad)
248 __MOBILE_AP_FUNC_ENTER__;
251 ERR("Invalid param\n");
257 char *passphrase = NULL;
259 tethering_wifi_security_type_e type;
261 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
263 #ifdef TETHERING_DATA_USAGE_SUPPORT
264 ad->data_statistics.pdp_total_sent = 0;
265 ad->data_statistics.pdp_total_receive = 0;
266 if (ad->main.hotspot_mode != VCONFKEY_MOBILE_HOTSPOT_MODE_NONE)
267 tethering_get_data_usage(ad->handle, _data_usage_cb, (void *)ad);
270 ret = tethering_wifi_get_ssid(ad->handle, &ssid);
271 if (ret != TETHERING_ERROR_NONE || ssid == NULL) {
272 ERR("tethering_wifi_get_ssid is failed : %d\n", ret);
275 g_strlcpy(ad->setup.device_name, ssid, sizeof(ad->setup.device_name));
278 ret = tethering_wifi_get_passphrase(ad->handle, &passphrase);
279 if (ret != TETHERING_ERROR_NONE || passphrase == NULL) {
280 ERR("tethering_wifi_get_passphrase is failed : %d\n", ret);
284 g_strlcpy(ad->setup.wifi_passphrase, passphrase,
285 sizeof(ad->setup.wifi_passphrase));
286 g_strlcpy(ad->setup.wifi_passphrase_new, passphrase,
287 sizeof(ad->setup.wifi_passphrase_new));
290 ret = tethering_wifi_get_ssid_visibility(ad->handle, &visibility);
291 if (ret != TETHERING_ERROR_NONE) {
292 ERR("tethering_wifi_get_ssid_visibility is failed\n");
294 ad->setup.visibility = visibility;
295 ad->setup.visibility_new = visibility;
297 ret = tethering_wifi_get_security_type(ad->handle, &type);
298 if (ret != TETHERING_ERROR_NONE) {
299 ERR("tethering_wifi_get_security_type is failed\n");
301 ad->setup.security_type = type;
302 ad->setup.security_type_new = type;
304 __MOBILE_AP_FUNC_EXIT__;
307 void _update_wifi_item(mh_appdata_t *ad, int wifi_state)
309 __MOBILE_AP_FUNC_ENTER__;
311 if (ad->main.wifi_state == wifi_state) {
315 if (ad->main.wifi_state == MH_STATE_PROCESS) {
316 ad->main.wifi_state = MH_STATE_NONE;
317 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
318 } else if (ad->main.wifi_state == MH_STATE_NONE) {
319 ad->main.wifi_state = MH_STATE_PROCESS;
320 elm_genlist_item_select_mode_set(ad->main.wifi_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
323 if (ad->main.wifi_item)
324 elm_genlist_item_update(ad->main.wifi_item);
326 if (ad->main.setup_item)
327 elm_object_item_signal_emit(ad->main.setup_item, "elm,state,bottom", "");
329 __MOBILE_AP_FUNC_EXIT__;
334 void _update_bt_item(mh_appdata_t *ad, int bt_state)
336 __MOBILE_AP_FUNC_ENTER__;
338 if (ad->main.bt_state == bt_state) {
342 if (ad->main.bt_state == MH_STATE_PROCESS) {
343 ad->main.bt_state = MH_STATE_NONE;
344 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
345 } else if (ad->main.bt_state == MH_STATE_NONE) {
346 ad->main.bt_state = MH_STATE_PROCESS;
347 elm_genlist_item_select_mode_set(ad->main.bt_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
350 if (ad->main.bt_item)
351 elm_genlist_item_update(ad->main.bt_item);
353 __MOBILE_AP_FUNC_EXIT__;
358 void _update_usb_item(mh_appdata_t *ad, int usb_state)
360 __MOBILE_AP_FUNC_ENTER__;
362 if (ad->main.usb_state == usb_state) {
366 if (ad->main.usb_state == MH_STATE_PROCESS) {
367 ad->main.usb_state = MH_STATE_NONE;
368 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
369 } else if (ad->main.usb_state == MH_STATE_NONE) {
370 ad->main.usb_state = MH_STATE_PROCESS;
371 elm_genlist_item_select_mode_set(ad->main.usb_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
374 elm_genlist_item_update(ad->main.usb_item);
376 __MOBILE_AP_FUNC_EXIT__;
381 void _genlist_update_device_item(mh_appdata_t *ad)
383 __MOBILE_AP_FUNC_ENTER__;
386 ERR("Invalid param\n");
389 unsigned int no_of_dev = 0;
390 no_of_dev = _get_list_clients_count(ad);
391 Elm_Object_Item *item = NULL;
393 if (ad->main.device_item) {
394 elm_object_item_del(ad->main.device_item);
395 ad->main.device_item = NULL;
396 if (no_of_dev == 0) {
397 item = elm_genlist_item_append(ad->main.genlist,
398 ad->main.device0_itc, ad, NULL,
399 ELM_GENLIST_ITEM_NONE, NULL, NULL);
400 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
402 item = elm_genlist_item_append(ad->main.genlist,
403 ad->main.device_itc, ad, NULL,
404 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
405 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
407 ad->main.device_item = item;
410 if (ad->connected_device.navi_it) {
411 _update_conn_clients(ad);
414 __MOBILE_AP_FUNC_EXIT__;
418 void _update_main_view(mh_appdata_t *ad, tethering_type_e type)
420 __MOBILE_AP_FUNC_ENTER__;
423 ERR("Invalid param\n");
427 int state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
428 Eina_Bool wifi_state = EINA_FALSE;
429 Eina_Bool bt_state = EINA_FALSE;
430 Eina_Bool usb_state = EINA_FALSE;
431 Eina_Bool wifi_ap_state = EINA_FALSE;
432 Elm_Object_Item *item = NULL;
436 ad->main.hotspot_mode = _get_vconf_hotspot_mode();
437 state = ad->main.hotspot_mode;
439 wifi_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI);
440 bt_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT);
441 usb_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB);
442 wifi_ap_state = (Eina_Bool)(state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP);
445 if (ad->main.wifi_item)
446 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
447 if (ad->main.setup_item)
448 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
449 if (ad->main.bt_item)
450 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
451 if (ad->main.usb_item)
452 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
454 if (ad->main.setup_item)
455 elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE);
456 if (ad->main.bt_item)
457 elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE);
458 if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) {
459 if (ad->main.usb_item)
460 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
462 if (ad->main.usb_item)
463 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
467 if (wifi_state || bt_state || usb_state) {
468 #ifdef TETHERING_DATA_USAGE_SUPPORT
469 if (ad->main.usage_item == NULL) {
470 item = elm_genlist_item_insert_before(ad->main.genlist,
471 ad->main.usage_itc, ad, NULL,
473 ELM_GENLIST_ITEM_NONE, NULL, NULL);
474 elm_genlist_item_select_mode_set(item,
475 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
476 ad->main.usage_item = item;
480 no_of_dev = _get_list_clients_count(ad);
481 if (ad->main.device_item == NULL) {
482 if (no_of_dev == 0) {
483 item = elm_genlist_item_append(ad->main.genlist,
484 ad->main.device0_itc, ad, NULL,
485 ELM_GENLIST_ITEM_NONE, NULL, NULL);
486 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
488 item = elm_genlist_item_append(ad->main.genlist,
489 ad->main.device_itc, ad, NULL,
490 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
491 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
493 ad->main.device_item = item;
496 if (ad->main.device_item) {
497 elm_object_item_del(ad->main.device_item);
498 ad->main.device_item = NULL;
500 #ifdef TETHERING_DATA_USAGE_SUPPORT
501 if (ad->main.usage_item) {
502 elm_object_item_del(ad->main.usage_item);
503 ad->main.usage_item = NULL;
509 if (ad->main.help_item) {
510 elm_genlist_item_update(ad->main.help_item);
512 item = elm_genlist_item_insert_after(ad->main.genlist,
513 ad->main.help_itc, ad, NULL,
515 ELM_GENLIST_ITEM_NONE, NULL,
518 ERR("elm_genlist_item_insert_after NULL\n");
520 elm_genlist_item_select_mode_set(item,
521 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
522 ad->main.help_item = item;
526 if (ad->main.help_item) {
527 elm_object_item_del(ad->main.help_item);
528 ad->main.help_item = NULL;
533 case TETHERING_TYPE_WIFI:
534 /* Update Wi-Fi tethering on / off button */
535 if (ad->main.wifi_state != MH_STATE_NONE) {
536 _update_wifi_item(ad, MH_STATE_NONE);
538 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
540 elm_check_state_set(obj, wifi_state);
543 if (ad->main.wifi_item) {
544 elm_genlist_item_update(ad->main.wifi_item);
549 case TETHERING_TYPE_BT:
550 /* Update BT tethering on / off button */
551 if (ad->main.bt_state != MH_STATE_NONE) {
552 _update_bt_item(ad, MH_STATE_NONE);
554 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
556 elm_check_state_set(obj, bt_state);
559 if (ad->main.bt_item) {
560 elm_genlist_item_update(ad->main.bt_item);
565 case TETHERING_TYPE_USB:
566 /* Update USB tethering on / off button */
567 if (ad->main.usb_state != MH_STATE_NONE) {
568 _update_usb_item(ad, MH_STATE_NONE);
570 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
572 elm_check_state_set(obj, usb_state);
574 if (ad->main.usb_item)
575 elm_genlist_item_update(ad->main.usb_item);
580 DBG("Unknown tethering type : %d\n", type);
584 __MOBILE_AP_FUNC_EXIT__;
589 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
592 __MOBILE_AP_FUNC_ENTER__;
595 ERR("The param is NULL\n");
599 mh_appdata_t *ad = (mh_appdata_t *)data;
601 _update_wifi_item(ad, MH_STATE_PROCESS);
602 ad->type = TETHERING_TYPE_WIFI;
603 ad->is_wifi_teth_enabling = true;
604 if (_handle_wifi_onoff_change(ad) != 0) {
605 ERR("_handle_wifi_onoff_change is failed\n");
606 _update_wifi_item(ad, MH_STATE_NONE);
607 ad->is_wifi_teth_enabling = false;
610 __MOBILE_AP_FUNC_EXIT__;
615 static void __select_wifi_item(void *data, Evas_Object *obj, void *event_info)
617 __MOBILE_AP_FUNC_ENTER__;
620 ERR("The param is NULL\n");
623 mh_appdata_t *ad = (mh_appdata_t *)data;
625 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
626 mh_draw_wifi_setup_view(ad);
628 __MOBILE_AP_FUNC_EXIT__;
633 static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
635 __MOBILE_AP_FUNC_ENTER__;
638 ERR("The param is NULL\n");
642 mh_appdata_t *ad = (mh_appdata_t *)data;
644 _update_bt_item(ad, MH_STATE_PROCESS);
645 ad->type = TETHERING_TYPE_BT;
646 ad->is_bt_teth_enabling = true;
648 if (_handle_bt_onoff_change(ad) != 0) {
649 ERR("_handle_bt_onoff_change is failed\n");
650 _update_bt_item(ad, MH_STATE_NONE);
651 ad->is_bt_teth_enabling = false;
654 __MOBILE_AP_FUNC_EXIT__;
659 static void __select_bt_item(void *data, Evas_Object *obj, void *event_info)
661 __MOBILE_AP_FUNC_ENTER__;
663 Evas_Object *content;
664 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
667 ERR("The param is NULL\n");
671 elm_genlist_item_selected_set(item, EINA_FALSE);
673 content = elm_object_item_part_content_get(item, "elm.icon");
674 __bt_onoff_changed_cb(data, content, NULL);
676 __MOBILE_AP_FUNC_EXIT__;
681 static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info)
683 __MOBILE_AP_FUNC_ENTER__;
686 ERR("The param is NULL\n");
690 mh_appdata_t *ad = (mh_appdata_t *)data;
691 _update_usb_item(ad, MH_STATE_PROCESS);
692 ad->type = TETHERING_TYPE_USB;
693 ad->is_usb_teth_enabling = true;
694 if (_handle_usb_onoff_change(ad) != 0) {
695 ERR("_handle_usb_onoff_change is failed\n");
696 _update_usb_item(ad, MH_STATE_NONE);
697 ad->is_usb_teth_enabling = false;
700 __MOBILE_AP_FUNC_EXIT__;
705 static void __select_usb_item(void *data, Evas_Object *obj, void *event_info)
707 __MOBILE_AP_FUNC_ENTER__;
709 Evas_Object *content;
710 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
713 ERR("The param is NULL\n");
717 elm_genlist_item_selected_set(item, EINA_FALSE);
719 content = elm_object_item_part_content_get(item, "elm.icon");
720 __usb_onoff_changed_cb(data, content, NULL);
722 __MOBILE_AP_FUNC_EXIT__;
727 static void __back_btn_cb(void *data, Elm_Object_Item *navi_item)
732 ERR("The param is NULL\n");
736 mh_appdata_t *ad = (mh_appdata_t*)data;
738 _release_list_client_handle(ad);
739 _main_callback_del(ad);
741 ug_destroy_me(((mh_ugdata_t *)ad->gadget)->ug);
747 static char *__get_wifi_label(void *data, Evas_Object *obj, const char *part)
749 if (!strcmp("elm.text", part)) {
750 return strdup(STR_WIFI_TETH);
756 static Evas_Object *__get_wifi_icon(void *data, Evas_Object *obj,
759 mh_appdata_t *ad = (mh_appdata_t*)data;
760 Evas_Object *btn = NULL;
761 Evas_Object *progressbar = NULL;
762 Evas_Object *icon_layout = NULL;
765 ERR("The param is NULL\n");
769 if (!strcmp("elm.swallow.end", part)) {
770 icon_layout = elm_layout_add(obj);
771 elm_layout_theme_set(icon_layout, "layout", "list/C/type.3", "default");
773 if (ad->main.wifi_state == MH_STATE_PROCESS) {
774 progressbar = _create_progressbar(obj, "process_medium");
775 elm_layout_content_set(icon_layout, "elm.swallow.content", progressbar);
777 btn = elm_check_add(obj);
778 elm_object_style_set(btn, "on&off");
779 evas_object_show(btn);
781 evas_object_pass_events_set(btn, EINA_TRUE);
782 evas_object_propagate_events_set(btn, EINA_FALSE);
783 elm_check_state_set(btn, ad->main.hotspot_mode &
784 VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI ? EINA_TRUE : EINA_FALSE);
786 evas_object_smart_callback_add(btn, "changed", __wifi_onoff_changed_cb, ad);
787 elm_layout_content_set(icon_layout, "elm.swallow.content", btn);
794 static char *__get_bt_label(void *data, Evas_Object *obj, const char *part)
796 if (!strcmp("elm.text", part)) {
797 return strdup(STR_BLUETOOTH_TETH);
803 static Evas_Object *__get_bt_icon(void *data, Evas_Object *obj, const char *part)
805 mh_appdata_t *ad = (mh_appdata_t *)data;
806 Evas_Object *btn = NULL;
807 Evas_Object *progressbar = NULL;
808 Evas_Object *icon_layout = NULL;
811 ERR("The param is NULL\n");
815 if (!strcmp("elm.swallow.end", part)) {
816 icon_layout = elm_layout_add(obj);
817 elm_layout_theme_set(icon_layout, "layout", "list/C/type.3", "default");
819 if (ad->main.bt_state == MH_STATE_PROCESS) {
820 progressbar = _create_progressbar(obj, "process_medium");
821 elm_layout_content_set(icon_layout, "elm.swallow.content", progressbar);
823 btn = elm_check_add(obj);
825 ERR("btn is NULL\n");
828 elm_object_style_set(btn, "on&off");
829 evas_object_pass_events_set(btn, EINA_TRUE);
830 evas_object_propagate_events_set(btn, EINA_FALSE);
831 elm_check_state_set(btn, ad->main.hotspot_mode &
832 VCONFKEY_MOBILE_HOTSPOT_MODE_BT ? EINA_TRUE : EINA_FALSE);
833 evas_object_show(btn);
834 evas_object_smart_callback_add(btn, "changed", __bt_onoff_changed_cb, ad);
835 elm_layout_content_set(icon_layout, "elm.swallow.content", btn);
842 static char *__get_usb_label(void *data, Evas_Object *obj, const char *part)
844 if (!strcmp("elm.text", part)) {
845 return strdup(STR_USB_TETH);
851 static Evas_Object *__get_usb_icon(void *data, Evas_Object *obj,
854 mh_appdata_t *ad = (mh_appdata_t *)data;
855 Evas_Object *btn = NULL;
856 Evas_Object *progressbar = NULL;
857 Evas_Object *icon_layout = NULL;
860 ERR("The param is NULL\n");
864 if (!strcmp("elm.swallow.end", part)) {
865 icon_layout = elm_layout_add(obj);
866 elm_layout_theme_set(icon_layout, "layout", "list/C/type.3", "default");
868 if (ad->main.usb_state == MH_STATE_PROCESS) {
869 progressbar = _create_progressbar(obj, "process_medium");
870 elm_layout_content_set(icon_layout, "elm.swallow.content", progressbar);
872 btn = elm_check_add(obj);
874 ERR("btn is NULL\n");
877 elm_object_style_set(btn, "on&off");
878 evas_object_pass_events_set(btn, EINA_TRUE);
879 evas_object_propagate_events_set(btn, EINA_FALSE);
880 elm_check_state_set(btn, ad->main.hotspot_mode &
881 VCONFKEY_MOBILE_HOTSPOT_MODE_USB ? EINA_TRUE : EINA_FALSE);
882 evas_object_show(btn);
883 evas_object_smart_callback_add(btn, "changed", __usb_onoff_changed_cb, ad);
884 elm_layout_content_set(icon_layout, "elm.swallow.content", btn);
891 static char *__get_help_label(void *data, Evas_Object *obj, const char *part)
893 mh_appdata_t *ad = (mh_appdata_t *)data;
894 char buf[MH_LABEL_LENGTH_MAX] = {0, };
895 char device_name[MH_LABEL_LENGTH_MAX] = {0, };
896 char passphrase[MH_LABEL_LENGTH_MAX] = {0, };
897 char security_type[MH_LABEL_LENGTH_MAX] = {0, };
900 char *device_name_utf = NULL;
901 int wifi_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
904 ERR("The param is NULL\n");
908 if (!strcmp("elm.text.multiline", part)) {
909 device_name_utf = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
910 if (device_name_utf == NULL) {
911 ERR("vconf_get_str failed \n");
915 ptr = elm_entry_utf8_to_markup(device_name_utf);
917 g_free(device_name_utf);
918 ERR("elm_entry_utf8_to_markup is failed\n");
922 g_strlcpy(ad->setup.device_name, ptr,
923 sizeof(ad->setup.device_name));
924 g_strlcpy(device_name, ptr, MH_LABEL_LENGTH_MAX);
925 g_free(device_name_utf);
929 if (ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
930 ptr = elm_entry_utf8_to_markup(ad->setup.wifi_passphrase);
932 ERR("elm_entry_utf8_to_markup is failed\n");
935 g_strlcpy(passphrase, ptr, MH_LABEL_LENGTH_MAX);
938 snprintf(security_type, sizeof(security_type),
939 STR_SECURITY_TYPE_PS, "WPA2 PSK");
942 wifi_state = ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI;
944 if (wifi_state && ad->setup.visibility == false)
945 hidden = STR_WIFI_TETH_HIDDEN;
947 if (wifi_state && ad->setup.security_type != TETHERING_WIFI_SECURITY_TYPE_NONE) {
948 snprintf(buf, MH_LABEL_LENGTH_MAX,
961 STR_PASSWORD_FOR_WIFI_TETH,
962 hidden[0] != '\0' ? "<br>" : "",
965 snprintf(buf, MH_LABEL_LENGTH_MAX,
972 hidden[0] != '\0' ? "<br>" : "",
982 static char *__get_no_connected_device_label(void *data, Evas_Object *obj,
985 mh_appdata_t *ad = (mh_appdata_t*)data;
986 char buf[MH_LABEL_LENGTH_MAX] = {0, };
990 ERR("The param is NULL\n");
994 if (!strcmp("elm.text.multiline", part)) {
995 no_of_dev = _get_list_clients_count(ad);
996 snprintf(buf, MH_LABEL_LENGTH_MAX, "<font_size=30>%s<br>%d</font_size>", STR_CONNECTED_DEV, no_of_dev);
1003 static char *__get_connected_device_label(void *data, Evas_Object *obj,
1006 mh_appdata_t *ad = (mh_appdata_t*)data;
1007 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1011 ERR("The param is NULL\n");
1015 if (!strcmp("elm.text.sub", part)) {
1016 g_strlcpy(buf, STR_CONNECTED_DEV, sizeof(buf));
1018 } else if (!strcmp("elm.text", part)) {
1019 no_of_dev = _get_list_clients_count(ad);
1020 snprintf(buf, MH_LABEL_LENGTH_MAX, "%d", no_of_dev);
1027 #ifdef TETHERING_DATA_USAGE_SUPPORT
1028 static char *__get_usage_label(void *data, Evas_Object *obj, const char *part)
1030 mh_appdata_t *ad = (mh_appdata_t*)data;
1031 unsigned long long total = 0;
1032 unsigned long long sent = 0;
1033 unsigned long long received = 0;
1035 char buf[MH_LABEL_LENGTH_MAX] = {0, };
1036 char label[MH_LABEL_LENGTH_MAX] = {0, };
1039 ERR("The param is NULL\n");
1043 if (!strcmp("elm.text", part)) {
1044 g_strlcpy(label, STR_DATA_USAGE, sizeof(label));
1045 return strdup(label);
1046 } else if (!strcmp("elm.text.multiline", part)) {
1047 sent = ad->data_statistics.pdp_total_sent;
1048 received = ad->data_statistics.pdp_total_receive;
1050 if (sent >= MH_MB || received >= MH_MB) {
1054 total = sent + received;
1056 } else if (sent + received >= MH_MB) {
1057 total = (sent + received) / MH_MB;
1059 } else if (sent >= MH_KB || received >= MH_KB) {
1063 total = sent + received;
1065 } else if (sent + received >= MH_KB) {
1066 total = (sent + received) / MH_KB;
1069 total = sent + received;
1073 if (total > INT_MAX) {
1074 ERR("data usage overflow\n");
1077 snprintf(label, MH_LABEL_LENGTH_MAX, fmt_str, (int)total);
1078 return strdup(label);
1085 static void __set_genlist_itc(mh_appdata_t *ad)
1087 /* On, Off view's item class for genlist */
1088 #if 0 /* not used */
1089 ad->main.sp_itc = elm_genlist_item_class_new();
1090 if (ad->main.sp_itc == NULL) {
1091 ERR("elm_genlist_item_class_new failed\n");
1095 ad->main.sp_itc->item_style = "dialogue/separator";
1096 ad->main.sp_itc->func.text_get = NULL;
1097 ad->main.sp_itc->func.content_get = NULL;
1098 ad->main.sp_itc->func.state_get = NULL;
1099 ad->main.sp_itc->func.del = NULL;
1101 ad->main.wifi_itc = elm_genlist_item_class_new();
1102 if (ad->main.wifi_itc == NULL) {
1103 ERR("elm_genlist_item_class_new failed\n");
1107 ad->main.wifi_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1108 ad->main.wifi_itc->func.text_get = __get_wifi_label;
1109 ad->main.wifi_itc->func.content_get = __get_wifi_icon;
1110 ad->main.wifi_itc->func.state_get = NULL;
1111 ad->main.wifi_itc->func.del = NULL;
1113 #if 0 /* not used */
1114 ad->main.sp2_itc = elm_genlist_item_class_new();
1115 if (ad->main.sp2_itc == NULL) {
1116 ERR("elm_genlist_item_class_new failed\n");
1120 ad->main.sp2_itc->item_style = "dialogue/separator.2";
1121 ad->main.sp2_itc->func.text_get = NULL;
1122 ad->main.sp2_itc->func.content_get = NULL;
1123 ad->main.sp2_itc->func.state_get = NULL;
1124 ad->main.sp2_itc->func.del = NULL;
1126 /* End of On, Off view's item class for genlist */
1128 /* Off view's item class for genlist */
1129 ad->main.bt_itc = elm_genlist_item_class_new();
1130 if (ad->main.bt_itc == NULL) {
1131 ERR("elm_genlist_item_class_new failed\n");
1135 ad->main.bt_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1136 ad->main.bt_itc->func.text_get = __get_bt_label;
1137 ad->main.bt_itc->func.content_get = __get_bt_icon;
1138 ad->main.bt_itc->func.state_get = NULL;
1139 ad->main.bt_itc->func.del = NULL;
1141 ad->main.usb_itc = elm_genlist_item_class_new();
1142 if (ad->main.usb_itc == NULL) {
1143 ERR("elm_genlist_item_class_new failed\n");
1147 ad->main.usb_itc->item_style = MH_GENLIST_1LINE_TEXT_ICON_STYLE;
1148 ad->main.usb_itc->func.text_get = __get_usb_label;
1149 ad->main.usb_itc->func.content_get = __get_usb_icon;
1150 ad->main.usb_itc->func.state_get = NULL;
1151 ad->main.usb_itc->func.del = NULL;
1153 ad->main.help_itc = elm_genlist_item_class_new();
1154 if (ad->main.help_itc == NULL) {
1155 ERR("elm_genlist_item_class_new failed\n");
1159 ad->main.help_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1160 ad->main.help_itc->func.text_get = __get_help_label;
1161 ad->main.help_itc->func.content_get = NULL;
1162 ad->main.help_itc->func.state_get = NULL;
1163 ad->main.help_itc->func.del = NULL;
1165 /* End of Off view's item class for genlist */
1167 /* On view's item class for genlist */
1168 ad->main.device0_itc = elm_genlist_item_class_new();
1169 if (ad->main.device0_itc == NULL) {
1170 ERR("elm_genlist_item_class_new failed\n");
1174 ad->main.device0_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1175 ad->main.device0_itc->func.text_get = __get_no_connected_device_label;
1176 ad->main.device0_itc->func.content_get = NULL;
1177 ad->main.device0_itc->func.state_get = NULL;
1178 ad->main.device0_itc->func.del = NULL;
1180 ad->main.device_itc = elm_genlist_item_class_new();
1181 if (ad->main.device_itc == NULL) {
1182 ERR("elm_genlist_item_class_new failed\n");
1186 ad->main.device_itc->item_style = MH_GENLIST_2LINE_BOTTOM_TEXT_STYLE;
1187 ad->main.device_itc->func.text_get = __get_connected_device_label;
1188 ad->main.device_itc->func.content_get = NULL;
1189 ad->main.device_itc->func.state_get = NULL;
1190 ad->main.device_itc->func.del = NULL;
1192 #ifdef TETHERING_DATA_USAGE_SUPPORT
1193 ad->main.usage_itc = elm_genlist_item_class_new();
1194 if (ad->main.usage_itc == NULL) {
1195 ERR("elm_genlist_item_class_new failed\n");
1199 ad->main.usage_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE;
1200 ad->main.usage_itc->func.text_get = __get_usage_label;
1201 ad->main.usage_itc->func.content_get = NULL;
1202 ad->main.usage_itc->func.state_get = NULL;
1203 ad->main.usage_itc->func.del = NULL;
1205 /* End of On view's item class for genlist */
1209 static void __gl_realized(void *data, Evas_Object *obj, void *event_info)
1211 if (data == NULL || event_info == NULL) {
1212 ERR("Invalid param\n");
1216 mh_appdata_t *ad = (mh_appdata_t *)data;
1217 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1220 char str[MH_LABEL_LENGTH_MAX] = {0, };
1223 if (item == ad->main.wifi_item || item == ad->main.bt_item || item == ad->main.usb_item) {
1224 ao = elm_object_item_access_object_get(item);
1225 btn = elm_object_item_part_content_get(item, "on&off");
1226 snprintf(str, sizeof(str), "%s, %s", "On/off button",
1227 (elm_check_state_get(btn) ? "On" : "Off"));
1228 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1230 if (item == ad->main.wifi_item || item == ad->main.bt_item) {
1231 DBG("Wi-Fi or BT item : %p\n", item);
1232 elm_object_item_signal_emit(item, "elm,state,top", "");
1233 } else if (item == ad->main.usb_item) {
1235 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1237 } else if (item == ad->main.setup_item) {
1238 DBG("setup_item\n");
1239 ao = elm_object_item_access_object_get(item);
1240 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Item");
1242 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1243 } else if (item == ad->main.device_item) {
1244 DBG("device_item\n");
1245 ao = elm_object_item_access_object_get(item);
1246 snprintf(str, sizeof(str), "%s, %s", "Expandable list",
1247 "Double tap to open list");
1248 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, str);
1250 elm_object_item_signal_emit(item, "elm,state,top", "");
1251 } else if (ad->main.device_item != NULL &&
1252 ad->main.device_item == elm_genlist_item_parent_get(item)) {
1253 DBG("device_item's child\n");
1254 elm_object_item_signal_emit(item, "elm,state,center", "");
1256 for (i = 0; i < 4; i++) {
1257 if (item == ad->main.sp_item[i])
1258 elm_object_item_access_unregister(item);
1261 #ifdef TETHERING_DATA_USAGE_SUPPORT
1262 if (item == ad->main.usage_item) {
1263 DBG("usage_item\n");
1264 elm_object_item_signal_emit(item, "elm,state,bottom", "");
1270 static void __create_inner_contents(mh_appdata_t *ad)
1272 __MOBILE_AP_FUNC_ENTER__;
1274 Elm_Object_Item *item = NULL;
1278 ad->main.genlist = elm_genlist_add(ad->naviframe);
1279 elm_genlist_mode_set(ad->main.genlist, ELM_LIST_COMPRESS);
1280 evas_object_smart_callback_add(ad->main.genlist, "realized", __gl_realized, ad);
1282 __set_genlist_itc(ad);
1284 item = elm_genlist_item_append(ad->main.genlist, ad->main.wifi_itc,
1285 ad, NULL, ELM_GENLIST_ITEM_NONE,
1286 __select_wifi_item, ad);
1287 ad->main.wifi_item = item;
1289 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
1290 item = elm_genlist_item_append(ad->main.genlist, ad->main.help_itc,
1291 ad, NULL, ELM_GENLIST_ITEM_NONE,
1293 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1294 ad->main.help_item = item;
1297 item = elm_genlist_item_append(ad->main.genlist, ad->main.bt_itc,
1298 ad, NULL, ELM_GENLIST_ITEM_NONE,
1299 __select_bt_item, ad);
1300 ad->main.bt_item = item;
1302 item = elm_genlist_item_append(ad->main.genlist, ad->main.usb_itc,
1303 ad, NULL, ELM_GENLIST_ITEM_NONE,
1304 __select_usb_item, ad);
1305 ad->main.usb_item = item;
1306 if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) {
1307 if (ad->main.usb_item)
1308 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1310 if (ad->main.usb_item)
1311 elm_object_item_disabled_set(ad->main.usb_item, EINA_FALSE);
1313 if (ad->main.hotspot_mode & (VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI |
1314 VCONFKEY_MOBILE_HOTSPOT_MODE_USB |
1315 VCONFKEY_MOBILE_HOTSPOT_MODE_BT)) {
1316 #ifdef TETHERING_DATA_USAGE_SUPPORT
1317 item = elm_genlist_item_append(ad->main.genlist, ad->main.usage_itc,
1318 ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1319 elm_genlist_item_select_mode_set(item,
1320 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1321 ad->main.usage_item = item;
1323 /* Insert "Connected devices" item */
1324 tethering_foreach_connected_clients(ad->handle, TETHERING_TYPE_ALL,
1325 _connected_clients_cb, (void *)ad);
1327 no_of_dev = _get_list_clients_count(ad);
1328 if (no_of_dev == 0) {
1329 item = elm_genlist_item_append(ad->main.genlist,
1330 ad->main.device0_itc, ad, NULL,
1331 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1332 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1334 item = elm_genlist_item_append(ad->main.genlist,
1335 ad->main.device_itc, ad, NULL,
1336 ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad);
1337 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT);
1339 ad->main.device_item = item;
1342 if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP) {
1343 if (ad->main.wifi_item)
1344 elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
1345 if (ad->main.setup_item)
1346 elm_object_item_disabled_set(ad->main.setup_item, EINA_TRUE);
1347 if (ad->main.bt_item)
1348 elm_object_item_disabled_set(ad->main.bt_item, EINA_TRUE);
1349 if (ad->main.usb_item)
1350 elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE);
1353 __MOBILE_AP_FUNC_EXIT__;
1357 void _main_free_genlist_itc(mh_appdata_t *ad)
1359 __MOBILE_AP_FUNC_ENTER__;
1364 mh_main_view_t *mv = &ad->main;
1366 #ifdef TETHERING_DATA_USAGE_SUPPORT
1367 _free_genlist_itc(&mv->usage_itc);
1369 _free_genlist_itc(&mv->device_itc);
1370 _free_genlist_itc(&mv->device0_itc);
1371 _free_genlist_itc(&mv->help_itc);
1372 _free_genlist_itc(&mv->usb_itc);
1373 _free_genlist_itc(&mv->bt_itc);
1374 _free_genlist_itc(&mv->setup_itc);
1375 _free_genlist_itc(&mv->wifi_itc);
1376 #if 0 /* not used */
1377 _free_genlist_itc(&mv->sp_itc);
1378 _free_genlist_itc(&mv->sp2_itc);
1380 __MOBILE_AP_FUNC_EXIT__;
1384 void _main_callback_del(mh_appdata_t *ad)
1386 __MOBILE_AP_FUNC_ENTER__;
1389 ERR("ad is NULL\n");
1395 obj = elm_object_item_part_content_get(ad->main.wifi_item, "elm.swallow.end");
1397 evas_object_smart_callback_del(obj, "changed", __wifi_onoff_changed_cb);
1399 obj = elm_object_item_part_content_get(ad->main.bt_item, "elm.swallow.end");
1401 evas_object_smart_callback_del(obj, "changed", __bt_onoff_changed_cb);
1403 obj = elm_object_item_part_content_get(ad->main.usb_item, "elm.swallow.end");
1405 evas_object_smart_callback_del(obj, "changed", __usb_onoff_changed_cb);
1407 evas_object_smart_callback_del(ad->main.genlist, "realized", __gl_realized);
1409 __MOBILE_AP_FUNC_EXIT__;
1412 #if 0 /* device rename not supported */
1413 static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad)
1418 __MOBILE_AP_FUNC_ENTER__;
1420 elm_win_screen_size_get(ad->win, NULL, NULL, &w, &h);
1421 pos = elm_win_rotation_get(ad->win);
1426 evas_object_move(ctx, w/2, h);
1429 evas_object_move(ctx, h/2, w);
1432 evas_object_move(ctx, h/2, w);
1435 __MOBILE_AP_FUNC_EXIT__;
1438 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
1440 __MOBILE_AP_FUNC_ENTER__;
1442 mh_appdata_t *ad = (mh_appdata_t *)data;
1443 Evas_Object *ctx = ad->ctxpopup;
1445 __ctx_move_more_ctxpopup(ctx, ad);
1446 evas_object_show(ctx);
1448 __MOBILE_AP_FUNC_EXIT__;
1451 static void __dismissed_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event)
1453 __MOBILE_AP_FUNC_ENTER__;
1455 mh_appdata_t *ad = (mh_appdata_t *)data;
1456 Evas_Object *ctx = ad->ctxpopup;
1459 evas_object_del(ctx);
1462 __ctx_move_more_ctxpopup(ctx, ad);
1463 evas_object_show(ctx);
1464 rotate_flag = EINA_FALSE;
1466 __MOBILE_AP_FUNC_EXIT__;
1469 static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj,
1472 Evas_Object *navi = (Evas_Object *)data;
1473 Evas_Object *ctx = obj;
1476 ERR("data is null\n");
1479 __MOBILE_AP_FUNC_ENTER__;
1481 evas_object_smart_callback_del(ctx, "dismissed",
1482 __dismissed_more_ctxpopup_cb);
1483 evas_object_smart_callback_del(elm_object_top_widget_get(ctx),
1484 "rotation,changed", __rotate_more_ctxpopup_cb);
1485 evas_object_event_callback_del_full(ctx, EVAS_CALLBACK_DEL,
1486 __ctx_delete_more_ctxpopup_cb, navi);
1487 __MOBILE_AP_FUNC_EXIT__;
1490 static void _gl_rename_device_sel(void *data, Evas_Object *obj, void *event_info)
1492 __MOBILE_AP_FUNC_ENTER__;
1494 mh_appdata_t *ad = (mh_appdata_t *)data;
1497 ERR("ad is null\n");
1500 evas_object_del(ad->ctxpopup);
1501 ad->ctxpopup = NULL;
1503 _create_rename_device_popup((void *)ad);
1504 __MOBILE_AP_FUNC_EXIT__;
1507 static void __create_ctxpopup_more_button(void *data, Evas_Object *obj,
1510 mh_appdata_t *ad = (mh_appdata_t *)data;
1511 Evas_Object *ctxpopup = NULL;
1514 ERR("ad is null\n");
1517 __MOBILE_AP_FUNC_ENTER__;
1519 if (ad->setup.navi_it == NULL) {
1523 elm_naviframe_item_pop_cb_set(ad->setup.navi_it, _setting_back_btn_cb, (void *)ad);
1524 ctxpopup = elm_ctxpopup_add(ad->naviframe);
1525 elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
1527 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK,
1528 eext_ctxpopup_back_cb, ad);
1529 eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE,
1530 eext_ctxpopup_back_cb, ad);
1531 elm_object_style_set(ctxpopup, "more/default");
1532 evas_object_smart_callback_add(ctxpopup, "dismissed",
1533 __dismissed_more_ctxpopup_cb, ad);
1534 evas_object_smart_callback_add(elm_object_top_widget_get(ctxpopup), "rotation,changed",
1535 __rotate_more_ctxpopup_cb, ad);
1536 evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL,
1537 __ctx_delete_more_ctxpopup_cb, ad->naviframe);
1539 elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_UP,
1540 ELM_CTXPOPUP_DIRECTION_DOWN,
1541 ELM_CTXPOPUP_DIRECTION_UNKNOWN,
1542 ELM_CTXPOPUP_DIRECTION_UNKNOWN);
1544 __ctx_move_more_ctxpopup(ctxpopup, ad);
1545 elm_ctxpopup_item_append(ctxpopup, STR_RENAME_DEVICE_HEADER,
1546 NULL, _gl_rename_device_sel, ad);
1548 evas_object_show(ctxpopup);
1550 ad->ctxpopup = ctxpopup;
1552 __MOBILE_AP_FUNC_EXIT__;
1556 void _main_draw_contents(mh_appdata_t *ad)
1560 Elm_Object_Item *navi_item;
1562 __create_inner_contents(ad);
1564 ad->main.back_btn = elm_button_add(ad->naviframe);
1565 if (ad->main.back_btn == NULL) {
1566 ERR("elm_button_add is failed\n");
1567 if (ad->main.genlist) {
1568 evas_object_del(ad->main.genlist);
1569 ad->main.genlist = NULL;
1573 elm_object_style_set(ad->main.back_btn, "naviframe/back_btn/default");
1575 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_BACK,
1576 eext_naviframe_back_cb, NULL);
1577 #if 0 /* device rename not supported */
1578 eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE,
1579 __create_ctxpopup_more_button, ad);
1582 evas_object_smart_callback_add(ad->main.back_btn, "clicked", (Evas_Smart_Cb)__back_btn_cb, (void *)ad);
1583 elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);
1585 navi_item = elm_naviframe_item_push(ad->naviframe, IDS_TETH,
1586 ad->main.back_btn, NULL, ad->main.genlist, NULL);
1587 elm_object_item_domain_text_translatable_set(navi_item, PKGNAME, EINA_TRUE);
1589 elm_naviframe_item_pop_cb_set(navi_item, (Elm_Naviframe_Item_Pop_Cb)__back_btn_cb, (void *)ad);
1590 ad->navi_item = navi_item;