X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmh_view_main.c;h=d9805dddf8e55b7f8397ba9f629222e89afe59b9;hb=refs%2Fchanges%2F12%2F289912%2F1;hp=cc5ee80a1c95c407e0abf2f78609a34ecc66d3b9;hpb=3b0695931dc145b5f1a8fc74035c104439f9f41f;p=apps%2Fnative%2Fug-mobile-ap.git diff --git a/src/mh_view_main.c b/src/mh_view_main.c index cc5ee80..d9805dd 100755 --- a/src/mh_view_main.c +++ b/src/mh_view_main.c @@ -3,7 +3,7 @@ * * Copyright 2012 Samsung Electronics Co., Ltd -* Licensed under the Flora License, Version 1.0 (the "License"); +* Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,30 +23,51 @@ #include #include "mh_view_main.h" +#include "mh_common_utility.h" #include "mh_popup.h" #include "mh_string.h" static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad); -static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static Eina_Bool rotate_flag = EINA_FALSE; +static void __ctx_delete_more_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj, + void *event_info); +static void __create_ctxpopup_more_button(void *data, Evas_Object *obj, + void *event_info); void _genlist_update_device_item(mh_appdata_t *ad); mh_appdata_t *g_ad = NULL; #define UPDATE_INTERVAL 1 -void _select_connected_dev(void *data, Evas_Object *obj, void *event_info) +#ifdef TIZEN_FEATURE_EMULATOR +static tethering_type_e updated_type = TETHERING_TYPE_ALL; +static tethering_type_e selected_type = TETHERING_TYPE_ALL; +static Eina_Bool selected_state = EINA_FALSE; + +tethering_type_e _get_updated_type(void) +{ + return updated_type; +} + +tethering_type_e _get_selected_type(void) +{ + return selected_type; +} + +Eina_Bool _get_selected_state(void) +{ + return selected_state; +} +#endif + +void _list_connected_dev(mh_appdata_t *ap) { __MOBILE_AP_FUNC_ENTER__; - if (data == NULL) { + if (ap == NULL) { ERR("data is NULL\n"); return; } - mh_appdata_t *ad = (mh_appdata_t *)data; - - elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); - _create_connected_client_view(ad); + _add_connected_clients(ap); __MOBILE_AP_FUNC_EXIT__; } @@ -128,17 +149,46 @@ Eina_Bool ap_update_device_conn_time(void * data) return ECORE_CALLBACK_CANCEL; } mh_appdata_t *ad = (mh_appdata_t *)data; - int count = 0; + +#ifdef TIZEN_FEATURE_EMULATOR + if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) { + _stop_update_device_conn_time(ad); + return ECORE_CALLBACK_CANCEL; + } + + if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) { + updated_type = TETHERING_TYPE_WIFI; + elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_WIFI], + "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); + } + + if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) { + updated_type = TETHERING_TYPE_BT; + elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_BT], + "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); + } + + if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) { + updated_type = TETHERING_TYPE_USB; + elm_genlist_item_fields_update(ad->main.emul_station_items[TETHERING_TYPE_USB], + "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); + } + + updated_type = TETHERING_TYPE_ALL; + + return ECORE_CALLBACK_RENEW; +#endif + if (ad->main.hotspot_mode == VCONFKEY_MOBILE_HOTSPOT_MODE_NONE) { _stop_update_device_conn_time(ad); __MOBILE_AP_FUNC_EXIT__; return ECORE_CALLBACK_CANCEL; } - while (count < ad->connected_device.no_of_clients) { - if (ad->connected_device.station_items[count]) - elm_genlist_item_fields_update(ad->connected_device.station_items[count++], + while (count < ad->main.no_of_clients) { + if (ad->main.station_items[count]) + elm_genlist_item_fields_update(ad->main.station_items[count++], "elm.text.sub", ELM_GENLIST_ITEM_FIELD_TEXT); } return ECORE_CALLBACK_RENEW; @@ -365,25 +415,25 @@ void _genlist_update_device_item(mh_appdata_t *ad) no_of_dev = _get_list_clients_count(ad); Elm_Object_Item *item = NULL; - if (ad->main.device_item) { - elm_object_item_del(ad->main.device_item); - ad->main.device_item = NULL; - if (no_of_dev == 0) { - item = elm_genlist_item_append(ad->main.genlist, - ad->main.device0_itc, ad, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + if (no_of_dev == 0) { + if (ad->main.device_item) { + elm_object_item_del(ad->main.device_item); + ad->main.device_item = NULL; + _update_conn_clients(ad); + } + } else { + if (ad->main.device_item) { + _update_conn_clients(ad); } else { item = elm_genlist_item_append(ad->main.genlist, ad->main.device_itc, ad, NULL, - ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT); + ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + ad->main.device_item = item; + _list_connected_dev(ad); + } } - ad->main.device_item = item; - } - if (ad->connected_device.navi_it) - _update_conn_clients(ad); __MOBILE_AP_FUNC_EXIT__; return; @@ -429,7 +479,7 @@ void _update_main_view(mh_appdata_t *ad, tethering_type_e type) elm_object_item_disabled_set(ad->main.setup_item, EINA_FALSE); if (ad->main.bt_item) elm_object_item_disabled_set(ad->main.bt_item, EINA_FALSE); - if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) { + if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) { if (ad->main.usb_item) elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE); } else { @@ -453,16 +503,13 @@ void _update_main_view(mh_appdata_t *ad, tethering_type_e type) no_of_dev = _get_list_clients_count(ad); if (ad->main.device_item == NULL) { - if (no_of_dev == 0) { - item = elm_genlist_item_append(ad->main.genlist, - ad->main.device0_itc, ad, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - } else { + if (no_of_dev != 0) { item = elm_genlist_item_append(ad->main.genlist, ad->main.device_itc, ad, NULL, - ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad); + ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT); + _list_connected_dev(ad); + _update_conn_clients(ad); } ad->main.device_item = item; } @@ -556,6 +603,99 @@ void _update_main_view(mh_appdata_t *ad, tethering_type_e type) return; } +#ifdef TIZEN_FEATURE_EMULATOR +void _update_emul_main_view(mh_appdata_t *ad, tethering_type_e type, Eina_Bool state) +{ + __MOBILE_AP_FUNC_ENTER__; + + if (ad == NULL) { + ERR("Invalid param\n"); + return; + } + + Elm_Object_Item *item = NULL; + + switch (type) { + case TETHERING_TYPE_WIFI: + /* Update Wi-Fi tethering on / off button */ + _update_wifi_item(ad, MH_STATE_NONE); + if (state) { + ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI; + if (ad->main.help_item) { + elm_genlist_item_update(ad->main.help_item); + } else { + item = elm_genlist_item_insert_after(ad->main.genlist, + ad->main.help_itc, ad, NULL, + ad->main.wifi_item, + ELM_GENLIST_ITEM_NONE, NULL, + NULL); + if (item == NULL) { + ERR("elm_genlist_item_insert_after NULL\n"); + } else { + elm_genlist_item_select_mode_set(item, + ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + ad->main.help_item = item; + } + } + } else { + ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI; + if (ad->main.help_item) { + elm_object_item_del(ad->main.help_item); + ad->main.help_item = NULL; + } + } + + if (ad->main.wifi_item) + elm_genlist_item_update(ad->main.wifi_item); + break; + + case TETHERING_TYPE_BT: + /* Update BT tethering on / off button */ + _update_bt_item(ad, MH_STATE_NONE); + if (state) + ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_BT; + else + ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_BT; + + if (ad->main.bt_item) + elm_genlist_item_update(ad->main.bt_item); + break; + + case TETHERING_TYPE_USB: + /* Update USB tethering on / off button */ + _update_usb_item(ad, MH_STATE_NONE); + if (state) + ad->main.hotspot_mode |= VCONFKEY_MOBILE_HOTSPOT_MODE_USB; + else + ad->main.hotspot_mode ^= VCONFKEY_MOBILE_HOTSPOT_MODE_USB; + + if (ad->main.usb_item) + elm_genlist_item_update(ad->main.usb_item); + break; + + default: + DBG("Unknown tethering type : %d\n", type); + break; + } + + if (ad->main.hotspot_mode && ad->main.device_item == NULL) { + item = elm_genlist_item_append(ad->main.genlist, + ad->main.device_itc, ad, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT); + ad->main.device_item = item; + } else if (ad->main.hotspot_mode == 0 && ad->main.device_item) { + elm_object_item_del(ad->main.device_item); + ad->main.device_item = NULL; + } + + __update_emul_clients_genlist(ad); + + __MOBILE_AP_FUNC_EXIT__; + return; +} +#endif + static int __is_allowed(tethering_type_e type) { int state = 0; @@ -608,12 +748,24 @@ static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj, _update_wifi_item(ad, MH_STATE_PROCESS); ad->type = TETHERING_TYPE_WIFI; ad->is_wifi_teth_enabling = true; + +#ifdef TIZEN_FEATURE_EMULATOR + selected_type = TETHERING_TYPE_WIFI; + selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) ? EINA_FALSE : EINA_TRUE; + DBG("type [%d] state[%d]", selected_type, selected_state); +#endif + if (_handle_wifi_onoff_change(ad) != 0) { ERR("_handle_wifi_onoff_change is failed\n"); _update_wifi_item(ad, MH_STATE_NONE); ad->is_wifi_teth_enabling = false; } +#ifdef TIZEN_FEATURE_EMULATOR + if (_get_checkbox_status(selected_type) || !selected_state) + _update_emul_main_view(ad, selected_type, selected_state); +#endif + __MOBILE_AP_FUNC_EXIT__; return; @@ -663,12 +815,23 @@ static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info ad->type = TETHERING_TYPE_BT; ad->is_bt_teth_enabling = true; +#ifdef TIZEN_FEATURE_EMULATOR + selected_type = TETHERING_TYPE_BT; + selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) ? EINA_FALSE : EINA_TRUE; + DBG("type [%d] state[%d]", selected_type, selected_state); +#endif + if (_handle_bt_onoff_change(ad) != 0) { ERR("_handle_bt_onoff_change is failed\n"); _update_bt_item(ad, MH_STATE_NONE); ad->is_bt_teth_enabling = false; } +#ifdef TIZEN_FEATURE_EMULATOR + if (_get_checkbox_status(selected_type) || !selected_state) + _update_emul_main_view(ad, selected_type, selected_state); +#endif + __MOBILE_AP_FUNC_EXIT__; return; @@ -716,12 +879,23 @@ static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_inf _update_usb_item(ad, MH_STATE_PROCESS); ad->type = TETHERING_TYPE_USB; ad->is_usb_teth_enabling = true; + +#ifdef TIZEN_FEATURE_EMULATOR + selected_type = TETHERING_TYPE_USB; + selected_state = (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) ? EINA_FALSE : EINA_TRUE; +#endif + if (_handle_usb_onoff_change(ad) != 0) { ERR("_handle_usb_onoff_change is failed\n"); _update_usb_item(ad, MH_STATE_NONE); ad->is_usb_teth_enabling = false; } +#ifdef TIZEN_FEATURE_EMULATOR + if (_get_checkbox_status(selected_type) || !selected_state) + _update_emul_main_view(ad, selected_type, selected_state); +#endif + __MOBILE_AP_FUNC_EXIT__; return; @@ -894,9 +1068,9 @@ static char *__get_help_label(void *data, Evas_Object *obj, const char *part) { mh_appdata_t *ad = (mh_appdata_t *)data; char buf[MH_LABEL_LENGTH_MAX] = {0, }; - char device_name[MH_LABEL_LENGTH_MAX] = {0, }; - char passphrase[MH_LABEL_LENGTH_MAX] = {0, }; - char security_type[MH_LABEL_LENGTH_MAX] = {0, }; + char device_name[DEVICE_NAME_LENGTH_MAX] = {0, }; + char passphrase[WIFI_PASSPHRASE_LENGTH_MAX] = {0, }; + char security_type[SECURITY_TYPE_LENGTH_MAX] = {0, }; char *fmt = STR_SECURITY_TYPE_PS; char *hidden = ""; char *ptr = NULL; @@ -962,7 +1136,7 @@ static char *__get_help_label(void *data, Evas_Object *obj, const char *part) passphrase, security_type, STR_ENTER_THE_PASSWORD_ON_THE_OTHER_DEVICE, - hidden[0] != '\0' ? "
" : "", + hidden && hidden[0] != '\0' ? "
" : "", hidden); } else { snprintf(buf, MH_LABEL_LENGTH_MAX, @@ -972,7 +1146,7 @@ static char *__get_help_label(void *data, Evas_Object *obj, const char *part) "", STR_DEV_NAME, device_name, - hidden[0] != '\0' ? "
" : "", + hidden && hidden[0] != '\0' ? "
" : "", hidden); } @@ -982,45 +1156,18 @@ static char *__get_help_label(void *data, Evas_Object *obj, const char *part) return NULL; } -static char *__get_no_connected_device_label(void *data, Evas_Object *obj, - const char *part) -{ - mh_appdata_t *ad = (mh_appdata_t*)data; - char buf[MH_LABEL_LENGTH_MAX] = {0, }; - int no_of_dev; - - if (data == NULL) { - ERR("The param is NULL\n"); - return NULL; - } - - if (!strcmp("elm.text.multiline", part)) { - no_of_dev = _get_list_clients_count(ad); - snprintf(buf, MH_LABEL_LENGTH_MAX, "%s
%d", STR_CONNECTED_DEV, no_of_dev); - return strdup(buf); - } - - return NULL; -} - -static char *__get_connected_device_label(void *data, Evas_Object *obj, +static char *__get_device_label(void *data, Evas_Object *obj, const char *part) { - mh_appdata_t *ad = (mh_appdata_t*)data; char buf[MH_LABEL_LENGTH_MAX] = {0, }; - int no_of_dev; if (data == NULL) { ERR("The param is NULL\n"); return NULL; } - if (!strcmp("elm.text.sub", part)) { - g_strlcpy(buf, STR_CONNECTED_DEV, sizeof(buf)); - return strdup(buf); - } else if (!strcmp("elm.text", part)) { - no_of_dev = _get_list_clients_count(ad); - snprintf(buf, MH_LABEL_LENGTH_MAX, "%d", no_of_dev); + if (!strcmp("elm.text", part)) { + snprintf(buf, MH_LABEL_LENGTH_MAX, "%s", STR_CONNECTED_DEV); return strdup(buf); } @@ -1141,18 +1288,6 @@ static void __set_genlist_itc(mh_appdata_t *ad) /* End of Off view's item class for genlist */ - /* On view's item class for genlist */ - ad->main.device0_itc = elm_genlist_item_class_new(); - if (ad->main.device0_itc == NULL) { - ERR("elm_genlist_item_class_new failed\n"); - return; - } - - ad->main.device0_itc->item_style = MH_GENLIST_MULTILINE_TEXT_STYLE; - ad->main.device0_itc->func.text_get = __get_no_connected_device_label; - ad->main.device0_itc->func.content_get = NULL; - ad->main.device0_itc->func.state_get = NULL; - ad->main.device0_itc->func.del = NULL; ad->main.device_itc = elm_genlist_item_class_new(); if (ad->main.device_itc == NULL) { @@ -1160,8 +1295,8 @@ static void __set_genlist_itc(mh_appdata_t *ad) return; } - ad->main.device_itc->item_style = MH_GENLIST_2LINE_BOTTOM_TEXT_STYLE; - ad->main.device_itc->func.text_get = __get_connected_device_label; + ad->main.device_itc->item_style = MH_GENLIST_GROUP_INDEX_STYLE; + ad->main.device_itc->func.text_get = __get_device_label; ad->main.device_itc->func.content_get = NULL; ad->main.device_itc->func.state_get = NULL; ad->main.device_itc->func.del = NULL; @@ -1280,7 +1415,7 @@ static void __create_inner_contents(mh_appdata_t *ad) ad, NULL, ELM_GENLIST_ITEM_NONE, __select_usb_item, ad); ad->main.usb_item = item; - if (_get_vconf_usb_state() != VCONFKEY_SYSMAN_USB_AVAILABLE) { + if (_get_vconf_usb_state() == VCONFKEY_SYSMAN_USB_DISCONNECTED) { if (ad->main.usb_item) elm_object_item_disabled_set(ad->main.usb_item, EINA_TRUE); } else { @@ -1302,16 +1437,13 @@ static void __create_inner_contents(mh_appdata_t *ad) _connected_clients_cb, (void *)ad); no_of_dev = _get_list_clients_count(ad); - if (no_of_dev == 0) { + if (no_of_dev != 0) { item = elm_genlist_item_append(ad->main.genlist, - ad->main.device0_itc, ad, NULL, + ad->main.device_itc, ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - } else { - item = elm_genlist_item_append(ad->main.genlist, - ad->main.device_itc, ad, NULL, - ELM_GENLIST_ITEM_NONE, _select_connected_dev, (void *)ad); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DEFAULT); + _list_connected_dev(ad); + _update_conn_clients(ad); } ad->main.device_item = item; } @@ -1382,6 +1514,18 @@ void _main_callback_del(mh_appdata_t *ad) __MOBILE_AP_FUNC_EXIT__; } +void _ctxpopup_more_button_callback_add(mh_appdata_t *ad) +{ + eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE, + __create_ctxpopup_more_button, ad); +} + +void _ctxpopup_more_button_callback_del(mh_appdata_t *ad) +{ + eext_object_event_callback_del(ad->naviframe, EEXT_CALLBACK_MORE, + __create_ctxpopup_more_button); +} + static void __ctx_move_more_ctxpopup(Evas_Object *ctx, mh_appdata_t *ad) { Evas_Coord w; @@ -1426,15 +1570,9 @@ static void __dismissed_more_ctxpopup_cb(void *data, Evas_Object *obj, void *eve mh_appdata_t *ad = (mh_appdata_t *)data; Evas_Object *ctx = ad->ctxpopup; + evas_object_del(ctx); + ctx = NULL; - if (!rotate_flag) { - evas_object_del(ctx); - ctx = NULL; - } else { - __ctx_move_more_ctxpopup(ctx, ad); - evas_object_show(ctx); - rotate_flag = EINA_FALSE; - } __MOBILE_AP_FUNC_EXIT__; } @@ -1473,6 +1611,7 @@ static void __gl_configure_wifi_tethering(void *data, Evas_Object *obj, void *ev ad->ctxpopup = NULL; elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + _ctxpopup_more_button_callback_del(ad); mh_draw_wifi_setup_view(ad); __MOBILE_AP_FUNC_EXIT__; @@ -1545,9 +1684,7 @@ void _main_draw_contents(mh_appdata_t *ad) eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL); - eext_object_event_callback_add(ad->naviframe, EEXT_CALLBACK_MORE, - __create_ctxpopup_more_button, ad); - + _ctxpopup_more_button_callback_add(ad); evas_object_smart_callback_add(ad->main.back_btn, "clicked", (Evas_Smart_Cb)__back_btn_cb, (void *)ad); elm_object_focus_allow_set(ad->main.back_btn, EINA_FALSE);