From 6994e6e34937d5a973cef16c544848383e66807f Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Tue, 31 Mar 2015 17:00:03 +0900 Subject: [PATCH 01/16] Fix sub menu launch bug after refactoring Change-Id: I0d7c7b9d7920b1df3dce20f8e4d5d9d9e1e23298 Signed-off-by: JuWan Kim --- src/settingviewmgr.cpp | 25 ++++++++----------------- src/view_uigadget.cpp | 3 +-- ug/network/include/common.h | 2 +- ug/network/src/NetworkMainView.cpp | 2 ++ 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 4da9d71..0666250 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -360,29 +360,20 @@ bool CSettingMgr::Initialize(Evas_Object *win) return false; } - CUiGadgetView g_uigadget(VCLASS_TITLE_UG); - CSublistView g_sublist(VCLASS_TITLE_SUBLIST); - CPasscodePopupView g_passcodePopup(VCLASS_TITLE_CHANGE_PASSCODE); - CSystemClockView g_systemclock(VCLASS_TITLE_SYSTEM_CLOCK); - CNeedPasscodeView g_needpasscode(VCLASS_TITLE_NEED_PASSCODE); - g_func_map[0].style = STYLE_UIGADGET; - g_func_map[0].view = &g_uigadget; + g_func_map[0].view = new CUiGadgetView(VCLASS_TITLE_UG); g_func_map[1].style = STYLE_CTXPOPUP; - g_func_map[1].view = &g_sublist; + g_func_map[1].view = new CSublistView(VCLASS_TITLE_SUBLIST); g_func_map[2].style = STYLE_PASSCODE_POPUP; - g_func_map[2].view = &g_passcodePopup; + g_func_map[2].view = new CPasscodePopupView(VCLASS_TITLE_CHANGE_PASSCODE); g_func_map[3].style = STYLE_CLOCK_CTXPOPUP; - g_func_map[3].view = &g_systemclock; + g_func_map[3].view = new CSystemClockView(VCLASS_TITLE_SYSTEM_CLOCK); g_func_map[4].style = STYLE_NEED_PASSCODE; - g_func_map[4].view = &g_needpasscode; - - - + g_func_map[4].view = new CNeedPasscodeView(VCLASS_TITLE_NEED_PASSCODE); instance->m->win = win; instance->m->depth = 0; @@ -454,9 +445,9 @@ bool CSettingMgr::ViewPush(const char *name, void *data) ASSERT(m); ASSERT(name); - struct _settinginfo *sinfo; - CSettingBaseView *sclass; - struct settingview_data *view; + struct _settinginfo *sinfo = NULL; + CSettingBaseView *sclass = NULL; + struct settingview_data *view = NULL; m->depth++; diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp index 0eb479e..698fbb2 100644 --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -248,7 +248,6 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) ASSERT(prev); Evas_Object *win, *base; - SUiGadgetView *m; struct evas_obj_data *param; CSettingMgr *mgr = CSettingMgr::GetInstance(); @@ -363,4 +362,4 @@ struct setting_class *view_uigadget_get_vclass(void) { return &_vclass; } -#endif \ No newline at end of file +#endif diff --git a/ug/network/include/common.h b/ug/network/include/common.h index 6653826..e640778 100644 --- a/ug/network/include/common.h +++ b/ug/network/include/common.h @@ -35,7 +35,7 @@ enum setting_mode { }; enum action_btn_enum { - CONNECT, + CONNECT = 0, REFRESH, OTHER, CLOSE diff --git a/ug/network/src/NetworkMainView.cpp b/ug/network/src/NetworkMainView.cpp index 6b5e9b0..a07ecc9 100644 --- a/ug/network/src/NetworkMainView.cpp +++ b/ug/network/src/NetworkMainView.cpp @@ -1012,6 +1012,7 @@ void CNetworkMainView::m_SetActionBtnPos() btn = elm_object_part_content_get(m->base, button_swallow[CONNECT]); if (!btn) { + elm_object_part_content_unset(m->base, button_swallow[CONNECT]); elm_object_part_content_set(m->base, button_swallow[CONNECT], m->connect_btn); evas_object_show(m->connect_btn); } @@ -1645,6 +1646,7 @@ bool CNetworkMainView::Create(void *data) } _CHECK(m_CreateUpperLayout()) _COMMAND{ + m->wireless_discon_ly = NULL; if (m->network_type == TYPE_WIRELESS) ret = m_SetWireless(); -- 2.7.4 From 264651781ae2ac7316aa7e9db6bcc25df92bc3ce Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Tue, 31 Mar 2015 17:55:08 +0900 Subject: [PATCH 02/16] Modify codes for WIN32 build environment Change-Id: I8cee5754e6666f7c49a48706543fcdb0302465e5 Signed-off-by: JuWan Kim --- src/data_wrapper.cpp | 1 + src/parser.cpp | 1 + src/settings_provider.cpp | 83 +++++++++++++++++---------------- src/view_maincatalog.cpp | 2 +- src/view_need_pwd.cpp | 4 +- src/view_pwd_popup.cpp | 4 +- src/view_uigadget.cpp | 8 ++-- ug/channel/src/tv_scan.cpp | 2 +- ug/channel/src/view_result_page.cpp | 12 ++--- ug/channel/src/view_scan_start.cpp | 36 +++++++------- ug/channel/src/view_search_page.cpp | 12 ++--- ug/network/src/IpSettingView.cpp | 8 ++-- ug/network/src/NetworkMainView.cpp | 2 +- ug/proxy/src/ProxyMainView.cpp | 8 ++-- ug/system/clock/src/ug_clock_utils.cpp | 8 ++-- ug/wifi-direct/src/wifi_direct_view.cpp | 2 +- 16 files changed, 99 insertions(+), 94 deletions(-) mode change 100644 => 100755 src/view_need_pwd.cpp mode change 100644 => 100755 src/view_pwd_popup.cpp mode change 100644 => 100755 src/view_uigadget.cpp mode change 100644 => 100755 ug/channel/src/view_scan_start.cpp mode change 100644 => 100755 ug/wifi-direct/src/wifi_direct_view.cpp diff --git a/src/data_wrapper.cpp b/src/data_wrapper.cpp index 4646c3b..35bf944 100644 --- a/src/data_wrapper.cpp +++ b/src/data_wrapper.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/src/parser.cpp b/src/parser.cpp index 2da0aef..a4ccd6d 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "parser.h" #include "dbg.h" diff --git a/src/settings_provider.cpp b/src/settings_provider.cpp index 0334ec2..eaef600 100644 --- a/src/settings_provider.cpp +++ b/src/settings_provider.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "dbg.h" #include "settings_provider.h" #include @@ -76,80 +77,80 @@ struct keymap { static struct keymap item_keymap[] = { { - .key = "settings/picture/picturemode", - .type = PICTURE_MODE + "settings/picture/picturemode", + PICTURE_MODE }, { - .key = "settings/picture/contrast", - .type = PICTURE_CONTRAST + "settings/picture/contrast", + PICTURE_CONTRAST }, { - .key = "settings/picture/brightness", - .type = PICTURE_BRIGHTNESS + "settings/picture/brightness", + PICTURE_BRIGHTNESS }, { - .key = "settings/picture/sharpness", - .type = PICTURE_SHARPNESS + "settings/picture/sharpness", + PICTURE_SHARPNESS }, { - .key = "settings/picture/color", - .type = PICTURE_COLOR + "settings/picture/color", + PICTURE_COLOR }, { - .key = "settings/picture/tint", - .type = PICTURE_TINT + "settings/picture/tint", + PICTURE_TINT }, { - .key = "settings/picture/homebaropacity", - .type = PICTURE_HOMEBAR_OPACITY + "settings/picture/homebaropacity", + PICTURE_HOMEBAR_OPACITY }, { - .key = "settings/picture/screenadjustment", - .type = PICTURE_SCREEN_ADJUSTMENT + "settings/picture/screenadjustment", + PICTURE_SCREEN_ADJUSTMENT }, { - .key = "settings/sound/soundmode", - .type = SOUND_MODE + "settings/sound/soundmode", + SOUND_MODE }, { - .key = "settings/sound/speakersettings", - .type = SPEAKER_SETTINGS + "settings/sound/speakersettings", + SPEAKER_SETTINGS }, { - .key = "settings/system/sleeptimer", - .type = SYSTEM_SLEEPTIMER + "settings/system/sleeptimer", + SYSTEM_SLEEPTIMER }, { - .key = "settings/system/wakeup_timer_setup", - .type = SYSTEM_WAKEUPTIMER + "settings/system/wakeup_timer_setup", + SYSTEM_WAKEUPTIMER }, { - .key = "settings/system/subtitle", - .type = SYSTEM_SUBTITLE + "settings/system/subtitle", + SYSTEM_SUBTITLE }, { - .key = "settings/system/country", - .type = SYSTEM_COUNTRY + "settings/system/country", + SYSTEM_COUNTRY }, { - .key = "settings/system/language", - .type = SYSTEM_LANGUAGE + "settings/system/language", + SYSTEM_LANGUAGE }, { - .key = "settings/system/reset", - .type = SYSTEM_RESET + "settings/system/reset", + SYSTEM_RESET }, { - .key = "settings/system/change_passcode", - .type = SYSTEM_PASSCODE + "settings/system/change_passcode", + SYSTEM_PASSCODE }, { - .key = "settings/system/clock_mode", - .type = SYSTEM_CLOCK_MODE + "settings/system/clock_mode", + SYSTEM_CLOCK_MODE }, { - .key = "settings/channel/channel_lock", - .type = CHANNEL_LOCK + "settings/channel/channel_lock", + CHANNEL_LOCK } }; @@ -518,13 +519,13 @@ static int _set_string(const char *key, const char *val) switch (type) { case SYSTEM_LANGUAGE: - status = vconf_set_str(KEY_SYSTEM_LANGUAGE, val); + status = vconf_set_str(KEY_SYSTEM_LANGUAGE, (char *) val); break; case SYSTEM_COUNTRY: - status = vconf_set_str(KEY_SYSTEM_COUNTRY, val); + status = vconf_set_str(KEY_SYSTEM_COUNTRY, (char *)val); break; case SYSTEM_PASSCODE: - status = vconf_set_str(KEY_CHANGE_PASSCODE, val); + status = vconf_set_str(KEY_CHANGE_PASSCODE, (char *)val); break; default: break; diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp index 61331df..0e67b27 100644 --- a/src/view_maincatalog.cpp +++ b/src/view_maincatalog.cpp @@ -1212,7 +1212,7 @@ static int _draw_subitems(SMainCatalog *data, const char *name) static void _move_from_main_item_to_subitem(SMainCatalog *data, Evas_Object *mainbtn) { - Evas_Object *btn, *pb, *icon; + Evas_Object *btn = NULL, *pb, *icon; int i; if (!data || !mainbtn) diff --git a/src/view_need_pwd.cpp b/src/view_need_pwd.cpp old mode 100644 new mode 100755 index 0716ff4..8438ddd --- a/src/view_need_pwd.cpp +++ b/src/view_need_pwd.cpp @@ -409,10 +409,10 @@ static Evas_Object *_add_entry(Evas_Object *parent) { Evas_Object *entry; Elm_Entry_Filter_Limit_Size length = { - .max_char_count = 1 + 1 }; Elm_Entry_Filter_Accept_Set type = { - .accepted = PWD_RANGE + PWD_RANGE }; if (!parent) diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.cpp old mode 100644 new mode 100755 index 20a6e74..ae64bb4 --- a/src/view_pwd_popup.cpp +++ b/src/view_pwd_popup.cpp @@ -566,10 +566,10 @@ static Evas_Object *_add_entry(Evas_Object *parent) { Evas_Object *entry; Elm_Entry_Filter_Limit_Size length = { - .max_char_count = 1 + 1 }; Elm_Entry_Filter_Accept_Set type = { - .accepted = PWD_RANGE + PWD_RANGE }; if (!parent) diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp old mode 100644 new mode 100755 index 698fbb2..a3aacde --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -164,10 +164,10 @@ bool CUiGadgetView::m_Load(void) struct settingitem *parent; struct ug_cbs cbs = { - .layout_cb = sm_CbUgLayout, - .result_cb = sm_CbUgResult, - .destroy_cb = sm_CbUgDestroy, - .end_cb = NULL + sm_CbUgLayout, + sm_CbUgResult, + sm_CbUgDestroy, + NULL }; cbs.priv = this; diff --git a/ug/channel/src/tv_scan.cpp b/ug/channel/src/tv_scan.cpp index de35471..cc2da53 100644 --- a/ug/channel/src/tv_scan.cpp +++ b/ug/channel/src/tv_scan.cpp @@ -297,7 +297,7 @@ stop: tvs->signal_timer = NULL; return ECORE_CALLBACK_CANCEL; #endif - return true; + return EINA_TRUE; } /** diff --git a/ug/channel/src/view_result_page.cpp b/ug/channel/src/view_result_page.cpp index a720e25..a7c50e6 100644 --- a/ug/channel/src/view_result_page.cpp +++ b/ug/channel/src/view_result_page.cpp @@ -222,12 +222,12 @@ static void _terminate(Evas_Object *base) * This struct is for registering the callbacks for the view */ static struct view_class _vclass = { - .title = VIEW_RESULT, - .create = _create, - .update = _update, - .resume = _resume, - .pause = _pause, - .terminate = _terminate, + VIEW_RESULT, + _create, + _update, + _resume, + _pause, + _terminate, }; /** diff --git a/ug/channel/src/view_scan_start.cpp b/ug/channel/src/view_scan_start.cpp old mode 100644 new mode 100755 index 7184033..fc2ba72 --- a/ug/channel/src/view_scan_start.cpp +++ b/ug/channel/src/view_scan_start.cpp @@ -417,20 +417,20 @@ static void _update_antenna_list(struct _data *data) Evas_Object *btn; int i; struct _antenna_info atninfo[] = { - [ALL_ITEM] = { - .style = (char *) ITEM_STYLE, - .cb = _item_clicked_cb, - .text = ALL + { + (char *) ITEM_STYLE, + _item_clicked_cb, + ALL }, - [CABLE_ITEM] = { - .style = (char *) ITEM_STYLE, - .cb = _item_clicked_cb, - .text = CABLE + { + (char *) ITEM_STYLE, + _item_clicked_cb, + CABLE }, - [AIR_ITEM] = { - .style = (char *) ITEM_STYLE, - .cb = _item_clicked_cb, - .text = AIR + { + (char *) ITEM_STYLE, + _item_clicked_cb, + AIR } }; @@ -676,12 +676,12 @@ static void _terminate(Evas_Object *base) * This struct is for registering the callbacks for the view */ static struct view_class _vclass = { - .title = VIEW_START, - .create = _create, - .update = _update, - .resume = _resume, - .pause = _pause, - .terminate = _terminate, + VIEW_START, + _create, + _update, + _resume, + _pause, + _terminate, }; /** diff --git a/ug/channel/src/view_search_page.cpp b/ug/channel/src/view_search_page.cpp index 3ef025b..60d6512 100644 --- a/ug/channel/src/view_search_page.cpp +++ b/ug/channel/src/view_search_page.cpp @@ -596,12 +596,12 @@ static void _terminate(Evas_Object *base) * This struct is for registering the callbacks for the view */ static struct view_class _vclass = { - .title = VIEW_SEARCH, - .create = _create, - .update = _update, - .resume = _resume, - .pause = _pause, - .terminate = _terminate, + VIEW_SEARCH, + _create, + _update, + _resume, + _pause, + _terminate, }; /** diff --git a/ug/network/src/IpSettingView.cpp b/ug/network/src/IpSettingView.cpp index 202fcd1..da95996 100644 --- a/ug/network/src/IpSettingView.cpp +++ b/ug/network/src/IpSettingView.cpp @@ -250,7 +250,7 @@ void CIpSettingView::m_GetIpInfo(char *des, const char *key) bool CIpSettingView::m_CreateDNSSetting(void) { - Evas_Object *base; + Evas_Object *base = NULL; Evas_Object *btn; Evas_Object *box; char mode[STRING_MAX_SIZE]; @@ -311,7 +311,7 @@ bool CIpSettingView::m_CreateDNSSetting(void) bool CIpSettingView::m_CreateBtns(void) { - Evas_Object *base; + Evas_Object *base = NULL; Evas_Object *ok_btn; Evas_Object *cancel_btn; @@ -345,7 +345,7 @@ bool CIpSettingView::m_CreateBtns(void) bool CIpSettingView::m_CreateIpSetting(void) { - Evas_Object *base; + Evas_Object *base = NULL; Evas_Object *scroll; Evas_Object *box; Evas_Object *btn; @@ -645,7 +645,7 @@ void CIpSettingView::m_KeepBtnFocused(void) void CIpSettingView::m_CreateValuePopup(void) { - Evas_Object *base, *ctxpopup, *btn; + Evas_Object *base = NULL, *ctxpopup, *btn; Evas_Coord pos_x, pos_y; int i; diff --git a/ug/network/src/NetworkMainView.cpp b/ug/network/src/NetworkMainView.cpp index a07ecc9..dcbb21d 100644 --- a/ug/network/src/NetworkMainView.cpp +++ b/ug/network/src/NetworkMainView.cpp @@ -117,7 +117,7 @@ struct SNetworkMainView { virtual void OnMouseClicked(int id, Evas_Object *obj) { _DBG(); - Evas_Object *base; + Evas_Object *base = NULL; Evas_Object *layout, *box; Evas_Object *btn[BTN_TYPE]; Evas_Coord x; diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp index b16a2e7..c23de00 100644 --- a/ug/proxy/src/ProxyMainView.cpp +++ b/ug/proxy/src/ProxyMainView.cpp @@ -689,7 +689,7 @@ bool CProxyMainView::m_GetProxyMethod(void) m->net_type = TYPE_WIRELESS; value = 0; - ret = vconf_get_int(VCONF_PROXY_METHOD, &value); + ret = vconf_get_int((char*) VCONF_PROXY_METHOD, &value); if (ret != true) { _ERR("vconf_get_int() failed."); return false; @@ -1016,16 +1016,16 @@ void CProxyMainView::OnMouseClicked(int id, Evas_Object *obj) return; } - vconf_set_int(VCONF_PROXY_METHOD, m->eMethod); + vconf_set_int((char*)VCONF_PROXY_METHOD, m->eMethod); if (m->eMethod == PROXY_METHOD_MANUAL) { if (!strncmp(m->ip, IP_ZERO, IP_STRING_LEN)) { _ERR("IP addr is invalid."); } - vconf_set_str(VCONF_PROXY_IP, m->ip); + vconf_set_str((char*)VCONF_PROXY_IP, m->ip); } else if(m->eMethod == PROXY_METHOD_AUTO) { - vconf_set_str(VCONF_PROXY_URL, m->url); + vconf_set_str((char*)VCONF_PROXY_URL, m->url); } ug_destroy_me(m->ug); break; diff --git a/ug/system/clock/src/ug_clock_utils.cpp b/ug/system/clock/src/ug_clock_utils.cpp index 4cb0969..34dc0ef 100755 --- a/ug/system/clock/src/ug_clock_utils.cpp +++ b/ug/system/clock/src/ug_clock_utils.cpp @@ -257,7 +257,7 @@ int utils_set_vconf_value(const char *key, int value) return -1; } - ret = vconf_set_int(key, value); + ret = vconf_set_int((char*) key, value); if (ret != 0) { _ERR("vconf set int failed."); return -1; @@ -283,7 +283,7 @@ int utils_get_vconf_value(const char *key, int *value) return -1; } - ret = vconf_get_int(key, value); + ret = vconf_get_int((char*)key, value); if (ret != 0) { _ERR("vconf get int failed."); return -1; @@ -302,11 +302,13 @@ int utils_get_vconf_value(const char *key, int *value) static struct tm *_get_current_time() { time_t tt; - struct tm *t; + struct tm *t = NULL; tt = 0; time(&tt); + /* FIXME: memory of *t is not allocated ?? */ + t = localtime(&tt); return t; diff --git a/ug/wifi-direct/src/wifi_direct_view.cpp b/ug/wifi-direct/src/wifi_direct_view.cpp old mode 100644 new mode 100755 index eddad62..c88ac1a --- a/ug/wifi-direct/src/wifi_direct_view.cpp +++ b/ug/wifi-direct/src/wifi_direct_view.cpp @@ -1409,7 +1409,7 @@ static bool _discoverd_peers_cb( WIFI_DIRECT_DEFAULT_BUF_LEN); strncpy(info->mac_addr, discov_info->mac_address, WIFI_DIRECT_DEFAULT_BUF_LEN); - info->is_conn = discov_info->is_connected; + info->is_conn = (Eina_Bool) discov_info->is_connected; info->wps_types = discov_info->supported_wps_types; ret = _update_genlist_item(priv, info); -- 2.7.4 From f1c903558622c8ca11620917d4c325f115bc1df9 Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Wed, 1 Apr 2015 20:00:08 +0900 Subject: [PATCH 03/16] Refactoring /ug/wifi-direct Done Change-Id: I10ffb181a6611608bbefad5733b13d4ca40ae7fd Signed-off-by: JuWan Kim --- ug/include/UgCommon.h | 12 + ug/include/WifiDirectMgr.h | 52 + ug/network/src/ug_network_settings.cpp | 11 - ug/proxy/src/ProxyMainView.cpp | 2 +- ug/proxy/src/ug_proxy_settings.cpp | 10 - ug/src/WifiDirectMgr.cpp | 478 +++++++ ug/wifi-direct/CMakeLists.txt | 6 +- ug/wifi-direct/include/WifiDirectMainView.h | 81 ++ ug/wifi-direct/include/defs.h | 3 + ug/wifi-direct/include/wifi_direct_mgr.h | 81 -- ug/wifi-direct/include/wifi_direct_view.h | 25 - ug/wifi-direct/src/WifiDirectMainView.cpp | 1540 ++++++++++++++++++++ ug/wifi-direct/src/ug_wifi_direct.cpp | 31 +- ug/wifi-direct/src/wifi_direct_mgr.cpp | 612 -------- ug/wifi-direct/src/wifi_direct_view.cpp | 2035 --------------------------- 15 files changed, 2194 insertions(+), 2785 deletions(-) create mode 100644 ug/include/WifiDirectMgr.h create mode 100644 ug/src/WifiDirectMgr.cpp create mode 100644 ug/wifi-direct/include/WifiDirectMainView.h delete mode 100644 ug/wifi-direct/include/wifi_direct_mgr.h delete mode 100644 ug/wifi-direct/include/wifi_direct_view.h create mode 100644 ug/wifi-direct/src/WifiDirectMainView.cpp delete mode 100644 ug/wifi-direct/src/wifi_direct_mgr.cpp delete mode 100755 ug/wifi-direct/src/wifi_direct_view.cpp diff --git a/ug/include/UgCommon.h b/ug/include/UgCommon.h index 32a8b32..3102b9f 100644 --- a/ug/include/UgCommon.h +++ b/ug/include/UgCommon.h @@ -1,10 +1,22 @@ #ifndef __UG_COMMON_H__ #define __UG_COMMON_H__ + +#define WIFI_DIRECT_DEFAULT_BUF_LEN 256 +#define WIFI_DIRECT_STATE_BUF_LEN 32 + enum EProxyMethod { PROXY_METHOD_NONE = 0, PROXY_METHOD_MANUAL, PROXY_METHOD_AUTO }; +struct device_info { + char dev_name[WIFI_DIRECT_DEFAULT_BUF_LEN]; + char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN]; + bool is_conn; + int wps_types; + char wps_pin[WIFI_DIRECT_STATE_BUF_LEN]; + char state[WIFI_DIRECT_STATE_BUF_LEN]; +}; #endif /* __UG_COMMON_H__ */ diff --git a/ug/include/WifiDirectMgr.h b/ug/include/WifiDirectMgr.h new file mode 100644 index 0000000..cc5eae8 --- /dev/null +++ b/ug/include/WifiDirectMgr.h @@ -0,0 +1,52 @@ +#ifndef __WIFIDIRECTMGR_H__ +#define __WIFIDIRECTMGR_H__ + +#include "UgCommon.h" +#include "wifi-direct.h" + +class CWifiDirectMgr { +private: + static CWifiDirectMgr *instance; + struct SWifiDirectMgr *m; + +private: + CWifiDirectMgr(void) : m(0) {} + virtual ~CWifiDirectMgr() {} + +public: + static bool Initialize(void); + static void Finalize(void); + static CWifiDirectMgr* GetInstance(void); + + char* GetDevieName(void); + char* GetMacAddr(void); + bool GetState(wifi_direct_state_e *status); + bool Activate(void); + bool Deactivate(void); + bool SetMaxClient(void); // set_configure_num + + bool GetAllDicoveredPeerInfo(wifi_direct_discovered_peer_cb cb, void *data); + bool GetAllConnectedPeerInfo(wifi_direct_connected_peer_cb cb, void *data); + + bool StartDiscovery(void); + bool CancelDiscovery(void); + bool Connect(const char *macaddr); + bool Disconnect(const char *macaddr); + bool AcceptConnection(char *macaddr); + bool GetWPStype(bool samewithpbc); + bool SetWPStype(wifi_direct_wps_type_e *type); + + bool SetDeviceStateChangedCb(wifi_direct_device_state_changed_cb cb, void *data); + bool UnSetDeviceStateChangedCb(void); + bool SetDiscoveryStateChangedCb(wifi_direct_discovery_state_chagned_cb cb, void *data); + bool UnSetDiscoveryStateChangedCb(void); + bool SetConnectionStateChangedCb(wifi_direct_connection_state_changed_cb cb, void *data); + bool UnSetConnectionStateChangedCb(void); + + bool UnSetClientIpAddrAssignedCb(void); + + + const char* GetErrorMsg(int err); +}; + +#endif /* __WIFIDIRECTMGR_H__ */ diff --git a/ug/network/src/ug_network_settings.cpp b/ug/network/src/ug_network_settings.cpp index 04ff410..7fa91c6 100644 --- a/ug/network/src/ug_network_settings.cpp +++ b/ug/network/src/ug_network_settings.cpp @@ -176,18 +176,7 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv) */ static void _on_destroy(ui_gadget_h ug, service_h service, void *priv) { - struct _ug_data *ugd = (struct _ug_data *) priv; - - if (!ug || !priv) { - _ERR("Parameter error!"); - return; - } - - if (!ugd || !ugd->base) - return; - CViewMgr::Finalize(); - //viewmgr_fini(ugd->vmgr); } /** diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp index c23de00..df0f7f1 100644 --- a/ug/proxy/src/ProxyMainView.cpp +++ b/ug/proxy/src/ProxyMainView.cpp @@ -847,7 +847,7 @@ bool CProxyMainView::Create(void *data) _CHECK_FAIL{ delete m; m = NULL; } } _CREATE_END_AND_CATCH{ return false; } - return m->base; + return true; } void CProxyMainView::Destroy() diff --git a/ug/proxy/src/ug_proxy_settings.cpp b/ug/proxy/src/ug_proxy_settings.cpp index a76a562..892934e 100644 --- a/ug/proxy/src/ug_proxy_settings.cpp +++ b/ug/proxy/src/ug_proxy_settings.cpp @@ -175,16 +175,6 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv) */ static void _on_destroy(ui_gadget_h ug, service_h service, void *priv) { - struct _ug_data *ugd = (struct _ug_data *) priv; - - if (!ug || !priv) { - _ERR("Parameter error!"); - return; - } - - if (!ugd || !ugd->base) - return; - CViewMgr::Finalize(); } diff --git a/ug/src/WifiDirectMgr.cpp b/ug/src/WifiDirectMgr.cpp new file mode 100644 index 0000000..a562129 --- /dev/null +++ b/ug/src/WifiDirectMgr.cpp @@ -0,0 +1,478 @@ +#include +#include +#include "defs.h" +#include "dbg.h" +#include "WifiMgr.h" +#include "WifiDirectMgr.h" + +#define LOCAL_MAX_CLIENT 8 + +#define WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN 0 +#define WIFI_DIRECT_SCAN_TIMEOUT 3 + +CWifiDirectMgr *CWifiDirectMgr::instance = NULL; + +struct SWifiDirectMgr { + CWifiMgr *pWifiMgr; +}; + +bool CWifiDirectMgr::Initialize() +{ + ASSERT(!instance); + + instance = new CWifiDirectMgr; + if(!instance) + return false; + + instance->m = new SWifiDirectMgr; + if(instance->m == NULL) return false; + + + if(CWifiMgr::Initialize()) { + _ERR("Fail to init wifi"); + return false; + } + + int ret = -1; + ret = wifi_direct_initialize(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_initialize failed, ret:%s.", instance->GetErrorMsg(ret)); + CWifiMgr::Finalize(); + delete instance->m; + delete instance; + instance = NULL; + return false; + } + + return true; +} + + +void CWifiDirectMgr::Finalize() +{ + if(!instance) + return; + ASSERT(instance->m); + + int ret = -1; + ret = wifi_direct_deinitialize(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_deinitialize failed, ret:%s.", instance->GetErrorMsg(ret)); + } + + CWifiMgr::Finalize(); + + delete instance->m; + delete instance; + instance = NULL; +} + + +CWifiDirectMgr * CWifiDirectMgr::GetInstance() +{ + return instance; +} + + +char* CWifiDirectMgr::GetDevieName(void) +{ + int ret; + char *name = NULL; + + ret = wifi_direct_get_device_name(&name); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("get device name failed, ret: %s.", GetErrorMsg(ret)); + return NULL; + } + + return name; +} + + +char* CWifiDirectMgr::GetMacAddr(void) +{ + int ret; + char *mac_addr = NULL; + + ret = wifi_direct_get_mac_address(&mac_addr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("get mac address failed, ret: %s.", GetErrorMsg(ret)); + return NULL; + } + + return mac_addr; +} + + +bool CWifiDirectMgr::GetState(wifi_direct_state_e *status) +{ + int ret; + + if (!status) { + _ERR("The param is NULL."); + return false; + } + + ret = wifi_direct_get_state(status); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("get state failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::Activate(void) +{ + int ret; + + ret = wifi_direct_activate(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_activate failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::Deactivate(void) +{ + int ret; + + ret = wifi_direct_deactivate(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_deactivate failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::SetMaxClient(void) +{ + int ret; + + ret = wifi_direct_set_max_clients(LOCAL_MAX_CLIENT); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("set max client failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::GetAllDicoveredPeerInfo(wifi_direct_discovered_peer_cb cb, void *data) +{ + int ret; + + if (!cb || !data) { + _ERR("The parameter is NULL."); + return false; + } + + ret = wifi_direct_foreach_discovered_peers(cb, data); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("foreach connected pees failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::GetAllConnectedPeerInfo(wifi_direct_connected_peer_cb cb, void *data) +{ + int ret; + + if (!cb || !data) { + _ERR("The parameter is NULL."); + return false; + } + + ret = wifi_direct_foreach_connected_peers(cb, data); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("foreach connected peers failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::StartDiscovery(void) +{ + int ret; + + ret = wifi_direct_start_discovery(WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN, WIFI_DIRECT_SCAN_TIMEOUT); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("start discovery failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::CancelDiscovery(void) +{ + int ret; + + ret = wifi_direct_cancel_discovery(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_cancel_discovery failed ret:%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::Connect(const char *macaddr) +{ + int ret; + + if (!macaddr) { + _ERR("mac_address is NULL"); + return false; + } + + ret = wifi_direct_connect(macaddr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_connect failed,%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::Disconnect(const char *macaddr) +{ + int ret; + + if (!macaddr) { + _ERR("mac_address is NULL"); + return false; + } + + ret = wifi_direct_disconnect(macaddr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_disconnect failed,%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::AcceptConnection(char *macaddr) +{ + int ret; + + if (!macaddr) { + _ERR("mac_address is NULL"); + return false; + } + + ret = wifi_direct_accept_connection(macaddr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_accept_connection failed,%s.", GetErrorMsg(ret)); + return false; + } + + return true; +} + + +bool CWifiDirectMgr::GetWPStype(bool samewithpbc) +{ + _DBG("Not Yet"); +#if 0 + wifi_direct_wps_type_e type; + + if (!is_pbc) { + _ERR("Parameter is NULL"); + return false; + } + + int ret; + ret = wifi_direct_get_wps_type(&type); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_get_wps_type failed,%s.", + wifi_direct_mgr_err_dbg(ret)); + return false; + } + + if ((type & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC) + *is_pbc = EINA_TRUE; + else + *is_pbc = EINA_FALSE; + + return true; +#endif + return false; +} + + +bool CWifiDirectMgr::SetWPStype(wifi_direct_wps_type_e *type) +{ + if (!type) { + _ERR("Parameter is NULL"); + return false; + } + + _DBG("Not Yet"); +#if 0 + int ret; + ret = wifi_direct_set_wps_type(*type); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_get_wps_type failed,%s.", + wifi_direct_mgr_err_dbg(ret)); + return false; + } +#endif + + return true; +} + + +bool CWifiDirectMgr::SetDeviceStateChangedCb(wifi_direct_device_state_changed_cb cb, void *data) +{ + int ret = -1; + ret = wifi_direct_set_device_state_changed_cb(cb, data); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("set device state changed cb failed ret:%s.", GetErrorMsg(ret)); + return false; + } + return true; +} + + +bool CWifiDirectMgr::UnSetDeviceStateChangedCb(void) +{ + int ret = -1; + ret = wifi_direct_unset_device_state_changed_cb(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("unset device state changed cb failed ret:%s.", GetErrorMsg(ret)); + return false; + } + return true; +} + + +bool CWifiDirectMgr::SetDiscoveryStateChangedCb(wifi_direct_discovery_state_chagned_cb cb, void *data) +{ + int ret = -1; + ret = wifi_direct_set_discovery_state_changed_cb(cb, data); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("set discovery state changed cb failed ret:%s.", GetErrorMsg(ret)); + wifi_direct_unset_device_state_changed_cb(); + return false; + } + return true; +} + + +bool CWifiDirectMgr::UnSetDiscoveryStateChangedCb(void) +{ + int ret = -1; + ret = wifi_direct_unset_discovery_state_changed_cb(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("unset discovery state changed cb failed ret:%s.", GetErrorMsg(ret)); + return false; + } + return true; +} + + +bool CWifiDirectMgr::SetConnectionStateChangedCb(wifi_direct_connection_state_changed_cb cb, void *data) +{ + int ret = -1; + ret = wifi_direct_set_connection_state_changed_cb(cb, data); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("set connection state changed cb failed ret:%s.", GetErrorMsg(ret)); + wifi_direct_unset_device_state_changed_cb(); + wifi_direct_unset_discovery_state_changed_cb(); + return false; + } + return true; +} + + +bool CWifiDirectMgr::UnSetConnectionStateChangedCb(void) +{ + int ret = -1; + ret = wifi_direct_unset_connection_state_changed_cb(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("unset connection state changed cb failed ret:%s.", GetErrorMsg(ret)); + return false; + } + return true; +} + + +bool CWifiDirectMgr::UnSetClientIpAddrAssignedCb(void) +{ + int ret = -1; + ret = wifi_direct_unset_client_ip_address_assigned_cb(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("unset device state changed cb failed ret:%s.", GetErrorMsg(ret)); + return false; + } + return true; +} + + +const char *CWifiDirectMgr::GetErrorMsg(int err) +{ + switch (err) { + case WIFI_DIRECT_ERROR_OUT_OF_MEMORY: + return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY"; + break; + case WIFI_DIRECT_ERROR_NOT_PERMITTED: + return "WIFI_DIRECT_ERROR_NOT_PERMITTED"; + break; + case WIFI_DIRECT_ERROR_INVALID_PARAMETER: + return "WIFI_DIRECT_ERROR_INVALID_PARAMETER"; + break; + case WIFI_DIRECT_ERROR_RESOURCE_BUSY: + return "WIFI_DIRECT_ERROR_RESOURCE_BUSY"; + break; + case WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT: + return "WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT"; + break; + case WIFI_DIRECT_ERROR_NOT_INITIALIZED: + return "WIFI_DIRECT_ERROR_NOT_INITIALIZED"; + break; + case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED: + return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED"; + break; + case WIFI_DIRECT_ERROR_WIFI_USED: + return "WIFI_DIRECT_ERROR_WIFI_USED"; + break; + case WIFI_DIRECT_ERROR_MOBILE_AP_USED: + return "WIFI_DIRECT_ERROR_MOBILE_AP_USED"; + break; + case WIFI_DIRECT_ERROR_CONNECTION_FAILED: + return "WIFI_DIRECT_ERROR_CONNECTION_FAILED"; + break; + case WIFI_DIRECT_ERROR_AUTH_FAILED: + return "WIFI_DIRECT_ERROR_AUTH_FAILED"; + break; + case WIFI_DIRECT_ERROR_OPERATION_FAILED: + return "WIFI_DIRECT_ERROR_OPERATION_FAILED"; + break; + case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT: + return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT"; + break; + default: + break; + } + + return "UNKNOWN"; +} + diff --git a/ug/wifi-direct/CMakeLists.txt b/ug/wifi-direct/CMakeLists.txt index c36b456..e6717bd 100644 --- a/ug/wifi-direct/CMakeLists.txt +++ b/ug/wifi-direct/CMakeLists.txt @@ -48,12 +48,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(SRCS src/ug_wifi_direct.cpp - src/wifi_direct_mgr.cpp - src/wifi_direct_view.cpp + src/WifiDirectMainView.cpp src/util.cpp + ../src/WifiMgr.cpp + ../src/WifiDirectMgr.cpp ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include) ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"") diff --git a/ug/wifi-direct/include/WifiDirectMainView.h b/ug/wifi-direct/include/WifiDirectMainView.h new file mode 100644 index 0000000..69c1f2b --- /dev/null +++ b/ug/wifi-direct/include/WifiDirectMainView.h @@ -0,0 +1,81 @@ +#ifndef __WIFI_DIRECT_MAIN_VIEW_H__ +#define __WIFI_DIRECT_MAIN_VIEW_H__ + +#include "UgCommon.h" +#include "wifi-direct.h" + +class CWifiDirectMainView : public CBaseView, public IMouseClickedListener, public IUnfocusedListener { +private : + struct SWifiDirectMainView *m; + + static void sm_CbDeviceStateChanged(int errcode, wifi_direct_device_state_e state, void *data); + static void sm_CbDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state, void *data); + void m_OnDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state); + + static void sm_CbConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr, void *data); + void m_OnConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr); + + static bool sm_CbConnectedPeers(wifi_direct_connected_peer_info_s *conn_info, void *data); + bool m_OnConnectedPeers(wifi_direct_connected_peer_info_s *conn_info); + + static bool sm_CbDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info, void *data); + bool m_OnDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info); + + static char *sm_GetItemLabel(void *data, Evas_Object *obj, const char *part); + + static Eina_Bool sm_CbConnectionInd(void *data); + + static void sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *event_info); + void m_OnGenlistItemSelected(Evas_Object *obj, void *event_info); + + bool m_WifiDirectInit(void); + bool m_RegisterWifiDirectCallback(void); + void m_UnRegisterWifiDirectCallback(void); + bool m_CreateButton(void); + bool m_CreateGenlist(void); + bool m_CreateActionBtns(void); + bool m_CreateDeviceListView(void); + void m_FillContentPart(Evas_Object *obj); + bool m_DisplayDisconnect(void); + bool m_CreateDisconnectPart(void); + void m_RefreshOnText(void); + + void m_ProcessDiscoveryStart(void); + void m_ProcessDiscoveryFound(void); + void m_ProcessDiscoveryFinish(void); + + void m_ProcessConnectionReq(const char *addr); + void m_ProcessConnectionProg(void); + void m_ProcessConnectionRsp(void); + void m_ProcessConnectionInd(void); + + bool m_CreateWifiDirectScan(void); + void m_ShowActionBtn(void); + bool m_UpdateGenlistItem(device_info *info); + + bool m_IsPeerExist(device_info *info); + bool m_CreateReqPopupLayout(void); + bool m_UpdateDeviceConnState(bool conn); + bool m_WifiDirectCbBtnConnect(device_info *info, int is_conn); + bool m_CreateWifiDirectDim(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CWifiDirectMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IUnfocusedListener(this), m(0) {} + virtual ~CWifiDirectMainView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); +}; + +#endif /* __WIFI_DIRECT_MAIN_VIEW_H__ */ + diff --git a/ug/wifi-direct/include/defs.h b/ug/wifi-direct/include/defs.h index 27be376..a8c9156 100644 --- a/ug/wifi-direct/include/defs.h +++ b/ug/wifi-direct/include/defs.h @@ -37,6 +37,9 @@ #define ELM_SCALE elm_config_scale_get() +/* View */ +#define WIFI_DIRECT_MAINVIEW "WIFI_DIRECT_MAINVIEW" + /*GROUP*/ #define GRP_MAIN "main_view" #define GRP_WIFI_DIRECT_SELECT "grp_wifi_direct_select" diff --git a/ug/wifi-direct/include/wifi_direct_mgr.h b/ug/wifi-direct/include/wifi_direct_mgr.h deleted file mode 100644 index d448ed4..0000000 --- a/ug/wifi-direct/include/wifi_direct_mgr.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __WIFI_DIRECT_MGR_H__ -#define __WIFI_DIRECT_MGR_H__ - -#include "defs.h" -#include -#include -#include -#include -#include - -#define WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN 0 -#define WIFI_DIRECT_SCAN_TIMEOUT 3 - -struct device_info { - char dev_name[WIFI_DIRECT_DEFAULT_BUF_LEN]; - char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN]; - Eina_Bool is_conn; - int wps_types; - char wps_pin[WIFI_DIRECT_STATE_BUF_LEN]; - char state[WIFI_DIRECT_STATE_BUF_LEN]; -}; - -struct discovered_device_info { - char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN]; - int conn_status; - int wps_types; - char wps_pin[WIFI_DIRECT_STATE_BUF_LEN]; -}; - -struct wifi_direct_cbs { - wifi_direct_device_state_changed_cb device_state_cb; - wifi_direct_discovery_state_chagned_cb discovery_state_cb; - wifi_direct_connection_state_changed_cb connection_state_cb; - wifi_direct_connected_peer_cb connected_peer_cb; - wifi_direct_discovered_peer_cb discovered_peer_cb; -}; - -const char *wifi_direct_mgr_err_dbg(int errcode); -char *wifi_direct_mgr_get_device_name(void); -char *wifi_direct_mgr_get_mac_address(void); -int wifi_direct_mgr_register_callback(struct wifi_direct_cbs *cbs, - void *data); -int wifi_direct_mgr_unregister_callback(void); -int wifi_direct_mgr_wifi_init(void); -int wifi_direct_mgr_wifi_fini(void); -int wifi_direct_mgr_wifi_direct_init(void); -int wifi_direct_mgr_wifi_direct_fini(void); -int wifi_direct_mgr_get_state(wifi_direct_state_e *status); -int wifi_direct_mgr_activate(void); -int wifi_direct_mgr_deactivate(void); -int wifi_direct_mgr_set_configure_num(void); -int wifi_direct_mgr_foreach_discovered_peers( - wifi_direct_discovered_peer_cb cb, void *data); -int wifi_direct_mgr_foreach_connected_peers( - wifi_direct_connected_peer_cb cb, void *data); -int wifi_direct_mgr_start_discovery(void); -int wifi_direct_mgr_cancel_discovery(void); -int wifi_direct_mgr_connect(const char *mac_addr); -int wifi_direct_mgr_disconnect(const char *mac_addr); -int wifi_direct_mgr_reject_connection(const char *mac_addr); -int wifi_direct_mgr_accept_connection(char *mac_addr); -int wifi_direct_mgr_get_wps_type(Eina_Bool *is_pbc); -int wifi_direct_mgr_set_wps_type(wifi_direct_wps_type_e *type); - -#endif /* __WIFI_DIRECT_MGR_H__ */ diff --git a/ug/wifi-direct/include/wifi_direct_view.h b/ug/wifi-direct/include/wifi_direct_view.h deleted file mode 100644 index 1fb28b4..0000000 --- a/ug/wifi-direct/include/wifi_direct_view.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __WIFI_DIRECT_VIEW_H__ -#define __WIFI_DIRECT_VIEW_H__ - -#include -#include - -Evas_Object *wifi_direct_view_create(Evas_Object *win, ui_gadget_h ug); - -#endif /* __WIFI_DIRECT_VIEW_H__ */ diff --git a/ug/wifi-direct/src/WifiDirectMainView.cpp b/ug/wifi-direct/src/WifiDirectMainView.cpp new file mode 100644 index 0000000..77af00d --- /dev/null +++ b/ug/wifi-direct/src/WifiDirectMainView.cpp @@ -0,0 +1,1540 @@ +#include +#include +#include +#include +#include "defs.h" +#include "dbg.h" +#include "util.h" + +#include "WifiDirectMgr.h" + +#include +#include + +#include "BaseView.h" +#include "ViewMgr.h" +#include "WifiDirectMainView.h" + +const char *action_button[] = { TXT_REFRESH_BTN, TXT_CLOSE_BTN, TXT_STOP_BTN }; +const char *popup_button_on[] = { TXT_ON_BTN, TXT_OFF_BTN }; +static char *popup_button_conn[] = { TXT_CONNECT, TXT_DISCONNECT }; +static char *popup_button_req[] = { TXT_YES, TXT_NO }; +static char *part_req[] = { PART_YES, PART_NO }; + +enum action_btn_enum { + ACTION_BTN_REFRESH, + ACTION_BTN_CLOSE, + ACTION_BTN_STOP +}; +enum direct_swith_enum { + DIRECT_ON = 0, + DIRECT_OFF +}; + +struct SWifiDirectMainView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *genlist; + Evas_Object *on_btn; + Evas_Object *direct_popup; + Evas_Object *connect_popup; + Evas_Object *dim_ly; + Evas_Object *btn_refresh; + Evas_Object *btn_close; + Evas_Object *btn_stop; + Evas_Object *scan_ly; + Evas_Object *scan_pb; + Evas_Object *no_conn_ly; + Evas_Object *prog_popup; + Evas_Object *req_popup; + + Elm_Genlist_Item_Class *itc; + Elm_Object_Item *popup_item; + Eina_List *item_list; + Ecore_Timer *timer; + + int conn_idx; + int direct_on_flag; + int finish_flag; + char *req_addr; + + + CViewMgr *pViewMgr; + CWifiDirectMgr *pWifiDirectMgr; +}; + + +void CWifiDirectMainView::sm_CbDeviceStateChanged(int errcode, wifi_direct_device_state_e state, void *data) +{ + bool ret = false; + SWifiDirectMainView *m; + + if (!data) { + _ERR("The param is invalid."); + return; + } + + m = (SWifiDirectMainView *) data; + + if (state != WIFI_DIRECT_DEVICE_STATE_ACTIVATED) { + elm_genlist_clear(m->genlist); + return; + } + + ret = m->pWifiDirectMgr->SetMaxClient(); + if (ret != true) { + _ERR("set configure num failed."); + return; + } + + ret = m->pWifiDirectMgr->StartDiscovery(); + if (ret != true) + _ERR("start discovery failed."); +} + + +void CWifiDirectMainView::sm_CbDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state, void *data) +{ + CWifiDirectMainView *instance = NULL; + + if (!state || !data) { + _ERR("data is invalid."); + return; + } + + instance = (CWifiDirectMainView *) data; + instance->m_OnDiscoveryStateChanged(errcode, state); +} + + +void CWifiDirectMainView::m_OnDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state) +{ + switch (state) { + case WIFI_DIRECT_DISCOVERY_STARTED: + m_ProcessDiscoveryStart(); + break; + case WIFI_DIRECT_DISCOVERY_FOUND: + m_ProcessDiscoveryFound(); + break; + case WIFI_DIRECT_DISCOVERY_FINISHED: + m_ProcessDiscoveryFinish(); + break; + default: + break; + } +} + + +void CWifiDirectMainView::sm_CbConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr, void *data) +{ + CWifiDirectMainView *instance = NULL; + + if (!state || !data) { + _ERR("data is invalid."); + return; + } + + instance = (CWifiDirectMainView *) data; + instance->m_OnConnectionStateChanged(errcode, state, addr); +} + + +void CWifiDirectMainView::m_OnConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr) +{ + if (!state || !addr) { + _ERR("The param is invalid."); + return; + } + + switch (state) { + case WIFI_DIRECT_CONNECTION_REQ: + m_ProcessConnectionReq(addr); + break; + case WIFI_DIRECT_CONNECTION_IN_PROGRESS: + m_ProcessConnectionProg(); + break; + case WIFI_DIRECT_CONNECTION_RSP: + m_ProcessConnectionRsp(); + break; + case WIFI_DIRECT_DISCONNECTION_IND: + m_ProcessConnectionInd(); + break; + default: + break; + } +} + + +bool CWifiDirectMainView::sm_CbConnectedPeers(wifi_direct_connected_peer_info_s *conn_info, void *data) +{ + CWifiDirectMainView *instance = NULL; + + if (!data) { + _ERR("data is invalid."); + return false; + } + + instance = (CWifiDirectMainView *) data; + return instance->m_OnConnectedPeers(conn_info); +} + + +bool CWifiDirectMainView::m_OnConnectedPeers(wifi_direct_connected_peer_info_s *conn_info) +{ + struct device_info *info; + bool ret = false; + + if (!conn_info) { + _ERR("The param is NULL."); + return false; + } + + info = (struct device_info *) calloc(1, sizeof(*info)); + if (!info) { + _ERR("calloc failed."); + return false; + } + + strncpy(info->dev_name, conn_info->device_name, WIFI_DIRECT_DEFAULT_BUF_LEN); + strncpy(info->mac_addr, conn_info->mac_address, WIFI_DIRECT_DEFAULT_BUF_LEN); + info->is_conn = true; + + ret = m_UpdateGenlistItem(info); + if (ret != true) { + _ERR("update genlist view failed."); + free(info); + return false; + } + + return true; +} + + +bool CWifiDirectMainView::sm_CbDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info, void *data) +{ + CWifiDirectMainView *instance = NULL; + + if (!data) { + _ERR("data is invalid."); + return false; + } + + instance = (CWifiDirectMainView *) data; + instance->m_OnDiscoverdPeers(discov_info); + return true; +} + + +bool CWifiDirectMainView::m_OnDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info) +{ + struct device_info *info; + bool ret = false; + + if (!discov_info) { + _ERR("The param is invalid."); + return false; + } + + info = (struct device_info *) calloc(1, sizeof(*info)); + if (!info) { + _ERR("calloc failed."); + return false; + } + + strncpy(info->dev_name, discov_info->device_name, WIFI_DIRECT_DEFAULT_BUF_LEN); + strncpy(info->mac_addr, discov_info->mac_address, WIFI_DIRECT_DEFAULT_BUF_LEN); + info->is_conn = (Eina_Bool) discov_info->is_connected; + info->wps_types = discov_info->supported_wps_types; + + ret = m_UpdateGenlistItem(info); + if (ret != true) { + _ERR("update genlist view failed."); + free(info); + return false; + } + + return true; +} + + +char *CWifiDirectMainView::sm_GetItemLabel(void *data, Evas_Object *obj, const char *part) +{ + struct device_info *info; + char buf_name[WIFI_DIRECT_DEFAULT_BUF_LEN]; + + if (!data) { + _ERR("data is NULL."); + return NULL; + } + + info = (struct device_info *) data; + + memset(&buf_name, 0x00, WIFI_DIRECT_DEFAULT_BUF_LEN); + if (!strcmp(part, TXT_ELM_TEXT)) { + strncpy(buf_name, info->dev_name, WIFI_DIRECT_HALF_BUF_LEN); + strncat(buf_name, TXT_COLON, WIFI_DIRECT_COLON_LEN); + strncat(buf_name, info->state, WIFI_DIRECT_HALF_BUF_LEN); + + return strdup(buf_name); + } + + return NULL; +} + + +void CWifiDirectMainView::t_OnShow() +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CWifiDirectMainView::t_OnUpdate(void *data) +{ + _DBG(); + + evas_object_show(m->base); +} + + +void CWifiDirectMainView::t_OnHide() +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +Eina_Bool CWifiDirectMainView::sm_CbConnectionInd(void *data) +{ + bool ret = false; + SWifiDirectMainView *m; + + if (!data) { + _ERR("the param is invalid."); + return ECORE_CALLBACK_CANCEL; + } + + m = (SWifiDirectMainView *) data; + + ret = m->pWifiDirectMgr->StartDiscovery(); + if (ret != true) + _ERR("start discovery failed."); + + m->timer = NULL; + + return ECORE_CALLBACK_CANCEL; +} + + +void CWifiDirectMainView::sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *event_info) +{ + CWifiDirectMainView *instance = NULL; + + if (!data) { + _ERR("data is invalid."); + return; + } + + instance = (CWifiDirectMainView *) data; + instance->m_OnGenlistItemSelected(obj, event_info); +} + + +void CWifiDirectMainView::m_OnGenlistItemSelected(Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *gen_item; + Evas_Object *layout, *box, *item_btn; + Evas_Object *btn[BTN_DIRECT]; + struct device_info *info; + int cur_idx; + int i; + bool ret = false; + int btn_x, btn_y, btn_w, btn_h; + int move_x, move_y; + + if (!obj || !event_info) { + _ERR("The param is invalid."); + return; + } + + if (!m->dim_ly) { + ret = m_CreateWifiDirectDim(); + if (ret != true) { + Destroy(); + return; + } + } + + evas_object_show(m->dim_ly); + + gen_item = (Elm_Object_Item *) event_info; + m->popup_item = gen_item; + + layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFI_DIRECT_SELECT); + if (!layout) { + _ERR("add connect popup failed."); + return; + } + + box = util_add_box(layout, PART_SWALLOW_CONTENT); + if (!box) { + _ERR("add box failed."); + evas_object_del(layout); + return; + } + + for (i = 0; i < BTN_DIRECT; i++) { + btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, _(popup_button_conn[i])); + if (!btn[i]) { + _ERR("add connect btn failed."); + evas_object_del(layout); + return; + } + + elm_box_pack_end(box, btn[i]); +#if 0 + evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + } + //evas_object_smart_callback_add(btn[i], SIG_CLICKED, _item_conn_btn_clicked_cb, priv); + Connect(btn[0], 13); + Connect(btn[1], 14); + + cur_idx = elm_genlist_item_index_get(gen_item); + if (cur_idx < 0) + return; + + info = (struct device_info *) eina_list_nth(m->item_list, cur_idx); + if (!info) + return; + + if (info->is_conn) + elm_object_signal_emit(btn[DIRECT_ON], SIG_BTN_SELECTED, PROG); + else + elm_object_signal_emit(btn[DIRECT_OFF], SIG_BTN_SELECTED, PROG); + + util_set_cycle_focus(btn, BTN_DIRECT); + + item_btn = elm_object_item_track(gen_item); + if (!item_btn) { + _ERR("get genlist item track failed."); + evas_object_del(layout); + return; + } + + evas_object_geometry_get(item_btn, &btn_x, &btn_y, &btn_w, &btn_h); + + move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; + move_y = btn_y + btn_h; + evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); + m->connect_popup = layout; + + //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); + Connect(layout, 15); + + elm_object_focus_set(btn[0], true); +} + + +bool CWifiDirectMainView::m_WifiDirectInit(void) +{ + + if(!CWifiDirectMgr::Initialize()) { + return false; + } + + m->pWifiDirectMgr = NULL; + m->pWifiDirectMgr = CWifiDirectMgr::GetInstance(); + ASSERT(m->pWifiDirectMgr); + + return true; +} + + +bool CWifiDirectMainView::m_RegisterWifiDirectCallback(void) +{ + if(!m->pWifiDirectMgr->SetDeviceStateChangedCb(sm_CbDeviceStateChanged, m)) { + return false; + } + + if(!m->pWifiDirectMgr->SetDiscoveryStateChangedCb(sm_CbDiscoveryStateChanged, this)) { + return false; + } + + if(!m->pWifiDirectMgr->SetConnectionStateChangedCb(sm_CbConnectionStateChanged, this)) { + return false; + } + return true; +} + + +void CWifiDirectMainView::m_UnRegisterWifiDirectCallback(void) +{ + m->pWifiDirectMgr->UnSetConnectionStateChangedCb(); + m->pWifiDirectMgr->UnSetDiscoveryStateChangedCb(); + m->pWifiDirectMgr->UnSetDeviceStateChangedCb(); + m->pWifiDirectMgr->UnSetClientIpAddrAssignedCb(); +} + + +bool CWifiDirectMainView::m_CreateButton(void) +{ + Evas_Object *on_btn; + + on_btn = util_add_button(m->base, STYLE_WIFI_DIRECT_BTN, PART_WIFI_DIRECT_ON, TXT_WIFI_DIRECT); + if (!on_btn) { + _ERR("Add wifi direct button failed."); + return false; + } + + elm_object_focus_allow_set(on_btn, true); + elm_object_focus_set(on_btn, true); + elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT); + + //evas_object_smart_callback_add(on_btn, SIG_CLICKED, _wifi_direct_btn_clicked_cb, priv); +#if 0 + evas_object_event_callback_add(on_btn, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + Connect(m->on_btn, 1); + m->on_btn = on_btn; + + m_RefreshOnText(); + + return true; +} + + +bool CWifiDirectMainView::m_CreateGenlist(void) +{ + Evas_Object *genlist; + Elm_Genlist_Item_Class *itc; + + genlist = elm_genlist_add(m->base); + if (!genlist) { + _ERR("add genlist failed."); + return false; + } + + itc = elm_genlist_item_class_new(); + if (!itc) { + _ERR("genlist item class new failed."); + evas_object_del(genlist); + return false; + } + + m->genlist = genlist; + + itc->item_style = STYLE_TEXT_ICON; + itc->func.text_get = sm_GetItemLabel; + itc->func.content_get = NULL; + itc->func.state_get = NULL; + itc->func.del = NULL; + + m->itc = itc; + + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT); + + return true; +} + + +bool CWifiDirectMainView::m_CreateActionBtns(void) +{ + Evas_Object *btn_refresh; + Evas_Object *btn_close; + + btn_refresh = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN, _(action_button[ACTION_BTN_REFRESH])); + btn_close = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_CLOSE_BTN, _(action_button[ACTION_BTN_CLOSE])); + + m->btn_refresh = btn_refresh; + m->btn_close = btn_close; + +#if 0 + evas_object_event_callback_add(m->btn_refresh, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); + evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + //evas_object_smart_callback_add(m->btn_refresh, SIG_CLICKED, _refresh_btn_clicked_cb, priv); + //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv); + Connect(m->btn_refresh, 4); + Connect(m->btn_close, 5); + + return true; +} + + +bool CWifiDirectMainView::m_CreateDeviceListView(void) +{ + wifi_direct_state_e status; + bool ret = false; + + if (m->no_conn_ly) + evas_object_hide(m->no_conn_ly); + + ret = m->pWifiDirectMgr->GetState(&status); + if (ret != true) { + _ERR("get state failed."); + return false; + } + + if (status < WIFI_DIRECT_STATE_ACTIVATED) { + ret = m->pWifiDirectMgr->Activate(); + if (ret != true) { + _ERR("activate failed."); + return false; + } + } else { + ret = m->pWifiDirectMgr->SetMaxClient(); + if (ret != true) { + _ERR("set configure num failed."); + return false; + } + + ret = m->pWifiDirectMgr->StartDiscovery(); + if (ret != true) { + _ERR("start discovery failed."); + return false; + } + } + + m_FillContentPart(m->genlist); + + elm_object_focus_set(m->btn_refresh, true); + return true; +} + + +void CWifiDirectMainView::m_FillContentPart(Evas_Object *obj) +{ + Evas_Object *old_obj; + + old_obj = elm_object_part_content_get(m->base, PART_GENLIST_ITEMS); + if (old_obj) { + elm_object_part_content_unset(m->base, PART_GENLIST_ITEMS); + evas_object_hide(old_obj); + } + + elm_object_part_content_set(m->base, PART_GENLIST_ITEMS, obj); + evas_object_show(obj); +} + + +bool CWifiDirectMainView::m_DisplayDisconnect(void) +{ + bool ret = false; + + if (!m->no_conn_ly) { + ret = m_CreateDisconnectPart(); + if (ret != true) { + _ERR("m_CreateDisconnectPart() failed."); + return false; + } + } + + m_FillContentPart(m->no_conn_ly); + + elm_object_part_content_unset(m->base, PART_REFRESH_BTN); + evas_object_hide(m->btn_refresh); + elm_object_part_content_set(m->base, PART_REFRESH_BTN, m->btn_close); + evas_object_show(m->btn_close); + + //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv); + Connect(m->btn_close, 6); +#if 0 + evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + return true; +} + + +bool CWifiDirectMainView::m_CreateDisconnectPart(void) +{ + Evas_Object *ly; + + ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFIDIRECT_DISCONNECT_LY); + if (!ly) { + _ERR("Add noconnect_ly failed."); + return false; + } + + elm_object_part_text_set(ly, PART_DISCONNECT_TEXT, TXT_WIFIDIRECT_NONE); + + m->no_conn_ly = ly; + evas_object_hide(ly); + + return true; +} + + +void CWifiDirectMainView::m_RefreshOnText(void) +{ + if (m->scan_ly) + evas_object_hide(m->scan_ly); + + if (m->direct_on_flag == DIRECT_ON) + elm_object_part_text_set(m->on_btn, PART_WIFI_DIRECT_SELECT, _(popup_button_on[DIRECT_ON])); + else + elm_object_part_text_set(m->on_btn, PART_WIFI_DIRECT_SELECT, _(popup_button_on[DIRECT_OFF])); +} + + +void CWifiDirectMainView::m_ProcessDiscoveryStart(void) +{ + bool ret = false; + struct device_info *info; + void *obj; + + if (m->genlist) + elm_genlist_clear(m->genlist); + + if (m->item_list) + EINA_LIST_FREE(m->item_list, obj) + { + info = (struct device_info *) obj; + free(info); + } + + ret = m->pWifiDirectMgr->GetAllConnectedPeerInfo(sm_CbConnectedPeers, this); + if (ret != true) { + _ERR("foreach connected peers failed "); + return; + } + + ret = m_CreateWifiDirectScan(); + if (ret != true) + _ERR("m_CreateWifiDirectScan() failed "); +} + + +void CWifiDirectMainView::m_ProcessDiscoveryFound(void) +{ + bool ret = false; + + ret = m->pWifiDirectMgr->GetAllDicoveredPeerInfo(sm_CbDiscoverdPeers, this); + if (ret != true) + _ERR("foreach connected peers failed "); +} + + +void CWifiDirectMainView::m_ProcessDiscoveryFinish(void) +{ + elm_object_part_content_unset(m->base, PART_REFRESH_BTN); + evas_object_hide(m->btn_stop); + + m_ShowActionBtn(); + + m_FillContentPart(m->genlist); +} + + +void CWifiDirectMainView::m_ProcessConnectionReq(const char *addr) +{ + Eina_Bool is_pbc; + bool ret = false; + + if (!addr) { + _ERR("the param is invalid."); + return; + } + + ret = m->pWifiDirectMgr->GetWPStype(&is_pbc); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("Get wps type failed."); + return; + } + + m->req_addr = strdup(addr); + if (!m->req_addr) { + _ERR("strdup wrong."); + return; + } + + if (is_pbc == true) { + ret = m_CreateReqPopupLayout(); + if (ret != true) + _ERR("Create rep popup failed."); + } +} + + +void CWifiDirectMainView::m_ProcessConnectionProg(void) +{ + Evas_Object *layout; + char title[MAX_STRING_LENTH]; + int x, y, w, h; + int move_x, move_y; + + if (m->dim_ly) + evas_object_show(m->dim_ly); + + layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_CONNECT_ACCEPT); + if (!layout) { + _ERR("add con_popup layout failed."); + return; + } + + memset(&title, 0x00, MAX_STRING_LENTH); + snprintf(title, MAX_STRING_LENTH - 1, "%s", TXT_CONN_PROG); + elm_object_part_text_set(layout, PART_TITLE, title); + + evas_object_geometry_get(m->on_btn, &x, &y, &w, &h); + move_x = x + w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; + move_y = y + CENTER_HEIGHT; + evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); + + m->prog_popup = layout; +} + + +void CWifiDirectMainView::m_ProcessConnectionRsp(void) +{ + struct device_info *info; + int cur_index; + + cur_index = m->conn_idx; + info = (struct device_info *) eina_list_nth(m->item_list, cur_index); + if (!info) + return; + + info->is_conn = true; + strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN); + + elm_genlist_item_update(m->popup_item); + + if (m->dim_ly) + evas_object_hide(m->dim_ly); + + if (m->prog_popup) { + evas_object_del(m->prog_popup); + m->prog_popup = NULL; + } + + if (m->connect_popup) { + evas_object_del(m->connect_popup); + m->connect_popup = NULL; + } +} + + +void CWifiDirectMainView::m_ProcessConnectionInd(void) +{ + Ecore_Timer *timer; + + timer = ecore_timer_add(HANDLER_INTERVAL, sm_CbConnectionInd, m); + if (!timer) { + _ERR("add timer failed."); + return; + } + + m->timer = timer; +} + + +bool CWifiDirectMainView::m_CreateWifiDirectScan(void) +{ + Evas_Object *ly; + Evas_Object *pb; + Evas_Object *btn; + + + ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, + GRP_WIFIDIRECT_SCAN_LY); + if (!ly) { + _ERR("Add scan_ly failed."); + return false; + } + + m->scan_ly = ly; + + elm_object_part_content_unset(m->base, PART_REFRESH_BTN); + evas_object_hide(m->btn_refresh); + + elm_object_part_content_unset(m->base, PART_CLOSE_BTN); + evas_object_hide(m->btn_close); + + pb = util_add_progressbar(ly, STYLE_SEARCH_PROGRESS, PART_SEARCH_IMAGE); + if (!pb) { + _ERR("Add progressbar failed."); + goto error; + } + + btn = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN, _(action_button[ACTION_BTN_STOP])); + if (!btn) { + _ERR("Add stop button failed."); + goto error; + } + + m->scan_pb = pb; + m->btn_stop = btn; + + elm_object_focus_set(m->btn_stop, true); +#if 0 + evas_object_event_callback_add(m->btn_stop, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + //evas_object_smart_callback_add(m->btn_stop, SIG_CLICKED, _stop_btn_clicked_cb, priv); + Connect(m->btn_stop, 7); + + m_FillContentPart(m->scan_ly); + + return true; + +error: + evas_object_del(ly); + return false; +} + + +void CWifiDirectMainView::m_ShowActionBtn(void) +{ + Evas_Object *btn; + + if (!m->btn_refresh || !m->btn_close) { + _ERR("action btn NULL!"); + return; + } + + btn = elm_object_part_content_get(m->base, PART_REFRESH_BTN); + if (btn) { + elm_object_part_content_unset(m->base, PART_REFRESH_BTN); + evas_object_hide(btn); + } + + elm_object_part_content_set(m->base, PART_REFRESH_BTN, m->btn_refresh); + evas_object_show(m->btn_refresh); + + elm_object_part_content_set(m->base, PART_CLOSE_BTN, m->btn_close); + evas_object_show(m->btn_close); + + //evas_object_smart_callback_add(m->btn_refresh, SIG_CLICKED, _refresh_btn_clicked_cb, priv); + //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv); + Connect(m->btn_refresh, 8); + Connect(m->btn_close, 9); +#if 0 + evas_object_event_callback_add(m->btn_refresh, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); + evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif +} + + +bool CWifiDirectMainView::m_UpdateGenlistItem(device_info *info) +{ + Eina_Bool exist; + + if (!info) { + _ERR("The param is invalid."); + return false; + } + + exist = m_IsPeerExist(info); + if (!exist) { + m->item_list = eina_list_append(m->item_list, info); + + if (info->is_conn) + strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN); + else + strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN); + + elm_genlist_item_append(m->genlist, m->itc, info, NULL, ELM_GENLIST_ITEM_NONE, sm_CbGenlistItemSelected, (void *)this); + } + + return true; +} + + +bool CWifiDirectMainView::m_IsPeerExist(device_info *new_info) +{ + struct device_info *cur_info; + void *obj; + Eina_List *l; + + if (!new_info) { + _ERR("The param is invalid."); + return false; + } + + if (!m->item_list) { + _ERR("The list is NULL now."); + return false; + } + + EINA_LIST_FOREACH(m->item_list, l, obj) { + cur_info = (struct device_info *) obj; + if (!strncmp(cur_info->mac_addr, new_info->mac_addr, WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) + return true; + } + + return false; +} + + +bool CWifiDirectMainView::m_CreateReqPopupLayout(void) +{ + Evas_Object *layout; + Evas_Object *btn[BTN_DIRECT]; + int i, x, y, w, h; + + if (!m->base) { + _ERR("the param is invalid."); + return false; + } + + layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_CONNECT_ACCEPT); + if (!layout) { + _ERR("elm_layout_add() failed."); + return false; + } + + for (i = 0; i < BTN_DIRECT; i++) { + btn[i] = util_add_button(layout, STYLE_POPUP_BUTTON, part_req[i], _(popup_button_req[i])); + if (!btn[i]) { + _ERR("add btn req failed."); + evas_object_del(layout); + return false; + } + +#if 0 + evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + } + //evas_object_smart_callback_add(btn[i], SIG_CLICKED, _req_btn_clicked_cb, priv); + Connect(btn[0], 10); + Connect(btn[1], 11); + + evas_object_geometry_get(m->genlist, &x, &y, &w, &h); + evas_object_move(layout, (x + RSP_X) * ELM_SCALE, (y + RSP_Y) * ELM_SCALE); + + m->req_popup = layout; + + elm_object_focus_set(btn[DIRECT_ON], true); + + //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); + Connect(layout, 12); + + return true; +} + + +bool CWifiDirectMainView::m_UpdateDeviceConnState(bool conn) +{ + struct device_info *cur_info; + void *obj; + Eina_List *l; + + EINA_LIST_FOREACH(m->item_list, l, obj) { + cur_info = (struct device_info *) obj; + if (!strncmp(cur_info->mac_addr, m->req_addr, WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) { + cur_info->is_conn = conn; + return true; + } + } + + return false; +} + + +bool CWifiDirectMainView::m_WifiDirectCbBtnConnect(struct device_info *info, int is_conn) +{ + int ret = -1; + wifi_direct_wps_type_e wps_type; + + if (!info) { + _ERR("parameter is NULL!"); + return false; + } + + if (is_conn) { + if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC) + wps_type = WIFI_DIRECT_WPS_TYPE_PBC; + else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) + wps_type = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD; + else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) + wps_type = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY; + + ret = m->pWifiDirectMgr->SetWPStype(&wps_type); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct set wps type failev!"); + return false; + } + + ret = m->pWifiDirectMgr->Connect(info->mac_addr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_connect:%s fail!", info->dev_name); + return false; + } + } else { + ret = m->pWifiDirectMgr->Disconnect(info->mac_addr); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_disconnect:%s fail!", info->dev_name); + return false; + } + } + return true; +} + + +bool CWifiDirectMainView::m_CreateWifiDirectDim(void) +{ + Evas_Object *ly; + + ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY); + if (!ly) { + _ERR("Add dim layout failed."); + return false; + } + + m->dim_ly = ly; + + evas_object_hide(ly); + + return true; +} + + +bool CWifiDirectMainView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + _CREATE_BEGIN{ + _CHECK(m = new SWifiDirectMainView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m_WifiDirectInit()) + _CHECK(m_RegisterWifiDirectCallback()) + _CHECK(m->base = util_add_layout(m->win, UG_WIFI_DIRECT_EDJ_FILE, GRP_MAIN)) + _CHECK(m_CreateButton()) + _CHECK(m_CreateGenlist()) + _CHECK(m_CreateActionBtns()) + _CHECK(m_CreateDeviceListView()) + _COMMAND { + char descrption[MAX_STRING_LENTH]; + memset(&descrption, 0x00, MAX_STRING_LENTH); + snprintf(descrption, MAX_STRING_LENTH - 1, "%s", TXT_WIFI_DIRECT_DISC); + elm_object_part_text_set(m->base, PART_DESCRIPTION, descrption); + } + _WHEN_SUCCESS { + m->pViewMgr = CViewMgr::GetInstance(); + //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _base_layout_key_down_cb, priv); + Connect(m->base, 0); + evas_object_show(m->base); + } + _CHECK_FAIL{/* m_CreateDeviceListView() */} + _CHECK_FAIL{/* m_CreateActionBtns() */} + _CHECK_FAIL{/* m_CreateGenlist() */} + _CHECK_FAIL{/* m_CreateButton() */} + _CHECK_FAIL{ evas_object_del(m->base); } + _CHECK_FAIL{m_UnRegisterWifiDirectCallback();} + _CHECK_FAIL{CWifiDirectMgr::Finalize();} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CWifiDirectMainView::Destroy() +{ + ASSERT(m); + _DBG(); + + struct device_info *info; + void *obj; + + if (!m->item_list) + EINA_LIST_FREE(m->item_list, obj) + { + info = (struct device_info *) obj; + free(info); + } + + if (m->dim_ly) + evas_object_del(m->dim_ly); + + if (m->scan_ly) + evas_object_del(m->scan_ly); + + if (m->timer) + ecore_timer_del(m->timer); + + m_UnRegisterWifiDirectCallback(); + CWifiDirectMgr::Finalize(); + + if (m->base) + evas_object_del(m->base); + + CBaseView::Destroy(); + delete m; + m = NULL; +} + + +Evas_Object* CWifiDirectMainView::Base(void) +{ + ASSERT(m); + + return m->base; +} + + +void CWifiDirectMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + /* ID list */ + /* 0 m->base */ + /* 1 */ + + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 0: + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE) || !strcmp(ev->keyname, KEY_EXIT)) { + ug_destroy_me(m->ug); + } + break; + case 12: + case 15: + case 16: + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { + if (m->dim_ly) + evas_object_hide(m->dim_ly); + + evas_object_del(obj); + } + break; + default: + break; + } +} + + +void CWifiDirectMainView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + { + Evas_Object *layout; + Evas_Object *box; + Evas_Object *btn[BTN_DIRECT]; + int i; + int btn_x, btn_y, btn_w, btn_h; + int move_x, move_y; + + if (!m->dim_ly) { + m->dim_ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY); + if (!m->dim_ly) { + _ERR("Add dim layout failed."); + Destroy(); + return ; + } + evas_object_hide(m->dim_ly); + } + + evas_object_show(m->dim_ly); + + layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFI_DIRECT_SELECT); + if (!layout){ + _ERR("Fail to add layout"); + return; + } + + elm_object_focus_allow_set(layout, true); + + box = util_add_box(layout, PART_SWALLOW_CONTENT); + if (!box) { + _ERR("Fail to add box"); + evas_object_del(layout); + return; + } + + for (i = 0; i < BTN_DIRECT; i++) { + btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, _(popup_button_on[i])); + if (!btn[i]) { + _ERR("add btn direct failed."); + evas_object_del(layout); + return; + } + + elm_box_pack_end(box, btn[i]); +#if 0 + evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); +#endif + } + //evas_object_smart_callback_add(btn[0], SIG_CLICKED, _wifi_direct_select_btn_cb, priv); + //evas_object_smart_callback_add(btn[1], SIG_CLICKED, _wifi_direct_select_btn_cb, priv); + Connect(btn[0], 2); + Connect(btn[1], 3); + + if (m->direct_on_flag == DIRECT_ON) + elm_object_signal_emit(btn[DIRECT_ON], SIG_BTN_SELECTED, PROG); + else + elm_object_signal_emit(btn[DIRECT_OFF], SIG_BTN_SELECTED, PROG); + + util_set_cycle_focus(btn, BTN_DIRECT); + + evas_object_geometry_get(m->on_btn, &btn_x, &btn_y, &btn_w, &btn_h); + move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; + move_y = btn_y + btn_h; + evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); + + m->direct_popup = layout; + + //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); + Connect(layout, 16); + + elm_object_focus_set(btn[0], true); + } + break; + case 2: + case 3: + { + struct device_info *info; + void *temp_obj; + const char *value; + bool ret = false; + + value = (const char *) elm_object_text_get(obj); + if (!value) { + _ERR("get text from network type btn is NULL."); + return; + } + + if (!strcmp(value, popup_button_on[DIRECT_ON])) { + if (m->direct_on_flag == DIRECT_OFF) { + m->direct_on_flag = DIRECT_ON; + + elm_genlist_clear(m->genlist); + + if (m->item_list) + EINA_LIST_FREE(m->item_list, temp_obj) + { + info = (struct device_info *) temp_obj; + free(info); + } + + m_CreateDeviceListView(); + + m_ShowActionBtn(); + } + } else { + m->direct_on_flag = DIRECT_OFF; + + ret = m_DisplayDisconnect(); + if (ret != true) { + _ERR("m_DisplayDisconnect() failed."); + return; + } + + ret = m->pWifiDirectMgr->Deactivate(); + if (ret != true) { + _ERR("wif direct deactivate failed."); + return; + } + } + + m_RefreshOnText(); + + if (m->direct_popup) { + evas_object_del(m->direct_popup); + m->direct_popup = NULL; + } + + if (m->dim_ly) + evas_object_hide(m->dim_ly); + + } + break; + case 4: + case 8: + { + struct device_info *info; + void *temp_obj; + + if (m->scan_ly) + evas_object_hide(m->scan_ly); + + elm_genlist_clear(m->genlist); + + if (m->item_list) + EINA_LIST_FREE(m->item_list, temp_obj) + { + info = (struct device_info *) temp_obj; + free(info); + } + + m_CreateDeviceListView(); + } + break; + case 5: + case 6: + case 9: + ug_destroy_me(m->ug); + Destroy(); + break; + case 7: + { + bool ret = false; + Evas_Object *btn; + + ret = m->pWifiDirectMgr->CancelDiscovery(); + if (ret != true) { + _ERR("Cancel disconery failed."); + return; + } + + btn = elm_object_part_content_get(m->base, PART_REFRESH_BTN); + if (btn) { + elm_object_part_content_unset(m->base, PART_REFRESH_BTN); + evas_object_hide(btn); + } + + m_ShowActionBtn(); + + m_FillContentPart(m->genlist); + } + break; + case 10: + case 11: + { + const char *value; + bool ret = false; + + if (!obj) { + _ERR("The param is invalid."); + return; + } + + value = elm_object_text_get(obj); + if (!value) { + _ERR("get text from network type btn is NULL."); + return; + } + + if (!strcmp(value, popup_button_req[DIRECT_ON])) { + ret = m->pWifiDirectMgr->AcceptConnection(m->req_addr); + if (ret != true) { + _ERR("Disconnection failed."); + return; + } + + ret = m_UpdateDeviceConnState(true); + if (ret != true) + _ERR("m_UpdateDeviceConnState() failed."); + } else { +#if 0 + ret = m->pWifiDirectMgr->RejectConnection(m->req_addr); + if (ret != true) { + _ERR("Accept connection failed."); + return; + } +#endif + + ret = m_UpdateDeviceConnState(false); + if (ret != true) + _ERR("m_UpdateDeviceConnState() failed."); + } + + free(m->req_addr); + m->req_addr = NULL; + + if (m->req_popup) { + evas_object_del(m->req_popup); + m->req_popup = NULL; + } + + if (m->dim_ly) + evas_object_hide(m->dim_ly); + + } + break; + case 13: + case 14: + { + const char *value; + bool ret = false; + Elm_Object_Item *gen_item; + struct device_info *info; + int cur_idx; + + if (!obj) { + _ERR("the param is invalid."); + return; + } + + value = elm_object_text_get(obj); + if (!value) { + _ERR("get text from wifi_direct device btn is NULL."); + return; + } + + gen_item = m->popup_item; + + cur_idx = elm_genlist_item_index_get(gen_item); + if (cur_idx < 0) + return; + + info = (struct device_info *) eina_list_nth(m->item_list, cur_idx); + if (!info) + return; + + if (!strcmp(value, TXT_CONNECT)) { + ret = m_WifiDirectCbBtnConnect(info, CONN_YES); + if (ret == false) { + _ERR("Connect failed"); + return; + } + + info->is_conn = true; + } else if (!strcmp(value, TXT_DISCONNECT)) { + ret = m_WifiDirectCbBtnConnect(info, CONN_NO); + if (ret != WIFI_DIRECT_ERROR_NONE) { + _ERR("wifi_direct_mgr_disconnect failed,,%s", + info->mac_addr); + return; + } + + strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN); + info->is_conn = false; + } + + if (m->direct_popup) { + evas_object_del(m->direct_popup); + m->direct_popup = NULL; + } + + if (m->connect_popup) { + evas_object_del(m->connect_popup); + m->connect_popup = NULL; + } + + if (m->dim_ly) + evas_object_hide(m->dim_ly); + } + break; + default: + break; + } +} + + +void CWifiDirectMainView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + switch(id) { + case 0: + break; + default: + break; + } +} + diff --git a/ug/wifi-direct/src/ug_wifi_direct.cpp b/ug/wifi-direct/src/ug_wifi_direct.cpp index 3553f50..0917376 100644 --- a/ug/wifi-direct/src/ug_wifi_direct.cpp +++ b/ug/wifi-direct/src/ug_wifi_direct.cpp @@ -22,7 +22,12 @@ #include #include "i18n.h" #include "dbg.h" -#include "wifi_direct_view.h" +#include "defs.h" + +#include +#include "wifi.h" +#include "BaseView.h" +#include "WifiDirectMainView.h" #if defined (__cplusplus) extern "C" { @@ -32,6 +37,8 @@ struct _ug_data { Evas_Object *win; Evas_Object *base; ui_gadget_h ug; + CViewMgr *pViewMgr; + CWifiDirectMainView *pWifiDirectMainView; }; /** @@ -51,7 +58,6 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) { struct _ug_data *ugd; - Evas_Object *base; Evas_Object *win; if (!ug || !priv) { @@ -74,16 +80,24 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode, elm_win_focus_highlight_enabled_set(win, EINA_TRUE); elm_win_focus_highlight_style_set(win, "invisible"); - base = (Evas_Object *) wifi_direct_view_create(win, ug); - if (!base) { - _ERR("add base layout failed."); + CViewMgr::Initialize(ugd->win, NULL); + ugd->pViewMgr = CViewMgr::GetInstance(); + if(!ugd->pViewMgr) { + CViewMgr::Finalize(); + _ERR("Fail to get CViewMgr instance"); return NULL; } + ugd->pWifiDirectMainView = new CWifiDirectMainView(WIFI_DIRECT_MAINVIEW); + if(!ugd->pViewMgr->AddView(ugd->pWifiDirectMainView)) { + _ERR("Fail to add pFbBaseView"); + CViewMgr::Finalize(); + return false; + } - ugd->base = base; - evas_object_raise(base); + ugd->pViewMgr->PushView(WIFI_DIRECT_MAINVIEW, NULL); + ugd->base = ugd->pWifiDirectMainView->Base(); - return base; + return ugd->base; } /** @@ -136,6 +150,7 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv) */ static void _on_destroy(ui_gadget_h ug, service_h service, void *priv) { + CViewMgr::Finalize(); } /** diff --git a/ug/wifi-direct/src/wifi_direct_mgr.cpp b/ug/wifi-direct/src/wifi_direct_mgr.cpp deleted file mode 100644 index 02cf4a3..0000000 --- a/ug/wifi-direct/src/wifi_direct_mgr.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "defs.h" -#include "dbg.h" -#include "wifi_direct_mgr.h" - -#define LOCAL_MAX_CLIENT 8 - -/** -* Convert the error code to the corresponding string. -* -* @param[in] errcode the wifi direct error code bypassed -* @return the error description -*/ -const char *wifi_direct_mgr_err_dbg(int errcode) -{ - switch (errcode) { - case WIFI_DIRECT_ERROR_OUT_OF_MEMORY: - return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY"; - break; - case WIFI_DIRECT_ERROR_NOT_PERMITTED: - return "WIFI_DIRECT_ERROR_NOT_PERMITTED"; - break; - case WIFI_DIRECT_ERROR_INVALID_PARAMETER: - return "WIFI_DIRECT_ERROR_INVALID_PARAMETER"; - break; - case WIFI_DIRECT_ERROR_RESOURCE_BUSY: - return "WIFI_DIRECT_ERROR_RESOURCE_BUSY"; - break; - case WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT: - return "WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT"; - break; - case WIFI_DIRECT_ERROR_NOT_INITIALIZED: - return "WIFI_DIRECT_ERROR_NOT_INITIALIZED"; - break; - case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED: - return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED"; - break; - case WIFI_DIRECT_ERROR_WIFI_USED: - return "WIFI_DIRECT_ERROR_WIFI_USED"; - break; - case WIFI_DIRECT_ERROR_MOBILE_AP_USED: - return "WIFI_DIRECT_ERROR_MOBILE_AP_USED"; - break; - case WIFI_DIRECT_ERROR_CONNECTION_FAILED: - return "WIFI_DIRECT_ERROR_CONNECTION_FAILED"; - break; - case WIFI_DIRECT_ERROR_AUTH_FAILED: - return "WIFI_DIRECT_ERROR_AUTH_FAILED"; - break; - case WIFI_DIRECT_ERROR_OPERATION_FAILED: - return "WIFI_DIRECT_ERROR_OPERATION_FAILED"; - break; - case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT: - return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT"; - break; - default: - break; - } - - return "UNKNOWN"; -} - -/** -* Get device name. -* -* @return device name on success,otherwise NULL -*/ -char *wifi_direct_mgr_get_device_name(void) -{ - int ret; - char *name; - - name = NULL; - ret = wifi_direct_get_device_name(&name); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("get device name failed, ret: %s.", - wifi_direct_mgr_err_dbg(ret)); - return NULL; - } - - return name; -} - -/** -* Get local MAC address. -* -* @return MAC address string on success, otherwise NULL -*/ -char *wifi_direct_mgr_get_mac_address(void) -{ - int ret; - char *mac_addr; - - mac_addr = NULL; - ret = wifi_direct_get_mac_address(&mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("get mac address failed, ret: %s.", - wifi_direct_mgr_err_dbg(ret)); - return NULL; - } - - return mac_addr; -} - -/** -* Initialize WiFi server. -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_wifi_init(void) -{ - int ret; - - ret = wifi_initialize(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_initialize failed, ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Finalize WiFi server -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_wifi_fini(void) -{ - int ret; - - ret = wifi_deinitialize(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_deinitialize failed, ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Initialize WiFi Direct server -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_wifi_direct_init(void) -{ - int ret; - - ret = wifi_direct_initialize(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_initialize failed, ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Finalize Wi-Fi Direct server. -* -* Uses the midware API to deregister the client application with the Wi-Fi Direct server. -* and releases all resources. Pre Application must be already registered to the Wi-Fi Direct server. -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_wifi_direct_fini(void) -{ - int ret; - - ret = wifi_direct_deinitialize(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_deinitialize failed, ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Register the callback functions called. -* -* Each callback function is synchronous. -* -* @param[in] cbs The fuction struct contains the action callback fuctions -* @param[in] data the user data -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_register_callback(struct wifi_direct_cbs *cbs, - void *data) -{ - int ret; - - if (!cbs || !data) { - _ERR("The parameter is NULL."); - return RET_FAILED; - } - - ret = wifi_direct_set_device_state_changed_cb(cbs->device_state_cb, - data); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("set device state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - ret = wifi_direct_set_discovery_state_changed_cb( - cbs->discovery_state_cb, data); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("set discovery state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - wifi_direct_unset_device_state_changed_cb(); - return RET_FAILED; - } - - ret = wifi_direct_set_connection_state_changed_cb( - cbs->connection_state_cb, data); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("set connection state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - wifi_direct_unset_device_state_changed_cb(); - wifi_direct_unset_discovery_state_changed_cb(); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Unregister the action callback fuctions. -* -* Opposite action to wifi_direct_mgr_register_callback. -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_unregister_callback(void) -{ - int ret; - int result; - - result = RET_SUCCESS; - ret = wifi_direct_unset_device_state_changed_cb(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("unset device state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - result = RET_FAILED; - } - - ret = wifi_direct_unset_discovery_state_changed_cb(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("unset discovery state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - result = RET_FAILED; - } - - ret = wifi_direct_unset_connection_state_changed_cb(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("unset connection state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - result = RET_FAILED; - } - - ret = wifi_direct_unset_client_ip_address_assigned_cb(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("unset device state changed cb failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - result = RET_FAILED; - } - - return result; -} - -/** -* Get the state of Wi-Fi Direct server -* -* @param[in] status The param bypassed used to save the status of the Wi-Fi Direct server -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_get_state(wifi_direct_state_e *status) -{ - int ret; - - if (!status) { - _ERR("The param is NULL."); - return RET_FAILED; - } - - ret = wifi_direct_get_state(status); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("get state failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Activate Wi-Fi Direct server -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_activate(void) -{ - int ret; - - ret = wifi_direct_activate(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_activate failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Deactivate Wi-Fi Direct server -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_deactivate(void) -{ - int ret; - - ret = wifi_direct_deactivate(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_deactivate failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Set the number of the clients. -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_set_configure_num(void) -{ - int ret; - - ret = wifi_direct_set_max_clients(LOCAL_MAX_CLIENT); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("set max client failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Get the information of all discovered peers.Synchronous. -* -* @param[in] cb the callback function -* @param[in] data the user data -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_foreach_discovered_peers( - wifi_direct_discovered_peer_cb cb, void *data) -{ - int ret; - - if (!cb || !data) { - _ERR("The parameter is NULL."); - return RET_FAILED; - } - - ret = wifi_direct_foreach_discovered_peers(cb, data); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("foreach connected pees failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Get the information of the connected peers.Synchronous. -* -* @param[in] cd the callback function -* @param[in] data the user data -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_foreach_connected_peers( - wifi_direct_connected_peer_cb cb, void *data) -{ - int ret; - - if (!cb || !data) { - _ERR("The parameter is NULL."); - return RET_FAILED; - } - - ret = wifi_direct_foreach_connected_peers(cb, data); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("foreach connected peers failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Start discovery process.Asynchronous. -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_start_discovery(void) -{ - int ret; - - ret = wifi_direct_start_discovery(WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN, - WIFI_DIRECT_SCAN_TIMEOUT); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("start discovery failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Cancel discovery process -* -* The oppsite action to wifi_direct_mgr_start_discovery -* -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_cancel_discovery(void) -{ - int ret; - - ret = wifi_direct_cancel_discovery(); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_cancel_discovery failed ret:%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Connect the peer specified by MAC address. Asynchronous. -* -* @param[in] mac_adrr the MAC address -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_connect(const char *mac_addr) -{ - int ret; - - if (!mac_addr) { - _ERR("mac_address is NULL"); - return RET_FAILED; - } - - ret = wifi_direct_connect(mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_connect failed,%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Disconnect to a peer. -* -* @param[in] mac_adrr the MAC address -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_disconnect(const char *mac_addr) -{ - int ret; - - if (!mac_addr) { - _ERR("mac_address is NULL"); - return RET_FAILED; - } - - ret = wifi_direct_disconnect(mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_disconnect failed,%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Accept connection requested by a peer. -* -* Called for request event,WIFI_DIRECT_CONNECTION_REQ -* -* @param[in] mac_adrr the MAC address of the request peer -* @return[in] 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_accept_connection(char *mac_addr) -{ - int ret; - - if (!mac_addr) { - _ERR("mac_address is NULL"); - return RET_FAILED; - } - - ret = wifi_direct_accept_connection(mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_accept_connection failed,%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - return RET_SUCCESS; -} - -/** -* Verify the WPS type. -* -* This function get the WPS(Wi-Fi Protected Setup) type and check if it is equal to PBC type, -* if equal, set EINA_TRUE to is_pbc, otherwise set EINA_FALSE,and return it. -* -* @param[in] is_pbc The point pointing to mark if WPS is PBC -* @return[in] 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_get_wps_type(Eina_Bool *is_pbc) -{ - _DBG("Not Yet"); -#if 0 - wifi_direct_wps_type_e type; - - if (!is_pbc) { - _ERR("Parameter is NULL"); - return RET_FAILED; - } - - int ret; - ret = wifi_direct_get_wps_type(&type); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_get_wps_type failed,%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } - - if ((type & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC) - *is_pbc = EINA_TRUE; - else - *is_pbc = EINA_FALSE; - - return RET_SUCCESS; -#endif - return RET_FAILED; -} - -/** -* Set the WPS(Wi-Fi Protected Setyup) type. -* -* @param[in] type The WPS type -* @return 0 on success, otherwise -1 -*/ -int wifi_direct_mgr_set_wps_type(wifi_direct_wps_type_e *type) -{ - if (!type) { - _ERR("Parameter is NULL"); - return RET_FAILED; - } - - _DBG("Not Yet"); -#if 0 - int ret; - ret = wifi_direct_set_wps_type(*type); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_get_wps_type failed,%s.", - wifi_direct_mgr_err_dbg(ret)); - return RET_FAILED; - } -#endif - - return RET_SUCCESS; -} diff --git a/ug/wifi-direct/src/wifi_direct_view.cpp b/ug/wifi-direct/src/wifi_direct_view.cpp deleted file mode 100755 index c88ac1a..0000000 --- a/ug/wifi-direct/src/wifi_direct_view.cpp +++ /dev/null @@ -1,2035 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "defs.h" -#include "dbg.h" -#include "wifi_direct_view.h" -#include "wifi_direct_mgr.h" -#include "util.h" - -struct _priv { - Evas_Object *win; - Evas_Object *base; - Evas_Object *genlist; - Evas_Object *on_btn; - Evas_Object *direct_popup; - Evas_Object *connect_popup; - Evas_Object *dim_ly; - Evas_Object *btn_refresh; - Evas_Object *btn_close; - Evas_Object *btn_stop; - Evas_Object *scan_ly; - Evas_Object *scan_pb; - Evas_Object *no_conn_ly; - Evas_Object *prog_popup; - Evas_Object *req_popup; - - ui_gadget_h ug; - Elm_Genlist_Item_Class *itc; - Elm_Object_Item *popup_item; - Eina_List *item_list; - Ecore_Timer *timer; - - int conn_idx; - int direct_on_flag; - int finish_flag; - char *req_addr; -}; - -enum action_btn_enum { - ACTION_BTN_REFRESH, - ACTION_BTN_CLOSE, - ACTION_BTN_STOP -}; - -enum direct_swith_enum { - DIRECT_ON = 0, - DIRECT_OFF -}; - -const char *action_button[] = { TXT_REFRESH_BTN, TXT_CLOSE_BTN, TXT_STOP_BTN }; -const char *popup_button_on[] = { TXT_ON_BTN, TXT_OFF_BTN }; -static char *popup_button_conn[] = { TXT_CONNECT, TXT_DISCONNECT }; -static char *popup_button_req[] = { TXT_YES, TXT_NO }; -static char *part_req[] = { PART_YES, PART_NO }; - -static void _device_state_changed_cb(int errcode, - wifi_direct_device_state_e state, void *data); -static void _discovery_state_changed_cb(int errcode, - wifi_direct_discovery_state_e state, void *data); -static void _connection_state_changed_cb(int errcode, - wifi_direct_connection_state_e state, const char *addr, - void *data); -static bool _connected_peer_cb( - wifi_direct_connected_peer_info_s * conn_info, void *data); -static bool _discoverd_peers_cb( - wifi_direct_discovered_peer_info_s * discov_info, - void *data); - -static struct wifi_direct_cbs cbs = { - _device_state_changed_cb, - _discovery_state_changed_cb, - _connection_state_changed_cb, - _connected_peer_cb, - _discoverd_peers_cb -}; - -static void _fill_content_part(struct _priv *priv, Evas_Object *obj); -static int _create_wifi_direct_scan(struct _priv *priv); -static void _create_device_list_view(struct _priv *priv); -static void _show_action_btn(struct _priv *priv); - -/** -* Initialize the priv. -* -* @return _priv _priv object initialized -*/ -static struct _priv *_init_priv(void) -{ - struct _priv *priv; - - priv = (struct _priv *) calloc(1, sizeof(*priv)); - if (!priv) { - _ERR("calloc failed."); - return NULL; - } - - return priv; -} - -/** -* Finalize the priv. -* -* Recycles memory allocated for the priv and free the point. -* -* @param[in] priv _priv object to be finalized -*/ -static void _fini_priv(struct _priv *priv) -{ - struct device_info *info; - void *obj; - - if (!priv) { - _ERR("priv is already NULL."); - return; - } - - if (!priv->item_list) - EINA_LIST_FREE(priv->item_list, obj) - { - info = (struct device_info *) obj; - free(info); - } - - if (priv->dim_ly) - evas_object_del(priv->dim_ly); - - if (priv->scan_ly) - evas_object_del(priv->scan_ly); - - if (priv->timer) - ecore_timer_del(priv->timer); - - wifi_direct_mgr_wifi_fini(); - wifi_direct_mgr_unregister_callback(); - wifi_direct_mgr_wifi_direct_fini(); - - if (priv->base) - evas_object_del(priv->base); - - free(priv); -} - -/** -* It is a callback function responding mouse event -* -* This function set focus on the object when mouse is put on it -* -* @param[in] dt the user data -* @param[in] e evas handler -* @param[in] obj the corresponding object which the mouse event occurred -* @param[in] ei event information -*/ -static void _list_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) { - _ERR("Invalid argument obj"); - return; - } - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* Evas_Smart_Cb type callback for handling click event -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event event information -*/ -static void _refresh_btn_clicked_cb(void *data, - Evas_Object *obj, void *ev) -{ - struct _priv *priv; - struct device_info *info; - void *temp_obj; - - if (!data || !obj) { - _ERR("The param is invalid.\n"); - return; - } - - priv = (struct _priv *) data; - - if (priv->scan_ly) - evas_object_hide(priv->scan_ly); - - elm_genlist_clear(priv->genlist); - - if (priv->item_list) - EINA_LIST_FREE(priv->item_list, temp_obj) - { - info = (struct device_info *) temp_obj; - free(info); - } - - _create_device_list_view(priv); -} - -/** -* Evas_Smart_Cb type callback for handling click event -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event event information -*/ -static void _close_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _priv *priv; - - if (!data || !obj) { - _ERR("The param is invalid.\n"); - return; - } - - priv = (struct _priv *) data; - - if (!priv->ug) { - _ERR("priv->ug is NULL."); - return; - } - - ug_destroy_me(priv->ug); - - _fini_priv(priv); -} - -/** -* Create the action buttons. -* -* @param[in] priv _priv object bypassed -*/ -static void _show_action_btn(struct _priv *priv) -{ - Evas_Object *btn; - - if (!priv || !priv->base) { - _ERR("Parameter error!"); - return; - } - - if (!priv->btn_refresh || !priv->btn_close) { - _ERR("action btn NULL!"); - return; - } - - btn = elm_object_part_content_get(priv->base, PART_REFRESH_BTN); - if (btn) { - elm_object_part_content_unset(priv->base, PART_REFRESH_BTN); - evas_object_hide(btn); - } - - elm_object_part_content_set(priv->base, PART_REFRESH_BTN, - priv->btn_refresh); - evas_object_show(priv->btn_refresh); - - elm_object_part_content_set(priv->base, PART_CLOSE_BTN, - priv->btn_close); - evas_object_show(priv->btn_close); - - evas_object_smart_callback_add(priv->btn_refresh, SIG_CLICKED, - _refresh_btn_clicked_cb, priv); - evas_object_event_callback_add(priv->btn_refresh, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); - evas_object_smart_callback_add(priv->btn_close, SIG_CLICKED, - _close_btn_clicked_cb, priv); - evas_object_event_callback_add(priv->btn_close, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); -} - -/** -* Create the dim layout but did not show it. -* -* @param[in] priv _priv object bypassed -* @return on success, otherwise -1. -*/ -static int _create_wifi_direct_dim(struct _priv *priv) -{ - Evas_Object *base; - Evas_Object *ly; - - if (!priv || !priv->base) { - _ERR("Parameter error!"); - return RET_FAILED; - } - - base = priv->base; - - ly = util_add_layout(base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY); - if (!ly) { - _ERR("Add dim layout failed."); - return RET_FAILED; - } - - priv->dim_ly = ly; - - evas_object_hide(ly); - - return RET_SUCCESS; -} - -/** -* Evas_Smart_Cb type callback for handling click event -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] ev event information -*/ -static void _stop_btn_clicked_cb(void *data, - Evas_Object *obj, void *ev) -{ - int ret; - struct _priv *priv; - Evas_Object *btn; - - if (!data || !obj) { - _ERR("The param is invalid.\n"); - return; - } - - priv = (struct _priv *) data; - - ret = wifi_direct_mgr_cancel_discovery(); - if (ret != RET_SUCCESS) { - _ERR("Cancel disconery failed."); - return; - } - - btn = elm_object_part_content_get(priv->base, PART_REFRESH_BTN); - if (btn) { - elm_object_part_content_unset(priv->base, PART_REFRESH_BTN); - evas_object_hide(btn); - } - - _show_action_btn(priv); - - _fill_content_part(priv, priv->genlist); -} - -/** -* Create the scan process view -* -* @param[in] priv _priv object bypassed -*/ -static int _create_wifi_direct_scan(struct _priv *priv) -{ - Evas_Object *ly; - Evas_Object *pb; - Evas_Object *btn; - - if (!priv || !priv->base) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - ly = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE, - GRP_WIFIDIRECT_SCAN_LY); - if (!ly) { - _ERR("Add scan_ly failed.\n"); - return RET_FAILED; - } - - priv->scan_ly = ly; - - elm_object_part_content_unset(priv->base, PART_REFRESH_BTN); - evas_object_hide(priv->btn_refresh); - - elm_object_part_content_unset(priv->base, PART_CLOSE_BTN); - evas_object_hide(priv->btn_close); - - pb = util_add_progressbar(ly, STYLE_SEARCH_PROGRESS, PART_SEARCH_IMAGE); - if (!pb) { - _ERR("Add progressbar failed.\n"); - goto error; - } - - btn = util_add_button(priv->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN, - _(action_button[ACTION_BTN_STOP])); - if (!btn) { - _ERR("Add stop button failed."); - goto error; - } - - priv->scan_pb = pb; - priv->btn_stop = btn; - - elm_object_focus_set(priv->btn_stop, EINA_TRUE); - evas_object_event_callback_add(priv->btn_stop, EVAS_CALLBACK_MOUSE_IN, - _list_btn_mouse_in_cb, priv); - evas_object_smart_callback_add(priv->btn_stop, SIG_CLICKED, - _stop_btn_clicked_cb, priv); - - _fill_content_part(priv, priv->scan_ly); - - return RET_SUCCESS; - -error: - evas_object_del(ly); - return RET_FAILED; -} - -/** -* Display device list view. -* -* Called when start or refresh the WiFi direct -* -* @param[in] priv the _priv object -*/ -static void _create_device_list_view(struct _priv *priv) -{ - wifi_direct_state_e status; - int ret; - - if (!priv) { - _ERR("parameter is invalid."); - return; - } - - if (priv->no_conn_ly) - evas_object_hide(priv->no_conn_ly); - - ret = wifi_direct_mgr_get_state(&status); - if (ret != RET_SUCCESS) { - _ERR("get state failed."); - return; - } - - if (status < WIFI_DIRECT_STATE_ACTIVATED) { - ret = wifi_direct_mgr_activate(); - if (ret != RET_SUCCESS) { - _ERR("activate failed."); - return; - } - } else { - ret = wifi_direct_mgr_set_configure_num(); - if (ret != RET_SUCCESS) { - _ERR("set configure num failed."); - return; - } - - ret = wifi_direct_mgr_start_discovery(); - if (ret != RET_SUCCESS) { - _ERR("start discovery failed."); - return; - } - } - - _fill_content_part(priv, priv->genlist); - - elm_object_focus_set(priv->btn_refresh, EINA_TRUE); -} - -/** -* Evas_object_Event_Cb type callback for handling delection event -* -* @param[in] data the user data -* @param[in] e evas handler -* @param[in] obj the corresponding object which clicked event occurred -* @param[in] ei event information -*/ -static void _popup_back_pressed_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) -{ - Evas_Event_Key_Down *ev; - struct _priv *priv; - - if (!data || !obj || !ei) { - _ERR("Parameter error!"); - return; - } - - priv = (struct _priv *) data; - ev = (Evas_Event_Key_Down *)ei; - - if (!ev->keyname) { - _ERR("ev->keyname is NULL."); - return; - } - - if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { - if (priv->dim_ly) - evas_object_hide(priv->dim_ly); - - evas_object_del(obj); - } -} - -/** -* Handle connection request. -* -* @param[in] info the target device infomation -* @param[in] is_conn request type -* @return 0 on success,otherwize -1 -*/ -int wifi_direct_cbbutton_connect( - struct device_info *info, int is_conn) -{ - int ret; - wifi_direct_wps_type_e wps_type; - - if (!info) { - _ERR("parameter is NULL!"); - return RET_FAILED; - } - - if (is_conn) { - if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PBC) - == WIFI_DIRECT_WPS_TYPE_PBC) - wps_type = WIFI_DIRECT_WPS_TYPE_PBC; - else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) == - WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) - wps_type = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD; - else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) == - WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) - wps_type = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY; - - ret = wifi_direct_mgr_set_wps_type(&wps_type); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct set wps type failev!"); - return RET_FAILED; - } - - ret = wifi_direct_mgr_connect(info->mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_connect:%s fail!", info->dev_name); - return RET_FAILED; - } - } else { - ret = wifi_direct_mgr_disconnect(info->mac_addr); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_disconnect:%s fail!", info->dev_name); - return RET_FAILED; - } - } - - return RET_SUCCESS; -} - -/** -* @Evas_Smart_Cb type callback for handling click event. -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event_info event information -*/ -static void _item_conn_btn_clicked_cb(void *data, - Evas_Object *obj, void *event_inf) -{ - struct _priv *priv; - const char *value; - int ret; - Elm_Object_Item *gen_item; - struct device_info *info; - int cur_idx; - - if (!data || !obj) { - _ERR("the param is invalid."); - return; - } - - value = elm_object_text_get(obj); - if (!value) { - _ERR("get text from wifi_direct device btn is NULL."); - return; - } - - priv = (struct _priv *) data; - - gen_item = priv->popup_item; - - cur_idx = elm_genlist_item_index_get(gen_item); - if (cur_idx < 0) - return; - - info = (struct device_info *) eina_list_nth(priv->item_list, cur_idx); - if (!info) - return; - - if (!strcmp(value, TXT_CONNECT)) { - ret = wifi_direct_cbbutton_connect(info, CONN_YES); - if (ret == RET_FAILED) { - _ERR("Connect failed"); - return; - } - - info->is_conn = EINA_TRUE; - } else if (!strcmp(value, TXT_DISCONNECT)) { - ret = wifi_direct_cbbutton_connect(info, CONN_NO); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("wifi_direct_mgr_disconnect failed,,%s", - info->mac_addr); - return; - } - - strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN); - info->is_conn = EINA_FALSE; - } - - if (priv->direct_popup) { - evas_object_del(priv->direct_popup); - priv->direct_popup = NULL; - } - - if (priv->connect_popup) { - evas_object_del(priv->connect_popup); - priv->connect_popup = NULL; - } - - if (priv->dim_ly) - evas_object_hide(priv->dim_ly); -} - -/** -* @Evas_Smart_Cb type callback for handling click event. -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event_info event information -*/ -static void _genlist_item_select_cb(void *data, - Evas_Object *obj, void *event_info) -{ - struct _priv *priv; - Elm_Object_Item *gen_item; - Evas_Object *layout; - Evas_Object *box; - Evas_Object *item_btn; - Evas_Object *btn[BTN_DIRECT]; - struct device_info *info; - int cur_idx; - int i; - int ret; - int btn_x; - int btn_y; - int btn_w; - int btn_h; - int move_x; - int move_y; - - if (!data || !obj || !event_info) { - _ERR("The param is invalid."); - return; - } - - priv = (struct _priv *) data; - - if (!priv->dim_ly) { - ret = _create_wifi_direct_dim(priv); - if (ret != RET_SUCCESS) { - _fini_priv(priv); - return; - } - } - - evas_object_show(priv->dim_ly); - - gen_item = (Elm_Object_Item *) event_info; - priv->popup_item = gen_item; - - layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE, - GRP_WIFI_DIRECT_SELECT); - if (!layout) { - _ERR("add connect popup failed.\n"); - return; - } - - box = util_add_box(layout, PART_SWALLOW_CONTENT); - if (!box) { - _ERR("add box failed."); - evas_object_del(layout); - return; - } - - for (i = 0; i < BTN_DIRECT; i++) { - btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, - _(popup_button_conn[i])); - if (!btn[i]) { - _ERR("add connect btn failed."); - evas_object_del(layout); - return; - } - - elm_box_pack_end(box, btn[i]); - evas_object_smart_callback_add(btn[i], SIG_CLICKED, - _item_conn_btn_clicked_cb, priv); - evas_object_event_callback_add(btn[i], - EVAS_CALLBACK_MOUSE_IN, - _list_btn_mouse_in_cb, priv); - } - - cur_idx = elm_genlist_item_index_get(gen_item); - if (cur_idx < 0) - return; - - info = (struct device_info *) eina_list_nth(priv->item_list, cur_idx); - if (!info) - return; - - if (info->is_conn) - elm_object_signal_emit(btn[DIRECT_ON], - SIG_BTN_SELECTED, PROG); - else - elm_object_signal_emit(btn[DIRECT_OFF], - SIG_BTN_SELECTED, PROG); - - util_set_cycle_focus(btn, BTN_DIRECT); - - item_btn = elm_object_item_track(gen_item); - if (!item_btn) { - _ERR("get genlist item track failed."); - evas_object_del(layout); - return; - } - - evas_object_geometry_get(item_btn, &btn_x, &btn_y, &btn_w, &btn_h); - - move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; - move_y = btn_y + btn_h; - evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); - priv->connect_popup = layout; - - evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, - _popup_back_pressed_cb, priv); - - elm_object_focus_set(btn[0], EINA_TRUE); -} - -/** -* Check if the peer discovered is already in the list. -* -* @param[in] priv the _priv object bypassed -* @param[in] new_info device_info object to be checked -* @return 0 if exist,otherwise -1 -*/ -static Eina_Bool _is_peer_exist(struct _priv *priv, - struct device_info *new_info) -{ - struct device_info *cur_info; - void *obj; - Eina_List *l; - - if (!priv || !new_info) { - _ERR("The param is invalid."); - return EINA_FALSE; - } - - if (!priv->item_list) { - _ERR("The list is NULL now."); - return EINA_FALSE; - } - - EINA_LIST_FOREACH(priv->item_list, l, obj) { - cur_info = (struct device_info *) obj; - if (!strncmp(cur_info->mac_addr, new_info->mac_addr, - WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) - return EINA_TRUE; - } - - return EINA_FALSE; -} - -/** -* Update the device connection state. -* -* @param[in] priv the _priv object bypassed -* @param[in] conn connection type -* @return 0 if exist,otherwise -1 -*/ -static Eina_Bool _update_device_conn_state(struct _priv *priv, - Eina_Bool conn) -{ - struct device_info *cur_info; - void *obj; - Eina_List *l; - - EINA_LIST_FOREACH(priv->item_list, l, obj) { - cur_info = (struct device_info *) obj; - if (!strncmp(cur_info->mac_addr, priv->req_addr, - WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) { - cur_info->is_conn = conn; - return EINA_TRUE; - } - } - - return EINA_FALSE; -} - -/** -* Update the device list. -* -* @param[in] priv the _priv object bypassed -* @param[in] device_info new device infomation -* @return 0 in success,otherwise -1 -*/ -static int _update_genlist_item(struct _priv *priv, - struct device_info *info) -{ - Eina_Bool exist; - - if (!priv || !info || !priv->genlist) { - _ERR("The param is invalid."); - return RET_FAILED; - } - - exist = _is_peer_exist(priv, info); - if (!exist) { - priv->item_list = eina_list_append(priv->item_list, info); - - if (info->is_conn) - strncpy(info->state, TXT_CONNECT, - WIFI_DIRECT_STATE_BUF_LEN); - else - strncpy(info->state, TXT_DISCONNECT, - WIFI_DIRECT_STATE_BUF_LEN); - - elm_genlist_item_append(priv->genlist, priv->itc, info, NULL, - ELM_GENLIST_ITEM_NONE, _genlist_item_select_cb, - (void *)priv); - } - - return RET_SUCCESS; -} - -/** -* Called when the device state is WIFI_DIRECT_DISCOVERY_STARTED. -* -* @param[in] cd the callback functions to invoke -* @param[in] data the user data -*/ -static void _process_discovery_start(struct wifi_direct_cbs cbs, - void *data) -{ - int ret; - struct _priv *priv; - struct device_info *info; - void *obj; - - if (!data) { - _ERR("Parameter error!"); - return; - } - - priv = (struct _priv *) data; - - if (priv->genlist) - elm_genlist_clear(priv->genlist); - - if (priv->item_list) - EINA_LIST_FREE(priv->item_list, obj) - { - info = (struct device_info *) obj; - free(info); - } - - ret = wifi_direct_mgr_foreach_connected_peers( - cbs.connected_peer_cb, data); - if (ret != RET_SUCCESS) { - _ERR("foreach connected peers failed "); - return; - } - - ret = _create_wifi_direct_scan(priv); - if (ret != RET_SUCCESS) - _ERR("_create_wifi_direct_scan failed "); -} - -/** -* Called when the device state is WIFI_DIRECT_DISCOVERY_FOUND. -* -* @param[in] cbs the callback functions -* @param[in] data the user data -*/ -static void _process_discovery_found(struct wifi_direct_cbs cbs, - void *data) -{ - int ret; - - if (!data) { - _ERR("Parameter error!"); - return; - } - - ret = wifi_direct_mgr_foreach_discovered_peers( - cbs.discovered_peer_cb, data); - if (ret != RET_SUCCESS) - _ERR("foreach connected peers failed "); -} - -/** -* Called when the device state is WIFI_DIRECT_DISCOVERY_FINISHED. -* -* @param[in] data the user data -*/ -static void _process_discovery_finished(void *data) -{ - struct _priv *priv; - - if (!data) { - _ERR("Parameter is NULL."); - return; - } - - priv = (struct _priv *) data; - - elm_object_part_content_unset(priv->base, PART_REFRESH_BTN); - evas_object_hide(priv->btn_stop); - - _show_action_btn(priv); - - _fill_content_part(priv, priv->genlist); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] ev event information -*/ -static void _req_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _priv *priv; - const char *value; - int ret; - - if (!data || !obj) { - _ERR("The param is invalid.\n"); - return; - } - - priv = (struct _priv *) data; - - value = elm_object_text_get(obj); - if (!value) { - _ERR("get text from network type btn is NULL."); - return; - } - - if (!strcmp(value, popup_button_req[DIRECT_ON])) { - ret = wifi_direct_mgr_accept_connection(priv->req_addr); - if (ret != RET_SUCCESS) { - _ERR("Disconnection failed."); - return; - } - - ret = _update_device_conn_state(priv, EINA_TRUE); - if (ret != EINA_TRUE) - _ERR("_update_device_conn_state failed."); - } else { - ret = wifi_direct_mgr_reject_connection(priv->req_addr); - if (ret != RET_SUCCESS) { - _ERR("Accept connection failed."); - return; - } - - ret = _update_device_conn_state(priv, EINA_FALSE); - if (ret != EINA_TRUE) - _ERR("_update_device_conn_state failed."); - } - - free(priv->req_addr); - priv->req_addr = NULL; - - if (priv->req_popup) { - evas_object_del(priv->req_popup); - priv->req_popup = NULL; - } - - if (priv->dim_ly) - evas_object_hide(priv->dim_ly); -} - -/** -* Create the reqest popup when has connection request by other devices. -* -* @param[in] priv the _priv object bypassed -* @return 0 on sucess, otherwise -1 -*/ -static int _create_req_popup_ly(struct _priv *priv) -{ - Evas_Object *layout; - Evas_Object *btn[BTN_DIRECT]; - int i; - int x; - int y; - int w; - int h; - - if (!priv || !priv->base) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE, - GRP_CONNECT_ACCEPT); - if (!layout) { - _ERR("elm_layout_add() failed.\n"); - return RET_FAILED; - } - - for (i = 0; i < BTN_DIRECT; i++) { - btn[i] = util_add_button(layout, STYLE_POPUP_BUTTON, - part_req[i], _(popup_button_req[i])); - if (!btn[i]) { - _ERR("add btn req failed."); - evas_object_del(layout); - return RET_FAILED; - } - - evas_object_smart_callback_add(btn[i], - SIG_CLICKED, _req_btn_clicked_cb, priv); - evas_object_event_callback_add(btn[i], - EVAS_CALLBACK_MOUSE_IN, - _list_btn_mouse_in_cb, priv); - } - - evas_object_geometry_get(priv->genlist, &x, &y, &w, &h); - evas_object_move(layout, (x + RSP_X) * ELM_SCALE, - (y + RSP_Y) * ELM_SCALE); - - priv->req_popup = layout; - - elm_object_focus_set(btn[DIRECT_ON], EINA_TRUE); - - evas_object_event_callback_add(layout, - EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); - - return RET_SUCCESS; -} - -/** -* Process the connection request when the device state is WIFI_DIRECT_CONNECTION_REQ. -* -* @param[in] addr the MAC address -* @param[in] data the user data -*/ -static void _process_connection_req(const char *addr, void *data) -{ - struct _priv *priv; - Eina_Bool is_pbc; - int ret; - - if (!data || !addr) { - _ERR("the param is invalid."); - return; - } - - priv = (struct _priv *) data; - - ret = wifi_direct_mgr_get_wps_type(&is_pbc); - if (ret != WIFI_DIRECT_ERROR_NONE) { - _ERR("Get wps type failed."); - return; - } - - priv->req_addr = strdup(addr); - if (!priv->req_addr) { - _ERR("strdup wrong."); - return; - } - - if (is_pbc == EINA_TRUE) { - ret = _create_req_popup_ly(priv); - if (ret != RET_SUCCESS) - _ERR("Create rep popup failed."); - } -} - -/** -* Called when the device state is WIFI_DIRECT_CONNECTION_PROG. -* -* @param[in] data The data to be passed to the function -*/ -static void _process_connection_prog(void *data) -{ - struct _priv *priv; - Evas_Object *layout; - char title[MAX_STRING_LENTH]; - int x; - int y; - int w; - int h; - int move_x; - int move_y; - - if (!data) { - _ERR("the param is invalid."); - return; - } - - priv = (struct _priv *) data; - - if (priv->dim_ly) - evas_object_show(priv->dim_ly); - - layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE, - GRP_CONNECT_ACCEPT); - if (!layout) { - _ERR("add con_popup layout failed."); - return; - } - - memset(&title, 0x00, MAX_STRING_LENTH); - snprintf(title, MAX_STRING_LENTH - 1, "%s", TXT_CONN_PROG); - elm_object_part_text_set(layout, PART_TITLE, title); - - evas_object_geometry_get(priv->on_btn, &x, &y, &w, &h); - move_x = x + w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; - move_y = y + CENTER_HEIGHT; - evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); - - priv->prog_popup = layout; -} - -/** -* Starts the device discovery when timer is empired. -* -* @param[in] data the user data -* @return ECORE_CALLBACK_CANCEL returns to finish time -*/ -static Eina_Bool _connection_ind_cb(void *data) -{ - int ret; - struct _priv *priv; - - if (!data) { - _ERR("the param is invalid."); - return ECORE_CALLBACK_CANCEL; - } - - priv = (struct _priv *) data; - - ret = wifi_direct_mgr_start_discovery(); - if (ret != RET_SUCCESS) - _ERR("start discovery failed."); - - priv->timer = NULL; - - return ECORE_CALLBACK_CANCEL; -} - -/** -* Called when the device state is WIFI_DIRECT_DISCONNECTION_IND. -* -* @param[in] data The data to be passed to the function -*/ -static void _process_connection_ind(void *data) -{ - struct _priv *priv; - Ecore_Timer *timer; - - if (!data) { - _ERR("parameter is invalid."); - return; - } - - priv = (struct _priv *) data; - - timer = ecore_timer_add(HANDLER_INTERVAL, _connection_ind_cb, priv); - if (!timer) { - _ERR("add timer failed."); - return; - } - - priv->timer = timer; -} - -/** -* Called when the device state is WIFI_DIRECT_CONNECTION_RSP -* -* @param[in] data the user data -*/ -static void _process_connection_rsp(void *data) -{ - struct _priv *priv; - struct device_info *info; - int cur_index; - - if (!data) { - _ERR("the param is invalid."); - return; - } - - priv = (struct _priv *) data; - - cur_index = priv->conn_idx; - info = (struct device_info *) eina_list_nth(priv->item_list, cur_index); - if (!info) - return; - - info->is_conn = EINA_TRUE; - strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN); - - elm_genlist_item_update(priv->popup_item); - - if (priv->dim_ly) - evas_object_hide(priv->dim_ly); - - if (priv->prog_popup) { - evas_object_del(priv->prog_popup); - priv->prog_popup = NULL; - } - - if (priv->connect_popup) { - evas_object_del(priv->connect_popup); - priv->connect_popup = NULL; - } -} - -/** -* Callback function is called when device state is changed. -* -* @param[in] errcode error code -* @param[in] state WiFi Direct device state -* @param[in] data the user data -*/ -static void _device_state_changed_cb(int errcode, - wifi_direct_device_state_e state, void *data) -{ - int ret; - struct _priv *priv; - - if (!data) { - _ERR("The param is invalid."); - return; - } - - priv = (struct _priv *) data; - - if (state != WIFI_DIRECT_DEVICE_STATE_ACTIVATED) { - elm_genlist_clear(priv->genlist); - return; - } - - ret = wifi_direct_mgr_set_configure_num(); - if (ret != RET_SUCCESS) { - _ERR("set configure num failed."); - return; - } - - ret = wifi_direct_mgr_start_discovery(); - if (ret != RET_SUCCESS) - _ERR("start discovery failed."); -} - -/** -* Callback function is called when discovery state is changed. -* -* discovery state: -* WIFI_DIRECT_DISCOVERY_STARTED -* WIFI_DIRECT_DISCOVERY_FOUND -* WIFI_DIRECT_DISCOVERY_FINISHED -* -* @param[in] errcode error code -* @param[in] state WiFi Direct descovery state -* @param[in] data the user data -*/ -static void _discovery_state_changed_cb( - int errcode, wifi_direct_discovery_state_e state, void *data) -{ - if (!state || !data) { - _ERR("data is invalid."); - return; - } - - switch (state) { - case WIFI_DIRECT_DISCOVERY_STARTED: - _process_discovery_start(cbs, data); - break; - case WIFI_DIRECT_DISCOVERY_FOUND: - _process_discovery_found(cbs, data); - break; - case WIFI_DIRECT_DISCOVERY_FINISHED: - _process_discovery_finished(data); - break; - default: - break; - } -} - -/** -* Callback function is called when connection state is changed. -* -* connection state: -* WIFI_DIRECT_CONNECTION_REQ -* WIFI_DIRECT_CONNECTION_IN_PROGRESS -* WIFI_DIRECT_CONNECTION_RSP -* WIFI_DIRECT_DISCONNECTION_IND -* ... -* -* @param[in] errcode error code -* @param[in] state WiFi Direct descovery state -* @param[in] data the user data passed -*/ -static void _connection_state_changed_cb(int errcode, - wifi_direct_connection_state_e state, - const char *addr, void *data) -{ - if (!state || !addr || !data) { - _ERR("The param is invalid."); - return; - } - - switch (state) { - case WIFI_DIRECT_CONNECTION_REQ: - _process_connection_req(addr, data); - break; - case WIFI_DIRECT_CONNECTION_IN_PROGRESS: - _process_connection_prog(data); - break; - case WIFI_DIRECT_CONNECTION_RSP: - _process_connection_rsp(data); - break; - case WIFI_DIRECT_DISCONNECTION_IND: - _process_connection_ind(data); - break; - default: - break; - } -} - -/** -* Called for each connected peer and save its information. -* -* @param[in] conn_info wifi_direct_connected_peer_info_s store info of connected peer -* @param[in] data the user data -* @return EINA_TURE on success, otherwise EINA_FALSE -*/ -static bool _connected_peer_cb( - wifi_direct_connected_peer_info_s * conn_info, void *data) -{ - struct _priv *priv; - struct device_info *info; - int ret; - - if (!conn_info || !data) { - _ERR("The param is NULL."); - return EINA_FALSE; - } - - priv = (struct _priv *) data; - - info = (struct device_info *) calloc(1, sizeof(*info)); - if (!info) { - _ERR("calloc failed."); - return EINA_FALSE; - } - - strncpy(info->dev_name, conn_info->device_name, - WIFI_DIRECT_DEFAULT_BUF_LEN); - strncpy(info->mac_addr, conn_info->mac_address, - WIFI_DIRECT_DEFAULT_BUF_LEN); - info->is_conn = EINA_TRUE; - - ret = _update_genlist_item(priv, info); - if (ret != RET_SUCCESS) { - _ERR("update genlist view failed."); - free(info); - return EINA_FALSE; - } - - return EINA_TRUE; -} - -/** -* Called for each discovered peer and save its information. -* -* @param[in] discov_info wifi_direct_discovered_peer_info_s store info of discovered peer -* @param[in] data the user data passed to the callback function -* @return EINA_TURE on success, otherwise EINA_FALSE -*/ -static bool _discoverd_peers_cb( - wifi_direct_discovered_peer_info_s * discov_info, - void *data) -{ - struct _priv *priv; - struct device_info *info; - int ret; - - if (!discov_info || !data) { - _ERR("The param is invalid."); - return EINA_FALSE; - } - - priv = (struct _priv *) data; - info = (struct device_info *) calloc(1, sizeof(*info)); - if (!info) { - _ERR("calloc failed."); - return EINA_FALSE; - } - - strncpy(info->dev_name, discov_info->device_name, - WIFI_DIRECT_DEFAULT_BUF_LEN); - strncpy(info->mac_addr, discov_info->mac_address, - WIFI_DIRECT_DEFAULT_BUF_LEN); - info->is_conn = (Eina_Bool) discov_info->is_connected; - info->wps_types = discov_info->supported_wps_types; - - ret = _update_genlist_item(priv, info); - if (ret != RET_SUCCESS) { - _ERR("update genlist view failed."); - free(info); - return EINA_FALSE; - } - - return EINA_TRUE; -} - -/** -* Refresh the ON/OFF sign on the Wi-Fi Direct button when popup button is clicked. -* -* @param[in] priv _priv object bypassed -*/ -static void _refresh_wifi_direct_on_text(struct _priv *priv) -{ - if (!priv) { - _ERR("the param is invalid."); - return; - } - - if (priv->scan_ly) - evas_object_hide(priv->scan_ly); - - if (priv->direct_on_flag == DIRECT_ON) - elm_object_part_text_set(priv->on_btn, PART_WIFI_DIRECT_SELECT, - _(popup_button_on[DIRECT_ON])); - else - elm_object_part_text_set(priv->on_btn, PART_WIFI_DIRECT_SELECT, - _(popup_button_on[DIRECT_OFF])); -} - -/** -* Set the object to the specified part. -* -* @param[in] priv _priv object bypassed -* @param[in] obj Evas_Object to be set to the part -*/ -static void _fill_content_part(struct _priv *priv, Evas_Object *obj) -{ - Evas_Object *old_obj; - - if (!priv || !obj) { - _ERR("The param is invalid.\n"); - return; - } - - old_obj = elm_object_part_content_get(priv->base, PART_GENLIST_ITEMS); - if (old_obj) { - elm_object_part_content_unset(priv->base, PART_GENLIST_ITEMS); - evas_object_hide(old_obj); - } - - elm_object_part_content_set(priv->base, PART_GENLIST_ITEMS, obj); - evas_object_show(obj); -} - -/** -* Create the Wi-Fi Direct off layout, but does not show here. -* -* @param[in] priv _priv object bypassed -* @return 0 on success,otherwise -1 -*/ -static int _create_wifi_direct_disconnect_part(struct _priv *priv) -{ - Evas_Object *ly; - - if (!priv || !priv->base) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - ly = util_add_layout(priv->base, - UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFIDIRECT_DISCONNECT_LY); - if (!ly) { - _ERR("Add noconnect_ly failed.\n"); - return RET_FAILED; - } - - elm_object_part_text_set(ly, PART_DISCONNECT_TEXT, - TXT_WIFIDIRECT_NONE); - - priv->no_conn_ly = ly; - evas_object_hide(ly); - - return RET_SUCCESS; -} - -/** -* Called when WiFi Direct is off . -* -* @param[in] priv _priv object bypassed -* @return 0 on success, otherwise -1 -*/ -static int _display_wifi_direct_disconnect(struct _priv *priv) -{ - int ret; - - if (!priv) { - _ERR("the param is invalid."); - return RET_FAILED; - } - - if (!priv->no_conn_ly) { - ret = _create_wifi_direct_disconnect_part(priv); - if (ret != RET_SUCCESS) { - _ERR("_create_wifi_direct_disconnect_part failed."); - return RET_FAILED; - } - } - - _fill_content_part(priv, priv->no_conn_ly); - - elm_object_part_content_unset(priv->base, PART_REFRESH_BTN); - evas_object_hide(priv->btn_refresh); - elm_object_part_content_set(priv->base, PART_REFRESH_BTN, - priv->btn_close); - evas_object_show(priv->btn_close); - - evas_object_smart_callback_add(priv->btn_close, - SIG_CLICKED, _close_btn_clicked_cb, priv); - evas_object_event_callback_add(priv->btn_close, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); - - return RET_SUCCESS; -} - -/** -* Evas_Smart_Cb type callback for handling on/off button click event. -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event_inf event information -*/ -static void _wifi_direct_select_btn_cb(void *data, - Evas_Object *obj, void *event_inf) -{ - struct _priv *priv; - struct device_info *info; - void *temp_obj; - const char *value; - int ret; - - if (!data || !obj) { - _ERR("the param is invalid."); - return; - } - - priv = (struct _priv *) data; - - value = (const char *) elm_object_text_get(obj); - if (!value) { - _ERR("get text from network type btn is NULL."); - return; - } - - if (!strcmp(value, popup_button_on[DIRECT_ON])) { - if (priv->direct_on_flag == DIRECT_OFF) { - priv->direct_on_flag = DIRECT_ON; - - elm_genlist_clear(priv->genlist); - - if (priv->item_list) - EINA_LIST_FREE(priv->item_list, temp_obj) - { - info = (struct device_info *) temp_obj; - free(info); - } - - _create_device_list_view(priv); - - _show_action_btn(priv); - } - } else { - priv->direct_on_flag = DIRECT_OFF; - - ret = _display_wifi_direct_disconnect(priv); - if (ret != RET_SUCCESS) { - _ERR("_display_wifi_direct_disconnect failed."); - return; - } - - ret = wifi_direct_mgr_deactivate(); - if (ret != RET_SUCCESS) { - _ERR("wif direct deactivate failed."); - return; - } - } - - _refresh_wifi_direct_on_text(priv); - - if (priv->direct_popup) { - evas_object_del(priv->direct_popup); - priv->direct_popup = NULL; - } - - if (priv->dim_ly) - evas_object_hide(priv->dim_ly); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in] data the user data -* @param[in] obj the corresponding object which the click event occurred -* @param[in] event_inf event information -*/ -static void _wifi_direct_btn_clicked_cb(void *data, - Evas_Object *obj, void *event_inf) -{ - Evas_Object *layout; - Evas_Object *box; - Evas_Object *btn[BTN_DIRECT]; - struct _priv *priv; - int ret; - int i; - int btn_x; - int btn_y; - int btn_w; - int btn_h; - int move_x; - int move_y; - - if (!data) { - _ERR("Parameter error!"); - return; - } - - priv = (struct _priv *) data; - - if (!priv->dim_ly) { - ret = _create_wifi_direct_dim(priv); - if (ret != RET_SUCCESS) { - _fini_priv(priv); - return; - } - } - - evas_object_show(priv->dim_ly); - - layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE, - GRP_WIFI_DIRECT_SELECT); - if (!layout) - return; - - elm_object_focus_allow_set(layout, EINA_TRUE); - - box = util_add_box(layout, PART_SWALLOW_CONTENT); - if (!box) { - evas_object_del(layout); - return; - } - - for (i = 0; i < BTN_DIRECT; i++) { - btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, - _(popup_button_on[i])); - if (!btn[i]) { - _ERR("add btn direct failed."); - evas_object_del(layout); - return; - } - - elm_box_pack_end(box, btn[i]); - evas_object_smart_callback_add(btn[i], SIG_CLICKED, - _wifi_direct_select_btn_cb, priv); - evas_object_event_callback_add(btn[i], - EVAS_CALLBACK_MOUSE_IN, - _list_btn_mouse_in_cb, priv); - } - - if (priv->direct_on_flag == DIRECT_ON) - elm_object_signal_emit(btn[DIRECT_ON], - SIG_BTN_SELECTED, PROG); - else - elm_object_signal_emit(btn[DIRECT_OFF], - SIG_BTN_SELECTED, PROG); - - util_set_cycle_focus(btn, BTN_DIRECT); - - evas_object_geometry_get(priv->on_btn, &btn_x, &btn_y, &btn_w, &btn_h); - move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT; - move_y = btn_y + btn_h; - evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE); - - priv->direct_popup = layout; - - evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, - _popup_back_pressed_cb, priv); - - elm_object_focus_set(btn[0], EINA_TRUE); -} - -/** -* Set the Wi-Fi Direct description. -* -* @param[in] priv _priv object bypassed -*/ -static void _set_description(struct _priv *priv) -{ - char descrption[MAX_STRING_LENTH]; - - if (!priv) { - _ERR("priv is invalid."); - return; - } - - memset(&descrption, 0x00, MAX_STRING_LENTH); - snprintf(descrption, MAX_STRING_LENTH - 1, "%s", TXT_WIFI_DIRECT_DISC); - elm_object_part_text_set(priv->base, PART_DESCRIPTION, descrption); -} - -/** -* Create the Wi-Fi Direct state button. -* -* @param[in] priv _priv object bypassed -* @return 0 on success, -1 otherwise -*/ -static int _create_wifi_direct_button(struct _priv *priv) -{ - Evas_Object *on_btn; - Evas_Object *base; - - if (!priv || !priv->base) { - _ERR("Parameter error!"); - return RET_FAILED; - } - - base = priv->base; - - on_btn = util_add_button(base, STYLE_WIFI_DIRECT_BTN, - PART_WIFI_DIRECT_ON, TXT_WIFI_DIRECT); - if (!on_btn) { - _ERR("Add wifi direct button failed."); - return RET_FAILED; - } - - elm_object_focus_allow_set(on_btn, EINA_TRUE); - elm_object_focus_set(on_btn, EINA_TRUE); - elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT); - - evas_object_smart_callback_add(on_btn, SIG_CLICKED, - _wifi_direct_btn_clicked_cb, priv); - evas_object_event_callback_add(on_btn, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); - - priv->on_btn = on_btn; - - _refresh_wifi_direct_on_text(priv); - - return RET_SUCCESS; -} - -/** -* Create the genlist item text label. -* -* @param[in] data the user data -* @return pointer pointing to the text label -*/ -static char *_item_label_get(void *data, Evas_Object *obj, - const char *part) -{ - struct device_info *info; - char buf_name[WIFI_DIRECT_DEFAULT_BUF_LEN]; - - if (!data) { - _ERR("data is NULL."); - return NULL; - } - - info = (struct device_info *) data; - - memset(&buf_name, 0x00, WIFI_DIRECT_DEFAULT_BUF_LEN); - if (!strcmp(part, TXT_ELM_TEXT)) { - strncpy(buf_name, info->dev_name, WIFI_DIRECT_HALF_BUF_LEN); - strncat(buf_name, TXT_COLON, WIFI_DIRECT_COLON_LEN); - strncat(buf_name, info->state, WIFI_DIRECT_HALF_BUF_LEN); - - return strdup(buf_name); - } - - return NULL; -} - -/** -* Create the genlist object. -* -* @param[in] priv _priv object bypassed -* @return genlist object on success, otherwise NULL -*/ -static Evas_Object *_create_genlist(struct _priv *priv) -{ - Evas_Object *genlist; - Elm_Genlist_Item_Class *itc; - - if (!priv || !priv->base) { - _ERR("priv is invalid."); - return NULL; - } - - genlist = elm_genlist_add(priv->base); - if (!genlist) { - _ERR("add genlist failed."); - return NULL; - } - - priv->genlist = genlist; - - itc = elm_genlist_item_class_new(); - if (!itc) { - _ERR("genlist item class new failed."); - evas_object_del(genlist); - return NULL; - } - - itc->item_style = STYLE_TEXT_ICON; - itc->func.text_get = _item_label_get; - itc->func.content_get = NULL; - itc->func.state_get = NULL; - itc->func.del = NULL; - - priv->itc = itc; - - evas_object_size_hint_weight_set(genlist, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(genlist, - EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT); - - return genlist; -} - -/** -* Creates the action buttons including refresh button and close button. -* -* @param[in] priv _priv object bypassed -* @return 0 on success, otherwise -1 -*/ -static int _create_action_btn(struct _priv *priv) -{ - Evas_Object *btn_refresh; - Evas_Object *btn_close; - - if (!priv || !priv->base) { - _ERR("priv is invalid."); - return RET_FAILED; - } - - btn_refresh = util_add_button(priv->base, STYLE_ACTION_BUTTON, - PART_REFRESH_BTN, _(action_button[ACTION_BTN_REFRESH])); - btn_close = util_add_button(priv->base, STYLE_ACTION_BUTTON, - PART_CLOSE_BTN, _(action_button[ACTION_BTN_CLOSE])); - - priv->btn_refresh = btn_refresh; - priv->btn_close = btn_close; - - evas_object_event_callback_add(priv->btn_refresh, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); - evas_object_smart_callback_add(priv->btn_refresh, - SIG_CLICKED, _refresh_btn_clicked_cb, priv); - evas_object_event_callback_add(priv->btn_close, - EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); - evas_object_smart_callback_add(priv->btn_close, - SIG_CLICKED, _close_btn_clicked_cb, priv); - - return RET_SUCCESS; -} - -/** -* Initialize Wi-Fi Direct stack. -* -* @param[in] priv _priv object bypassed -* @return 0 on success, otherwise -1 -*/ -static int _wifi_direct_view_stack_init(struct _priv *priv) -{ - int ret; - - if (!priv) { - _ERR("priv is NULL."); - return RET_FAILED; - } - - ret = wifi_direct_mgr_wifi_init(); - if (ret != RET_SUCCESS) { - _ERR("init wifi failed."); - return ret; - } - - ret = wifi_direct_mgr_wifi_direct_init(); - if (ret != RET_SUCCESS) { - _ERR("init wifi direct failed."); - wifi_direct_mgr_wifi_fini(); - return ret; - } - - ret = wifi_direct_mgr_register_callback(&cbs, (void *)priv); - if (ret != RET_SUCCESS) { - _ERR("register callback failed."); - wifi_direct_mgr_wifi_fini(); - wifi_direct_mgr_wifi_direct_fini(); - return ret; - } - - return ret; -} - -/** -* Evas_Object_Event_Cb type callback for handling deletion event. -* -* @param[in] data the user data -* @param[in] e evas handler -* @param[in] obj the corresponding object which the deletion event occurred -* @param[in] event_info event information -*/ -static void _base_layout_key_down_cb(void *data, - Evas *e, Evas_Object *obj, void *event_info) -{ - struct _priv *priv; - Evas_Event_Key_Down *ei; - - if (!data || !event_info) { - _ERR("the param is invalid."); - return; - } - - priv = (struct _priv *) data; - ei = (Evas_Event_Key_Down *) event_info; - - if (!ei->keyname) { - _ERR("ei->keyname is NULL."); - return; - } - - if (!priv->ug) { - _ERR("priv->ug -s NULL."); - return; - } - - if (!strcmp(ei->keyname, KEY_BACK) || !strcmp(ei->keyname, KEY_BACK_REMOTE) || !strcmp(ei->keyname, KEY_EXIT)) { - ug_destroy_me(priv->ug); - _fini_priv(priv); - } -} - -/** -* Create wifi direct main view. -* -* @param[in] win parent window -* @param[in] ug UI gadget object -* @return base layout -*/ -Evas_Object *wifi_direct_view_create(Evas_Object *win, ui_gadget_h ug) -{ - Evas_Object *base; - Evas_Object *obj; - struct _priv *priv; - int ret; - - if (!win || !ug) { - _ERR("The param is invalid.\n"); - return NULL; - } - - priv = _init_priv(); - if (!priv) { - _ERR("calloc priv failed.\n"); - return NULL; - } - - priv->win = win; - priv->ug = ug; - priv->direct_on_flag = DIRECT_ON; - - ret = _wifi_direct_view_stack_init(priv); - if (ret != RET_SUCCESS) { - _ERR("wifi direct view stack init failed."); - } - - base = util_add_layout(win, UG_WIFI_DIRECT_EDJ_FILE, GRP_MAIN); - if (!base) { - _ERR("Add base layout failed.\n"); - goto error; - } - - priv->base = base; - - _set_description(priv); - - ret = _create_wifi_direct_button(priv); - if (ret != RET_SUCCESS) { - _ERR("fail to create wifi direct button."); - goto error; - } - - obj = _create_genlist(priv); - if (!obj) { - _ERR("fail to create genlist."); - goto error; - } - - ret = _create_action_btn(priv); - if (ret != RET_SUCCESS) { - _ERR("fail to create action button."); - goto error; - } - - _create_device_list_view(priv); - - evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, - _base_layout_key_down_cb, priv); - - evas_object_show(base); - - return base; - -error: - _fini_priv(priv); - return NULL; -} -- 2.7.4 From 1eb1e0153a268b45449a27e1f4522631e1c45160 Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Thu, 2 Apr 2015 16:50:00 +0900 Subject: [PATCH 04/16] Refactoring ug/channel Done Change-Id: I7ee5b81fda296ede648b44a29a9213ede455ef5c Signed-off-by: JuWan Kim --- ug/channel/CMakeLists.txt | 18 +- ug/channel/include/ChannelMainView.h | 34 ++ ug/channel/include/ChannelResultView.h | 25 ++ ug/channel/include/ChannelSearchView.h | 26 ++ ug/channel/include/defs.h | 3 + ug/channel/include/tv_scan.h | 65 --- ug/channel/include/ug_auto_program.h | 10 - ug/channel/include/view_result_page.h | 24 -- ug/channel/include/view_scan_start.h | 25 -- ug/channel/include/view_search_page.h | 25 -- ug/channel/include/viewmgr_auto_program.h | 46 -- ug/channel/src/ChannelMainView.cpp | 361 ++++++++++++++++ ug/channel/src/ChannelResultView.cpp | 141 ++++++ ug/channel/src/ChannelSearchView.cpp | 369 ++++++++++++++++ ug/channel/src/tv_scan.cpp | 668 ---------------------------- ug/channel/src/ug_auto_program.cpp | 79 ++-- ug/channel/src/view_result_page.cpp | 241 ----------- ug/channel/src/view_scan_start.cpp | 695 ------------------------------ ug/channel/src/view_search_page.cpp | 615 -------------------------- ug/channel/src/viewmgr_auto_program.cpp | 279 ------------ ug/include/TVServiceMgr.h | 34 ++ ug/network/CMakeLists.txt | 12 - ug/proxy/CMakeLists.txt | 11 - ug/proxy/src/ug_proxy_settings.cpp | 4 +- ug/src/TVServiceMgr.cpp | 296 +++++++++++++ ug/system/clock/CMakeLists.txt | 6 - ug/wifi-direct/CMakeLists.txt | 11 - ug/wifi-direct/src/WifiDirectMainView.cpp | 18 +- 28 files changed, 1348 insertions(+), 2793 deletions(-) create mode 100644 ug/channel/include/ChannelMainView.h create mode 100644 ug/channel/include/ChannelResultView.h create mode 100644 ug/channel/include/ChannelSearchView.h delete mode 100644 ug/channel/include/tv_scan.h delete mode 100644 ug/channel/include/view_result_page.h delete mode 100644 ug/channel/include/view_scan_start.h delete mode 100644 ug/channel/include/view_search_page.h delete mode 100644 ug/channel/include/viewmgr_auto_program.h create mode 100644 ug/channel/src/ChannelMainView.cpp create mode 100644 ug/channel/src/ChannelResultView.cpp create mode 100644 ug/channel/src/ChannelSearchView.cpp delete mode 100644 ug/channel/src/tv_scan.cpp delete mode 100644 ug/channel/src/view_result_page.cpp delete mode 100755 ug/channel/src/view_scan_start.cpp delete mode 100644 ug/channel/src/view_search_page.cpp delete mode 100644 ug/channel/src/viewmgr_auto_program.cpp create mode 100644 ug/include/TVServiceMgr.h create mode 100644 ug/src/TVServiceMgr.cpp mode change 100644 => 100755 ug/wifi-direct/src/WifiDirectMainView.cpp diff --git a/ug/channel/CMakeLists.txt b/ug/channel/CMakeLists.txt index 79f361e..02e6c40 100644 --- a/ug/channel/CMakeLists.txt +++ b/ug/channel/CMakeLists.txt @@ -25,14 +25,6 @@ SET(AUTO_PRGM_EDJ_THEME "ug_auto_program_theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(AUTO_PRGM_UG_PKGS REQUIRED - eina - edje - evas - elementary - capi-appfw-application - capi-system-info - aul - ui-gadget-1 ) #tv-service #tv-player-core @@ -48,14 +40,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(SRCS src/ug_auto_program.cpp src/util.cpp - src/viewmgr_auto_program.cpp - src/view_scan_start.cpp - src/view_search_page.cpp - src/view_result_page.cpp - src/tv_scan.cpp + src/ChannelMainView.cpp + src/ChannelResultView.cpp + src/ChannelSearchView.cpp + ../src/TVServiceMgr.cpp ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include) ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"") diff --git a/ug/channel/include/ChannelMainView.h b/ug/channel/include/ChannelMainView.h new file mode 100644 index 0000000..2ff73b2 --- /dev/null +++ b/ug/channel/include/ChannelMainView.h @@ -0,0 +1,34 @@ +#ifndef __CHANNEL_MAIN_VIEW_H__ +#define __CHANNEL_MAIN_VIEW_H__ + + +class CChannelMainView : public CBaseView, public IMouseClickedListener, public IFocusedListener, public IUnfocusedListener { +private : + struct SChannelMainView *m; + bool m_CreateBox(void); + bool m_UpdateAntennaList(void); + void m_UpdateFocus(void); + + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CChannelMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IFocusedListener(this), IUnfocusedListener(this), m(0) {} + virtual ~CChannelMainView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); +}; + +#endif /* __CHANNEL_MAIN_VIEW_H__ */ + + diff --git a/ug/channel/include/ChannelResultView.h b/ug/channel/include/ChannelResultView.h new file mode 100644 index 0000000..f73410d --- /dev/null +++ b/ug/channel/include/ChannelResultView.h @@ -0,0 +1,25 @@ +#ifndef __CHANNEL_RESULT_VIEW_H__ +#define __CHANNEL_RESULT_VIEW_H__ + + +class CChannelResultView : public CBaseView, public IMouseClickedListener{ +private : + struct SChannelResultView *m; + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CChannelResultView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CChannelResultView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CHANNEL_RESULT_VIEW_H__ */ diff --git a/ug/channel/include/ChannelSearchView.h b/ug/channel/include/ChannelSearchView.h new file mode 100644 index 0000000..9031f6b --- /dev/null +++ b/ug/channel/include/ChannelSearchView.h @@ -0,0 +1,26 @@ +#ifndef __CHANNEL_SEARCH_VIEW_H__ +#define __CHANNEL_SEARCH_VIEW_H__ + + +class CChannelSearchView : public CBaseView, public IMouseClickedListener{ +private : + struct SChannelSearchView *m; + bool m_StartScan(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CChannelSearchView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CChannelSearchView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CHANNEL_SEARCH_VIEW_H__ */ diff --git a/ug/channel/include/defs.h b/ug/channel/include/defs.h index 83d28ab..a02da90 100644 --- a/ug/channel/include/defs.h +++ b/ug/channel/include/defs.h @@ -17,6 +17,9 @@ #ifndef __DEFS_H__ #define __DEFS_H__ +/* View */ +#define CHANNEL_MAINVIEW "CHANNEL_MAINVIEW" + #define VIEW_START "scanstart" #define VIEW_SEARCH "searchpage" #define VIEW_RESULT "resultpage" diff --git a/ug/channel/include/tv_scan.h b/ug/channel/include/tv_scan.h deleted file mode 100644 index ddbf461..0000000 --- a/ug/channel/include/tv_scan.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TV_SCAN_H__ -#define __TV_SCAN_H__ - -struct tv_scan; - -enum local_mode { - INVALID_LOCAL = -1, - KR_MODE, - US_MODE, - MAX_LOCAL -}; - -enum antenna_mode { - SCAN_TYPE_INVALID = -1, - SCAN_TYPE_ALL, - SCAN_TYPE_CABLE, - SCAN_TYPE_AIR -}; - -struct tv_scan_result { - unsigned int air_dtv; - unsigned int cable_dtv; - unsigned int air_atv; - unsigned int cable_atv; -}; - -struct tv_scan_cbs { - void (*progress_cb)(struct tv_scan *tvs, enum antenna_mode mode, - int count, int num, void *arg); - void (*found_cb)(struct tv_scan *tvs, int count, int num, - const struct tv_scan_result *result, void *arg); - void (*done_cb)(struct tv_scan *tvs, - const struct tv_scan_result *result, void *arg); - - void *data; -}; - -struct tv_scan *tv_scan_init(enum antenna_mode scan_mode); -int tv_scan_fini(struct tv_scan *tvs); -int tv_scan_set_callbacks(struct tv_scan *tvs, struct tv_scan_cbs *cbs); -int tv_scan_start(struct tv_scan *tvs); -int tv_scan_pause(struct tv_scan *tvs); -int tv_scan_resume(struct tv_scan *tvs); -int tv_scan_stop(struct tv_scan *tvs); -int tv_scan_get_total_channel(struct tv_scan *tvs); -struct tv_scan_result *tv_scan_get_result(struct tv_scan *tvs); -int tv_scan_is_stopped(struct tv_scan *tvs); - -#endif /* __TV_SCAN_H__ */ diff --git a/ug/channel/include/ug_auto_program.h b/ug/channel/include/ug_auto_program.h index c1c4240..3b5ba7b 100644 --- a/ug/channel/include/ug_auto_program.h +++ b/ug/channel/include/ug_auto_program.h @@ -18,15 +18,5 @@ #define __UG_CHANNEL_SEARCH_VIEW_H_ #include -#include "tv_scan.h" - -struct _ugdata { - Evas_Object *win; - Evas_Object *ugd_base; - ui_gadget_h ug; - struct viewmgr *vmgr; - enum antenna_mode scan_type; - int find_chs; -}; #endif/*__UG_CHANNEL_SEARCH_VIEW_H_*/ diff --git a/ug/channel/include/view_result_page.h b/ug/channel/include/view_result_page.h deleted file mode 100644 index 19a49b2..0000000 --- a/ug/channel/include/view_result_page.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __VIEW_RESULT_PAGE_H__ -#define __VIEW_RESULT_PAGE_H__ - -#include "ug_auto_program.h" -#include "viewmgr_auto_program.h" - -struct view_class *view_resultpage_get_vclass(void); - -#endif /* __VIEW_RESULT_PAGE_H__ */ diff --git a/ug/channel/include/view_scan_start.h b/ug/channel/include/view_scan_start.h deleted file mode 100644 index 2625744..0000000 --- a/ug/channel/include/view_scan_start.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __VIEW_SCAN_START_H__ -#define __VIEW_SCAN_START_H__ - -#include "ug_auto_program.h" -#include "viewmgr_auto_program.h" - -struct view_class *view_scanstart_get_vclass(void); - -#endif /* __VIEW_SCAN_START_H__ */ diff --git a/ug/channel/include/view_search_page.h b/ug/channel/include/view_search_page.h deleted file mode 100644 index 4b9cf21..0000000 --- a/ug/channel/include/view_search_page.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __VIEW_SEARCHPAGE_H__ -#define __VIEW_SEARCHPAGE_H__ - -#include "ug_auto_program.h" -#include "viewmgr_auto_program.h" - -struct view_class *view_searchpage_get_vclass(void); - -#endif /* __VIEW_SEARCHPAGE_H__ */ diff --git a/ug/channel/include/viewmgr_auto_program.h b/ug/channel/include/viewmgr_auto_program.h deleted file mode 100644 index 3815a4d..0000000 --- a/ug/channel/include/viewmgr_auto_program.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __VIEWMGR_AUTO_PROGRAM_H__ -#define __VIEWMGR_AUTO_PROGRAM_H__ - -#include -#include - -struct viewmgr { - Eina_List *vlist; - Evas_Object *win; - int count; -}; - -struct view_class { - char *title; - Evas_Object* (*create)(struct viewmgr *vmgr, void *data); - void (*update)(Evas_Object *base); - void (*resume)(Evas_Object *base); - void (*pause)(Evas_Object *base); - void (*terminate)(Evas_Object *base); -}; - -struct viewmgr *viewmgr_init(Evas_Object *win); -void viewmgr_fini(struct viewmgr *vmgr); -int viewmgr_push(struct viewmgr *vmgr, struct view_class *vclass, void *data); -int viewmgr_pop(struct viewmgr *vmgr); -int viewmgr_resume(struct viewmgr *vmgr); -int viewmgr_pause(struct viewmgr *vmgr); -Evas_Object *viewmgr_get_win(struct viewmgr *vmgr); - -#endif /* __VIEWMGR_AUTO_PROGRAM_H__ */ diff --git a/ug/channel/src/ChannelMainView.cpp b/ug/channel/src/ChannelMainView.cpp new file mode 100644 index 0000000..e42f54c --- /dev/null +++ b/ug/channel/src/ChannelMainView.cpp @@ -0,0 +1,361 @@ +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "util.h" +#include "defs.h" +#include "TVServiceMgr.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ChannelMainView.h" + +#define HORIZONTAL_ALIGN 0.5 +#define VERTICAL_ALIGN 0.0 +#define MAX_ITEMS 3 +#define ALL "All" +#define CABLE "Cable" +#define AIR "Air" + +enum antenna_type { + ALL_ITEM, + CABLE_ITEM, + AIR_ITEM +}; + +struct SChannelMainView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *start_btn; + Evas_Object *cancel_btn; + Evas_Object *box; + Evas_Object *last_focus_item; + Evas_Object *selected_item; + Evas_Object *atn_btn[MAX_ITEMS]; + enum antenna_mode scan_type; + + CViewMgr *pViewMgr; +}; + +bool CChannelMainView::m_CreateBox(void) +{ + m->box = util_add_box(m->base, HORIZONTAL_ALIGN, VERTICAL_ALIGN); + if (!m->box) { + _ERR("box add failed"); + return false; + } + + elm_object_part_content_set(m->base, PART_ANTENNA_LIST, m->box); + evas_object_size_hint_weight_set(m->box, EVAS_HINT_EXPAND, 0); + + return true; +} + + +bool CChannelMainView::m_UpdateAntennaList(void) +{ + Evas_Object *btn; + int i; + const char *temp[MAX_ITEMS] = { ALL, CABLE, AIR }; + + elm_box_clear(m->box); + m->last_focus_item = NULL; + m->selected_item = NULL; + + for (i = 0; i < MAX_ITEMS; i++) { + btn = util_add_button(m->box, (char *) ITEM_STYLE, NULL, temp[i], EINA_TRUE); + if (!btn) { + _ERR("Fail to add button"); + return false; + } + elm_box_pack_end(m->box, btn); + //evas_object_smart_callback_add(btn, SIGNAL_CLICKED, atninfo[i].cb, data); + //elm_object_signal_callback_add(btn, SIGNAL_FOCUSED, ELM_SOURCE, _btn_focused_cb, data); + //elm_object_signal_callback_add(btn, SIGNAL_UNFOCUSED, ELM_SOURCE, _btn_unfocused_cb, data); + Connect(btn, 100+i); + + m->atn_btn[i] = btn; + + if (i == 0) { + elm_object_focus_set(btn, EINA_TRUE); + elm_object_signal_emit(btn, SIGNAL_SELECTED, CHANNEL_SOURCE); + m->selected_item = btn; + } + } + + m_UpdateFocus(); + return true; +} + + +void CChannelMainView::m_UpdateFocus(void) +{ + elm_object_focus_next_object_set(m->atn_btn[ALL_ITEM], m->start_btn, ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(m->atn_btn[CABLE_ITEM], m->start_btn, ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(m->atn_btn[AIR_ITEM], m->start_btn, ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(m->atn_btn[ALL_ITEM], m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(m->atn_btn[CABLE_ITEM], m->atn_btn[CABLE_ITEM], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(m->atn_btn[AIR_ITEM], m->atn_btn[AIR_ITEM], ELM_FOCUS_LEFT); + + if (m->selected_item) { + elm_object_focus_next_object_set(m->start_btn, m->selected_item, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(m->cancel_btn, m->selected_item, ELM_FOCUS_LEFT); + } else { + elm_object_focus_next_object_set(m->start_btn, m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(m->cancel_btn, m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); + } + + elm_object_focus_next_object_set(m->start_btn, m->cancel_btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(m->cancel_btn, m->start_btn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(m->cancel_btn, m->start_btn, ELM_FOCUS_UP); +} + + +void CChannelMainView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CChannelMainView::t_OnUpdate(void *data) +{ + _DBG(); + + evas_object_show(m->base); +} + + +void CChannelMainView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +bool CChannelMainView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SChannelMainView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GRP_SCAN_START)) + _COMMAND{ + //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _key_pressed_cb, priv); + Connect(m->base, 0); + elm_object_part_text_set(m->base, PART_STAR_MAIN_TITLE_BLOCK, START_MAIN_TITLE); + } + _CHECK(m->start_btn = util_add_button(m->base, BTN_STYLE, PART_START_BTN, TEXT_BTN_START, EINA_TRUE)) + _CHECK(m->cancel_btn = util_add_button(m->base, BTN_STYLE, PART_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE)) + _COMMAND{ +#if 0 + evas_object_data_set(m->base, "SCANSTARTDATA", m); +#endif + //evas_object_smart_callback_add(start_btn, SIGNAL_CLICKED, _start_btn_clicked_cb, priv); + //evas_object_smart_callback_add(cancel_btn, SIGNAL_CLICKED, _cancel_btn_clicked_cb, priv); + Connect(m->start_btn, 1); + Connect(m->cancel_btn, 2); + evas_object_raise(m->base); + } + _CHECK(m_CreateBox()) + _CHECK(m_UpdateAntennaList()) + _WHEN_SUCCESS { + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + _CHECK_FAIL{for(int i = 0; i < MAX_ITEMS ; i++) evas_object_del(m->atn_btn[i]);} + _CHECK_FAIL{evas_object_del(m->box);} + _CHECK_FAIL{evas_object_del(m->cancel_btn);} + _CHECK_FAIL{evas_object_del(m->start_btn);} + _CHECK_FAIL{evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CChannelMainView::Destroy(void) +{ + ASSERT(m); + + if(m->atn_btn[0]) { + for(int i = 0; i < MAX_ITEMS ; i++) evas_object_del(m->atn_btn[i]); + } + + if(m->box) + evas_object_del(m->box); + if(m->cancel_btn) + evas_object_del(m->cancel_btn); + if(m->start_btn) + evas_object_del(m->start_btn); + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CChannelMainView::Base(void) +{ + ASSERT(m); + + return m->base; +} + + + +void CChannelMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname NULL!"); + return; + } + + switch(id) { + case 0: + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + ug_destroy_me(m->ug); + break; + default: + break; + } + +} + + +void CChannelMainView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + { + Eina_Bool tuner_exist; + + /* + * TODO: add the interface when TV service provider the related API. + * Here is a pseudo-data. + */ + tuner_exist = EINA_TRUE; + if (!tuner_exist) { + /* + * TODO: popup the notification iniformation: + * there is no tuner + */ + return; + } + +#if 0 + if (viewmgr_push(m->vmgr, view_searchpage_get_vclass(), m->ugd) == -1) { + _ERR("search view push failed"); + return; + } +#endif + } + break; + case 2: + { + ug_destroy_me(m->ug); + } + break; + case 100: + case 101: + case 102: + { + const char *text; + + if (!m->selected_item) { + elm_object_focus_set(obj, EINA_TRUE); + elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE); + m->selected_item = obj; + } else { + if (m->selected_item != obj) { + elm_object_signal_emit(m->selected_item, SIGNAL_UNSELECTED, CHANNEL_SOURCE); + elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE); + m->selected_item = obj; + } + } + + text = elm_object_text_get(m->selected_item); + if (text && !strcmp(text, ALL)) + m->scan_type = SCAN_TYPE_ALL; + else if (text && !strcmp(text, CABLE)) + m->scan_type = SCAN_TYPE_CABLE; + else if (text && !strcmp(text, AIR)) + m->scan_type = SCAN_TYPE_AIR; + else + m->scan_type = SCAN_TYPE_INVALID; + +#if 0 + m->ugd->scan_type = m->scan_type; +#endif + + m_UpdateFocus(); + } + break; + default: + break; + } +} + + +void CChannelMainView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + switch(id) { + case 100: + case 101: + case 102: + { + if (m->last_focus_item) { + elm_object_signal_emit(m->last_focus_item, + SIGNAL_SHOWLINE, CHANNEL_SOURCE); + elm_object_signal_emit(obj, SIGNAL_HIDELINE, CHANNEL_SOURCE); + } else { + elm_object_signal_emit(obj, SIGNAL_SHOWLINE, CHANNEL_SOURCE); + } + + m->last_focus_item = obj; + } + break; + default: + break; + } +} + + +void CChannelMainView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + switch(id) { + case 100: + case 101: + case 102: + { + elm_object_signal_emit(m->last_focus_item, SIGNAL_SHOWLINE, CHANNEL_SOURCE); + } + break; + default: + break; + } + +} + + diff --git a/ug/channel/src/ChannelResultView.cpp b/ug/channel/src/ChannelResultView.cpp new file mode 100644 index 0000000..8335e63 --- /dev/null +++ b/ug/channel/src/ChannelResultView.cpp @@ -0,0 +1,141 @@ +#include +#include +#include +#include "AppCommon.h" +#include +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ChannelResultView.h" + +#define RESULT_MSG_SIZE 60 + +struct SChannelResultView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *ok_btn; + + CViewMgr *pViewMgr; +}; + +void CChannelResultView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CChannelResultView::t_OnUpdate(void *data) +{ + _DBG(); + Evas_Object *ok_btn; + char msg[RESULT_MSG_SIZE]; + int chs = -1; + +#if 0 + chs = m->ugd->find_chs; +#endif + + snprintf(msg, sizeof(msg), "%s
%d %s", COMPLETE_MAIN_TITLE, chs, TEXT_CH_MEMORIZED); + elm_object_part_text_set(m->base, PART_RES_MAIN_TITLE, msg); + + ok_btn = util_add_button(m->base, BTN_STYLE, PART_OK_BTN, TEXT_BUTTON_OK, EINA_TRUE); + if (!ok_btn) { + _ERR("ok_btn is NULL"); + return; + } + + m->ok_btn = ok_btn; + elm_object_focus_set(ok_btn, EINA_TRUE); + //evas_object_smart_callback_add(ok_btn, SIGNAL_CLICKED, _ok_btn_clicked_cb, priv); + Connect(ok_btn,1); + + util_focus_next_set(ok_btn); + + evas_object_show(m->base); +} + + +void CChannelResultView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + + +bool CChannelResultView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SChannelResultView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GROUP_RES)) + + _WHEN_SUCCESS { + elm_win_resize_object_add(m->win, m->base); +#if 0 + evas_object_data_set(m->base, "RESDATA", m); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CChannelResultView::Destroy(void) +{ + ASSERT(m); + + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CChannelResultView::Base(void) +{ + ASSERT(m); + + return m->base; +} + +void CChannelResultView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + ug_destroy_me(m->ug); + break; + default: + break; + } +} diff --git a/ug/channel/src/ChannelSearchView.cpp b/ug/channel/src/ChannelSearchView.cpp new file mode 100644 index 0000000..7e84dea --- /dev/null +++ b/ug/channel/src/ChannelSearchView.cpp @@ -0,0 +1,369 @@ +#include +#include +#include +#include "AppCommon.h" +#include +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "TVServiceMgr.h" +#include "BaseView.h" +#include "ViewMgr.h" +#include "ChannelSearchView.h" + +#define MAX_BUF_SIZE 30 +#define CH_NAME_SIZE 30 +#define INITIAL_CH_NUMS 0 +#define PERCENT 100 +#define INITIAL_TEXT "0%" +#define INITIAL_VALUE 0.0 + +struct SChannelSearchView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *pb; + Evas_Object *stop_btn; + Evas_Object *exit_btn; + Evas_Object *cancel_btn; + + CTVServiceMgr *pTVServiceMgr; + CViewMgr *pViewMgr; +}; + +#if 0 +static void _progress_cb(struct tv_scan *tvs, enum antenna_mode mode, + int count, int num, void *arg) +{ + struct _data *priv; + char buf[CH_NAME_SIZE]; + int total; + int ratio; + + if (!tvs || !arg) { + _ERR("Invalid argument"); + return; + } + + priv = (struct _data *) arg; + + snprintf(buf, sizeof(buf), "CH. %d", count); + elm_object_part_text_set(m->base, PART_CH_NAME, buf); + elm_object_signal_emit(m->base, SEARCHCHANNEL, SUBTEXT_SOURCE); + + total = tv_scan_get_total_channel(tvs); + if (total <= 0) { + _ERR("Invalid Total value"); + return; + } + + ratio = count * PERCENT / total; + snprintf(buf, sizeof(buf), "%d%%", ratio); + elm_object_part_text_set(m->base, PART_PGBAR_NUM, buf); + elm_progressbar_value_set(m->pb, (float)ratio / PERCENT); +} + +/** + * Dealing with the scanning result. + * + * When finishing scanning, the total found channels will be calculated and the + * scan result view will be invoked in this function. + * + * @param[in] tvs: The tv service structure for managering the scanning + * @param[in] res: The structure for saving the number of ATV air, DTV air, + * ATV cable and DTV cable channel. + * @param[in] arg: A pointer to current data structure. + */ +static void _done_cb(struct tv_scan *tvs, + const struct tv_scan_result *res, void *arg) +{ + struct _data *priv; + struct _ugdata *ugd; + struct viewmgr *vmgr; + + if (!arg) { + _ERR("Invalid argument"); + return; + } + + priv = (struct _data *)arg; + + if (!m->tvs || !m->vmgr || !m->ugd) { + _ERR("Invalid argument"); + return; + } + + vmgr = m->vmgr; + ugd = m->ugd; + + ugd->find_chs = res->air_dtv + res->cable_dtv + + res->air_atv + res->cable_atv; + + if (viewmgr_push(vmgr, view_resultpage_get_vclass(), ugd) == -1) + _ERR("result view push failed"); +} + +/** + * Deal with the found channel signal. + * + * @param[in] tvs: The tv service structure for managering the scanning + * @param[in] count: The number of channel signal received up to now + * @param[in] num: The physical channel number + * @param[in] res: The structure for saving the number of ATV air, DTV air, + * ATV cable and DTV cable channel. + * @param[in] arg: A pointer to the current data structure. + * @return 0 on success, and -1 on fail + */ +static void _found_cb(struct tv_scan *tvs, int count, int num, + const struct tv_scan_result *res, void *arg) +{ + struct _data *priv; + char buf[CH_NAME_SIZE]; + int found; + + if (!arg) { + _ERR("Invalid argument"); + return; + } + + priv = (struct _data *)arg; + snprintf(buf, sizeof(buf), "CH. %d", count); + + elm_object_part_text_set(m->base, PART_CH_NAME, buf); + elm_object_signal_emit(m->base, CHANNELFOUND, SUBTEXT_SOURCE); + + found = res->air_dtv + res->cable_dtv + res->air_atv + res->cable_atv; + snprintf(buf, sizeof(buf), "%d %s", found, TEXT_CH_FOUND); + elm_object_part_text_set(m->base, PART_SRCH_SEARCH_RESULT, buf); + + m->ugd->find_chs = found; +} +#endif + +bool CChannelSearchView::m_StartScan(void) +{ + +#if 0 + if(!m->pTVServiceMgr->SetCallback(&cbs)) { + _ERR("tv_scan_set_callbacks failed"); + return -1; + } +#endif + + if(!m->pTVServiceMgr->Start()) { + _ERR("tv_scan_start failed."); + return -1; + } + + return false; +} + + +void CChannelSearchView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CChannelSearchView::t_OnUpdate(void *data) +{ + _DBG(); + + m->stop_btn = util_add_button(m->base, BTN_STYLE, PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE); + if (!m->stop_btn) { + _ERR("stop_btn is NULL"); + return; + } + + elm_object_focus_set(m->stop_btn, EINA_TRUE); + //evas_object_smart_callback_add(m->stop_btn, SIGNAL_CLICKED, _stop_btn_clicked_cb, priv); + Connect(m->stop_btn, 1); + util_focus_next_set(m->stop_btn); + + m->pb = elm_progressbar_add(m->base); + if (!m->pb) { + _ERR("pb is NULL"); + evas_object_del(m->stop_btn); + return; + } + + elm_object_style_set(m->pb, PRGBAR_STYLE); + elm_object_part_text_set(m->base, PART_PGBAR_NUM, INITIAL_TEXT); + elm_progressbar_value_set(m->pb, INITIAL_VALUE); + elm_object_part_content_set(m->base, PART_PROGRESSBAR, m->pb); + evas_object_show(m->pb); + + if (m_StartScan() != true) { + _ERR("start scan failed"); + return; + } + + evas_object_show(m->base); +} + + +void CChannelSearchView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + + +bool CChannelSearchView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + char buf[MAX_BUF_SIZE]; + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SChannelSearchView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(CTVServiceMgr::Initialize()) + _CHECK(m->pTVServiceMgr = CTVServiceMgr::GetInstance()) + _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GROUP_SRCH)) + + _WHEN_SUCCESS { + elm_win_resize_object_add(m->win, m->base); + elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, SEARCH_MAIN_TITLE); + elm_object_part_text_set(m->base, PART_CH_NAME, SCAN_CH_NAME); + snprintf(buf, sizeof(buf), "%d %s", INITIAL_CH_NUMS, TEXT_CH_FOUND); + elm_object_part_text_set(m->base, PART_SRCH_SEARCH_RESULT, buf); +#if 0 + evas_object_data_set(m->base, "SRCHDATA", m); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{evas_object_del(m->base);} + _CHECK_FAIL{/* m->pTVServiceMgr = CTVServiceMgr::GetInstance() */} + _CHECK_FAIL{CTVServiceMgr::Finalize();} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CChannelSearchView::Destroy(void) +{ + ASSERT(m); + + if(m->base) + evas_object_del(m->base); + + CTVServiceMgr::Finalize(); + + delete m; + m = NULL; +} + + +Evas_Object* CChannelSearchView::Base(void) +{ + ASSERT(m); + + return m->base; +} + +void CChannelSearchView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + case 4: + { + if(!m->pTVServiceMgr->Pause()) { + _ERR("tv_scan_pause failed"); + return; + } + + elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, PAUSE_MAIN_TITLE); + + m->exit_btn = util_add_button(m->base, BTN_STYLE, PART_EXIT_BTN, TEXT_BTN_STOP, EINA_TRUE); + if (!m->exit_btn) { + _ERR("exit_btn is NULL"); + return; + } + + //evas_object_smart_callback_add(m->exit_btn, SIGNAL_CLICKED, _destroy_search_page_cb, priv); + Connect(m->exit_btn, 2); + + m->cancel_btn = util_add_button(m->base, BTN_STYLE, PART_SRCH_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE); + if (!m->cancel_btn) { + _ERR("cancel_btn is NULL"); + evas_object_del(m->exit_btn); + m->exit_btn = NULL; + return; + } + + //evas_object_smart_callback_add(m->cancel_btn, SIGNAL_CLICKED, _cancel_btn_clicked_cb, priv); + Connect(m->cancel_btn, 3); + + elm_object_focus_allow_set(m->exit_btn, EINA_TRUE); + elm_object_focus_set(m->exit_btn, EINA_TRUE); + util_focus_next_set(m->exit_btn); + + evas_object_del(m->stop_btn); + m->stop_btn = NULL; + } + break; + case 2: + { + if(!m->pTVServiceMgr->Stop()) { + _ERR("tv_scan_stop failed"); + return; + } + + ug_destroy_me(m->ug); + } + break; + case 3: + { + elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, SEARCH_MAIN_TITLE); + + if(!m->pTVServiceMgr->Resume()) { + _ERR("resume tv scan failed."); + return; + } + + m->stop_btn = util_add_button(m->base, BTN_STYLE, PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE); + if (!m->stop_btn) { + _ERR("stop_btn is NULL"); + return; + } + + elm_object_focus_allow_set(m->stop_btn, EINA_TRUE); + elm_object_focus_set(m->stop_btn, EINA_TRUE); + //evas_object_smart_callback_add(m->stop_btn, SIGNAL_CLICKED, _stop_btn_clicked_cb, priv); + Connect(m->stop_btn, 4); + + util_focus_next_set(m->stop_btn); + + evas_object_del(m->exit_btn); + evas_object_del(m->cancel_btn); + m->exit_btn = NULL; + m->cancel_btn = NULL; + } + break; + default: + break; + } +} diff --git a/ug/channel/src/tv_scan.cpp b/ug/channel/src/tv_scan.cpp deleted file mode 100644 index cc2da53..0000000 --- a/ug/channel/src/tv_scan.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "dbg.h" -//#include "tv_service_proxy.h" -#include "tv_scan.h" - -#define SIGNAL_HANDLER_INTERVAL 0.1 - -enum tv_scan_state { - SCAN_STATE_READY, - SCAN_STATE_SEARCHING, - SCAN_STATE_PAUSED, - SCAN_STATE_STOPPING, - SCAN_STATE_MAX -}; - -struct tv_scan { - struct tv_scan_cbs cbs; - enum tv_scan_state state; - enum antenna_mode set_mode; -#if 0 - TvServiceScan service_scan; - TvServiceScanType scan_type; -#endif - int ch_count; - int ch_num; - int total_ch; - struct tv_scan_result res; - int is_stopped; - Eina_List *signal_queue; - Ecore_Timer *signal_timer; -}; - -struct _signal_info { -#if 0 - TvServiceScanType scan_type; - TvServiceScanEvent signal; - TvServiceScanEventData signal_data; -#endif -}; - -/** - * Get the scan type according to the setting of scanning mode in the beginning - * - * In this function, it will find the scan state the tv service provided - * accordding to the setting of scanning mode by user - * - * @param[in] mode: The setting of scanning mode in view_scan_start - * @param[out] type: The corresponding scan type provided by tv service - * @return 0 on success otherwise -1 - */ -#if 0 -static int _get_scan_mode(enum antenna_mode mode, TvServiceScanType *type) -{ - switch (mode) { - case SCAN_TYPE_ALL: - *type = TVS_SCAN_ALL_ANALOG_DIGITAL; - break; - case SCAN_TYPE_CABLE: - *type = TVS_SCAN_CABLE_ANALOG_DIGITAL; - break; - case SCAN_TYPE_AIR: - *type = TVS_SCAN_AIR_ANALOG_DIGITAL; - break; - default: - _ERR("Invalid scan mode: %d", mode); - return -1; - } - - return 0; -} -#endif - -/** - * Handling the beginning signal. - * - * When user press the button "start", it will begin scanning, and the tv - * service will return the total number of channels in the first for - * calculating the progress of the progressbar - * - * In this function, it will find the total number of channel signal according - * to the scanning type. - * - * @param[in] tvs: Data handler for tv scan manager. - * @param[in] sinfo: The channel signal information. - */ -static void _handle_begin_signal(struct tv_scan *tvs, - struct _signal_info *sinfo) -{ -#if 0 - if (!tvs || !sinfo) { - _ERR("Invalid argument"); - return; - } - - switch (sinfo->scan_type) { - case TVS_SCAN_ALL_ANALOG_DIGITAL: - tvs->total_ch = sinfo->signal_data.data.l[0] + - sinfo->signal_data.data.l[1]; - break; - case TVS_SCAN_AIR_ANALOG_DIGITAL: - tvs->total_ch = sinfo->signal_data.data.l[0]; - break; - case TVS_SCAN_CABLE_ANALOG_DIGITAL: - tvs->total_ch = sinfo->signal_data.data.l[1]; - break; - default: - _ERR("Invalid scan type"); - break; - } -#endif -} - -/** - * Handle the receiving channel signal. - * - * @param[in] tvs: Data handler for tv scan manager. - * @param[in] sinfo: The channel signal information. - */ -static void _handle_progress_signal(struct tv_scan *tvs, - struct _signal_info *sinfo) -{ -#if 0 - if (!tvs || !sinfo) { - _ERR("Invalid argument"); - return; - } - - tvs->ch_count++; - tvs->ch_num = sinfo->signal_data.data.l[0]; - - if (tvs->cbs.progress_cb) - tvs->cbs.progress_cb(tvs, tvs->set_mode, tvs->ch_count, - tvs->ch_num, tvs->cbs.data); -#endif -} - -/** - * Calculating the number of ATV channle signal or DTV channel signal. - * - * @param[in] atv: A pointer for saving the number of ATV channel signal. - * @param[in] dtv: A pointer for saving the number of DTV channel signal. - * @param[in] sinfo: The channel signal information. - */ -static void _channel_count(unsigned int *atv, unsigned int *dtv, - struct _signal_info *sinfo) -{ -#if 0 - if (!sinfo || !atv || !dtv) { - _ERR("Invalid argument"); - return; - } - - switch (sinfo->signal_data.data.s[1]) { - case TVS_CHANNEL_TYPE_ATV: - *atv += sinfo->signal_data.data.s[2]; - break; - case TVS_CHANNEL_TYPE_DTV: - *dtv += sinfo->signal_data.data.s[3]; - break; - default: - _ERR("Invalid TVS_CHANNEL_TYPE"); - break; - } -#endif -} - -/** - * Handle the found channel signal when tune lock success. - * - * @param[in] tvs: Data handler for tv scan manager. - * @param[in] sinfo: The channel signal information. - */ -static void _handle_found_signal(struct tv_scan *tvs, - struct _signal_info *sinfo) -{ -#if 0 - if (!tvs || !sinfo) { - _ERR("Invalid argument"); - return; - } - - /* judge *param.s[0]: antenna type */ - switch (sinfo->signal_data.data.s[0]) { - case TV_SERVICE_ANTENNA_TYPE_AIR: - _channel_count(&tvs->res.air_atv, - &tvs->res.air_dtv, sinfo); - break; - case TV_SERVICE_ANTENNA_TYPE_CABLE: - _channel_count(&tvs->res.cable_atv, - &tvs->res.cable_dtv, sinfo); - break; - default: - _ERR("Invalid channel type"); - return; - } - - if ((sinfo->signal_data.data.s[2] > 0 || - sinfo->signal_data.data.s[3] > 0) && tvs->cbs.found_cb) - tvs->cbs.found_cb(tvs, tvs->ch_count, tvs->ch_num, &tvs->res, - tvs->cbs.data); -#endif -} - -/** - * Handle the result when scanning is finished. - * - * @param[in] tvs: Data handler for tv scan manager. - * @param[in] sinfo: The channel signal information. - */ -static void _handle_done_signal(struct tv_scan *tvs, - struct _signal_info *sinfo) -{ -#if 0 - if (!tvs || !sinfo) { - _ERR("Invalid argument"); - return; - } - - if (sinfo->signal_data.data.l[0] == TVS_SCAN_SEARCH_FINISH_COMPLETE) { - tvs->state = SCAN_STATE_READY; - - if (tvs->cbs.done_cb) - tvs->cbs.done_cb(tvs, &tvs->res, tvs->cbs.data); - } -#endif -} - -/** - * Handle the receiving signal saved in tvs->signal_queue. - * - * @param[in] data: Data handler for tv scan manager. - */ -static Eina_Bool _handle_signal(void *data) -{ -#if 0 - struct tv_scan *tvs; - struct _signal_info *sinfo; - - if (!data) - return ECORE_CALLBACK_CANCEL; - - tvs = data; - - if (!tvs->signal_queue) - goto stop; - - sinfo = eina_list_data_get(tvs->signal_queue); - if (!sinfo) - goto stop; - - tvs->signal_queue = eina_list_remove_list( - tvs->signal_queue, tvs->signal_queue); - - switch (sinfo->signal) { - case TVS_SCAN_EVENT_SEARCH_BEGIN: - _handle_begin_signal(tvs, sinfo); - break; - case TVS_SCAN_EVENT_SEARCH_CHANNEL: - _handle_progress_signal(tvs, sinfo); - break; - case TVS_SCAN_EVENT_CHANNEL_FOUND: - _handle_found_signal(tvs, sinfo); - break; - case TVS_SCAN_EVENT_SEARCH_FINISH: - _handle_done_signal(tvs, sinfo); - break; - default: - _ERR("Invalid signal"); - break; - } - - free(sinfo); - - if (!tvs->signal_queue) - goto stop; - - return ECORE_CALLBACK_RENEW; - -stop: - tvs->signal_timer = NULL; - return ECORE_CALLBACK_CANCEL; -#endif - return EINA_TRUE; -} - -/** - * Handle the receiving signal from tv service. - * - * Tv service will send the signal one by one, and the variable Ecore_Timer: - * signal_timer is set for setting the time for dealing with the signal in - * signal_queue at regular intervals. - * - * @param[in] signal: Signal from Tv service. - * @param[in] signal_data: Data handler for tv service sacn event. - * @param[in] data: Data handler for tv scan manager. - */ -#if 0 -static void _signal_received(TvServiceScanEvent signal, - TvServiceScanEventData *signal_data, gpointer data) -{ - struct tv_scan *tvs; - struct _signal_info *sinfo; - - if (!data) { - _ERR("Invalid argument"); - return; - } - - tvs = data; - - sinfo = calloc(1, sizeof(*sinfo)); - if (!sinfo) { - _ERR("calloc failed"); - return; - } - - sinfo->signal = signal; - sinfo->signal_data = *signal_data; - sinfo->scan_type = tvs->scan_type; - - tvs->signal_queue = eina_list_append( - tvs->signal_queue, sinfo); - - if (!tvs->signal_timer) { - tvs->signal_timer = ecore_timer_add(SIGNAL_HANDLER_INTERVAL, - _handle_signal, tvs); - if (!tvs->signal_timer) { - _ERR("add timer failed."); - tvs->signal_queue = eina_list_remove(tvs->signal_queue, - sinfo); - free(sinfo); - return; - } - } -} -#endif - -/** - * Initialize the tv scan manager object - * - * In this function, it will create tv_scan struct object, and get the related - * scan mode (one of TVS_SCAN_ALL_ANALOG_DIGITAL / - * TVS_SCAN_CABLE_ANALOG_DIGITAL / TVS_SCAN_AIR_ANALOG_DIGITAL) - * fron tv service according to the optional setting mode - * (one of AIR / CABLE / ALL) in scan_start view, - * and register TvServiceScan object and set it for variable service_scan, - * and set the initial scan state SCAN_STATE_READY. - * - * @param[in] mode: the setting mode (one of AIR / CABLE / ALL) in - * view_scan_start - * @return The struct tvs or NULL if initialize failed - */ -struct tv_scan *tv_scan_init(enum antenna_mode mode) -{ -#if 0 - struct tv_scan *tvs; - TvServiceScan scan; - TvServiceScanType type; - gint result; - int r; - - tvs = calloc(1, sizeof(*tvs)); - if (!tvs) { - _ERR("calloc failed"); - return NULL; - } - - r = _get_scan_mode(mode, &type); - if (r == -1) { - _ERR("Get scan mode failed"); - free(tvs); - return NULL; - } - - result = tv_service_scan_create(&scan, type); - if (result != TVS_ERROR_OK) { - _ERR("Create Scan failed"); - free(tvs); - return NULL; - } - - tvs->service_scan = scan; - tvs->scan_type = type; - tvs->set_mode = mode; - tvs->state = SCAN_STATE_READY; - - return tvs; -#endif - return NULL; -} - -/** - * Release tv_scan struct resource - * - * In this function, it will release the object in tv_scan struct object, - * include channel information saved in signal_queue and the Ecore_Timer object - * and so on. - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_fini(struct tv_scan *tvs) -{ -#if 0 - struct _signal_info *sinfo; - - if (!tvs) { - _ERR("Invalid argument"); - return -1; - } - - if (tvs->state != SCAN_STATE_READY) - tv_scan_stop(tvs); - - if (tvs->signal_timer) - ecore_timer_del(tvs->signal_timer); - - EINA_LIST_FREE(tvs->signal_queue, sinfo) - free(sinfo); - - tv_service_scan_destroy(tvs->service_scan); - free(tvs); - -#endif - return 0; -} - -/** - * Register callbacks for tvs struct - * - * @param[in] tvs: Data handler for tv scan manager. - * @param[in] cbs: The registered callbacks for control the scan state - * @return 0 on success otherwise -1 - */ -int tv_scan_set_callbacks(struct tv_scan *tvs, struct tv_scan_cbs *cbs) -{ - if (!tvs || !cbs) { - _ERR("Invalid argument"); - return -1; - } - - tvs->cbs = *cbs; - - return 0; -} - -/** - * Start scanning channels - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_start(struct tv_scan *tvs) -{ -#if 0 - gint result; - - if (!tvs || !tvs->service_scan) { - _ERR("Invalid argument"); - return -1; - } - - if (tvs->state != SCAN_STATE_READY) { - _ERR("unable state to start scan"); - return -1; - } - - result = tv_service_scan_register_callback(tvs->service_scan, - _signal_received, (gpointer)tvs); - if (result != TVS_ERROR_OK) { - _ERR("register callback failed"); - return -1; - } - - result = tv_service_scan_start(tvs->service_scan); - if (result != TVS_ERROR_OK) { - _ERR("scan start failed"); - return -1; - } - - tvs->state = SCAN_STATE_SEARCHING; - tvs->is_stopped = 0; - tvs->ch_count = 0; - memset(&tvs->res, 0x00, sizeof(tvs->res)); - - return 0; -#endif - return -1; -} - -/** - * Pause the scanning of channels - * - * In this function, it will invoke the pausing function from tv service - * for pausing the scaning and stop sending channel signals. - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_pause(struct tv_scan *tvs) -{ -#if 0 - gint result; - - if (!tvs || !tvs->service_scan) { - _ERR("Invalid argument"); - return -1; - } - - if (tvs->state != SCAN_STATE_SEARCHING) { - _ERR("unable state to pause scan"); - return -1; - } - - result = tv_service_scan_pause(tvs->service_scan); - if (result != TVS_ERROR_OK) { - _ERR("Pause Scan failed"); - return -1; - } - - tvs->state = SCAN_STATE_PAUSED; - -#endif - return 0; -} - - -/** - * Resume the paused scanning of channels - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_resume(struct tv_scan *tvs) -{ -#if 0 - gint result; - - if (!tvs || !tvs->service_scan) { - _ERR("Invalid argument"); - return -1; - } - - if (tvs->state != SCAN_STATE_PAUSED) { - _ERR("unable state to resume scan"); - return -1; - } - - result = tv_service_scan_resume(tvs->service_scan); - if (result != TVS_ERROR_OK) { - _ERR("resume Scan failed"); - return -1; - } - - tvs->state = SCAN_STATE_SEARCHING; - -#endif - return 0; -} - -/** - * Stop the scanning of channels - * - * Stop the scanning and stop receiving channel signal - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_stop(struct tv_scan *tvs) -{ -#if 0 - gint result; - - if (!tvs) { - _ERR("Invalid argument"); - return -1; - } - - if (tvs->state == SCAN_STATE_READY) { - _ERR("unable state to stop scan"); - return -1; - } - - result = tv_service_scan_stop(tvs->service_scan); - if (result != TVS_ERROR_OK) { - _ERR("Create Scan failed"); - return -1; - } - - tvs->state = SCAN_STATE_STOPPING; - tvs->is_stopped = 1; - -#endif - return 0; -} - -/** - * Get the total number of channel signals saved in - * data handler for tv scan manager - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_get_total_channel(struct tv_scan *tvs) -{ - if (!tvs) { - _ERR("Invalid argument"); - return -1; - } - - return tvs->total_ch; -} - -/** - * Get the scanning result of channel signals - * - * There are four kinds of channel signals: ATV air, ATV cable, DTV air and - * DTV cable, and the numner of the channel signal is saved in variable - * tvs->res. - * - * @param[in] tvs: Data handler for tv scan manager. - * @return The tv_scan_result struct - */ -struct tv_scan_result *tv_scan_get_result(struct tv_scan *tvs) -{ - if (!tvs) { - _ERR("Invalid argument"); - return NULL; - } - - return &tvs->res; -} - -/** - * Get the state of scanning of channels - * - * Get the state of scanning of channels to judge whether the scanning - * is stopped. - * - * @param[in] tvs: Data handler for tv scan manager. - * @return 0 on success otherwise -1 - */ -int tv_scan_is_stopped(struct tv_scan *tvs) -{ - if (!tvs) { - _ERR("Invalid argument"); - return -1; - } - - return tvs->is_stopped; -} diff --git a/ug/channel/src/ug_auto_program.cpp b/ug/channel/src/ug_auto_program.cpp index 25c926a..8944d91 100644 --- a/ug/channel/src/ug_auto_program.cpp +++ b/ug/channel/src/ug_auto_program.cpp @@ -22,17 +22,30 @@ #include #include "defs.h" #include "dbg.h" -#include "viewmgr_auto_program.h" #include "ug_auto_program.h" -#include "view_scan_start.h" -#include "view_search_page.h" -#include "view_result_page.h" #include "util.h" +#include "TVServiceMgr.h" +#include +#include "BaseView.h" +#include "ChannelMainView.h" #if defined (__cplusplus) extern "C" { #endif +struct _ug_data { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + + enum antenna_mode scan_type; + int find_chs; + + CViewMgr *pViewMgr; + CChannelMainView *pChannelMainView; +}; + /** * Creates the base layout for channel UI gadget * @@ -55,16 +68,16 @@ extern "C" { static void *_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) { + struct _ug_data *ugd; Evas_Object *win; - struct _ugdata *ugd; - struct viewmgr *vmgr; if (!ug || !priv) { - _ERR("ug: %p , priv: %p ", ug, priv); + _ERR("Parameter error!"); return NULL; } - ugd = (struct _ugdata *) priv; + ugd = (struct _ug_data *) priv; + ugd->ug = ug; elm_theme_extension_add(NULL, AUTO_PRGM_EDJ_THEME); @@ -74,26 +87,29 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode, return NULL; } + ugd->win = win; + elm_win_focus_highlight_enabled_set(win, EINA_TRUE); elm_win_focus_highlight_style_set(win, INVISIBLE); - vmgr = viewmgr_init(win); - if (!vmgr) { - _ERR("viewmgr init failed"); + CViewMgr::Initialize(ugd->win, NULL); + ugd->pViewMgr = CViewMgr::GetInstance(); + if(!ugd->pViewMgr) { + CViewMgr::Finalize(); + _ERR("Fail to get CViewMgr instance"); return NULL; } - - ugd->ug = ug; - ugd->win = win; - ugd->vmgr = vmgr; - - if (viewmgr_push(vmgr, view_scanstart_get_vclass(), ugd) == -1) { - _ERR("scan view push failed"); - viewmgr_fini(vmgr); - return NULL; + ugd->pChannelMainView = new CChannelMainView(CHANNEL_MAINVIEW); + if(!ugd->pViewMgr->AddView(ugd->pChannelMainView)) { + _ERR("Fail to add pFbBaseView"); + CViewMgr::Finalize(); + return false; } - return ugd->ugd_base; + ugd->pViewMgr->PushView(CHANNEL_MAINVIEW, ugd->ug); + ugd->base = ugd->pChannelMainView->Base(); + + return ugd->base; } /** @@ -155,18 +171,7 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv) */ static void _on_destroy(ui_gadget_h ug, service_h service, void *priv) { - struct _ugdata *ugd; - - if (!ug || !priv) { - _ERR("Invalid parameter."); - return; - } - - ugd = (struct _ugdata *) priv; - - viewmgr_fini(ugd->vmgr); - - return; + CViewMgr::Finalize(); } /** @@ -234,12 +239,12 @@ static void _on_event(ui_gadget_h ug, enum ug_event event, */ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) { - struct _ugdata *ugd; + struct _ug_data *ugd; if (!ops) return -1; - ugd = (struct _ugdata *) calloc(1, sizeof(*ugd)); + ugd = (struct _ug_data *) calloc(1, sizeof(*ugd)); if (!ugd) return -1; @@ -266,12 +271,12 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) */ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops) { - struct _ugdata *ugd; + struct _ug_data *ugd; if (!ops) return; - ugd = (struct _ugdata *)ops->priv; + ugd = (struct _ug_data *)ops->priv; free(ugd); } diff --git a/ug/channel/src/view_result_page.cpp b/ug/channel/src/view_result_page.cpp deleted file mode 100644 index a7c50e6..0000000 --- a/ug/channel/src/view_result_page.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "dbg.h" -#include "defs.h" -#include "util.h" -#include "viewmgr_auto_program.h" -#include "ug_auto_program.h" -#include "view_search_page.h" -#include "view_result_page.h" - -#define RESULT_MSG_SIZE 60 - - -struct _data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *ok_btn; - struct viewmgr *vmgr; - struct _ugdata *ugd; -}; - -#define _GET_PRIV(o) (struct _data *) evas_object_data_get(o, "RESDATA") -#define _SET_PRIV(o, data) evas_object_data_set(o, "RESDATA", data) - -/** - * @Evas_Smart_Cb type callback for handling the click callback event for - * "OK" button. - * - * When "OK" button is clicked, channel ug will exit. - * - * @param[in] data: the user data related to current view - * @param[in] obj: the corresponding object on which the button click event - * occurred - * - * @param[in] ev: event information - */ -static void _ok_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _ugdata *ugd; - struct _data *priv; - - if (!data) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *) data; - ugd = priv->ugd; - - if (!ugd || !ugd->ug) { - _ERR("ugd->ug is NULL"); - return; - } - - ug_destroy_me(ugd->ug); -} - -/** - * Initializes the base layout for scanning result view. - * - * Create the layout of scanning result view. - * - * @param[in] vmgr: the handler to the struct object for managing the view - * @param[in] data: the user data related to current view - * @return The base or NULL if creatting failed - */ -static Evas_Object *_create(struct viewmgr *vmgr, void *data) -{ - Evas_Object *base; - Evas_Object *win; - struct _data *priv; - struct _ugdata *ugd; - - if (!vmgr || !data) { - _ERR("Invalid argument"); - return NULL; - } - - ugd = (struct _ugdata *) data; - - win = viewmgr_get_win(vmgr); - if (!win) - return NULL; - - priv = (struct _data *) calloc(1, sizeof(*priv)); - if (!priv) - return NULL; - - base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GROUP_RES); - if (!base) { - free(priv); - return NULL; - } - - elm_win_resize_object_add(win, base); - - priv->win = win; - priv->base = base; - priv->ugd = ugd; - priv->vmgr = vmgr; - - _SET_PRIV(base, priv); - - return base; -} - -/** - * Invoked after _create() function as defined in viewmgr_push(). - * - * Create the button in result view, and show the information about the - * number of found channels. - * - * @param[in] base: the layout of the view - */ -static void _update(Evas_Object *base) -{ - Evas_Object *ok_btn; - struct _data *priv; - char msg[RESULT_MSG_SIZE]; - int chs; - - if (!base) { - _ERR("Invalid argument"); - return; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return; - } - - chs = priv->ugd->find_chs; - - snprintf(msg, sizeof(msg), "%s
%d %s", COMPLETE_MAIN_TITLE, - chs, TEXT_CH_MEMORIZED); - elm_object_part_text_set(priv->base, PART_RES_MAIN_TITLE, msg); - - ok_btn = util_add_button(priv->base, BTN_STYLE, - PART_OK_BTN, TEXT_BUTTON_OK, EINA_TRUE); - if (!ok_btn) { - _ERR("ok_btn is NULL"); - return; - } - - priv->ok_btn = ok_btn; - elm_object_focus_set(ok_btn, EINA_TRUE); - evas_object_smart_callback_add(ok_btn, SIGNAL_CLICKED, - _ok_btn_clicked_cb, priv); - - util_focus_next_set(ok_btn); -} - -/** - * Resume the application. - * - * @param[in] base: the layout of the view - */ -static void _resume(Evas_Object *base) -{ - evas_object_show(base); -} - -/** - * Pause the application. - * - * Hide the layout - * - * @param[in] base: the layout of the view - */ -static void _pause(Evas_Object *base) -{ - evas_object_hide(base); -} - -/** - * Called after the main loop of the view exits. - * - * Delete the layout and release the resourse - * - * @param[in] base: the layout of the view - */ -static void _terminate(Evas_Object *base) -{ - struct _data *priv; - - if (!base) { - _ERR("Invalid argument"); - return; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return; - } - - if (priv->base) - evas_object_del(priv->base); - - free(priv); -} - -/** - * This struct is for registering the callbacks for the view - */ -static struct view_class _vclass = { - VIEW_RESULT, - _create, - _update, - _resume, - _pause, - _terminate, -}; - - /** - * Returns current view_class which implements the result view's life cycle - * - * @return view_class - */ -struct view_class *view_resultpage_get_vclass(void) -{ - return &_vclass; -} diff --git a/ug/channel/src/view_scan_start.cpp b/ug/channel/src/view_scan_start.cpp deleted file mode 100755 index fc2ba72..0000000 --- a/ug/channel/src/view_scan_start.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co. Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include "ug_auto_program.h" -#include "view_scan_start.h" -#include "view_search_page.h" -#include "view_result_page.h" -#include "viewmgr_auto_program.h" -#include "dbg.h" -#include "defs.h" -#include "tv_scan.h" -#include "util.h" - -#define HORIZONTAL_ALIGN 0.5 -#define VERTICAL_ALIGN 0.0 -#define MAX_ITEMS 3 -#define ALL "All" -#define CABLE "Cable" -#define AIR "Air" - - -enum antenna_type { - ALL_ITEM, - CABLE_ITEM, - AIR_ITEM -}; - -struct _data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *start_btn; - Evas_Object *cancel_btn; - Evas_Object *box; - Evas_Object *last_focus_item; - Evas_Object *selected_item; - Evas_Object *atn_btn[MAX_ITEMS]; - struct viewmgr *vmgr; - struct _ugdata *ugd; - enum antenna_mode scan_type; -}; - -struct _antenna_info { - char *style; - Evas_Smart_Cb cb; - char *text; -}; - -#define _GET_PRIV(o) (struct _data *) evas_object_data_get(o, "SCANSTARTDATA") -#define _SET_PRIV(o, data) evas_object_data_set(o, "SCANSTARTDATA", data) - -/** - * @EVAS_CALLBACK_KEY_DOWN type callback for handling key pressed callback - * event - * - * @param[in] data: user data related to current view - * @param[in] e: evas handler - * @param[in] obj: the corresponding object on which the key pressed event - * occurred - * @param[in] ei: event information - */ -static void _key_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *ei) -{ - Evas_Event_Key_Down *ev; - struct _data *priv; - struct _ugdata *ugd; - - if (!data || !ei) { - _ERR("Parameter error!"); - return; - } - - priv = (struct _data *) data; - ev = (Evas_Event_Key_Down *) ei; - - if (!priv->ugd) { - _ERR("priv->ugd is NULL"); - return; - } - - ugd = priv->ugd; - - if (!ugd->ug) { - _ERR("ugd->ug is NULL"); - return; - } - - if (!ev->keyname) { - _ERR("ev->keyname NULL!"); - return; - } - - if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - ug_destroy_me(ugd->ug); -} - -/** - * @Evas_Smart_Cb type callback for handling the click callback event for - * "start" button. - * - * @param[in] data: user data related to current view - * @param[in] obj: the corresponding object on which the button click event - * occurred - * @param[in] ev: event information - */ -static void _start_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _data *priv; - Eina_Bool tuner_exist; - - if (!data) { - _ERR("data is NULL"); - return; - } - - priv = (struct _data *) data; - - if (!priv->ugd || !priv->vmgr) { - _ERR("parameter is NULL"); - return; - } - - /* - * TODO: add the interface when TV service provider the related API. - * Here is a pseudo-data. - */ - tuner_exist = EINA_TRUE; - if (!tuner_exist) { - /* - * TODO: popup the notification iniformation: - * there is no tuner - */ - return; - } - - if (viewmgr_push(priv->vmgr, view_searchpage_get_vclass(), - priv->ugd) == -1) { - _ERR("search view push failed"); - return; - } -} - - /** - * @Evas_Smart_Cb type callback for handling the click callback event for - * "cancel" button. - * - * @param[in] data: user data related to current view - * @param[in] obj: the corresponding object on which the button click event - * occurred - * @param[in] ev: event information - */ -static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _data *priv; - struct _ugdata *ugd; - - if (!data) { - _ERR("data is NULL"); - return; - } - - priv = (struct _data *) data; - - if (!priv->ugd) { - _ERR("priv->ugd is NULL"); - return; - } - - ugd = priv->ugd; - - if (!ugd->ug) { - _ERR("ugd->ug is NULL"); - return; - } - - ug_destroy_me(ugd->ug); -} - -/** - * Callback function for button focus event. - * - * @param[in] data: user data related to current view - * @param[in] obj: the corresponding object on which the button focus event - * occurred - * @param[in] emission: the signal's name. - * @param[in] source: the signal's source. - */ -static void _btn_focused_cb(void *data, Evas_Object *obj, - const char *emission, const char *source) -{ - struct _data *priv; - - if (!obj || !data) { - _ERR("Invalid parameter"); - return; - } - - priv = (struct _data *) data; - - if (priv->last_focus_item) { - elm_object_signal_emit(priv->last_focus_item, - SIGNAL_SHOWLINE, CHANNEL_SOURCE); - elm_object_signal_emit(obj, SIGNAL_HIDELINE, CHANNEL_SOURCE); - } else { - elm_object_signal_emit(obj, SIGNAL_SHOWLINE, CHANNEL_SOURCE); - } - - priv->last_focus_item = obj; -} - -/** - * Callback function for button unfocus event. - * - * @param[in] data: user data related to current view - * @param[in] obj: the corresponding object on which the button focus event - * occurred - * @param[in] emission: the signal's name. - * @param[in] source: the signal's source. - */ -static void _btn_unfocused_cb(void *data, Evas_Object *obj, - const char *emission, const char *source) -{ - struct _data *priv; - - if (!obj || !data) { - _ERR("Invalid parameter"); - return; - } - - priv = (struct _data *) data; - elm_object_signal_emit(priv->last_focus_item, - SIGNAL_SHOWLINE, CHANNEL_SOURCE); -} - -/** - * Set the focus sequence for the objects in the layout. - * - * @param[in] data: user data related to current view - */ -static void _update_focus_sequence(struct _data *priv) -{ - if (!priv) { - _ERR("Invalid parameter"); - return; - } - - elm_object_focus_next_object_set(priv->atn_btn[ALL_ITEM], - priv->start_btn, ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(priv->atn_btn[CABLE_ITEM], - priv->start_btn, ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(priv->atn_btn[AIR_ITEM], - priv->start_btn, ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(priv->atn_btn[ALL_ITEM], - priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(priv->atn_btn[CABLE_ITEM], - priv->atn_btn[CABLE_ITEM], ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(priv->atn_btn[AIR_ITEM], - priv->atn_btn[AIR_ITEM], ELM_FOCUS_LEFT); - - if (priv->selected_item) { - elm_object_focus_next_object_set(priv->start_btn, - priv->selected_item, ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(priv->cancel_btn, - priv->selected_item, ELM_FOCUS_LEFT); - } else { - elm_object_focus_next_object_set(priv->start_btn, - priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(priv->cancel_btn, - priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT); - } - - elm_object_focus_next_object_set(priv->start_btn, - priv->cancel_btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(priv->cancel_btn, - priv->start_btn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(priv->cancel_btn, - priv->start_btn, ELM_FOCUS_UP); -} - -/** - * @Evas_Smart_Cb type callback for handling the click callback event. - * - * @param[in] data: user data related to current view - * @param[in] obj: the corresponding object on which the button click event - * occurred - * @param[in] ev: event information - */ -static void _item_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _data *priv; - const char *text; - - if (!data || !obj) { - _ERR("Invalid parameter"); - return; - } - - priv = (struct _data *) data; - - if (!priv->selected_item) { - elm_object_focus_set(obj, EINA_TRUE); - elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE); - priv->selected_item = obj; - } else { - if (priv->selected_item != obj) { - elm_object_signal_emit(priv->selected_item, - SIGNAL_UNSELECTED, CHANNEL_SOURCE); - elm_object_signal_emit(obj, SIGNAL_SELECTED, - CHANNEL_SOURCE); - priv->selected_item = obj; - } - } - - text = elm_object_text_get(priv->selected_item); - if (text && !strcmp(text, ALL)) - priv->scan_type = SCAN_TYPE_ALL; - else if (text && !strcmp(text, CABLE)) - priv->scan_type = SCAN_TYPE_CABLE; - else if (text && !strcmp(text, AIR)) - priv->scan_type = SCAN_TYPE_AIR; - else - priv->scan_type = SCAN_TYPE_INVALID; - - priv->ugd->scan_type = priv->scan_type; - - _update_focus_sequence(priv); -} - -/** - * Clear the content of the box. - * - * @param[in] data: user data related to current view - */ -static void _clear_box(struct _data *data) -{ - if (!data) { - _ERR("Invalid parameter."); - return; - } - - if (!data->box) { - _ERR("data->box is NULL"); - return; - } - - elm_box_clear(data->box); - - data->last_focus_item = NULL; - data->selected_item = NULL; -} - -/** - * Add items in the box of the layout. - * - * @param[in] parent: the box created in the layout. - * @param[in] btnstyle: the style of the button - * @param[in] btntext: the text shown in button - * @param[in] fun_cb: the click callback function for the button - * @param[in] data: user data related to current view - * @return Button or NULL if creatting failed - */ -static Evas_Object *_add_exit_item(Evas_Object *parent, const char *btnstyle, - const char *btntext, Evas_Smart_Cb fun_cb, struct _data *data) -{ - Evas_Object *btn; - - if (!data) { - _ERR("Invalid parameter."); - return NULL; - } - - if (!parent || !btnstyle || !btntext || !fun_cb) { - _ERR("Invalid parameter."); - return NULL; - } - - btn = util_add_button(parent, btnstyle, NULL, btntext, EINA_TRUE); - if (!btn) { - _ERR("add item failed"); - return NULL; - } - - elm_box_pack_end(parent, btn); - evas_object_smart_callback_add(btn, SIGNAL_CLICKED, - fun_cb, data); - elm_object_signal_callback_add(btn, SIGNAL_FOCUSED, - ELM_SOURCE, _btn_focused_cb, data); - elm_object_signal_callback_add(btn, SIGNAL_UNFOCUSED, - ELM_SOURCE, _btn_unfocused_cb, data); - - return btn; -} - -/** - * Create the item list of antenna type . - * - * @param[in] data: user data related to current view - */ -static void _update_antenna_list(struct _data *data) -{ - Evas_Object *btn; - int i; - struct _antenna_info atninfo[] = { - { - (char *) ITEM_STYLE, - _item_clicked_cb, - ALL - }, - { - (char *) ITEM_STYLE, - _item_clicked_cb, - CABLE - }, - { - (char *) ITEM_STYLE, - _item_clicked_cb, - AIR - } - }; - - if (!data) { - _ERR("Invalid parameter."); - return; - } - - if (!data->base || !data->box) { - _ERR("Invalid parameter."); - return; - } - - _clear_box(data); - - for (i = 0; i < MAX_ITEMS; i++) { - btn = _add_exit_item(data->box, atninfo[i].style, - atninfo[i].text, atninfo[i].cb, data); - if (!btn) { - _ERR("add exist item failed."); - return; - } - - data->atn_btn[i] = btn; - - if (i == 0) { - elm_object_focus_set(btn, EINA_TRUE); - elm_object_signal_emit(btn, - SIGNAL_SELECTED, CHANNEL_SOURCE); - data->selected_item = btn; - } - } - - _update_focus_sequence(data); -} - -/** - * Create box in the layout for adding item in it. - * - * @param[in] base: the layout created in _creat() of current view - * @return The box or NULL if creatting failed - */ -static Evas_Object *_create_box(Evas_Object *base) -{ - Evas_Object *box; - struct _data *priv; - - if (!base) { - _ERR("base is NULL"); - return NULL; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return NULL; - } - - box = util_add_box(base, HORIZONTAL_ALIGN, VERTICAL_ALIGN); - if (!box) { - _ERR("box add failed"); - return NULL; - } - - elm_object_part_content_set(base, PART_ANTENNA_LIST, box); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0); - - return box; -} - -/** - * Initializes the base layout for scanning start view. - * - * Create the beginning view layout based on window - * - * @param[in] vmgr: the handler to the struct object for managing the view - * @param[in] data: the user data related to current view - * @return The base or NULL if creatting failed - */ -static Evas_Object *_create(struct viewmgr *vmgr, void *data) -{ - Evas_Object *base; - Evas_Object *win; - Evas_Object *start_btn; - Evas_Object *cancel_btn; - Evas_Object *box; - struct _data *priv; - struct _ugdata *ugd; - - if (!vmgr || !data) { - _ERR("Invalid argument"); - return NULL; - } - - ugd = (struct _ugdata *)data; - - win = viewmgr_get_win(vmgr); - if (!win) { - _ERR("get win failed."); - return NULL; - } - - priv = (struct _data *) calloc(1, sizeof(*priv)); - if (!priv) { - _ERR("calloc memory failed."); - return NULL; - } - - base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GRP_SCAN_START); - if (!base) { - _ERR("scan start layout creat failed!"); - free(priv); - return NULL; - } - - //elm_win_resize_object_add(win, base); - evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, - _key_pressed_cb, priv); - elm_object_part_text_set(base, PART_STAR_MAIN_TITLE_BLOCK, - START_MAIN_TITLE); - - start_btn = util_add_button(base, BTN_STYLE, - PART_START_BTN, TEXT_BTN_START, EINA_TRUE); - if (!start_btn) { - _ERR("create start_btn failed"); - goto aborting; - } - - cancel_btn = util_add_button(base, BTN_STYLE, - PART_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE); - if (!cancel_btn) { - _ERR("create cancel_btn failed"); - goto aborting; - } - - priv->base = base; - priv->start_btn = start_btn; - priv->cancel_btn = cancel_btn; - priv->ugd = ugd; - priv->ugd->ugd_base = base; - priv->vmgr = vmgr; - priv->win = win; - - _SET_PRIV(base, priv); - - evas_object_smart_callback_add(start_btn, SIGNAL_CLICKED, - _start_btn_clicked_cb, priv); - evas_object_smart_callback_add(cancel_btn, SIGNAL_CLICKED, - _cancel_btn_clicked_cb, priv); - - evas_object_raise(base); - - box = _create_box(base); - if (!box) { - _ERR("create box failed."); - goto aborting; - } - - priv->box = box; - - _update_antenna_list(priv); - - return base; - -aborting: - evas_object_del(base); - free(priv); - return NULL; -} - -/** - * Invoked when refresh the window of application. - * - * @param[in] base: the layout of the view - * - * There is no action in this application. - */ -static void _update(Evas_Object *base) -{ -} - -/** - * Resume the application. - * - * @param[in] base: the layout of the view - */ -static void _resume(Evas_Object *base) -{ - if (!base) { - _ERR("Invalid argument"); - return; - } - - evas_object_show(base); -} - -/** - * Pause the view. - * - * Hide the layout - * - * @param[in] base: the layout of the view - */ -static void _pause(Evas_Object *base) -{ - if (!base) { - _ERR("Invalid argument"); - return; - } - - evas_object_hide(base); -} - -/** - * Called after the main loop of the view exits. - * - * Delete the layout and release the resourse - * - * @param[in] base: the layout of the view - */ -static void _terminate(Evas_Object *base) -{ - struct _data *priv; - - if (!base) { - _ERR("Invalid argument"); - return; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return; - } - - if (priv->base) - evas_object_del(priv->base); - - free(priv); -} - -/** - * This struct is for registering the callbacks for the view - */ -static struct view_class _vclass = { - VIEW_START, - _create, - _update, - _resume, - _pause, - _terminate, -}; - - /** - * Returns current view_class which implements the scan start view's life cycle - * - * @return view_class - */ -struct view_class *view_scanstart_get_vclass(void) -{ - return &_vclass; -} diff --git a/ug/channel/src/view_search_page.cpp b/ug/channel/src/view_search_page.cpp deleted file mode 100644 index 60d6512..0000000 --- a/ug/channel/src/view_search_page.cpp +++ /dev/null @@ -1,615 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include "ug_auto_program.h" -#include "view_search_page.h" -#include "view_result_page.h" -#include "viewmgr_auto_program.h" -#include "dbg.h" -#include "defs.h" -#include "tv_scan.h" -#include "util.h" - -#define MAX_BUF_SIZE 30 -#define CH_NAME_SIZE 30 -#define INITIAL_CH_NUMS 0 -#define PERCENT 100 -#define INITIAL_TEXT "0%" -#define INITIAL_VALUE 0.0 - -struct _data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *pb; - Evas_Object *stop_btn; - Evas_Object *exit_btn; - Evas_Object *cancel_btn; - struct viewmgr *vmgr; - struct tv_scan *tvs; - struct _ugdata *ugd; -}; - -#define _GET_PRIV(o) (struct _data *) evas_object_data_get(o, "SRCHDATA") -#define _SET_PRIV(o, data) evas_object_data_set(o, "SRCHDATA", data) - -/** - * The statement for "stop" button for clicking callback event, for - * there are two buttons with the same text "stop". - */ -static void _stop_btn_clicked_cb(void *data, Evas_Object *obj, void *ev); - -/** - * The click callback event for the "cancel" button. - * - * When "cancel" button is clicked, the scanning will be resumed. - * - * @param[in] data: user data related to current view - * @param[in] obj: a pointer to the object on which click event occurred - * @param[in] ev: event information - */ -static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _data *priv; - int r; - - if (!data) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *) data; - - if (!priv->cancel_btn || !priv->exit_btn) { - _ERR("priv->cancel_btn or priv->exit_btn is NULL"); - return; - } - - elm_object_part_text_set(priv->base, PART_SRCH_MAIN_TITLE, - SEARCH_MAIN_TITLE); - - r = tv_scan_resume(priv->tvs); - if (r != 0) { - _ERR("resume tv scan failed."); - return; - } - - priv->stop_btn = util_add_button(priv->base, BTN_STYLE, - PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE); - if (!priv->stop_btn) { - _ERR("stop_btn is NULL"); - return; - } - - elm_object_focus_allow_set(priv->stop_btn, EINA_TRUE); - elm_object_focus_set(priv->stop_btn, EINA_TRUE); - evas_object_smart_callback_add(priv->stop_btn, SIGNAL_CLICKED, - _stop_btn_clicked_cb, priv); - - util_focus_next_set(priv->stop_btn); - - evas_object_del(priv->exit_btn); - evas_object_del(priv->cancel_btn); - priv->exit_btn = NULL; - priv->cancel_btn = NULL; -} - -/** - * @Evas_Smart_Cb type callback for handling the click callback event for - * "stop" button. - * - * The click callback event for the "stop" button in paused view. - * When the "stop" button in paused view is clicked, the scanning will - * be stopped, and channel ug will be exited. - * - * @param[in] data: user data related to current view - * @param[in] obj: a pointer to the object on which click event occurred - * @param[in] ev: event information - */ -static void _destroy_search_page_cb(void *data, Evas_Object *obj, - void *ev) -{ - struct _ugdata *ugd; - struct _data *priv; - int r; - - if (!data) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *)data; - - if (!priv->ugd || !priv->tvs) { - _ERR("priv->ugd or priv->tvs is NULL"); - return; - } - - ugd = priv->ugd; - - r = tv_scan_stop(priv->tvs); - if (r != 0) { - _ERR("tv_scan_stop failed"); - return; - } - - if (!ugd->ug) { - _ERR("ugd->ug is NULL"); - return; - } - - ug_destroy_me(ugd->ug); -} - -/** - * @Evas_Smart_Cb type callback for handling the click callback event for - * "stop" button. - * - * When the "stop" button is clicked, the scanning will be paused, the view - * will be changed into paused state. - * - * @param[in] data: user data related to current view - * @param[in] obj: a pointer to the object on which click event occurred - * @param[in] ev: event information - */ -static void _stop_btn_clicked_cb(void *data, Evas_Object *obj, void *ev) -{ - struct _data *priv; - int r; - - if (!data || !obj) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *)data; - - if (!priv->base || !priv->tvs) { - _ERR("priv->base or priv->tvs is NULL"); - return; - } - - r = tv_scan_pause(priv->tvs); - if (r != 0) { - _ERR("tv_scan_pause failed"); - return; - } - - elm_object_part_text_set(priv->base, PART_SRCH_MAIN_TITLE, - PAUSE_MAIN_TITLE); - - priv->exit_btn = util_add_button(priv->base, BTN_STYLE, - PART_EXIT_BTN, TEXT_BTN_STOP, EINA_TRUE); - if (!priv->exit_btn) { - _ERR("exit_btn is NULL"); - return; - } - - evas_object_smart_callback_add(priv->exit_btn, SIGNAL_CLICKED, - _destroy_search_page_cb, priv); - - priv->cancel_btn = util_add_button(priv->base, BTN_STYLE, - PART_SRCH_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE); - if (!priv->cancel_btn) { - _ERR("cancel_btn is NULL"); - evas_object_del(priv->exit_btn); - priv->exit_btn = NULL; - return; - } - - evas_object_smart_callback_add(priv->cancel_btn, SIGNAL_CLICKED, - _cancel_btn_clicked_cb, priv); - - elm_object_focus_allow_set(priv->exit_btn, EINA_TRUE); - elm_object_focus_set(priv->exit_btn, EINA_TRUE); - util_focus_next_set(priv->exit_btn); - - evas_object_del(priv->stop_btn); - priv->stop_btn = NULL; -} - -/** - * Dealing with the receving signal. - * - * When receiving a channel signal, update the progress of the progressbar - * and the number of channel signal. - * - * @param[in] tvs: The tv service data structure - * @param[in] mode: The setting scan mode in view_scan_start.c - * @param[in] count: The number of channel signal received up to now - * @param[in] num: The physical channel number of current channel - * @param[in] arg: A pointer to current data structure. - */ -static void _progress_cb(struct tv_scan *tvs, enum antenna_mode mode, - int count, int num, void *arg) -{ - struct _data *priv; - char buf[CH_NAME_SIZE]; - int total; - int ratio; - - if (!tvs || !arg) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *) arg; - - snprintf(buf, sizeof(buf), "CH. %d", count); - elm_object_part_text_set(priv->base, PART_CH_NAME, buf); - elm_object_signal_emit(priv->base, SEARCHCHANNEL, SUBTEXT_SOURCE); - - total = tv_scan_get_total_channel(tvs); - if (total <= 0) { - _ERR("Invalid Total value"); - return; - } - - ratio = count * PERCENT / total; - snprintf(buf, sizeof(buf), "%d%%", ratio); - elm_object_part_text_set(priv->base, PART_PGBAR_NUM, buf); - elm_progressbar_value_set(priv->pb, (float)ratio / PERCENT); -} - -/** - * Dealing with the scanning result. - * - * When finishing scanning, the total found channels will be calculated and the - * scan result view will be invoked in this function. - * - * @param[in] tvs: The tv service structure for managering the scanning - * @param[in] res: The structure for saving the number of ATV air, DTV air, - * ATV cable and DTV cable channel. - * @param[in] arg: A pointer to current data structure. - */ -static void _done_cb(struct tv_scan *tvs, - const struct tv_scan_result *res, void *arg) -{ - struct _data *priv; - struct _ugdata *ugd; - struct viewmgr *vmgr; - - if (!arg) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *)arg; - - if (!priv->tvs || !priv->vmgr || !priv->ugd) { - _ERR("Invalid argument"); - return; - } - - vmgr = priv->vmgr; - ugd = priv->ugd; - - ugd->find_chs = res->air_dtv + res->cable_dtv + - res->air_atv + res->cable_atv; - - if (viewmgr_push(vmgr, view_resultpage_get_vclass(), ugd) == -1) - _ERR("result view push failed"); -} - -/** - * Deal with the found channel signal. - * - * @param[in] tvs: The tv service structure for managering the scanning - * @param[in] count: The number of channel signal received up to now - * @param[in] num: The physical channel number - * @param[in] res: The structure for saving the number of ATV air, DTV air, - * ATV cable and DTV cable channel. - * @param[in] arg: A pointer to the current data structure. - * @return 0 on success, and -1 on fail - */ -static void _found_cb(struct tv_scan *tvs, int count, int num, - const struct tv_scan_result *res, void *arg) -{ - struct _data *priv; - char buf[CH_NAME_SIZE]; - int found; - - if (!arg) { - _ERR("Invalid argument"); - return; - } - - priv = (struct _data *)arg; - snprintf(buf, sizeof(buf), "CH. %d", count); - - elm_object_part_text_set(priv->base, PART_CH_NAME, buf); - elm_object_signal_emit(priv->base, CHANNELFOUND, SUBTEXT_SOURCE); - - found = res->air_dtv + res->cable_dtv + res->air_atv + res->cable_atv; - snprintf(buf, sizeof(buf), "%d %s", found, TEXT_CH_FOUND); - elm_object_part_text_set(priv->base, PART_SRCH_SEARCH_RESULT, buf); - - priv->ugd->find_chs = found; -} - -/** - * Register callback functions for tvs scan manager and begin scanning. - * - * It registers the callback functions and private data. - * _progress_cb When receiving a channle signal, _progress_cb will be invoked; - * _found_cb When finding a channel, _found_cb will be invoked. - * _done_cb When finishing scanning, _done_cb will be invoked. - * - * @param[in] data: user data related to current view - * @return 0 on success, and -1 on fail - */ -static int _start_scan(struct _data *data) -{ - struct tv_scan_cbs cbs; - int r; - - if (!data) { - _ERR("Invalid argument data: %p", data); - return -1; - } - - if (!data->tvs) { - _ERR("Invalid argumentdata->tvs: %p", data->tvs); - return -1; - } - - cbs.data = data; - cbs.progress_cb = _progress_cb; - cbs.found_cb = _found_cb; - cbs.done_cb = _done_cb; - - r = tv_scan_set_callbacks(data->tvs, &cbs); - if (r != 0) { - _ERR("tv_scan_set_callbacks failed"); - return -1; - } - - r = tv_scan_start(data->tvs); - if (r != 0) { - _ERR("tv_scan_start failed."); - return -1; - } - - return 0; -} - -/** - * Initializes the base layout for searching view. - * - * Invoked as soon as "start" button is clicked in view_scan_start - * - * @param[in] vmgr: the handler to the struct object for managing the view - * @param[in] data: user data related to current view - * @return The base or NULL if creatting failed - */ -static Evas_Object *_create(struct viewmgr *vmgr, void *data) -{ - Evas_Object *base; - Evas_Object *win; - struct _data *priv; - struct _ugdata *ugd; - struct tv_scan *tvs; - char buf[MAX_BUF_SIZE]; - - if (!vmgr) { - _ERR("Invalid argument"); - return NULL; - } - - if (!data) { - _ERR("Invalid argument."); - return NULL; - } - - ugd = (struct _ugdata *)data; - - win = viewmgr_get_win(vmgr); - if (!win) { - _ERR("get win failed."); - return NULL; - } - - priv = (struct _data *) calloc(1, sizeof(*priv)); - if (!priv) { - _ERR("calloc memory failed"); - return NULL; - } - - tvs = tv_scan_init(ugd->scan_type); - if (!tvs) { - _ERR("tvs init failed, set scan_type: %d", ugd->scan_type); - free(priv); - return NULL; - } - - base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GROUP_SRCH); - if (!base) { - _ERR("base is NULL"); - tv_scan_fini(tvs); - free(priv); - return NULL; - } - - elm_win_resize_object_add(win, base); - elm_object_part_text_set(base, PART_SRCH_MAIN_TITLE, - SEARCH_MAIN_TITLE); - elm_object_part_text_set(base, PART_CH_NAME, SCAN_CH_NAME); - - snprintf(buf, sizeof(buf), "%d %s", INITIAL_CH_NUMS, TEXT_CH_FOUND); - elm_object_part_text_set(base, PART_SRCH_SEARCH_RESULT, buf); - - priv->vmgr = vmgr; - priv->win = win; - priv->ugd = ugd; - priv->tvs = tvs; - priv->base = base; - - _SET_PRIV(base, priv); - - return base; -} - -/** - * Invoked when refresh the window of application. - * - * @param[in] base: the layout of the view - * - * There is no action in this application. - */ -static void _update(Evas_Object *base) -{ - Evas_Object *stop_btn; - Evas_Object *pb; - struct _data *priv; - int r; - - if (!base) { - _ERR("Invalid argument"); - return; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return; - } - - stop_btn = util_add_button(base, BTN_STYLE, - PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE); - if (!stop_btn) { - _ERR("stop_btn is NULL"); - evas_object_del(base); - free(priv); - return; - } - - priv->stop_btn = stop_btn; - elm_object_focus_set(stop_btn, EINA_TRUE); - evas_object_smart_callback_add(stop_btn, SIGNAL_CLICKED, - _stop_btn_clicked_cb, priv); - util_focus_next_set(stop_btn); - - pb = elm_progressbar_add(base); - if (!pb) { - _ERR("pb is NULL"); - evas_object_del(base); - free(priv); - return; - } - - priv->pb = pb; - elm_object_style_set(pb, PRGBAR_STYLE); - elm_object_part_text_set(base, PART_PGBAR_NUM, INITIAL_TEXT); - elm_progressbar_value_set(pb, INITIAL_VALUE); - elm_object_part_content_set(base, PART_PROGRESSBAR, pb); - evas_object_show(pb); - - r = _start_scan(priv); - if (r != 0) { - _ERR("start scan failed"); - return; - } -} - -/** - * Resume the application. - * - * @param[in] base: the layout of the view - */ -static void _resume(Evas_Object *base) -{ - if (!base) { - _ERR("Invalid argument"); - return; - } - - evas_object_show(base); -} - -/** - * Pause the view. - * - * Hide the layout - * - * @param[in] base: the layout of the view - */ -static void _pause(Evas_Object *base) -{ - if (!base) { - _ERR("Invalid argument"); - return; - } - - evas_object_hide(base); -} - -/** - * Called after the main loop of the view exits. - * - * Delete the layout and release the resourse - * - * @param[in] base: the layout of the view - */ -static void _terminate(Evas_Object *base) -{ - struct _data *priv; - int r; - - if (!base) { - _ERR("Invalid argument"); - return; - } - - priv = _GET_PRIV(base); - if (!priv) { - _ERR("Data get failed"); - return; - } - - r = tv_scan_fini(priv->tvs); - if (r != 0) - _ERR("tv_scan_fini failed"); - - if (priv->base) - evas_object_del(priv->base); - - free(priv); -} - -/** - * This struct is for registering the callbacks for the view - */ -static struct view_class _vclass = { - VIEW_SEARCH, - _create, - _update, - _resume, - _pause, - _terminate, -}; - - /** - * Returns current view_class which implements the search view's life cycle - * - * @return view_class - */ -struct view_class *view_searchpage_get_vclass(void) -{ - return &_vclass; -} diff --git a/ug/channel/src/viewmgr_auto_program.cpp b/ug/channel/src/viewmgr_auto_program.cpp deleted file mode 100644 index 183c768..0000000 --- a/ug/channel/src/viewmgr_auto_program.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include "ug_auto_program.h" -#include "viewmgr_auto_program.h" -#include "dbg.h" -#include "defs.h" - -struct _viewinfo { - struct view_class *vclass; - Evas_Object *base; -}; - -/** - * Initialize the data handler view manager - * - * Viewmgr struct will be created. - * - * @param[in] win: window object - * @return The handler to the struct object of managing the view. - */ -struct viewmgr *viewmgr_init(Evas_Object *win) -{ - struct viewmgr *vmgr; - - if (!win) { - _ERR("Invalid argument"); - return NULL; - } - - vmgr = (struct viewmgr *) calloc(1, sizeof(*vmgr)); - if (!vmgr) { - _ERR("calloc vmgr failed."); - return NULL; - } - - vmgr->win = win; - - return vmgr; -} - -/** - * Invoked before channel ug is terminated - * Each view will be poped, and the related info about each view will be - * released in this function, and the viewmgr struct will be released. - * - * @param[in] vmgr: the handler to the struct object of managing the view - */ -void viewmgr_fini(struct viewmgr *vmgr) -{ - int i; - int count; - - if (!vmgr) { - _ERR("Invalid argument"); - return; - } - - count = eina_list_count(vmgr->vlist); - for (i = count; i > 0; i--) - viewmgr_pop(vmgr); - - free(vmgr); -} - -/** - * Evas_Object_Event_Cb type callback for handling deletion event - * - * Delete the layout and release the resouse - * - * @param[in] data: the data handler for view - * @param[in] e: evas handler - * @param[in] obj: the corresponding object which the deletion event occurred - * @param[in] ev : event information - */ -static void _view_deleted(void *data, Evas *e, Evas_Object *obj, void *ev) -{ - struct view_class *vclass; - - if (!data || !obj) { - _ERR("Invalid argument"); - return; - } - - vclass = (struct view_class *) data; - - if (vclass->terminate) - vclass->terminate(obj); -} - -/** - * Push the view in the top - * - * In push function, layout of current view will be deleted, - * and the related info will be released in this channel ug, - * and a new view will be created. - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @param[in] vclass: the basic struct for managing each view, it contains both - * functions and variables requried in each view. It has basic functions like - * create/show/hide/terminate - * @param[in] data: data handler of each view - * @return 0 on success otherwise -1 - */ -int viewmgr_push(struct viewmgr *vmgr, struct view_class *vclass, void *data) -{ - Evas_Object *base; - struct _viewinfo *vinfo; - - if (!vmgr || !vmgr->win || - !vclass || !vclass->create || !data) { - _ERR("Invalid argument"); - return -1; - } - - base = vclass->create(vmgr, data); - if (!base) { - _ERR("create base failed"); - return -1; - } - - evas_object_event_callback_add(base, EVAS_CALLBACK_DEL, - _view_deleted, vclass); - - if (vclass->update) - vclass->update(base); - - vinfo = (struct _viewinfo *) eina_list_data_get(vmgr->vlist); - if (vinfo && vinfo->base) - vinfo->vclass->pause(vinfo->base); - - vinfo = (struct _viewinfo *) calloc(1, sizeof(*vinfo)); - if (!vinfo) { - _ERR("calloc failed."); - return -1; - } - - vinfo->base = base; - vinfo->vclass = vclass; - - vmgr->vlist = eina_list_prepend(vmgr->vlist, vinfo); - - return 0; -} - -/** - * Pop the view and remove the view information of the popped item in Eina_List - * - * In pop function, current view layout will be deleted, - * and the related resource will be released in this channel ug. - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @return 0 on success otherwise -1 - */ -int viewmgr_pop(struct viewmgr *vmgr) -{ - struct _viewinfo *vinfo; - - if (!vmgr || !vmgr->vlist) { - _ERR("Invalid argument"); - return -1; - } - - vinfo = (struct _viewinfo *) eina_list_data_get(vmgr->vlist); - if (!vinfo || !vinfo->base) - return -1; - - evas_object_del(vinfo->base); - vinfo->base = NULL; - - vmgr->vlist = eina_list_remove_list(vmgr->vlist, vmgr->vlist); - free(vinfo); - - viewmgr_resume(vmgr); - - return 0; -} - -/** - * Resume the paused view - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @return 0 on success otherwise -1 - */ -int viewmgr_resume(struct viewmgr *vmgr) -{ - struct _viewinfo *vinfo; - struct view_class *vclass; - - if (!vmgr || !vmgr->vlist) { - _ERR("Invalid argument"); - return -1; - } - - vinfo = (struct _viewinfo *) eina_list_data_get(vmgr->vlist); - if (!vinfo || !vinfo->vclass || !vinfo->base) - return -1; - - vclass = vinfo->vclass; - if (vclass->resume) - vclass->resume(vinfo->base); - - return 0; -} - -/** - * Pause the view - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @return 0 on success otherwise -1 - */ -int viewmgr_pause(struct viewmgr *vmgr) -{ - struct _viewinfo *vinfo; - struct view_class *vclass; - - if (!vmgr || !vmgr->vlist) { - _ERR("Invalid argument"); - return -1; - } - - vinfo = (struct _viewinfo *) eina_list_data_get(vmgr->vlist); - - if (!vinfo || !vinfo->vclass || !vinfo->base) - return -1; - - vclass = vinfo->vclass; - if (vclass->pause) - vclass->pause(vinfo->base); - - return 0; -} - -/** - * Get the eina list from viewmgr - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @return The eina list in viewmgr - */ -Eina_List *viewmgr_get_list(struct viewmgr *vmgr) -{ - if (!vmgr) { - _ERR("Invalid argument"); - return NULL; - } - - return vmgr->vlist; -} - -/** - * Get the window object from viewmgr struct - * - * @param[in] vmgr: the handler to the struct object of managing the view - * @return The window object on success otherwise NULL - */ -Evas_Object *viewmgr_get_win(struct viewmgr *vmgr) -{ - if (!vmgr) { - _ERR("Invalid argument"); - return NULL; - } - - return vmgr->win; -} diff --git a/ug/include/TVServiceMgr.h b/ug/include/TVServiceMgr.h new file mode 100644 index 0000000..550e01c --- /dev/null +++ b/ug/include/TVServiceMgr.h @@ -0,0 +1,34 @@ +#ifndef __TVSERVICEMGR_H__ +#define __TVSERVICEMGR_H__ + +enum antenna_mode { + SCAN_TYPE_INVALID = -1, + SCAN_TYPE_ALL, + SCAN_TYPE_CABLE, + SCAN_TYPE_AIR +}; + +class CTVServiceMgr { +private: + static CTVServiceMgr *instance; + struct STVServiceMgr *m; + +private: + CTVServiceMgr(void) : m(0) {} + virtual ~CTVServiceMgr() {} + +public: + static bool Initialize(void); + static void Finalize(void); + static CTVServiceMgr *GetInstance(void); + + bool Start(void); + bool Pause(void); + bool Resume(void); + bool Stop(void); + bool GetAllChannel(void); + unsigned int GetServiceType(void); + bool IsStopped(void); +}; + +#endif /* __TVSERVICEMGR_H__ */ diff --git a/ug/network/CMakeLists.txt b/ug/network/CMakeLists.txt index 0fac965..b930c12 100644 --- a/ug/network/CMakeLists.txt +++ b/ug/network/CMakeLists.txt @@ -24,18 +24,6 @@ SET(UG_NETWORK_EDJ_THEME "ug-network-settings-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_NETWORK_PKGS REQUIRED - eina - edje - evas - elementary - aul - glib-2.0 - ui-gadget-1 - vconf - capi-appfw-application - capi-network-wifi - capi-network-connection - application-common ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_NETWORK_PKGS_LDFLAGS}") diff --git a/ug/proxy/CMakeLists.txt b/ug/proxy/CMakeLists.txt index 20da480..5f38a6d 100644 --- a/ug/proxy/CMakeLists.txt +++ b/ug/proxy/CMakeLists.txt @@ -24,17 +24,6 @@ SET(UG_PROXY_EDJ_THEME "ug-proxy-settings-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_PROXY_PKGS REQUIRED - eina - edje - evas - elementary - aul - glib-2.0 - ui-gadget-1 - vconf - capi-appfw-application - capi-network-wifi - capi-network-connection ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_PROXY_PKGS_LDFLAGS}") diff --git a/ug/proxy/src/ug_proxy_settings.cpp b/ug/proxy/src/ug_proxy_settings.cpp index 892934e..db8972e 100644 --- a/ug/proxy/src/ug_proxy_settings.cpp +++ b/ug/proxy/src/ug_proxy_settings.cpp @@ -34,9 +34,11 @@ extern "C" { #endif struct _ug_data { + ui_gadget_h ug; + Evas_Object *win; Evas_Object *base; - ui_gadget_h ug; + CViewMgr *pViewMgr; CProxyMainView *pProxyMainView; }; diff --git a/ug/src/TVServiceMgr.cpp b/ug/src/TVServiceMgr.cpp new file mode 100644 index 0000000..3c821f8 --- /dev/null +++ b/ug/src/TVServiceMgr.cpp @@ -0,0 +1,296 @@ +#include +#include +#include "dbg.h" +//#include "tv_service_proxy.h" +#include "AppCommon.h" + +#include "TVServiceMgr.h" + +#define SIGNAL_HANDLER_INTERVAL 0.1 + +CTVServiceMgr *CTVServiceMgr::instance = NULL; + +enum tv_scan_state { + SCAN_STATE_READY, + SCAN_STATE_SEARCHING, + SCAN_STATE_PAUSED, + SCAN_STATE_STOPPING, + SCAN_STATE_MAX +}; + + +struct tv_scan_result { + unsigned int air_dtv; + unsigned int cable_dtv; + unsigned int air_atv; + unsigned int cable_atv; +}; + + +struct STVServiceMgr { + //struct tv_scan_cbs cbs; + enum tv_scan_state state; + enum antenna_mode set_mode; +#if 0 + TvServiceScan service_scan; + TvServiceScanType scan_type; +#endif + int ch_count; + int ch_num; + int total_ch; + struct tv_scan_result res; + int is_stopped; + Eina_List *signal_queue; + Ecore_Timer *signal_timer; +}; + +struct _signal_info { +#if 0 + TvServiceScanType scan_type; + TvServiceScanEvent signal; + TvServiceScanEventData signal_data; +#endif +}; + + +bool CTVServiceMgr::Initialize(void) +{ + ASSERT(!instance); + + instance = new CTVServiceMgr; + if(!instance) + return false; + + instance->m = new STVServiceMgr; + if(instance->m == NULL) return false; + +#if 0 + struct tv_scan *tvs; + TvServiceScan scan; + TvServiceScanType type; + gint result; + int r; + + tvs = calloc(1, sizeof(*tvs)); + if (!tvs) { + _ERR("calloc failed"); + return NULL; + } + + r = _get_scan_mode(mode, &type); + if (r == -1) { + _ERR("Get scan mode failed"); + free(tvs); + return NULL; + } + + result = tv_service_scan_create(&scan, type); + if (result != TVS_ERROR_OK) { + _ERR("Create Scan failed"); + free(tvs); + return NULL; + } + + tvs->service_scan = scan; + tvs->scan_type = type; + tvs->set_mode = mode; + tvs->state = SCAN_STATE_READY; + + return tvs; +#endif + return NULL; + +} + + +void CTVServiceMgr::Finalize(void) +{ + if(!instance) + return; + ASSERT(instance->m); +#if 0 + struct _signal_info *sinfo; + + if (!tvs) { + _ERR("Invalid argument"); + return -1; + } + + if (tvs->state != SCAN_STATE_READY) + tv_scan_stop(tvs); + + if (tvs->signal_timer) + ecore_timer_del(tvs->signal_timer); + + EINA_LIST_FREE(tvs->signal_queue, sinfo) + free(sinfo); + + tv_service_scan_destroy(tvs->service_scan); + free(tvs); + +#endif + delete instance->m; + delete instance; + instance = NULL; +} + + +CTVServiceMgr *CTVServiceMgr::GetInstance(void) +{ + return instance; +} + + +bool CTVServiceMgr::Start(void) +{ + ASSERT(m); +#if 0 + gint result; + + if (!tvs || !tvs->service_scan) { + _ERR("Invalid argument"); + return -1; + } + + if (tvs->state != SCAN_STATE_READY) { + _ERR("unable state to start scan"); + return -1; + } + + result = tv_service_scan_register_callback(tvs->service_scan, + _signal_received, (gpointer)tvs); + if (result != TVS_ERROR_OK) { + _ERR("register callback failed"); + return -1; + } + + result = tv_service_scan_start(tvs->service_scan); + if (result != TVS_ERROR_OK) { + _ERR("scan start failed"); + return -1; + } + + tvs->state = SCAN_STATE_SEARCHING; + tvs->is_stopped = 0; + tvs->ch_count = 0; + memset(&tvs->res, 0x00, sizeof(tvs->res)); + + return 0; +#endif + return false; +} + + +bool CTVServiceMgr::Pause(void) +{ + ASSERT(m); +#if 0 + gint result; + + if (!tvs || !tvs->service_scan) { + _ERR("Invalid argument"); + return -1; + } + + if (tvs->state != SCAN_STATE_SEARCHING) { + _ERR("unable state to pause scan"); + return -1; + } + + result = tv_service_scan_pause(tvs->service_scan); + if (result != TVS_ERROR_OK) { + _ERR("Pause Scan failed"); + return -1; + } + + tvs->state = SCAN_STATE_PAUSED; + +#endif + return false; +} + + +bool CTVServiceMgr::Resume(void) +{ + ASSERT(m); +#if 0 + gint result; + + if (!tvs || !tvs->service_scan) { + _ERR("Invalid argument"); + return -1; + } + + if (tvs->state != SCAN_STATE_PAUSED) { + _ERR("unable state to resume scan"); + return -1; + } + + result = tv_service_scan_resume(tvs->service_scan); + if (result != TVS_ERROR_OK) { + _ERR("resume Scan failed"); + return -1; + } + + tvs->state = SCAN_STATE_SEARCHING; + +#endif + return false; +} + + +bool CTVServiceMgr::Stop(void) +{ + ASSERT(m); +#if 0 + gint result; + + if (!tvs) { + _ERR("Invalid argument"); + return -1; + } + + if (tvs->state == SCAN_STATE_READY) { + _ERR("unable state to stop scan"); + return -1; + } + + result = tv_service_scan_stop(tvs->service_scan); + if (result != TVS_ERROR_OK) { + _ERR("Create Scan failed"); + return -1; + } + + tvs->state = SCAN_STATE_STOPPING; + tvs->is_stopped = 1; + +#endif + return false; +} + + +bool CTVServiceMgr::GetAllChannel(void) +{ + ASSERT(m); + + return m->total_ch; +} + + +unsigned int CTVServiceMgr::GetServiceType(void) +{ + ASSERT(m); + +#if 0 + return &tvs->res; +#endif + return -1; +} + + +bool CTVServiceMgr::IsStopped(void) +{ + ASSERT(m); + + return m->is_stopped; +} diff --git a/ug/system/clock/CMakeLists.txt b/ug/system/clock/CMakeLists.txt index c83eebd..7223555 100755 --- a/ug/system/clock/CMakeLists.txt +++ b/ug/system/clock/CMakeLists.txt @@ -21,12 +21,6 @@ SET(UG_CLOCK_EDJ_THEME "ug_clock_theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_CLOCK_PKGS REQUIRED - eina - edje - evas - elementary - aul - ui-gadget-1 sysman ) diff --git a/ug/wifi-direct/CMakeLists.txt b/ug/wifi-direct/CMakeLists.txt index e6717bd..177c89d 100644 --- a/ug/wifi-direct/CMakeLists.txt +++ b/ug/wifi-direct/CMakeLists.txt @@ -25,17 +25,6 @@ SET(UG_WIFI_DIRECT_EDJ_THEME "ug-wifi-direct-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_WIFI_DIRECT_PKGS REQUIRED - eina - edje - evas - elementary - aul - glib-2.0 - ui-gadget-1 - vconf - capi-appfw-application - capi-network-wifi - capi-network-connection wifi-direct ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_WIFI_DIRECT_PKGS_LDFLAGS}") diff --git a/ug/wifi-direct/src/WifiDirectMainView.cpp b/ug/wifi-direct/src/WifiDirectMainView.cpp old mode 100644 new mode 100755 index 77af00d..3a6b1af --- a/ug/wifi-direct/src/WifiDirectMainView.cpp +++ b/ug/wifi-direct/src/WifiDirectMainView.cpp @@ -440,7 +440,7 @@ void CWifiDirectMainView::m_OnGenlistItemSelected(Evas_Object *obj, void *event_ //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); Connect(layout, 15); - elm_object_focus_set(btn[0], true); + elm_object_focus_set(btn[0], EINA_TRUE); } @@ -495,8 +495,8 @@ bool CWifiDirectMainView::m_CreateButton(void) return false; } - elm_object_focus_allow_set(on_btn, true); - elm_object_focus_set(on_btn, true); + elm_object_focus_allow_set(on_btn, EINA_TRUE); + elm_object_focus_set(on_btn, EINA_TRUE); elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP); elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT); @@ -609,7 +609,7 @@ bool CWifiDirectMainView::m_CreateDeviceListView(void) m_FillContentPart(m->genlist); - elm_object_focus_set(m->btn_refresh, true); + elm_object_focus_set(m->btn_refresh, EINA_TRUE); return true; } @@ -877,7 +877,7 @@ bool CWifiDirectMainView::m_CreateWifiDirectScan(void) m->scan_pb = pb; m->btn_stop = btn; - elm_object_focus_set(m->btn_stop, true); + elm_object_focus_set(m->btn_stop, EINA_TRUE); #if 0 evas_object_event_callback_add(m->btn_stop, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv); #endif @@ -928,7 +928,7 @@ void CWifiDirectMainView::m_ShowActionBtn(void) bool CWifiDirectMainView::m_UpdateGenlistItem(device_info *info) { - Eina_Bool exist; + bool exist; if (!info) { _ERR("The param is invalid."); @@ -1015,7 +1015,7 @@ bool CWifiDirectMainView::m_CreateReqPopupLayout(void) m->req_popup = layout; - elm_object_focus_set(btn[DIRECT_ON], true); + elm_object_focus_set(btn[DIRECT_ON], EINA_TRUE); //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); Connect(layout, 12); @@ -1249,7 +1249,7 @@ void CWifiDirectMainView::OnMouseClicked(int id, Evas_Object *obj) return; } - elm_object_focus_allow_set(layout, true); + elm_object_focus_allow_set(layout, EINA_TRUE); box = util_add_box(layout, PART_SWALLOW_CONTENT); if (!box) { @@ -1293,7 +1293,7 @@ void CWifiDirectMainView::OnMouseClicked(int id, Evas_Object *obj) //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv); Connect(layout, 16); - elm_object_focus_set(btn[0], true); + elm_object_focus_set(btn[0], EINA_TRUE); } break; case 2: -- 2.7.4 From cde66261a0be4cfc8a70fc0333303b23e1ae44d1 Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Mon, 6 Apr 2015 13:56:30 +0900 Subject: [PATCH 05/16] Refactoring /ug/system Done Change-Id: I9c40b012daabdf2b042e8ee874b46d94ff5587b1 Signed-off-by: JuWan Kim --- ug/proxy/src/ProxyMainView.cpp | 3 - ug/system/clock/CMakeLists.txt | 9 +- ug/system/clock/edje/ug_clock.edc | 2 +- ug/system/clock/edje/ug_clock_theme.edc | 2 +- ug/system/clock/include/ClockMainView.h | 31 + ug/system/clock/include/ClockSpinControlView.h | 33 + ug/system/clock/include/ClockSublistView.h | 30 + ug/system/clock/include/ClockTimeSpinControlView.h | 33 + .../clock/include/{ug_clock_define.h => defs.h} | 6 + ug/system/clock/include/ug_clock_spin_control.h | 26 - ug/system/clock/include/ug_clock_sublist.h | 24 - .../clock/include/ug_clock_time_spin_control.h | 25 - .../clock/include/{ug_clock_utils.h => util.h} | 0 ug/system/clock/src/ClockMainView.cpp | 464 +++++++++ ug/system/clock/src/ClockSpinControlView.cpp | 534 ++++++++++ ug/system/clock/src/ClockSublistView.cpp | 363 +++++++ ug/system/clock/src/ClockTimeSpinControlView.cpp | 629 +++++++++++ ug/system/clock/src/ug_clock.cpp | 1091 +------------------- ug/system/clock/src/ug_clock_spin_control.cpp | 788 -------------- ug/system/clock/src/ug_clock_sublist.cpp | 515 --------- ug/system/clock/src/ug_clock_time_spin_control.cpp | 840 --------------- .../clock/src/{ug_clock_utils.cpp => util.cpp} | 2 +- 22 files changed, 2169 insertions(+), 3281 deletions(-) create mode 100644 ug/system/clock/include/ClockMainView.h create mode 100644 ug/system/clock/include/ClockSpinControlView.h create mode 100644 ug/system/clock/include/ClockSublistView.h create mode 100644 ug/system/clock/include/ClockTimeSpinControlView.h rename ug/system/clock/include/{ug_clock_define.h => defs.h} (93%) delete mode 100755 ug/system/clock/include/ug_clock_spin_control.h delete mode 100755 ug/system/clock/include/ug_clock_sublist.h delete mode 100755 ug/system/clock/include/ug_clock_time_spin_control.h rename ug/system/clock/include/{ug_clock_utils.h => util.h} (100%) create mode 100644 ug/system/clock/src/ClockMainView.cpp create mode 100644 ug/system/clock/src/ClockSpinControlView.cpp create mode 100644 ug/system/clock/src/ClockSublistView.cpp create mode 100644 ug/system/clock/src/ClockTimeSpinControlView.cpp delete mode 100644 ug/system/clock/src/ug_clock_spin_control.cpp delete mode 100644 ug/system/clock/src/ug_clock_sublist.cpp delete mode 100644 ug/system/clock/src/ug_clock_time_spin_control.cpp rename ug/system/clock/src/{ug_clock_utils.cpp => util.cpp} (99%) diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp index df0f7f1..365307a 100644 --- a/ug/proxy/src/ProxyMainView.cpp +++ b/ug/proxy/src/ProxyMainView.cpp @@ -615,9 +615,6 @@ bool CProxyMainView::m_CreateMethodManualBtn(void) bool CProxyMainView::m_CreateMethodNoneBtn(void) { - Evas_Object *box; - box = m->box; - if(!m_CreateMethodBoxBtn(m->method_btn, _(TXT_MOTHED), _(TXT_MOTHED_NONE), BTN_ONE_LINE)) { _ERR("add method btn failed."); return false; diff --git a/ug/system/clock/CMakeLists.txt b/ug/system/clock/CMakeLists.txt index 7223555..cd86ddc 100755 --- a/ug/system/clock/CMakeLists.txt +++ b/ug/system/clock/CMakeLists.txt @@ -34,10 +34,11 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") SET(SRCS src/ug_clock.cpp - src/ug_clock_spin_control.cpp - src/ug_clock_sublist.cpp - src/ug_clock_utils.cpp - src/ug_clock_time_spin_control.cpp + src/util.cpp + src/ClockMainView.cpp + src/ClockSublistView.cpp + src/ClockSpinControlView.cpp + src/ClockTimeSpinControlView.cpp ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/ug/system/clock/edje/ug_clock.edc b/ug/system/clock/edje/ug_clock.edc index dd8e5e0..96de190 100755 --- a/ug/system/clock/edje/ug_clock.edc +++ b/ug/system/clock/edje/ug_clock.edc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "../include/ug_clock_define.h" +#include "../include/defs.h" collections { group { diff --git a/ug/system/clock/edje/ug_clock_theme.edc b/ug/system/clock/edje/ug_clock_theme.edc index 627e454..9a5cd8b 100755 --- a/ug/system/clock/edje/ug_clock_theme.edc +++ b/ug/system/clock/edje/ug_clock_theme.edc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "../include/ug_clock_define.h" +#include "../include/defs.h" collections { #include "widgets/button.edc" diff --git a/ug/system/clock/include/ClockMainView.h b/ug/system/clock/include/ClockMainView.h new file mode 100644 index 0000000..b9eb2f5 --- /dev/null +++ b/ug/system/clock/include/ClockMainView.h @@ -0,0 +1,31 @@ +#ifndef __CLOCK_MAIN_VIEW_H__ +#define __CLOCK_MAIN_VIEW_H__ + +class CClockMainView : public CBaseView, public IMouseClickedListener { +private : + struct SClockMainView *m; + + bool m_AddCloseBtn(void); + bool m_AddClockSublist(void); + void m_RefreshTimeBtnText(Evas_Object *btn, int *time); + void m_RefreshBtnText(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CClockMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CClockMainView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CLOCK_MAIN_VIEW_H__ */ + diff --git a/ug/system/clock/include/ClockSpinControlView.h b/ug/system/clock/include/ClockSpinControlView.h new file mode 100644 index 0000000..10a9eda --- /dev/null +++ b/ug/system/clock/include/ClockSpinControlView.h @@ -0,0 +1,33 @@ +#ifndef __CLOCK_SPINCONTROL_VIEW_H__ +#define __CLOCK_SPINCONTROL_VIEW_H__ + +class CClockSpinControlView : public CBaseView, public IMouseClickedListener { +private : + struct SClockSpinControlView *m; + + Evas_Object *m_AddArrowBtn(Evas_Object *obj, int flag); + bool m_AddDateSpin(void); + void m_InitDateSpin(void); + + void m_UpdateDateValue(Evas_Object *spin, int spin_idx); + bool m_AddSpin(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CClockSpinControlView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CClockSpinControlView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CLOCK_SPINCONTROL_VIEW_H__ */ diff --git a/ug/system/clock/include/ClockSublistView.h b/ug/system/clock/include/ClockSublistView.h new file mode 100644 index 0000000..90a76c1 --- /dev/null +++ b/ug/system/clock/include/ClockSublistView.h @@ -0,0 +1,30 @@ +#ifndef __CLOCK_SUBLIST_VIEW_H__ +#define __CLOCK_SUBLIST_VIEW_H__ + +class CClockSublistView : public CBaseView, public IMouseClickedListener { +private : + struct SClockSublistView *m; + + bool m_AddSublist(void); + bool m_AddSublistBtns(void); + void m_SetSublistInitValue(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CClockSublistView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CClockSublistView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CLOCK_SUBLIST_VIEW_H__ */ diff --git a/ug/system/clock/include/ClockTimeSpinControlView.h b/ug/system/clock/include/ClockTimeSpinControlView.h new file mode 100644 index 0000000..cc8bd4e --- /dev/null +++ b/ug/system/clock/include/ClockTimeSpinControlView.h @@ -0,0 +1,33 @@ +#ifndef __CLOCK_TIME_SPINCONTROL_VIEW_H__ +#define __CLOCK_TIME_SPINCONTROL_VIEW_H__ + +class CClockTimeSpinControlView : public CBaseView, public IMouseClickedListener { +private : + struct SClockTimeSpinControlView *m; + + Evas_Object *m_AddArrowBtn(Evas_Object *obj, int flag); + void m_UpdateTimeValue(Evas_Object *btn, int btn_idx); + bool m_AddTimeSpinWithAMPM(void); + bool m_AddTimeSpinWithoutAMPM(void); + bool m_AddTimeSpinBtns(void); + bool m_AddTimeSpin(void); + +protected : + virtual void t_OnShow(void); + virtual void t_OnUpdate(void *data); + virtual void t_OnHide(void); + +public : + CClockTimeSpinControlView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {} + virtual ~CClockTimeSpinControlView() {} + + virtual bool Create(void *data); + virtual void Destroy(void); + virtual Evas_Object* Base(void); + + virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + virtual void OnMouseClicked(int id, Evas_Object *obj); +}; + +#endif /* __CLOCK_TIME_TimeSpinControl_VIEW_H__ */ diff --git a/ug/system/clock/include/ug_clock_define.h b/ug/system/clock/include/defs.h similarity index 93% rename from ug/system/clock/include/ug_clock_define.h rename to ug/system/clock/include/defs.h index dac997f..11ae5f9 100755 --- a/ug/system/clock/include/ug_clock_define.h +++ b/ug/system/clock/include/defs.h @@ -22,6 +22,12 @@ #define AM "AM" #define PM "PM" +/* view */ +#define CLOCK_MAIN_VIEW "CLOCK_MAIN_VIEW" +#define CLOCK_SUBLIST_VIEW "CLOCK_SUBLIST_VIEW" +#define CLOCK_SPINCONTROL_VIEW "CLOCK_SPINCONTROL_VIEW" +#define CLOCK_TIME_SPINCONTROL_VIEW "CLOCK_TIME_SPINCONTROL_VIEW" + /* definitions for ug_clock.edc */ /* UG_CLOCK_GRP */ #define UG_CLOCK_GRP "main" diff --git a/ug/system/clock/include/ug_clock_spin_control.h b/ug/system/clock/include/ug_clock_spin_control.h deleted file mode 100755 index e8b7f9c..0000000 --- a/ug/system/clock/include/ug_clock_spin_control.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __UG_CLOCK_SPIN_CONTROL_H__ -#define __UG_CLOCK_SPIN_CONTROL_H__ - -#include - -void view_spin_control_create(Evas_Object *win, - Evas_Object *ug_base); - -#endif /* __UG_CLOCK_SPIN_CONTROL_H__ */ diff --git a/ug/system/clock/include/ug_clock_sublist.h b/ug/system/clock/include/ug_clock_sublist.h deleted file mode 100755 index a71dea1..0000000 --- a/ug/system/clock/include/ug_clock_sublist.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __UG_CLOCK_SUBLIST_H__ -#define __UG_CLOCK_SUBLIST_H__ - -#include - -void view_sublist_create(Evas_Object *win, Evas_Object *ug_base); - -#endif /* __UG_CLOCK_SUBLIST_H__ */ diff --git a/ug/system/clock/include/ug_clock_time_spin_control.h b/ug/system/clock/include/ug_clock_time_spin_control.h deleted file mode 100755 index d9f920f..0000000 --- a/ug/system/clock/include/ug_clock_time_spin_control.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __UG_CLOCK_TIME_SPIN_CONTROL_H__ -#define __UG_CLOCK_TIME_SPIN_CONTROL_H__ - -#include - -void view_time_spin_ctrl_create(Evas_Object *win, - Evas_Object *ug_base); - -#endif /* __UG_CLOCK_TIME_SPIN_CONTROL_H__ */ diff --git a/ug/system/clock/include/ug_clock_utils.h b/ug/system/clock/include/util.h similarity index 100% rename from ug/system/clock/include/ug_clock_utils.h rename to ug/system/clock/include/util.h diff --git a/ug/system/clock/src/ClockMainView.cpp b/ug/system/clock/src/ClockMainView.cpp new file mode 100644 index 0000000..e63ca26 --- /dev/null +++ b/ug/system/clock/src/ClockMainView.cpp @@ -0,0 +1,464 @@ +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ClockMainView.h" + +#define CLOCK_SUBLIST_NULL_BTNS 2 +#define UG_CLOCK_DATA_ID "ug_clock_data" + +struct SClockMainView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *close_btn; + Evas_Object *date_btn; + Evas_Object *switch_btn; + Evas_Object *time_btn; + Evas_Object *sublist_box; + Evas_Object *cur_btn; + + unsigned int date[DATE_MAX]; + int mode; + int time[TIME_MAX]; + + CViewMgr *pViewMgr; +}; + + +bool CClockMainView::m_AddCloseBtn(void) +{ + m->close_btn = utils_add_button(m->base); + if (!m->close_btn) { + _ERR("elm add button failed."); + return false; + } + + elm_object_style_set(m->close_btn, BTN_STYLE_CLOSE_BTN); + elm_object_text_set(m->close_btn, BTN_TEXT_CLOSE); + elm_object_part_content_set(m->base, SWALLOW_CLOSE_BTN, m->close_btn); + + //evas_object_smart_callback_add(m->close_btn, "clicked", _close_btn_clicked_cb, data); + //evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_close_btn_cb, data); + Connect(m->close_btn, 1, TYPE_CLICKED | TYPE_KEY_DOWN); +#if 0 + evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_MOUSE_IN, _close_btn_mouse_in_cb, data); + evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_MOUSE_OUT, _close_btn_mouse_out_cb, data); +#endif + return true; +} + + +bool CClockMainView::m_AddClockSublist(void) +{ + m->sublist_box = utils_add_box(m->base); + if (!m->sublist_box) { + _ERR("add clock sublist box failed."); + return false; + } + + m->date_btn = utils_add_button(m->base); + if (!m->date_btn) { + _ERR("add button failed."); + evas_object_del(m->sublist_box); + return NULL; + } + + elm_object_style_set(m->date_btn, BTN_STYLE_LIST_BTN); + elm_object_text_set(m->date_btn, BTN_TEXT_DATE); + + elm_box_pack_end(m->sublist_box, m->date_btn); + elm_object_focus_set(m->date_btn, EINA_TRUE); + utils_get_date_value(m->date); + + char buf[BUF_SIZE]; + snprintf(buf, sizeof(buf), "%02d / %02d / %04d", m->date[DATE_MONTH], m->date[DATE_DAY], m->date[DATE_YEAR]); + elm_object_part_text_set(m->date_btn, BTN_PART_VALUE, (const char *)buf); + + //evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); + //evas_object_smart_callback_add(m->date_btn, "clicked", _date_btn_clicked_cb, data); + Connect(m->date_btn, 2, TYPE_CLICKED | TYPE_KEY_DOWN); +#if 0 + evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_MOUSE_IN, _date_btn_mouse_in_cb, NULL); + evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_MOUSE_OUT, _date_btn_mouse_out_cb, NULL); +#endif + + m->switch_btn = utils_add_button(m->base); + if (!m->switch_btn) { + _ERR("add button failed."); + evas_object_del(m->date_btn); + evas_object_del(m->sublist_box); + return NULL; + } + + elm_object_style_set(m->switch_btn, BTN_STYLE_LIST_BTN); + elm_object_text_set(m->switch_btn, BTN_TEXT_24HOUR_TIME); + + elm_box_pack_end(m->sublist_box, m->switch_btn); + + /* Set ON/OFF for switch button. */ + if(utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &m->mode)) { + _ERR("vconf get value failed."); + return false; + } + + if (!m->mode) + elm_object_part_text_set(m->switch_btn, BTN_PART_VALUE, OFF); + else + elm_object_part_text_set(m->switch_btn, BTN_PART_VALUE, ON); + + //evas_object_event_callback_add(m->switch_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); + //evas_object_smart_callback_add(m->switch_btn, "clicked", _switch_btn_clicked_cb, data); + Connect(m->switch_btn, 3, TYPE_CLICKED | TYPE_KEY_DOWN); + +#if 0 + evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_IN, _switch_btn_mouse_in_cb, NULL); + evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_OUT, _switch_btn_mouse_out_cb, NULL); +#endif + + m->time_btn = utils_add_button(m->base); + if (!m->time_btn) { + _ERR("add time button failed."); + evas_object_del(m->switch_btn); + evas_object_del(m->date_btn); + evas_object_del(m->sublist_box); + return NULL; + } + + elm_object_style_set(m->time_btn, BTN_STYLE_LIST_BTN); + elm_object_text_set(m->time_btn, BTN_TEXT_TIME); + + elm_box_pack_end(m->sublist_box, m->time_btn); + + /* Set hour : minute : AM/PM for time button. */ + utils_get_time_value(m->time); + + m_RefreshTimeBtnText(m->time_btn, m->time); + + //evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); + //evas_object_smart_callback_add(m->time_btn, "clicked", _time_btn_clicked_cb, data); + Connect(m->time_btn, 4, TYPE_CLICKED | TYPE_KEY_DOWN); +#if 0 + evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_MOUSE_IN, _time_btn_mouse_in_cb, NULL); + evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_MOUSE_OUT, _time_btn_mouse_out_cb, NULL); +#endif + + Evas_Object *null_btn; + Evas_Object *last_btn; + + for (int idx = 0; idx < CLOCK_SUBLIST_NULL_BTNS; idx++) { + null_btn = utils_add_button(m->base); + if (!null_btn) { + _ERR("add null button failed."); + evas_object_del(m->time_btn); + evas_object_del(m->switch_btn); + evas_object_del(m->date_btn); + evas_object_del(m->sublist_box); + } + + elm_object_style_set(null_btn, BTN_STYLE_LIST_BTN); + elm_box_pack_end(m->sublist_box, null_btn); + } + + last_btn = utils_add_button(m->base); + if (!last_btn) { + _ERR("add last button failed."); + evas_object_del(m->time_btn); + evas_object_del(m->switch_btn); + evas_object_del(m->date_btn); + evas_object_del(m->sublist_box); + } + + elm_object_style_set(last_btn, BTN_STYE_LAST_BTN); + elm_object_part_content_set(m->base, SWALLOW_CLOCK_LAST, last_btn); + + Evas_Object *dbtn, *sbtn, *tbtn, *cbtn; + + dbtn = m->date_btn; + sbtn = m->switch_btn; + tbtn = m->time_btn; + cbtn = m->close_btn; + + elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(dbtn, sbtn, ELM_FOCUS_DOWN); + /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for date_btn */ + elm_object_focus_next_object_set(dbtn, cbtn, ELM_FOCUS_RIGHT); + + elm_object_focus_next_object_set(sbtn, tbtn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(sbtn, dbtn, ELM_FOCUS_UP); + /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for switch_btn */ + elm_object_focus_next_object_set(sbtn, cbtn, ELM_FOCUS_RIGHT); + + elm_object_focus_next_object_set(tbtn, tbtn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(tbtn, sbtn, ELM_FOCUS_UP); + /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for time_btn */ + elm_object_focus_next_object_set(tbtn, cbtn, ELM_FOCUS_RIGHT); + + elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(cbtn, dbtn, ELM_FOCUS_LEFT); + elm_object_part_content_set(m->base, SWALLOW_CLOCK_LIST, m->sublist_box); + + return true; +} + + +void CClockMainView::m_RefreshTimeBtnText(Evas_Object *btn, int *time) +{ + int mode; + char buf[BUF_SIZE]; + int ret; + + if (!btn || !time) + return; + + mode = 0; + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (mode) { + snprintf(buf, sizeof(buf), "%02d : %02d", time[TIME_HOUR], time[TIME_MINUTE]); + } else { + if (time[TIME_HOUR] >= 12) { + time[TIME_HOUR] -= 12; + time[TIME_AMPM] = 1; + } else { + time[TIME_AMPM] = 0; + } + + snprintf(buf, sizeof(buf), "%02d : %02d : %s", time[TIME_HOUR], time[TIME_MINUTE], time[TIME_AMPM] == 1 ? PM : AM); + } + + elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf); +} + + +void CClockMainView::m_RefreshBtnText(void) +{ + int ret, mode; + char buf[BUF_SIZE]; + + if (m->date_btn == m->cur_btn) { + snprintf(buf, sizeof(buf), "%02d / %02d / %04d", m->date[DATE_MONTH], m->date[DATE_DAY], m->date[DATE_YEAR]); + elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, (const char *)buf); + } else if (m->switch_btn == m->cur_btn) { + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &m->mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (m->mode) + elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, ON); + else + elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, OFF); + + utils_get_time_value(m->time); + + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (mode) + snprintf(buf, sizeof(buf), "%02d : %02d", m->time[TIME_HOUR], m->time[TIME_MINUTE]); + else + snprintf(buf, sizeof(buf), "%02d : %02d : %s", m->time[TIME_HOUR], m->time[TIME_MINUTE], m->time[TIME_AMPM] == 1 ? PM : AM); + + elm_object_part_text_set(m->time_btn, BTN_PART_VALUE, (const char *)buf); + } else { + m_RefreshTimeBtnText(m->cur_btn, m->time); + } +} + + +void CClockMainView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CClockMainView::t_OnUpdate(void *data) +{ + _DBG(); + unsigned int *date = NULL; + int *time = NULL; + int idx = -1; + + if(!data) { + _ERR("Invlid Parameter"); + return ; + } + + date = (unsigned int *) data; + + elm_object_focus_set(m->cur_btn, EINA_TRUE); + + if (date) + for (idx = DATE_MONTH; idx < DATE_MAX; idx++) + m->date[idx] = date[idx]; + + if (time) + for (idx = TIME_HOUR; idx < TIME_MAX; idx++) + m->time[idx] = time[idx]; + + m_RefreshBtnText(); + + evas_object_show(m->base); +} + + +void CClockMainView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +bool CClockMainView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SClockMainView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = utils_add_layout(m->win)) + _CHECK(m_AddCloseBtn()) + _CHECK(m_AddClockSublist()) + _COMMAND{ + elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, UG_CLOCK_GRP); + elm_object_part_text_set(m->base, TEXT_INTRO, STRINGS_INTRO); + + } + + _WHEN_SUCCESS { +#if 0 + evas_object_data_set(m->base, UG_CLOCK_DATA_ID, data); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{evas_object_del(m->sublist_box);} + _CHECK_FAIL{evas_object_del(m->close_btn);} + _CHECK_FAIL{evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CClockMainView::Destroy(void) +{ + ASSERT(m); + + if(m->sublist_box) + evas_object_del(m->sublist_box); + + if(m->close_btn) + evas_object_del(m->close_btn); + + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CClockMainView::Base(void) +{ + ASSERT(m); + + return m->base; +} + +void CClockMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname NULL!"); + return; + } + + switch(id) { + case 1: + case 2: + case 3: + case 4: + ug_destroy_me(m->ug); + break; + } +} + + +void CClockMainView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + ug_destroy_me(m->ug); + break; + case 2: + { + m->cur_btn = obj; +#if 0 + view_spin_control_create(m->win, m->base); +#endif + m->pViewMgr->PushView(CLOCK_SPINCONTROL_VIEW, NULL); + elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN); + } + break; + case 3: + { + m->cur_btn = obj; + +#if 0 + view_sublist_create(data->win, data->base); +#endif + m->pViewMgr->PushView(CLOCK_SUBLIST_VIEW, NULL); + + elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN); + } + break; + case 4: + { + m->cur_btn = obj; +#if 0 + view_time_spin_ctrl_create(m->win, m->base); +#endif + m->pViewMgr->PushView(CLOCK_TIME_SPINCONTROL_VIEW, NULL); + elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN); + } + break; + default: + break; + } +} diff --git a/ug/system/clock/src/ClockSpinControlView.cpp b/ug/system/clock/src/ClockSpinControlView.cpp new file mode 100644 index 0000000..c4f9f2d --- /dev/null +++ b/ug/system/clock/src/ClockSpinControlView.cpp @@ -0,0 +1,534 @@ +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ClockSpinControlView.h" + +#define ARROW_BTN_DATA_ID "arrow_btn_data_id" +#define DATE_SPIN_DATA_ID "spin_ctrl_data" +#define YEAR_BTN (2) + +#define UP_ARROW (1) +#define DOWN_ARROW (0) + +static const int days[] = { + 31, + 28, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31 +}; + +struct SClockSpinControlView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + + unsigned int date[DATE_MAX]; + int entry[DATE_MAX]; + + Eina_Array *spin_array; + CViewMgr *pViewMgr; +}; + + +Evas_Object * CClockSpinControlView::m_AddArrowBtn(Evas_Object *obj, int flag) +{ + Evas_Object *btn; + + btn = utils_add_button(m->base); + if (!btn) { + _ERR("utils add button failed."); + return NULL; + } + + elm_object_style_set(btn, BTN_STYLE_ARROW_BTN); + + if (flag == UP_ARROW) + elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn); + else + elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn); + + elm_object_focus_allow_set(btn, EINA_FALSE); + + evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj); + evas_object_raise(btn); + evas_object_repeat_events_set(btn, EINA_FALSE); + + return btn; +} + + +bool CClockSpinControlView::m_AddDateSpin(void) +{ + Evas_Object *btn, *uparrow, *downarrow; + char buf[BUF_SIZE]; + int idx; + + m->spin_array = eina_array_new(1); + if (!m->spin_array) { + _ERR("new eina array failed."); + return false; + } + + for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { + btn = utils_add_button(m->base); + if (!btn) { + _ERR("add spin control button failed."); + return false; + } + + elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_BTN); + if (idx == YEAR_BTN) + elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_YEAR_BTN); + + snprintf(buf, sizeof(buf), "spin_ctrl_%d_swallow", idx + 1); + elm_object_part_content_set(m->base, (const char *)buf, btn); + + eina_array_push(m->spin_array, btn); + + uparrow = m_AddArrowBtn( btn, UP_ARROW); + if (!uparrow) { + _ERR("add up arrow button failed."); + evas_object_del(btn); + return false; + } + //evas_object_smart_callback_add(btn, "clicked", _arrow_btn_clicked_cb, data); + Connect(uparrow, 1, TYPE_CLICKED); + + downarrow = m_AddArrowBtn( btn, DOWN_ARROW); + if (!downarrow) { + _ERR("add down arrow button failed."); + evas_object_del(btn); + evas_object_del(uparrow); + return false; + } + Connect(downarrow, 2, TYPE_CLICKED); + } + + elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, 0), EINA_TRUE); + + return true; +} + + +void CClockSpinControlView::m_InitDateSpin(void) +{ + Evas_Object *spin; + char buf[BUF_SIZE]; + + utils_get_date_value(m->date); + + spin = (Evas_Object *) eina_array_data_get(m->spin_array, 0); + if (!spin) { + _ERR("month button is null."); + return; + } + + snprintf(buf, sizeof(buf), "%02d", m->date[DATE_MONTH]); + elm_object_text_set(spin, buf); + + spin = (Evas_Object *) eina_array_data_get(m->spin_array, 1); + if (!spin) { + _ERR("month button is null."); + return; + } + + snprintf(buf, sizeof(buf), "%02d", m->date[DATE_DAY]); + elm_object_text_set(spin, buf); + + spin = (Evas_Object *) eina_array_data_get(m->spin_array, 2); + if (!spin) { + _ERR("month button is null."); + return; + } + + m->date[DATE_YEAR] = m->date[DATE_YEAR] < 2000 ? 2000 : m->date[DATE_YEAR]; + snprintf(buf, sizeof(buf), "%04d", m->date[DATE_YEAR]); + elm_object_text_set(spin, buf); + + int idx; + + for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { + spin = (Evas_Object *) eina_array_data_get(m->spin_array, idx); + if (!spin) { + _ERR("there is no button. idx: %d", idx); + return; + } + + elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_UP); + elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_DOWN); + + if (idx == DATE_MONTH) { + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx+1), ELM_FOCUS_NEXT); + elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT); + } else if (idx == DATE_YEAR) { + elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT); + } else { + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_NEXT); + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT); + } + } +} + + +void CClockSpinControlView::m_UpdateDateValue(Evas_Object *spin, int spin_idx) +{ + char buf[BUF_SIZE]; + + if (!spin) + return; + if (spin_idx < DATE_MONTH || spin_idx >= DATE_MAX) + return; + + if (spin_idx == DATE_MONTH) { + if (m->date[spin_idx] > 12) + m->date[spin_idx] = 1; + if (m->date[spin_idx] <= 0) + m->date[spin_idx] = 12; + + snprintf(buf, sizeof(buf), "%02d", m->date[spin_idx]); + } else if (spin_idx == DATE_DAY) { + if (m->date[spin_idx] > days[m->date[DATE_MONTH] - 1]) + m->date[spin_idx] = 1; + if (m->date[spin_idx] <= 0) + m->date[spin_idx] = days[m->date[DATE_MONTH] - 1]; + + snprintf(buf, sizeof(buf), "%02d", m->date[spin_idx]); + } else { + if (m->date[spin_idx] > 2037) + m->date[spin_idx] = 2000; + if (m->date[spin_idx] < 2000) + m->date[spin_idx] = 2037; + + snprintf(buf, sizeof(buf), "%04d", m->date[spin_idx]); + } + + elm_object_text_set(spin, buf); +} + + +bool CClockSpinControlView::m_AddSpin(void) +{ + if(!m_AddDateSpin()) { + _ERR("add spin control buttons failed."); + return false; + } + + m_InitDateSpin(); + + Evas_Object *spin; + + for (int idx = DATE_MONTH; idx < DATE_MAX; idx++) { + spin = (Evas_Object *) eina_array_data_get(m->spin_array, idx); + if (!spin) { + _ERR("eina m->spin_array data get failed. spin index: %d", idx); + return false; + } + + //evas_object_smart_callback_add(spin, CLICKED, _date_spin_clicked_cb, data); + //evas_object_event_callback_add(spin, EVAS_CALLBACK_KEY_DOWN, _date_spin_keydown_cb, data); + Connect(spin, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN | TYPE_KEY_UP); +#if 0 + evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_IN, _date_spin_mousein_cb, NULL); + evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_OUT, _date_spin_mouseout_cb, NULL); +#endif + } + + return true; +} + + +void CClockSpinControlView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CClockSpinControlView::t_OnUpdate(void *data) +{ + _DBG(); + + evas_object_show(m->base); +} + + +void CClockSpinControlView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +bool CClockSpinControlView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SClockSpinControlView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = utils_add_layout(m->win)) + _CHECK(m_AddSpin()) + + _WHEN_SUCCESS { + elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, SPIN_CTRL_GRP); +#if 0 + evas_object_data_set(m->base, DATE_SPIN_DATA_ID, data); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{if(m->spin_array) eina_array_free(m->spin_array);} + _CHECK_FAIL{if(m->base) evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CClockSpinControlView::Destroy(void) +{ + ASSERT(m); + + if(m->spin_array) + eina_array_free(m->spin_array); + + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CClockSpinControlView::Base(void) +{ + ASSERT(m); + + return m->base; +} + + +void CClockSpinControlView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + case 102: + { + Evas_Object *spin; + int idx = -1; + + for (int i = DATE_MONTH; i < DATE_MAX; i++) { + spin = (Evas_Object *) eina_array_data_get(m->spin_array, i); + if (!spin) + return; + + if (obj == spin) { + idx = i; + break; + } + } + + if (idx == -1) { + _ERR("can't get the right spin."); + return; + } + if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) { + m->date[idx]++; + m_UpdateDateValue(obj, idx); + } + } + break; + default: + break; + } +} + + +void CClockSpinControlView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + case 102: + { + int idx = -1; + Evas_Object *spin; + char buf[BUF_SIZE]; + + for (int i = DATE_MONTH; i < DATE_MAX; i++) { + spin = (Evas_Object *) eina_array_data_get(m->spin_array, i); + if (!spin) + return; + + if (obj == spin) { + idx = i; + break; + } + } + + if (idx == -1) { + _ERR("can't get the right spin."); + return; + } + + if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) { + m->date[idx]--; + m_UpdateDateValue(obj, idx); + } else if (!strncmp(ev->keyname, KEY_0, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_1, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_2, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_3, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_4, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_5, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_6, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_7, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_8, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_9, strlen(ev->keyname))) { + if (idx != DATE_YEAR) { + if (m->entry[idx] == 0) { + m->entry[idx]++; + m->date[idx] = atoi(ev->keyname); + } else { + m->entry[idx]++; + m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname); + m->entry[idx] = 0; + elm_object_focus_next(obj, ELM_FOCUS_NEXT); + } + } else { + if (m->entry[idx] == 0) { + m->entry[idx]++; + m->date[idx] = atoi(ev->keyname); + snprintf(buf, sizeof(buf), "%04d", m->date[idx]); + elm_object_text_set(obj, buf); + return; + } else if (m->entry[idx] == 3) { + m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname); + m->entry[idx] = 0; + } else { + m->entry[idx]++; + m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname); + snprintf(buf, sizeof(buf), "%04d", m->date[idx]); + elm_object_text_set(obj, buf); + return; + } + } + m_UpdateDateValue(obj, idx); + } else if (!strncmp(ev->keyname, KEY_RIGHT, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_LEFT, strlen(ev->keyname))) { + m->entry[idx] = 0; + } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) { + Destroy(); + } + } + break; + default: + break; + } +} + + +void CClockSpinControlView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + case 2: + { + Evas_Object *cur_btn, *btn, *up_btn; + int idx; + + cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID); + if (!cur_btn) { + _ERR("evas object data get failed. ID: %s", ARROW_BTN_DATA_ID); + return; + } + + up_btn = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW); + if (!up_btn) { + _ERR("part %s content get failed.", UP_ARROW_SWALLOW); + return; + } + + idx = 0; + for (int i = DATE_DAY; i < DATE_MAX; i++) { + btn = (Evas_Object *) eina_array_data_get(m->spin_array, i); + if (!btn) { + _ERR("eina array data get failed. button index: %d", i); + return; + } + + if (cur_btn == btn) { + idx = i; + break; + } + } + + if (obj == up_btn) + m->date[idx]++; + else + m->date[idx]--; + + m_UpdateDateValue(cur_btn, idx); + } + break; + case 100: + case 101: + case 102: + { + utils_set_date_value(m->date); +#if 0 + view_ug_clock_refresh(m->ug_base, m->date, NULL); +#endif + m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, m->date); + Destroy(); + } + break; + default: + break; + } +} diff --git a/ug/system/clock/src/ClockSublistView.cpp b/ug/system/clock/src/ClockSublistView.cpp new file mode 100644 index 0000000..34f72ff --- /dev/null +++ b/ug/system/clock/src/ClockSublistView.cpp @@ -0,0 +1,363 @@ +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ClockSublistView.h" + +#define SUBLIST_BTN_NUM 2 +#define SUBLIST_DATA_ID "sublist_data" + +#define BOX_HPADDING 0 +#define BOX_VPADDING 2 + +#define CLICKED "clicked" + +struct SClockSublistView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *box; + + unsigned int mode; + + Eina_Array *array; + CViewMgr *pViewMgr; +}; + +bool CClockSublistView::m_AddSublist(void) +{ + m->box = utils_add_box(m->base); + if (!m->box) { + _ERR("add sublist m->box failed."); + return false; + } + + if(!m_AddSublistBtns()) { + _ERR("add sublist buttons failed."); + evas_object_del(m->box); + m->box = NULL; + return false; + } + + m_SetSublistInitValue(); + + return true; +} + + +bool CClockSublistView::m_AddSublistBtns(void) +{ + Evas_Object *btn; + + elm_box_padding_set(m->box, BOX_HPADDING, BOX_VPADDING); + + m->array = eina_array_new(1); + if (!m->array) { + _ERR("new array for sublist buttons failed."); + return false; + } + + for (int idx = 0; idx < SUBLIST_BTN_NUM; idx++) { + btn = utils_add_button(m->base); + if (!btn) { + _ERR("add button failed."); + eina_array_free(m->array); + return false; + } + + //evas_object_smart_callback_add(btn, CLICKED, _sublist_btn_clicked_cb, data); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_sublist_btn_cb, data); + Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN | TYPE_KEY_UP); +#if 0 + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _sublist_btn_mouse_in_cb, NULL); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _sublist_btn_mouse_out_cb, NULL); +#endif + + elm_object_style_set(btn, BTN_STYLE_SUBLIST_BTN); + + elm_box_pack_end(m->box, btn); + eina_array_push(m->array, btn); + } + + elm_object_part_content_set(m->base, SWALLOW_SUBLIST, m->box); + + return true; +} + + +void CClockSublistView::m_SetSublistInitValue(void) +{ + Evas_Object *on_btn, *off_btn; + int mode = 0; + int ret; + + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + on_btn = (Evas_Object *) eina_array_data_get(m->array, 0); + off_btn = (Evas_Object *) eina_array_data_get(m->array, 1); + if (!on_btn || !off_btn) { + _ERR("there is no button in sublist array."); + return; + } + + elm_object_focus_set(on_btn, EINA_TRUE); + + elm_object_text_set(on_btn, ON); + elm_object_text_set(off_btn, OFF); + + if (mode) { + elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(off_btn, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST); + } else { + elm_object_signal_emit(off_btn, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST); + } + + elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(on_btn, off_btn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_RIGHT); + + elm_object_focus_next_object_set(off_btn, on_btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_RIGHT); +} + + +void CClockSublistView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CClockSublistView::t_OnUpdate(void *data) +{ + _DBG(); + + evas_object_show(m->base); +} + + +void CClockSublistView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +bool CClockSublistView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SClockSublistView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = utils_add_layout(m->win)) + _CHECK(m_AddSublist()) + _COMMAND{ + elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, SUBLIST_GRP); + } + + _WHEN_SUCCESS { +#if 0 + evas_object_data_set(m->base, SUBLIST_DATA_ID, data); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{if(m->array) eina_array_free(m->array); if(m->box) evas_object_del(m->box);} + _CHECK_FAIL{evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CClockSublistView::Destroy(void) +{ + ASSERT(m); + + if(m->array) + eina_array_free(m->array); + + if(m->box) + evas_object_del(m->box); + + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CClockSublistView::Base(void) +{ + ASSERT(m); + + return m->base; +} + + +void CClockSublistView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + { + Evas_Object *on_btn = NULL; + int mode, ret = -1; + on_btn = (Evas_Object *) eina_array_data_get(m->array, 0); + + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) { + + if (obj == on_btn) + return; + + elm_object_focus_set(on_btn, EINA_TRUE); + + if (mode) { + elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST); + } else { + elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST); + } + } + } + break; + } +} + + +void CClockSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + { + Evas_Object *on_btn, *off_btn; + Eina_Array *array; + int mode; + int ret; + + on_btn = (Evas_Object *) eina_array_data_get(array, 0); + off_btn = (Evas_Object *) eina_array_data_get(array, 1); + if (!on_btn || !off_btn) { + _ERR("ON button or OFF button is null."); + return; + } + + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (!strcmp(ev->keyname, KEY_DOWN)) { + if (obj != on_btn) + return; + + elm_object_focus_set(off_btn, EINA_TRUE); + + if (mode) { + elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(off_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST); + } else { + elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST); + elm_object_signal_emit(off_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST); + } + } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) { + Destroy(); + } + } + break; + } +} + + +void CClockSublistView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 100: + case 101: + { + Evas_Object *on_btn, *off_btn; + int ret; + + if (!m->array) + return; + + on_btn = (Evas_Object *) eina_array_data_get(m->array, 0); + off_btn = (Evas_Object *) eina_array_data_get(m->array, 1); + if (!on_btn || !off_btn) { + _ERR("ON button or OFF button is null."); + return; + } + + if (obj == on_btn) + ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, 1); + else + ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, 0); + + if (ret != 0) { + _ERR("set 24hour mode failed."); + return; + } + +#if 0 + view_ug_clock_refresh(data->ug_base, NULL, NULL); +#endif + m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, NULL); + + Destroy(); + } + break; + } +} diff --git a/ug/system/clock/src/ClockTimeSpinControlView.cpp b/ug/system/clock/src/ClockTimeSpinControlView.cpp new file mode 100644 index 0000000..b82cf43 --- /dev/null +++ b/ug/system/clock/src/ClockTimeSpinControlView.cpp @@ -0,0 +1,629 @@ +#include +#include +#include +#include "AppCommon.h" +#include "dbg.h" +#include "defs.h" +#include "util.h" + +#include "BaseView.h" +#include "ViewMgr.h" +#include "ClockTimeSpinControlView.h" + +#define ARROW_BTN_DATA_ID "arrow_btn_data_id" +#define TIME_SPIN_DATA_ID "time_spin_ctrl_data" + +#define BOX_HPADDING 2 +#define BOX_VPADDING 122 + +#define UP_ARROW (1) +#define DOWN_ARROW (0) + +struct SClockTimeSpinControlView { + ui_gadget_h ug; + + Evas_Object *win; + Evas_Object *base; + Evas_Object *ug_base; + Evas_Object *spin_box; + + int time[TIME_MAX]; + int entry[TIME_MAX]; + + Eina_Array *spin_array; + + CViewMgr *pViewMgr; +}; + + +Evas_Object * CClockTimeSpinControlView::m_AddArrowBtn(Evas_Object *obj, int flag) +{ + Evas_Object *btn; + + btn = utils_add_button(m->base); + if (!btn) { + _ERR("utils add button failed."); + return NULL; + } + + elm_object_style_set(btn, BTN_STYLE_ARROW_BTN); + + if (flag == UP_ARROW) + elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn); + else + elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn); + + elm_object_focus_allow_set(btn, EINA_FALSE); + + evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj); + evas_object_raise(btn); + evas_object_repeat_events_set(btn, EINA_FALSE); + + return btn; +} + + +void CClockTimeSpinControlView::m_UpdateTimeValue(Evas_Object *btn, int btn_idx) +{ + int mode; + char buf[BUF_SIZE]; + int ret; + + if (!btn) + return; + if (btn_idx < TIME_HOUR || btn_idx >= TIME_MAX) + return; + + mode = 0; + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return; + } + + if (btn_idx == TIME_HOUR) { + if (mode) { + if (m->time[btn_idx] > 23) + m->time[btn_idx] = 0; + if (m->time[btn_idx] < 0) + m->time[btn_idx] = 23; + } else { + if (m->time[btn_idx] > 11) + m->time[btn_idx] = 0; + if (m->time[btn_idx] < 0) + m->time[btn_idx] = 11; + } + + snprintf(buf, sizeof(buf), "%02d", m->time[btn_idx]); + } else if (btn_idx == TIME_MINUTE) { + if (m->time[btn_idx] > 59) + m->time[btn_idx] = 0; + if (m->time[btn_idx] < 0) + m->time[btn_idx] = 59; + + snprintf(buf, sizeof(buf), "%02d", m->time[btn_idx]); + } else { + if (m->time[btn_idx]) + snprintf(buf, sizeof(buf), "%s", PM); + else + snprintf(buf, sizeof(buf), "%s", AM); + } + + elm_object_text_set(btn, buf); +} + + +bool CClockTimeSpinControlView::m_AddTimeSpinWithAMPM(void) +{ + Evas_Object *btn; + Evas_Object *uparrow, *downarrow; + char buf[BUF_SIZE]; + + elm_box_horizontal_set(m->spin_box, EINA_TRUE); + elm_box_padding_set(m->spin_box, BOX_HPADDING, BOX_VPADDING); + + m->spin_array = eina_array_new(1); + if (!m->spin_array) { + _ERR("new eina m->spin_array failed."); + return false; + } + + for (int idx = TIME_HOUR; idx < TIME_AMPM; idx++) { + btn = utils_add_button(m->base); + if (!btn) { + _ERR("add time spin control button failed."); + return false; + } + + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _time_spin_keydown_cb, data); + //evas_object_smart_callback_add(btn, "clicked", _time_spin_click_cb, data); + Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN); +#if 0 + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _time_spin_mousein_cb, NULL); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _time_spin_mouseout_cb, NULL); +#endif + elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN); + + snprintf(buf, sizeof(buf), "%02d", m->time[idx]); + elm_object_text_set(btn, buf); + + eina_array_push(m->spin_array, btn); + elm_box_pack_end(m->spin_box, btn); + + uparrow = m_AddArrowBtn(btn, UP_ARROW); + if (!uparrow) { + _ERR("add up arrow button failed."); + evas_object_del(btn); + return false; + } + + downarrow = m_AddArrowBtn(btn, DOWN_ARROW); + if (!downarrow) { + _ERR("add down arrow button failed."); + evas_object_del(btn); + evas_object_del(uparrow); + return false; + } + } + + elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR), EINA_TRUE); + elm_object_part_content_set(m->base, SWALLOW_TIME_SPIN_2, m->spin_box); + + return true; +} + + +bool CClockTimeSpinControlView::m_AddTimeSpinWithoutAMPM(void) +{ + Evas_Object *btn; + Evas_Object *uparrow, *downarrow; + char buf[BUF_SIZE]; + + elm_box_horizontal_set(m->spin_box, EINA_TRUE); + elm_box_padding_set(m->spin_box, BOX_HPADDING, BOX_VPADDING); + + m->spin_array = eina_array_new(1); + if (!m->spin_array) { + _ERR("new eina m->spin_array failed."); + return false; + } + + for (int idx = TIME_HOUR; idx < TIME_AMPM; idx++) { + btn = utils_add_button(m->base); + if (!btn) { + _ERR("add time spin control button failed."); + return false; + } + + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _time_spin_keydown_cb, data); + //evas_object_smart_callback_add(btn, "clicked", _time_spin_click_cb, data); + Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN); +#if 0 + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _time_spin_mousein_cb, NULL); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _time_spin_mouseout_cb, NULL); +#endif + + elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN); + + snprintf(buf, sizeof(buf), "%02d", m->time[idx]); + elm_object_text_set(btn, buf); + + eina_array_push(m->spin_array, btn); + + elm_box_pack_end(m->spin_box, btn); + + uparrow = m_AddArrowBtn(btn, UP_ARROW); + if (!uparrow) { + _ERR("add up arrow button failed."); + evas_object_del(btn); + return false; + } + //evas_object_smart_callback_add(btn, "clicked", _arrow_btn_clicked_cb, data); + Connect(uparrow, 1, TYPE_CLICKED); + + downarrow = m_AddArrowBtn(btn, DOWN_ARROW); + if (!downarrow) { + _ERR("add down arrow button failed."); + evas_object_del(btn); + evas_object_del(uparrow); + return false; + } + Connect(downarrow, 2, TYPE_CLICKED); + } + + elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR), EINA_TRUE); + + elm_object_part_content_set( m->base, SWALLOW_TIME_SPIN_2, m->spin_box); + + return true; +} + + +bool CClockTimeSpinControlView::m_AddTimeSpinBtns(void) +{ + int mode; + int ret; + + utils_get_time_value(m->time); + + mode = 0; + ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); + if (ret != 0) { + _ERR("vconf get value failed."); + return false; + } + + if (mode) { + ret = m_AddTimeSpinWithoutAMPM(); + if (ret != 0) { + _ERR("add buttons without ampm failed."); + return false; + } + } else { + ret = m_AddTimeSpinWithAMPM(); + if (ret != 0) { + _ERR("add buttons with ampm failed."); + return false; + } + } + + return true; +} + + +bool CClockTimeSpinControlView::m_AddTimeSpin(void) +{ + Evas_Object *btn; + unsigned int count; + int idx; + + m->spin_box = utils_add_box(m->base); + if (!m->spin_box) { + _ERR("add time spin control box failed."); + return false; + } + + if(!m_AddTimeSpinBtns()) { + _ERR("add time spin control buttons failed."); + return false; + } + + + count = eina_array_count(m->spin_array); + + for (idx = TIME_HOUR; idx < count; idx++) { + btn = (Evas_Object *) eina_array_data_get(m->spin_array, idx); + if (!btn) { + _ERR("there is no button. idx: %d", idx); + return false; + } + + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN); + + if (idx == TIME_HOUR) { + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), + ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), + ELM_FOCUS_NEXT); + } else if (idx == count - 1) { + elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT); + } else { + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_NEXT); + elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT); + } + } + return true; +} + + +void CClockTimeSpinControlView::t_OnShow(void) +{ + _DBG(); + + evas_object_show(m->base); + + CBaseView::t_OnShow(); +} + + +void CClockTimeSpinControlView::t_OnUpdate(void *data) +{ + _DBG(); + + evas_object_show(m->base); +} + + +void CClockTimeSpinControlView::t_OnHide(void) +{ + _DBG(); + + evas_object_hide(m->base); + + CBaseView::t_OnHide(); +} + + +bool CClockTimeSpinControlView::Create(void *data) +{ + _DBG(); + ASSERT(!m); + + bool ret = false; + + ui_gadget_h ug; + if (!data) { + _ERR("Invalid argument"); + return false; + } + ug = (ui_gadget_h)data; + + _CREATE_BEGIN{ + _CHECK(m = new SClockTimeSpinControlView) + _CHECK(m->win = CViewMgr::GetInstance()->Window()) + _CHECK(m->base = utils_add_layout(m->win)) + _COMMAND { + int onoff = 0; + ret = true; + if(utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &onoff) != 0) { + _ERR("vconf get value failed."); + ret = false; + } + + if (onoff) + elm_object_signal_emit(m->base, SIGNAL_NAME_TIME_SPIN_2, SIGNAL_SOURCE_TIME_SPIN); + else + elm_object_signal_emit(m->base, SIGNAL_NAME_TIME_SPIN_1, SIGNAL_SOURCE_TIME_SPIN); + + } + _CHECK(ret) + _CHECK(m_AddTimeSpin()) + + _WHEN_SUCCESS { + elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, TIME_SPIN_CTRL_GRP); +#if 0 + evas_object_data_set(m->base, TIME_SPIN_DATA_ID, data); +#endif + m->ug = ug; + m->pViewMgr = CViewMgr::GetInstance(); + } + + _CHECK_FAIL{if(m->spin_array) eina_array_free(m->spin_array); if(m->spin_box) evas_object_del(m->spin_box);} + _CHECK_FAIL{/* ret */} + _CHECK_FAIL{if(m->base) evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +void CClockTimeSpinControlView::Destroy(void) +{ + ASSERT(m); + + if(m->spin_array) + eina_array_free(m->spin_array); + + if(m->spin_box) + evas_object_del(m->spin_box); + + if(m->base) + evas_object_del(m->base); + + delete m; + m = NULL; +} + + +Evas_Object* CClockTimeSpinControlView::Base(void) +{ + ASSERT(m); + + return m->base; +} + + +void CClockTimeSpinControlView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + { + Evas_Object *hour_btn, *minute_btn; + + hour_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR); + minute_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_MINUTE); + if (!hour_btn || !minute_btn) { + _ERR("eina m->spin_array data get failed."); + return; + } + + if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) { + if (obj == hour_btn) { + m->time[TIME_HOUR]++; + m_UpdateTimeValue(obj, TIME_HOUR); + } else if (obj == minute_btn) { + m->time[TIME_MINUTE]++; + m_UpdateTimeValue(obj, TIME_MINUTE); + } else { + if (m->time[TIME_AMPM] == 0) + m->time[TIME_AMPM] = 1; + else + m->time[TIME_AMPM] = 0; + m_UpdateTimeValue(obj, TIME_AMPM); + } + } + } + break; + default: + break; + } +} + + +void CClockTimeSpinControlView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case 100: + case 101: + { + Evas_Object *hour_btn, *minute_btn; + + hour_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR); + minute_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_MINUTE); + if (!hour_btn || !minute_btn) { + _ERR("eina m->spin_array data get failed."); + return; + } + + if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) { + if (obj == hour_btn) { + m->time[TIME_HOUR]--; + m_UpdateTimeValue(obj, TIME_HOUR); + } else if (obj == minute_btn) { + m->time[TIME_MINUTE]--; + m_UpdateTimeValue(obj, TIME_MINUTE); + } else { + if (m->time[TIME_AMPM] == 0) + m->time[TIME_AMPM] = 1; + else + m->time[TIME_AMPM] = 0; + m_UpdateTimeValue(obj, TIME_AMPM); + } + } else if (!strncmp(ev->keyname, KEY_0, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_1, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_2, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_3, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_4, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_5, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_6, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_7, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_8, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_9, strlen(ev->keyname))) { + if (obj == hour_btn) { + if (m->entry[TIME_HOUR] == 0) { + m->entry[TIME_HOUR]++; + m->time[TIME_HOUR] = atoi(ev->keyname); + } else { + m->entry[TIME_HOUR]++; + m->time[TIME_HOUR] = + (m->time[TIME_HOUR] * 10) + atoi(ev->keyname); + m->entry[TIME_HOUR] = 0; + + elm_object_focus_next(obj, ELM_FOCUS_NEXT); + } + m_UpdateTimeValue(obj, TIME_HOUR); + } else if (obj == minute_btn) { + if (m->entry[TIME_MINUTE] == 0) { + m->entry[TIME_MINUTE]++; + m->time[TIME_MINUTE] = atoi(ev->keyname); + } else { + m->entry[TIME_MINUTE]++; + m->time[TIME_MINUTE] = + (m->time[TIME_MINUTE] * 10) + atoi(ev->keyname); + m->entry[TIME_MINUTE] = 0; + + elm_object_focus_next(obj, ELM_FOCUS_NEXT); + } + m_UpdateTimeValue(obj, TIME_MINUTE); + } else { + return; + } + } else if (!strncmp(ev->keyname, KEY_LEFT, strlen(ev->keyname)) || + !strncmp(ev->keyname, KEY_RIGHT, strlen(ev->keyname))) { + if (obj == hour_btn) + m->entry[TIME_HOUR] = 0; + else if (obj == minute_btn) + m->entry[TIME_MINUTE] = 0; + else + return; + } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) { + Destroy(); + } + } + break; + default: + break; + } +} + + +void CClockTimeSpinControlView::OnMouseClicked(int id, Evas_Object *obj) +{ + switch(id) { + case 1: + case 2: + { + Evas_Object *cur_btn, *btn, *up; + int flag, idx = -1; + + cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID); + if (!cur_btn) + return; + + up = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW); + if (!up) + return; + + if (obj == up) + flag = 1; + else + flag = 0; + + for (int i = TIME_HOUR; i < TIME_MAX; i++) { + btn = (Evas_Object *) eina_array_data_get(m->spin_array, i); + + if (cur_btn == btn) { + idx = i; + break; + } + } + + if (idx != TIME_AMPM) { + if (flag) + m->time[idx]++; + else + m->time[idx]--; + } else { + if (m->time[idx] == 0) + m->time[idx] = 1; + else + m->time[idx] = 0; + } + + m_UpdateTimeValue(cur_btn, idx); + } + break; + case 100: + case 101: + { + utils_set_time_value(m->time); + +#if 0 /* FIXME: m->time should be passed */ + view_ug_clock_refresh(m->ug_base, NULL, m->time); +#else + m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, NULL); +#endif + Destroy(); + } + break; + default: + break; + } +} diff --git a/ug/system/clock/src/ug_clock.cpp b/ug/system/clock/src/ug_clock.cpp index e35505d..33de881 100755 --- a/ug/system/clock/src/ug_clock.cpp +++ b/ug/system/clock/src/ug_clock.cpp @@ -18,16 +18,18 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include #include +#include -#include "ug_clock_utils.h" +#include "util.h" #include "ug_clock.h" -#include "ug_clock_define.h" +#include "defs.h" #include "dbg.h" -#include "ug_clock_spin_control.h" -#include "ug_clock_sublist.h" -#include "ug_clock_time_spin_control.h" + +#include +#include "BaseView.h" +#include "ClockMainView.h" +#include "ClockSublistView.h" #define CLOCK_SUBLIST_NULL_BTNS 2 #define UG_CLOCK_DATA_ID "ug_clock_data" @@ -37,928 +39,73 @@ extern "C" { #endif struct _ug_data { + ui_gadget_h ug; + Evas_Object *win; Evas_Object *base; - Evas_Object *close_btn; - Evas_Object *date_btn; - Evas_Object *switch_btn; - Evas_Object *time_btn; - Evas_Object *sublist_box; - Evas_Object *cur_btn; - - unsigned int date[DATE_MAX]; - int mode; - int time[TIME_MAX]; - ui_gadget_h ug; + CViewMgr *pViewMgr; + CClockMainView *pClockMainView; + CClockSublistView *pClockSublistView; }; -/** -* Free allocated memory. -* -* This function frees allocated memory when needed. -* -* @param[in]: data : the user data of clock ug. -* -* @return: void. -*/ -static void _free_ug_data(struct _ug_data *data) -{ - if (!data) - return; - - if (data->base) { - evas_object_del(data->base); - data->base = NULL; - } - - free(data); -} - -/** -* This function will be invoked when the BACK key is pressed. -* When the BACK key is pressed, this UI gadget will be destroyed. -* -* @param[in]: keyname : the name of pressed key. -* @param[in]: data : the user data of clock ug. -* -* @return: void. -*/ -static void _key_down_cb(const char *keyname, struct _ug_data *data) -{ - if (!keyname || !data || !data->ug) - return; - - if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) - ug_destroy_me(data->ug); -} - -/** -* Callback function for button click event. -* -* This function will be invoked when the close button is clicked or -* the ENTER key is pressed. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the pointer of clicked evas object. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _close_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - - if (!priv) { - _ERR("private data is null."); - return; - } - - data = (struct _ug_data *) priv; - ug_destroy_me(data->ug); -} - -/** -* Callback function for key pressed event. -* -* This function will be invoked when this the close button is focused -* and the BACK key is pressed. -* -* @param[in]: priv : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the current evas object. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _key_down_on_close_btn_cb(void *priv, Evas *e, - Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - Evas_Event_Key_Down *event; - const char *keyname; - - if (!priv || !ei) { - _ERR("invalid argument."); - return; - } - - event = (Evas_Event_Key_Down *) ei; - keyname = event->keyname; - - if (!keyname) - return; - - data = (struct _ug_data *) priv; - - _key_down_cb(keyname, data); -} - -/** -* Callback function for key pressed event. -* -* This function will be invoked when BACK key is pressed. -* When the BACK key is pressed, this UI gadget will be destroyed. -* -* @param[in]: priv : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the current evas object. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _key_down_on_btns_cb(void *priv, Evas *e, - Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - Evas_Event_Key_Down *event; - const char *keyname; - - if (!priv || !ei) { - _ERR("invalid argument."); - return; - } - - event = (Evas_Event_Key_Down *) ei; - keyname = event->keyname; - if (!keyname) - return; - - data = (struct _ug_data *) priv; - - _key_down_cb(keyname, data); -} - -/** -* Mouse in event callback. -* -* This function will be invoked when the mouse moves in the region of -* close button. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the current evas object. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _close_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* Mouse out event callback. -* -* This function will be invoked when the mouse moves out the region of -* close button. -* -* @param[in]: dt The pointer of private data. -* @param[in]: e The evas canvas. -* @param[in]: obj The current evas object. -* @param[in]: ei The event info. -* -* @return: void. -*/ -static void _close_btn_mouse_out_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operation when needed. */ -} - -/** -* Add close button. -* -* This function adds close button for clock UI gadget. -* -* @param[in]: parent : the parent base layout of clock UI gadget. -* @param[in]: data : the user data. -* -* @return: The pointer of created evas object button or NULL. -*/ -static Evas_Object *_add_close_btn(Evas_Object *parent, - struct _ug_data *data) -{ - Evas_Object *btn; - - if (!parent || !data) { - _ERR("parent of close button is null."); - return NULL; - } - - btn = utils_add_button(parent); - if (!btn) { - _ERR("elm add button failed."); - return NULL; - } - - data->close_btn = btn; - - elm_object_style_set(btn, BTN_STYLE_CLOSE_BTN); - elm_object_text_set(btn, BTN_TEXT_CLOSE); - elm_object_part_content_set(parent, SWALLOW_CLOSE_BTN, btn); - - evas_object_smart_callback_add(data->close_btn, "clicked", - _close_btn_clicked_cb, data); - evas_object_event_callback_add(data->close_btn, EVAS_CALLBACK_KEY_DOWN, - _key_down_on_close_btn_cb, data); - evas_object_event_callback_add(data->close_btn, - EVAS_CALLBACK_MOUSE_IN, _close_btn_mouse_in_cb, data); - evas_object_event_callback_add(data->close_btn, - EVAS_CALLBACK_MOUSE_OUT, _close_btn_mouse_out_cb, data); - - return btn; -} - -/** -* CLICKED event callback. -* -* This is the CLICKED event callback function for 24 Hour mode button. -* When user clicks the 24 Hour mode button or the ENTER key is pressed -* on this button, this function will be triggered to show the sub UI of -* 24 Hour mode button. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the 24 Hour mode button. -* @param[in]: ei : the event info. -* -* @return: void. -*/ -static void _switch_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - - if (!priv) - return; - - data = (struct _ug_data *) priv; - data->cur_btn = obj; - - view_sublist_create(data->win, data->base); - - elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, - SIGNAL_SOURCE_BTN); -} - -/** -* MOUSEIN event callback function. -* -* This is the MOUSEIN event callback function for 24 Hour mode -* button. When the mouse moves in the region of 24 Hour mode -* button, this function will be called. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the 24 Hour mode button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _switch_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* MOUSEOUT event callback function. -* -* This is the MOUSEOUT event callback function for 24 Hour mode -* button. When the mouse moves out of the region of 24 Hour mode -* button, this function will be called. Till now there is no operation -* in this function, and you can add operations here as needed. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the 24 Hour mode button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _switch_btn_mouse_out_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operations when needed. */ -} - -/** -* This function creates the 24 Hour mode item button. -* -* @param[in]: data : the user data. -* -* @return: The created evas object 24 Hour mode button or NULL. -*/ -static Evas_Object *_add_clock_sublist_switch_btn( - struct _ug_data *data) -{ - Evas_Object *switch_btn; - const char *display; - int ret; - - if (!data) { - _ERR("data is null."); - return NULL; - } - - switch_btn = utils_add_button(data->base); - if (!switch_btn) { - _ERR("add button failed."); - return NULL; - } - - elm_object_style_set(switch_btn, BTN_STYLE_LIST_BTN); - elm_object_text_set(switch_btn, BTN_TEXT_24HOUR_TIME); - - elm_box_pack_end(data->sublist_box, switch_btn); - - /* Set ON/OFF for switch button. */ - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &data->mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return NULL; - } - - if (!data->mode) - display = OFF; - else - display = ON; - - elm_object_part_text_set(switch_btn, BTN_PART_VALUE, display); - - evas_object_event_callback_add(switch_btn, - EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); - evas_object_smart_callback_add(switch_btn, - "clicked", _switch_btn_clicked_cb, data); - evas_object_event_callback_add(switch_btn, - EVAS_CALLBACK_MOUSE_IN, _switch_btn_mouse_in_cb, NULL); - evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_OUT, - _switch_btn_mouse_out_cb, NULL); - - return switch_btn; -} - -/** -* CLICKED event callback function. -* -* This is the clicked event callback function for Date button. -* When user clicks the Date button or ENTER key is pressed, -* this function will be called to show sub UI of Date button. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the Date button. -* @param[in]: ei : the event info. -* -* @return: void. -*/ -static void _date_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - - if (!priv || !obj) { - _ERR("invalid argument."); - return; - } - - data = (struct _ug_data *) priv; - data->cur_btn = obj; - - view_spin_control_create(data->win, data->base); - - elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, - SIGNAL_SOURCE_BTN); -} - -/** -* MOUSEIN event callback function. -* -* This is the MOUSEIN event callback function for Date button. -* When the mouse moves in the region of Date button, this -* function will be called. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the Date button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* MOUSEOUT event callback function. -* -* This is the MOUSEOUT event callback function for Date button. -* When the mouse moves out of the region of Date button, this -* function will be called. Till now there is no operation in this -* function, and you can add operations here as needed. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the Date button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_btn_mouse_out_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operations when needed. */ -} - -/** -* This function creates the Date item button. -* -* @param[in]: data : the user data. -* -* @return: The created evas object Date button or NULL. -*/ -static Evas_Object *_add_clock_sublist_date_btn(struct _ug_data *data) -{ - Evas_Object *date_btn; - char buf[BUF_SIZE]; - - if (!data) { - _ERR("data is null."); - return NULL; - } - - date_btn = utils_add_button(data->base); - if (!date_btn) { - _ERR("add button failed."); - return NULL; - } - - elm_object_style_set(date_btn, BTN_STYLE_LIST_BTN); - elm_object_text_set(date_btn, BTN_TEXT_DATE); - - elm_box_pack_end(data->sublist_box, date_btn); - - elm_object_focus_set(date_btn, EINA_TRUE); - - utils_get_date_value(data->date); - - snprintf(buf, sizeof(buf), - "%02d / %02d / %04d", data->date[DATE_MONTH], - data->date[DATE_DAY], data->date[DATE_YEAR]); - - elm_object_part_text_set(date_btn, BTN_PART_VALUE, (const char *)buf); - - evas_object_event_callback_add(date_btn, - EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); - evas_object_smart_callback_add(date_btn, - "clicked", _date_btn_clicked_cb, data); - evas_object_event_callback_add(date_btn, - EVAS_CALLBACK_MOUSE_IN, _date_btn_mouse_in_cb, NULL); - evas_object_event_callback_add(date_btn, - EVAS_CALLBACK_MOUSE_OUT, _date_btn_mouse_out_cb, NULL); - - return date_btn; -} - -/** -* CLICKED event callback function. -* -* This is the clicked event callback function for Time button. -* When user clicks the Time button or ENTER key is pressed -* on this button, this function will be called to show sub UI -* of Time button. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the Time button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _ug_data *data; - - if (!priv) - return; - - data = (struct _ug_data *) priv; - data->cur_btn = obj; - - view_time_spin_ctrl_create(data->win, data->base); - - elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, - SIGNAL_SOURCE_BTN); -} - -/** -* Refresh text of Time button. -* -* @param[in]: btn : the Time button. -* @param[in]: time : the refreshed value of time. -* -* @return: void. -*/ -static void _refresh_time_btn_text(Evas_Object *btn, int *time) -{ - int mode; - char buf[BUF_SIZE]; - int ret; - - if (!btn || !time) - return; - - mode = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - if (mode) { - snprintf(buf, sizeof(buf), "%02d : %02d", - time[TIME_HOUR], time[TIME_MINUTE]); - } else { - if (time[TIME_HOUR] >= 12) { - time[TIME_HOUR] -= 12; - time[TIME_AMPM] = 1; - } else { - time[TIME_AMPM] = 0; - } - - snprintf(buf, sizeof(buf), "%02d : %02d : %s", - time[TIME_HOUR], time[TIME_MINUTE], - time[TIME_AMPM] == 1 ? PM : AM); - } - - elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf); -} - -/** -* MOUSEIN event callback function. -* -* This is the MOUSEIN event callback function for Time button. -* When the mouse moves in the region of Time button, this -* function will be called. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the Time button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* MOUSEOUT event callback function. -* -* This is the MOUSEOUT event callback function for Time button. -* When the mouse moves out of the region of Time button, this -* function will be called. Till now there is no operation in this -* function, and you can add operations here as needed. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the Time button. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_btn_mouse_out_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operations when needed. */ -} - -/** -* This function creates the Time item button. -* -* @param[in]: data : the user data. -* -* @return: The created evas object Date button or NULL. -*/ -static Evas_Object *_add_clock_sublist_time_btn( - struct _ug_data *data) -{ - Evas_Object *time_btn; - - if (!data || !data->base) { - _ERR("invalid argument."); - return NULL; - } - - time_btn = utils_add_button(data->base); - if (!time_btn) { - _ERR("add time button failed."); - return NULL; - } - - elm_object_style_set(time_btn, BTN_STYLE_LIST_BTN); - elm_object_text_set(time_btn, BTN_TEXT_TIME); - - elm_box_pack_end(data->sublist_box, time_btn); - - /* Set hour : minute : AM/PM for time button. */ - utils_get_time_value(data->time); - - _refresh_time_btn_text(time_btn, data->time); - - evas_object_event_callback_add(time_btn, - EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data); - evas_object_smart_callback_add(time_btn, - "clicked", _time_btn_clicked_cb, data); - evas_object_event_callback_add(time_btn, - EVAS_CALLBACK_MOUSE_IN, _time_btn_mouse_in_cb, NULL); - evas_object_event_callback_add(time_btn, - EVAS_CALLBACK_MOUSE_OUT, _time_btn_mouse_out_cb, NULL); - - return time_btn; -} - -/** -* Create unused buttons. -* -* There is a unused region of clock UI gadget. We use blank -* buttons to implement this unused region. This function -* creates the unused region. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_clock_sublist_null_btn(struct _ug_data *data) -{ - Evas_Object *null_btn; - Evas_Object *last_btn; - int idx; - - if (!data || !data->base) { - _ERR("invalid argument."); - return -1; - } - - for (idx = 0; idx < CLOCK_SUBLIST_NULL_BTNS; idx++) { - null_btn = utils_add_button(data->base); - if (!null_btn) { - _ERR("add null button failed."); - return -1; - } - - elm_object_style_set(null_btn, BTN_STYLE_LIST_BTN); - elm_box_pack_end(data->sublist_box, null_btn); - } - - last_btn = utils_add_button(data->base); - if (!last_btn) { - _ERR("add last button failed."); - return -1; - } - - elm_object_style_set(last_btn, BTN_STYE_LAST_BTN); - elm_object_part_content_set( - data->base, SWALLOW_CLOCK_LAST, last_btn); - - return 0; -} - -/** -* Set moving directions of focus for created buttons. -* -* @param[in]: data : the user data. -* -* @return: void. -*/ -static void _set_btn_directions(struct _ug_data *data) -{ - Evas_Object *dbtn, *sbtn, *tbtn, *cbtn; - - if (!data || !data->date_btn || - !data->switch_btn || !data->time_btn) { - _ERR("all the sublist buttons may null."); - return; - } - - dbtn = data->date_btn; - sbtn = data->switch_btn; - tbtn = data->time_btn; - cbtn = data->close_btn; - - elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(dbtn, sbtn, ELM_FOCUS_DOWN); - /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for date_btn */ - elm_object_focus_next_object_set(dbtn, cbtn, ELM_FOCUS_RIGHT); - - elm_object_focus_next_object_set(sbtn, tbtn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(sbtn, dbtn, ELM_FOCUS_UP); - /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for switch_btn */ - elm_object_focus_next_object_set(sbtn, cbtn, ELM_FOCUS_RIGHT); - - elm_object_focus_next_object_set(tbtn, tbtn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(tbtn, sbtn, ELM_FOCUS_UP); - /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for time_btn */ - elm_object_focus_next_object_set(tbtn, cbtn, ELM_FOCUS_RIGHT); - - elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(cbtn, dbtn, ELM_FOCUS_LEFT); -} - -/** -* Create buttons for clock UI gadget. -* -* The main UI of clock UI gadget contains three items which are Date, -* 24 Hour mode and Time. And they are implemented using buttons. -* This function is to create these three buttons. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_clock_sublist_btn(struct _ug_data *data) -{ - Evas_Object *date_btn; - Evas_Object *switch_btn; - Evas_Object *time_btn; - int ret; - - if (!data) - return -1; - - date_btn = _add_clock_sublist_date_btn(data); - if (!date_btn) { - _ERR("add date button failed."); - return -1; - } - - data->date_btn = date_btn; - - switch_btn = _add_clock_sublist_switch_btn(data); - if (!switch_btn) { - _ERR("add switch button failed."); - evas_object_del(data->date_btn); - return -1; - } - - data->switch_btn = switch_btn; - - time_btn = _add_clock_sublist_time_btn(data); - if (!time_btn) { - _ERR("add time button failed."); - evas_object_del(data->date_btn); - evas_object_del(data->switch_btn); - return -1; - } - - data->time_btn = time_btn; - - ret = _add_clock_sublist_null_btn(data); - if (ret != 0) { - _ERR("add null buttons failed."); - evas_object_del(data->date_btn); - evas_object_del(data->switch_btn); - evas_object_del(data->time_btn); - return -1; - } - - _set_btn_directions(data); - - return 0; -} - -/** -* Create UI components of clock UI gadget. -* -* This function creates the three UI components of clock UI gadget: -* Date, 24Hour mode and Time. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_clock_sublist(struct _ug_data *data) -{ - Evas_Object *box; - int ret; - - if (!data) - return -1; - - box = utils_add_box(data->base); - if (!box) { - _ERR("add clock sublist box failed."); - return -1; - } - - data->sublist_box = box; - - ret = _add_clock_sublist_btn(data); - if (ret != 0) { - _ERR("add clock sublist btn failed."); - evas_object_del(data->sublist_box); - return -1; - } - - elm_object_part_content_set( - data->base, SWALLOW_CLOCK_LIST, data->sublist_box); - - return 0; -} - -/** -* Create the UI of this ui gadget. -* -* This function creates all the UI components of this UI gadget. -* -* @param[in]: ug : the UI gadget created by ug_create(). -* @param[in]: mode : the mode of ug, fullview or frameview. -* @param[in]: service : argument for the UI gadget. -* @param[in]: priv : the user data. -* -* @return: The base layout of this UI gadget. -*/ static void *_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) { - struct _ug_data *data; + struct _ug_data *ugd; Evas_Object *win; - Evas_Object *base; - Evas_Object *close_btn; - int ret; if (!ug || !priv) { _ERR("ug or private data is null."); return NULL; } - if ((mode == UG_MODE_INVALID) || - (mode >= UG_MODE_MAX) || (mode < UG_MODE_FULLVIEW)) { + if ((mode == UG_MODE_INVALID) || (mode >= UG_MODE_MAX) || (mode < UG_MODE_FULLVIEW)) { _ERR("invalid ug mode."); return NULL; } elm_theme_overlay_add(NULL, UG_CLOCK_EDJTHEME); - data = (struct _ug_data *) priv; - data->ug = ug; + ugd = (struct _ug_data *) priv; + ugd->ug = ug; win = (Evas_Object *) ug_get_window(); if (!win) { _ERR("ug get window failed."); - _free_ug_data(data); return NULL; } - data->win = win; + ugd->win = win; elm_win_focus_highlight_enabled_set(win, EINA_TRUE); - base = utils_add_layout(win); - if (!base) { - _ERR("add base layout failed."); - _free_ug_data(data); - return NULL; - } - - elm_layout_file_set(base, UG_CLOCK_EDJFILE, UG_CLOCK_GRP); - elm_object_part_text_set( - base, TEXT_INTRO, STRINGS_INTRO); - data->base = base; - close_btn = _add_close_btn(base, data); - if (!close_btn) { - _ERR("add close button for ug clock failed."); - _free_ug_data(data); + CViewMgr::Initialize(ugd->win, NULL); + ugd->pViewMgr = CViewMgr::GetInstance(); + if(!ugd->pViewMgr) { + CViewMgr::Finalize(); + _ERR("Fail to get CViewMgr instance"); return NULL; } + ugd->pClockMainView = new CClockMainView(CLOCK_MAIN_VIEW); + if(!ugd->pViewMgr->AddView(ugd->pClockMainView)) { + _ERR("Fail to add pFbBaseView"); + CViewMgr::Finalize(); + return false; + } - ret = _add_clock_sublist(data); - if (ret == -1) { - _ERR("add clock sublist failed."); - evas_object_del(close_btn); - _free_ug_data(data); - return NULL; + ugd->pClockSublistView = new CClockSublistView(CLOCK_SUBLIST_VIEW); + if(!ugd->pViewMgr->AddView(ugd->pClockSublistView)) { + _ERR("Fail to add pFbBaseView"); + CViewMgr::Finalize(); + return false; } - evas_object_data_set(data->base, UG_CLOCK_DATA_ID, data); + ugd->pViewMgr->PushView(CLOCK_MAIN_VIEW, NULL); + ugd->base = ugd->pClockMainView->Base(); - return base; + return ugd->base; } /** @@ -974,169 +121,7 @@ static void *_on_create(ui_gadget_h ug, */ static void _on_destroy(ui_gadget_h ug, service_h service, void *priv) { - struct _ug_data *data; - - if (!ug || !priv) { - _ERR("ug or private data is null."); - return; - } - - data = (struct _ug_data *) priv; - - _free_ug_data(data); -} - -/** -* Refresh text of Date button. -* -* @param[in]: btn : the Date button. -* @param[in]: date : the user data. -* -* @return: void. -*/ -static void _refresh_date_btn_text(Evas_Object *btn, unsigned int *date) -{ - char buf[BUF_SIZE]; - - if (!btn || !date) - return; - - snprintf(buf, sizeof(buf), "%02d / %02d / %04d", - date[DATE_MONTH], date[DATE_DAY], date[DATE_YEAR]); - elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf); -} - -/** -* Refresh text of 24 Hour mode button. -* -* @param[in]: btn : the 24 Hour mode button. -* @param[in]: mode : the refreshed value of mode. -* -* @return: void. -*/ -static void _refresh_switch_btn_text(Evas_Object *btn, int mode) -{ - if (!btn) - return; - - if (mode) - elm_object_part_text_set(btn, BTN_PART_VALUE, ON); - else - elm_object_part_text_set(btn, BTN_PART_VALUE, OFF); -} - -/** -* Change the way of displayed time. -* -* This function displays time as the 24 Hour mode changes. -* If 24 Hour mode is ON, we display the time using 24 hour mode. -* If 24 Hour mode is OFF, we display the time using 12 hour mode. -* -* @param[in]: btn : the Time button. -* @param[in]: time : the value of time. -* -* @return: void. -*/ -static void _refresh_time_btn_as_mode(Evas_Object *btn, int *time) -{ - int mode; - int ret; - char buf[BUF_SIZE]; - - if (!btn || !time) - return; - - mode = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - if (mode) - snprintf(buf, sizeof(buf), "%02d : %02d", - time[TIME_HOUR], time[TIME_MINUTE]); - else - snprintf(buf, sizeof(buf), "%02d : %02d : %s", - time[TIME_HOUR], time[TIME_MINUTE], - time[TIME_AMPM] == 1 ? PM : AM); - - elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf); -} - -/** -* Refresh text of buttons. -* -* @param[in]: data : the user data. -* -* @return: void. -*/ -static void _refresh_btn_text(struct _ug_data *data) -{ - int ret; - - if (!data || !data->cur_btn) - return; - - if (data->date_btn == data->cur_btn) { - _refresh_date_btn_text(data->cur_btn, data->date); - } else if (data->switch_btn == data->cur_btn) { - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &data->mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - _refresh_switch_btn_text(data->cur_btn, data->mode); - - utils_get_time_value(data->time); - _refresh_time_btn_as_mode(data->time_btn, data->time); - } else { - _refresh_time_btn_text(data->cur_btn, data->time); - } -} - -/** -* Refresh the UI of clock UI gadget. -* -* This function refreshes the UI of clock UI gadget. For example, -* when the user sets a new date, this function will be called to refresh -* the date item of clock UI gadget. They are the same as mode item -* time item of clock UI gadget. -* -* @param[in]: base : the base layout of clock UI gadget. -* @param[in]: date : the user data. -* @param[in]: time : the new time need to be refreshed. -* -* @return: void. -*/ -void view_ug_clock_refresh(Evas_Object *base, unsigned int *date, int *time) -{ - struct _ug_data *data; - int idx; - - if (!base) { - _ERR("invalid argument."); - return; - } - - data = (struct _ug_data *) evas_object_data_get(base, UG_CLOCK_DATA_ID); - if (!data) { - _ERR("evas object data get failed. ID: %s", UG_CLOCK_DATA_ID); - return; - } - - elm_object_focus_set(data->cur_btn, EINA_TRUE); - - if (date) - for (idx = DATE_MONTH; idx < DATE_MAX; idx++) - data->date[idx] = date[idx]; - - if (time) - for (idx = TIME_HOUR; idx < TIME_MAX; idx++) - data->time[idx] = time[idx]; - - _refresh_btn_text(data); + CViewMgr::Finalize(); } /** diff --git a/ug/system/clock/src/ug_clock_spin_control.cpp b/ug/system/clock/src/ug_clock_spin_control.cpp deleted file mode 100644 index d832330..0000000 --- a/ug/system/clock/src/ug_clock_spin_control.cpp +++ /dev/null @@ -1,788 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dbg.h" -#include "ug_clock_define.h" -#include "ug_clock.h" -#include "ug_clock_spin_control.h" -#include "ug_clock_utils.h" - -#define ARROW_BTN_DATA_ID "arrow_btn_data_id" -#define DATE_SPIN_DATA_ID "spin_ctrl_data" -#define YEAR_BTN (2) - -#define UP_ARROW (1) -#define DOWN_ARROW (0) - -#define CLICKED "clicked" - -struct _date_spin_data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *ug_base; - - unsigned int date[DATE_MAX]; - int entry[DATE_MAX]; - - Eina_Array *spin_array; -}; - -static const int days[] = { - 31, - 28, - 31, - 30, - 31, - 30, - 31, - 31, - 30, - 31, - 30, - 31 -}; - -static void _destroy(Evas_Object *base); -static void _update_date_value(Evas_Object *spin, - unsigned int *date, int spin_idx); - -/** -* Free user data of date spin. -* -* @param[in]: data : the user data. -* -* @return: void. -*/ -static void _free_date_spin_data(struct _date_spin_data *data) -{ - if (!data) - return; - - if (data->base) { - evas_object_del(data->base); - data->base = NULL; - } - - if (data->spin_array) - eina_array_free(data->spin_array); - - free(data); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -void _arrow_btn_clicked_cb(void *priv, Evas_Object *obj, void *ev) -{ - struct _date_spin_data *data; - Evas_Object *cur_btn; - Evas_Object *btn; - Evas_Object *up_btn; - int i; - int idx; - int flag; - - if (!priv || !obj) - return; - - data = (struct _date_spin_data *) priv; - cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID); - if (!cur_btn) { - _ERR("evas object data get failed. ID: %s", ARROW_BTN_DATA_ID); - return; - } - - up_btn = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW); - if (!up_btn) { - _ERR("part %s content get failed.", UP_ARROW_SWALLOW); - return; - } - - if (obj == up_btn) - flag = 1; - else - flag = 0; - - idx = 0; - for (i = DATE_DAY; i < DATE_MAX; i++) { - btn = (Evas_Object *) eina_array_data_get(data->spin_array, i); - if (!btn) { - _ERR("eina array data get failed. button index: %d", i); - return; - } - - if (cur_btn == btn) { - idx = i; - break; - } - } - - if (flag) - data->date[idx]++; - else - data->date[idx]--; - - _update_date_value(cur_btn, data->date, idx); - -} - -/** -* Create arrow buttons for date spin. -* -* @param[in]: data : the user data. -* @param[in]: obj : the corresponding object which the arrow created on. -* @param[in]: flag : 1 - up arrow button, 0 - down arrow button. -* -* @return: the created arrow button. -*/ -static Evas_Object *_add_arrow_btn(struct _date_spin_data *data, - Evas_Object *obj, int flag) -{ - Evas_Object *btn; - - if (!data || !data->base || !obj) - return NULL; - - btn = utils_add_button(data->base); - if (!btn) { - _ERR("utils add button failed."); - return NULL; - } - - elm_object_style_set(btn, BTN_STYLE_ARROW_BTN); - - if (flag == UP_ARROW) - elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn); - else - elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn); - - elm_object_focus_allow_set(btn, EINA_FALSE); - - evas_object_smart_callback_add(btn, "clicked", - _arrow_btn_clicked_cb, data); - - evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj); - evas_object_raise(btn); - evas_object_repeat_events_set(btn, EINA_FALSE); - - return btn; -} - -/** -* Create date spin. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_date_spin(struct _date_spin_data *data) -{ - Evas_Object *btn, *uparrow, *downarrow; - Eina_Array *array; - char buf[BUF_SIZE]; - int idx; - - if (!data || !data->base) { - _ERR("invalid arguments."); - return -1; - } - - array = eina_array_new(1); - if (!array) { - _ERR("new eina array failed."); - return -1; - } - - for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { - btn = utils_add_button(data->base); - if (!btn) { - _ERR("add spin control button failed."); - return -1; - } - - elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_BTN); - if (idx == YEAR_BTN) - elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_YEAR_BTN); - - snprintf(buf, sizeof(buf), "spin_ctrl_%d_swallow", idx + 1); - elm_object_part_content_set( - data->base, (const char *)buf, btn); - - eina_array_push(array, btn); - - uparrow = _add_arrow_btn(data, btn, UP_ARROW); - if (!uparrow) { - _ERR("add up arrow button failed."); - evas_object_del(btn); - return -1; - } - - downarrow = _add_arrow_btn(data, btn, DOWN_ARROW); - if (!downarrow) { - _ERR("add down arrow button failed."); - evas_object_del(btn); - evas_object_del(uparrow); - return -1; - } - } - - elm_object_focus_set((Evas_Object *) eina_array_data_get(array, 0), EINA_TRUE); - - data->spin_array = array; - - return 0; -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_spin_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _date_spin_data *data; - - if (!priv) { - _ERR("invalid argument."); - return; - } - - data = (struct _date_spin_data *) priv; - - utils_set_date_value(data->date); - - view_ug_clock_refresh(data->ug_base, data->date, NULL); - - _destroy(data->base); -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse in event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse in event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_spin_mousein_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse out event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse out event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_spin_mouseout_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static int _add_date_spin_click_event(struct _date_spin_data *data) -{ - Evas_Object *spin; - Eina_Array *array; - int idx; - - if (!data || !data->spin_array) { - _ERR("no spin control buttons."); - return -1; - } - - array = data->spin_array; - - for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { - spin = (Evas_Object *) eina_array_data_get(array, idx); - if (!spin) { - _ERR("eina array data get failed. spin index: %d", idx); - return -1; - } - - evas_object_smart_callback_add(spin, CLICKED, - _date_spin_clicked_cb, data); - evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_IN, - _date_spin_mousein_cb, NULL); - evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_OUT, - _date_spin_mouseout_cb, NULL); - } - - return 0; -} - -/** -* Set focus move directions among buttons. -* -* @param[in]: array : the eina array including buttons. -* -* @return: void. -*/ -static void _set_date_spin_direction(Eina_Array *array) -{ - Evas_Object *spin; - int idx; - - if (!array) { - _ERR("spin control button array is null."); - return; - } - - for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { - spin = (Evas_Object *) eina_array_data_get(array, idx); - if (!spin) { - _ERR("there is no button. idx: %d", idx); - return; - } - - elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_UP); - elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_DOWN); - - if (idx == DATE_MONTH) { - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx+1), - ELM_FOCUS_NEXT); - elm_object_focus_next_object_set(spin, spin, - ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx + 1), - ELM_FOCUS_RIGHT); - } else if (idx == DATE_YEAR) { - elm_object_focus_next_object_set(spin, spin, - ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx - 1), - ELM_FOCUS_LEFT); - } else { - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx + 1), - ELM_FOCUS_NEXT); - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx + 1), - ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(array, idx - 1), - ELM_FOCUS_LEFT); - } - } -} - -/** -* Initialize value of date spin. -* -* @param[in]: data : the user data. -* -* @return: void. -*/ -static void _init_date_spin(struct _date_spin_data *data) -{ - Evas_Object *spin; - Eina_Array *spin_array; - char buf[BUF_SIZE]; - - if (!data || !data->spin_array) - return; - - spin_array = data->spin_array; - - utils_get_date_value(data->date); - - spin = (Evas_Object *) eina_array_data_get(spin_array, 0); - if (!spin) { - _ERR("month button is null."); - return; - } - - snprintf(buf, sizeof(buf), "%02d", data->date[DATE_MONTH]); - elm_object_text_set(spin, buf); - - spin = (Evas_Object *) eina_array_data_get(spin_array, 1); - if (!spin) { - _ERR("month button is null."); - return; - } - - snprintf(buf, sizeof(buf), "%02d", data->date[DATE_DAY]); - elm_object_text_set(spin, buf); - - spin = (Evas_Object *) eina_array_data_get(spin_array, 2); - if (!spin) { - _ERR("month button is null."); - return; - } - - data->date[DATE_YEAR] = data->date[DATE_YEAR] < 2000 ? - 2000 : data->date[DATE_YEAR]; - snprintf(buf, sizeof(buf), "%04d", data->date[DATE_YEAR]); - elm_object_text_set(spin, buf); -} - -/** -* Update value of date spin. -* -* @param[in]: spin : the corresponding date spin whose value need to update. -* @param[in]: date : the value to be updated. -* @param[in]: spin_idx : the index of corresponding date spin. -* -* @return: void. -*/ -static void _update_date_value(Evas_Object *spin, - unsigned int *date, int spin_idx) -{ - char buf[BUF_SIZE]; - - if (!spin || !date) - return; - if (spin_idx < DATE_MONTH || spin_idx >= DATE_MAX) - return; - - if (spin_idx == DATE_MONTH) { - if (date[spin_idx] > 12) - date[spin_idx] = 1; - if (date[spin_idx] <= 0) - date[spin_idx] = 12; - - snprintf(buf, sizeof(buf), "%02d", date[spin_idx]); - } else if (spin_idx == DATE_DAY) { - if (date[spin_idx] > days[date[DATE_MONTH] - 1]) - date[spin_idx] = 1; - if (date[spin_idx] <= 0) - date[spin_idx] = days[date[DATE_MONTH] - 1]; - - snprintf(buf, sizeof(buf), "%02d", date[spin_idx]); - } else { - if (date[spin_idx] > 2037) - date[spin_idx] = 2000; - if (date[spin_idx] < 2000) - date[spin_idx] = 2037; - - snprintf(buf, sizeof(buf), "%04d", date[spin_idx]); - } - - elm_object_text_set(spin, buf); -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _date_spin_keydown_cb(void *priv, Evas *e, - Evas_Object *obj, void *ei) -{ - Evas_Event_Key_Down *event; - struct _date_spin_data *data; - const char *keyname; - int i, idx; - Evas_Object *spin; - Eina_Array *spin_array; - char buf[BUF_SIZE]; - - if (!priv || !ei || !obj) { - _ERR("invalid argument."); - return; - } - - event = (Evas_Event_Key_Down *) ei; - keyname = event->keyname; - if (!keyname) - return; - - data = (struct _date_spin_data *) priv; - - if (!data->spin_array) - return; - - spin_array = data->spin_array; - - idx = -1; - for (i = DATE_MONTH; i < DATE_MAX; i++) { - spin = (Evas_Object *) eina_array_data_get(spin_array, i); - if (!spin) - return; - - if (obj == spin) { - idx = i; - break; - } - } - - if (idx == -1) { - _ERR("can't get the right spin."); - return; - } - - if (!strncmp(keyname, KEY_UP, strlen(keyname))) { - data->date[idx]++; - _update_date_value(obj, data->date, idx); - } else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) { - data->date[idx]--; - _update_date_value(obj, data->date, idx); - } else if (!strncmp(keyname, KEY_0, strlen(keyname)) || - !strncmp(keyname, KEY_1, strlen(keyname)) || - !strncmp(keyname, KEY_2, strlen(keyname)) || - !strncmp(keyname, KEY_3, strlen(keyname)) || - !strncmp(keyname, KEY_4, strlen(keyname)) || - !strncmp(keyname, KEY_5, strlen(keyname)) || - !strncmp(keyname, KEY_6, strlen(keyname)) || - !strncmp(keyname, KEY_7, strlen(keyname)) || - !strncmp(keyname, KEY_8, strlen(keyname)) || - !strncmp(keyname, KEY_9, strlen(keyname))) { - if (idx != DATE_YEAR) { - if (data->entry[idx] == 0) { - data->entry[idx]++; - - data->date[idx] = atoi(keyname); - } else { - data->entry[idx]++; - - data->date[idx] = data->date[idx] * 10 - + atoi(keyname); - data->entry[idx] = 0; - elm_object_focus_next(obj, ELM_FOCUS_NEXT); - } - } else { - if (data->entry[idx] == 0) { - data->entry[idx]++; - data->date[idx] = atoi(keyname); - - snprintf(buf, sizeof(buf), "%04d", - data->date[idx]); - elm_object_text_set(obj, buf); - return; - } else if (data->entry[idx] == 3) { - data->date[idx] = data->date[idx] * 10 - + atoi(keyname); - data->entry[idx] = 0; - } else { - data->entry[idx]++; - data->date[idx] = data->date[idx] * 10 - + atoi(keyname); - - snprintf(buf, sizeof(buf), "%04d", - data->date[idx]); - elm_object_text_set(obj, buf); - return; - } - } - - _update_date_value(obj, data->date, idx); - } else if (!strncmp(keyname, KEY_RIGHT, strlen(keyname)) || - !strncmp(keyname, KEY_LEFT, strlen(keyname))) { - data->entry[idx] = 0; - } else if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) { - _destroy(data->base); - } -} - -/** -* Add key event for date spin. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_date_spin_key_event(struct _date_spin_data *data) -{ - Evas_Object *spin; - int idx; - - if (!data || !data->spin_array) { - _ERR("invalid argument."); - return -1; - } - - for (idx = DATE_MONTH; idx < DATE_MAX; idx++) { - spin = (Evas_Object *) eina_array_data_get(data->spin_array, idx); - if (!spin) { - _ERR("button is null."); - return -1; - } - - evas_object_event_callback_add(spin, EVAS_CALLBACK_KEY_DOWN, - _date_spin_keydown_cb, data); - } - - return 0; -} - -/** -* Create data spin. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_spin(struct _date_spin_data *data) -{ - int ret; - - if (!data || !data->base) { - _ERR("private data is null."); - return -1; - } - - ret = _add_date_spin(data); - if (ret != 0) { - _ERR("add spin control buttons failed."); - return -1; - } - - _init_date_spin(data); - - _set_date_spin_direction(data->spin_array); - - ret = _add_date_spin_click_event(data); - if (ret != 0) { - _ERR("add click event for spin control button failed."); - return -1; - } - - ret = _add_date_spin_key_event(data); - if (ret != 0) { - _ERR("add key event for spin control button failed."); - return -1; - } - - return 0; -} - -/** -* Create all UI components of date spin. -* -* @param[in]: data : the user data. -* -* @return: the base layout of date spin. -*/ -static Evas_Object *_create(struct _date_spin_data *data) -{ - Evas_Object *base; - int ret; - - if (!data || !data->win) { - _ERR("window for spin control base is null."); - return NULL; - } - - base = utils_add_layout(data->win); - if (!base) { - _ERR("add base layout for spin control failed."); - return NULL; - } - - data->base = base; - elm_layout_file_set(base, UG_CLOCK_EDJFILE, SPIN_CTRL_GRP); - - ret = _add_spin(data); - if (ret != 0) { - _ERR("add spin control failed."); - evas_object_del(data->base); - data->base = NULL; - return NULL; - } - - evas_object_data_set(data->base, DATE_SPIN_DATA_ID, data); - - return base; -} - -/** -* Destroy all the UI componets of date spin. -* -* @param[in]: base : the base layout of date spin. -* -* @return: void. -*/ -static void _destroy(Evas_Object *base) -{ - struct _date_spin_data *data; - - if (!base) { - _ERR("base is null."); - return; - } - - data = (struct _date_spin_data *) evas_object_data_get(base, DATE_SPIN_DATA_ID); - if (!data) { - _ERR("evas object get data failed. ID: %s", DATE_SPIN_DATA_ID); - return; - } - - _free_date_spin_data(data); -} - -/** -* Entry of creating date spin UI. -* -* @param[in]: win : window. -* @param[in]: ug_base : the base layout of clock UI gadget. -* -* @return: void. -*/ -void view_spin_control_create(Evas_Object *win, - Evas_Object *ug_base) -{ - Evas_Object *base; - struct _date_spin_data *data; - - if (!win || !ug_base) { - _ERR("the window of spin control is null."); - return; - } - - data = (struct _date_spin_data *) calloc(1, sizeof(*data)); - if (!data) { - _ERR("calloc spin control data memory failed."); - return; - } - - data->win = win; - data->ug_base = ug_base; - - base = _create(data); - if (!base) { - _ERR("create spin control failed."); - _free_date_spin_data(data); - } -} diff --git a/ug/system/clock/src/ug_clock_sublist.cpp b/ug/system/clock/src/ug_clock_sublist.cpp deleted file mode 100644 index c47b5e8..0000000 --- a/ug/system/clock/src/ug_clock_sublist.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "dbg.h" -#include "ug_clock_define.h" -#include "ug_clock_sublist.h" -#include "ug_clock_utils.h" -#include "ug_clock.h" - -#define SUBLIST_BTN_NUM 2 -#define SUBLIST_DATA_ID "sublist_data" - -#define BOX_HPADDING 0 -#define BOX_VPADDING 2 - -#define CLICKED "clicked" - -struct _sublist_data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *ug_base; - Evas_Object *box; - - unsigned int mode; - - Eina_Array *array; -}; - -static void _destroy(Evas_Object *base); - -/** -* Free user data of mode sublist. -* -* @param[in]: data : the user data of mode sublist. -* -* @return: void. -*/ -static void _free_sublist_data(struct _sublist_data *data) -{ - if (!data) - return; - - if (data->base) { - evas_object_del(data->base); - data->base = NULL; - } - - if (data->array) - eina_array_free(data->array); - - free(data); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _sublist_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei) -{ - struct _sublist_data *data; - Eina_Array *array; - Evas_Object *on_btn, *off_btn; - int ret; - - if (!priv || !obj) { - _ERR("invalid argument."); - return; - } - - data = (struct _sublist_data *) priv; - - if (!data->array) - return; - - array = data->array; - - on_btn = (Evas_Object *) eina_array_data_get(array, 0); - off_btn = (Evas_Object *) eina_array_data_get(array, 1); - if (!on_btn || !off_btn) { - _ERR("ON button or OFF button is null."); - return; - } - - if (obj == on_btn) - data->mode = 1; - else - data->mode = 0; - - ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, data->mode); - if (ret != 0) { - _ERR("set 24hour mode failed."); - return; - } - - view_ug_clock_refresh(data->ug_base, NULL, NULL); - - _destroy(data->base); -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _key_down_on_sublist_btn_cb(void *priv, Evas *e, - Evas_Object *obj, void *ei) -{ - Evas_Object *on_btn, *off_btn; - Eina_Array *array; - Evas_Event_Key_Down *event; - struct _sublist_data *data; - const char *keyname; - int mode; - int ret; - - if (!priv || !ei || !obj) - return; - - data = (struct _sublist_data *) priv; - - if (!data->array || !data->base) - return; - - array = data->array; - - event = (Evas_Event_Key_Down *) ei; - - if (!event->keyname) - return; - - keyname = event->keyname; - - on_btn = (Evas_Object *) eina_array_data_get(array, 0); - off_btn = (Evas_Object *) eina_array_data_get(array, 1); - if (!on_btn || !off_btn) { - _ERR("ON button or OFF button is null."); - return; - } - - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) { - if (obj != on_btn) - return; - - elm_object_focus_set(off_btn, EINA_TRUE); - - if (mode) { - elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, - SIG_NAME_SUBLIST); - elm_object_signal_emit(off_btn, SIG_SRC_FOC_HIDE_ICON, - SIG_NAME_SUBLIST); - } else { - elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, - SIG_NAME_SUBLIST); - elm_object_signal_emit(off_btn, SIG_SRC_FOC_SHOW_ICON, - SIG_NAME_SUBLIST); - } - } else if (!strncmp(keyname, KEY_UP, strlen(keyname))) { - if (obj == on_btn) - return; - - elm_object_focus_set(on_btn, EINA_TRUE); - - if (mode) { - elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON, - SIG_NAME_SUBLIST); - elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, - SIG_NAME_SUBLIST); - } else { - elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, - SIG_NAME_SUBLIST); - elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON, - SIG_NAME_SUBLIST); - } - } else if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) { - _destroy(data->base); - } -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse in event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse in event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _sublist_btn_mouse_in_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse out event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse out event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _sublist_btn_mouse_out_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ -} - -/** -* Create mode sublist buttons. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_sublist_btns(struct _sublist_data *data) -{ - Eina_Array *array; - Evas_Object *btn; - Evas_Object *box; - int idx; - - if (!data || !data->base || !data->box) { - _ERR("invalid arguments."); - return -1; - } - - box = data->box; - elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING); - - array = eina_array_new(1); - if (!array) { - _ERR("new array for sublist buttons failed."); - return -1; - } - - for (idx = 0; idx < SUBLIST_BTN_NUM; idx++) { - btn = utils_add_button(data->base); - if (!btn) { - _ERR("add button failed."); - eina_array_free(array); - return -1; - } - - evas_object_smart_callback_add(btn, CLICKED, - _sublist_btn_clicked_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - _key_down_on_sublist_btn_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _sublist_btn_mouse_in_cb, NULL); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _sublist_btn_mouse_out_cb, NULL); - - elm_object_style_set(btn, BTN_STYLE_SUBLIST_BTN); - - elm_box_pack_end(box, btn); - eina_array_push(array, btn); - } - - data->array = array; - - elm_object_part_content_set(data->base, - SWALLOW_SUBLIST, data->box); - - return 0; -} - -/** -* Initialize value of mode sublist. -* -* @param[in]: array : eina array including mode sublist buttons. -* -* @return: void. -*/ -static void _set_sublist_init_value(Eina_Array *array) -{ - Evas_Object *on_btn, *off_btn; - int mode; - int ret; - - if (!array) - return; - - mode = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - on_btn = (Evas_Object *) eina_array_data_get(array, 0); - off_btn = (Evas_Object *) eina_array_data_get(array, 1); - if (!on_btn || !off_btn) { - _ERR("there is no button in sublist array."); - return; - } - - elm_object_focus_set(on_btn, EINA_TRUE); - - elm_object_text_set(on_btn, ON); - elm_object_text_set(off_btn, OFF); - - if (mode) { - elm_object_signal_emit(on_btn, - SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST); - elm_object_signal_emit(off_btn, - SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST); - } else { - elm_object_signal_emit(off_btn, - SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST); - elm_object_signal_emit(on_btn, - SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST); - } -} - -/** -* Set focus move directions among mode sublist buttons. -* -* @param[in]: array : the eina array including mode sublist buttons. -* -* @return: void. -*/ -static void _set_sublist_btn_directions(Eina_Array *array) -{ - Evas_Object *on_btn, *off_btn; - - if (!array) - return; - - on_btn = (Evas_Object *) eina_array_data_get(array, 0); - off_btn = (Evas_Object *) eina_array_data_get(array, 1); - if (!on_btn || !off_btn) { - _ERR("get sublist button from array failed."); - return; - } - - elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(on_btn, off_btn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_RIGHT); - - elm_object_focus_next_object_set(off_btn, on_btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_RIGHT); -} - -/** -* Create mode sublist. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_sublist(struct _sublist_data *data) -{ - int ret; - Evas_Object *box; - - if (!data || !data->base) { - _ERR("invalid argument."); - return -1; - } - - box = utils_add_box(data->base); - if (!box) { - _ERR("add sublist box failed."); - return -1; - } - - data->box = box; - - ret = _add_sublist_btns(data); - if (ret != 0) { - _ERR("add sublist buttons failed."); - evas_object_del(data->box); - data->box = NULL; - return -1; - } - - _set_sublist_init_value(data->array); - _set_sublist_btn_directions(data->array); - - return 0; -} - -/** -* Destroy all the UI componets of mode sublist. -* -* @param[in]: base : the base layout of mode sublist. -* -* @return: void. -*/ -static void _destroy(Evas_Object *base) -{ - struct _sublist_data *data; - - if (!base) - return; - - data = (struct _sublist_data *) evas_object_data_get(base, SUBLIST_DATA_ID); - if (!data) { - _ERR("evas object get data failed. ID: %s", SUBLIST_DATA_ID); - return; - } - - _free_sublist_data(data); -} - -/** -* Create all the UI componets of mode sublist. -* -* @param[in]: data : the user data. -* -* @return: the base layout of mode sublist. -*/ -static Evas_Object *_create(struct _sublist_data *data) -{ - Evas_Object *base; - int ret; - - if (!data || !data->win) { - _ERR("invalid argument."); - return NULL; - } - - base = utils_add_layout(data->win); - if (!base) { - _ERR("add base layout for sublist failed."); - return NULL; - } - - data->base = base; - - elm_layout_file_set(base, UG_CLOCK_EDJFILE, SUBLIST_GRP); - - ret = _add_sublist(data); - if (ret != 0) { - _ERR("add sublist failed."); - evas_object_del(data->base); - data->base = NULL; - return NULL; - } - - evas_object_data_set(data->base, SUBLIST_DATA_ID, data); - - return base; -} - -/** -* Entry of creating mode sublist. -* -* @parma[in]: win : window. -* @param[in]: ug_base : the base layout of clock UI gadget. -* -* @return: void. -*/ -void view_sublist_create(Evas_Object *win, Evas_Object *ug_base) -{ - Evas_Object *base; - struct _sublist_data *data; - - if (!win || !ug_base) { - _ERR("the window or base layout is null."); - return; - } - - data = (struct _sublist_data *) calloc(1, sizeof(*data)); - if (!data) { - _ERR("calloc sublist data failed."); - return; - } - data->win = win; - data->ug_base = ug_base; - - base = _create(data); - if (!base) { - _ERR("create sublist failed."); - _free_sublist_data(data); - } -} diff --git a/ug/system/clock/src/ug_clock_time_spin_control.cpp b/ug/system/clock/src/ug_clock_time_spin_control.cpp deleted file mode 100644 index 0c100f9..0000000 --- a/ug/system/clock/src/ug_clock_time_spin_control.cpp +++ /dev/null @@ -1,840 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dbg.h" -#include "ug_clock_define.h" -#include "ug_clock.h" -#include "ug_clock_time_spin_control.h" -#include "ug_clock_utils.h" - -#define ARROW_BTN_DATA_ID "arrow_btn_data_id" -#define TIME_SPIN_DATA_ID "time_spin_ctrl_data" - -#define BOX_HPADDING 2 -#define BOX_VPADDING 122 - -#define UP_ARROW (1) -#define DOWN_ARROW (0) - -struct _time_spin_data { - Evas_Object *win; - Evas_Object *base; - Evas_Object *ug_base; - Evas_Object *spin_box; - - int time[TIME_MAX]; - int entry[TIME_MAX]; - - Eina_Array *spin_array; -}; - -static void _destroy(Evas_Object *base); - -/** -* Free user data of time spin. -* -* @param[in]: data : the user data. -* -* @return: void. -*/ -static void _free_time_spin_data(struct _time_spin_data *data) -{ - if (!data) - return; - - if (data->base) { - evas_object_del(data->base); - data->base = NULL; - } - - if (data->spin_array) - eina_array_free(data->spin_array); - - free(data); -} - -/** -* Update value of time spin. -* -* @param[in]: spin : the corresponding date spin whose value need to update. -* @param[in]: date : the value to be updated. -* @param[in]: spin_idx : the index of corresponding time spin. -* -* @return: void. -*/ -static void _update_time_value(Evas_Object *btn, int *time, int btn_idx) -{ - int mode; - char buf[BUF_SIZE]; - int ret; - - if (!btn || !time) - return; - if (btn_idx < TIME_HOUR || btn_idx >= TIME_MAX) - return; - - mode = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return; - } - - if (btn_idx == TIME_HOUR) { - if (mode) { - if (time[btn_idx] > 23) - time[btn_idx] = 0; - if (time[btn_idx] < 0) - time[btn_idx] = 23; - } else { - if (time[btn_idx] > 11) - time[btn_idx] = 0; - if (time[btn_idx] < 0) - time[btn_idx] = 11; - } - - snprintf(buf, sizeof(buf), "%02d", time[btn_idx]); - } else if (btn_idx == TIME_MINUTE) { - if (time[btn_idx] > 59) - time[btn_idx] = 0; - if (time[btn_idx] < 0) - time[btn_idx] = 59; - - snprintf(buf, sizeof(buf), "%02d", time[btn_idx]); - } else { - if (time[btn_idx]) - snprintf(buf, sizeof(buf), "%s", PM); - else - snprintf(buf, sizeof(buf), "%s", AM); - } - - elm_object_text_set(btn, buf); -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_spin_keydown_cb(void *priv, - Evas *e, Evas_Object *obj, void *ei) -{ - Evas_Event_Key_Down *event; - struct _time_spin_data *data; - const char *keyname; - Eina_Array *array; - Evas_Object *hour_btn, *minute_btn; - - if (!priv || !ei || !obj) { - _ERR("invalid argument."); - return; - } - - data = (struct _time_spin_data *) priv; - - if (!data->spin_array) - return; - - array = data->spin_array; - - hour_btn = (Evas_Object *) eina_array_data_get(array, TIME_HOUR); - minute_btn = (Evas_Object *) eina_array_data_get(array, TIME_MINUTE); - if (!hour_btn || !minute_btn) { - _ERR("eina array data get failed."); - return; - } - - event = (Evas_Event_Key_Down *) ei; - - if (!event->keyname) - return; - - keyname = event->keyname; - - if (!strncmp(keyname, KEY_UP, strlen(keyname))) { - if (obj == hour_btn) { - data->time[TIME_HOUR]++; - - _update_time_value(obj, data->time, TIME_HOUR); - } else if (obj == minute_btn) { - data->time[TIME_MINUTE]++; - - _update_time_value(obj, data->time, TIME_MINUTE); - } else { - if (data->time[TIME_AMPM] == 0) - data->time[TIME_AMPM] = 1; - else - data->time[TIME_AMPM] = 0; - - _update_time_value(obj, data->time, TIME_AMPM); - } - } else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) { - if (obj == hour_btn) { - data->time[TIME_HOUR]--; - _update_time_value(obj, data->time, TIME_HOUR); - } else if (obj == minute_btn) { - data->time[TIME_MINUTE]--; - _update_time_value(obj, data->time, TIME_MINUTE); - } else { - if (data->time[TIME_AMPM] == 0) - data->time[TIME_AMPM] = 1; - else - data->time[TIME_AMPM] = 0; - - _update_time_value(obj, data->time, TIME_AMPM); - } - } else if (!strncmp(keyname, KEY_0, strlen(keyname)) || - !strncmp(keyname, KEY_1, strlen(keyname)) || - !strncmp(keyname, KEY_2, strlen(keyname)) || - !strncmp(keyname, KEY_3, strlen(keyname)) || - !strncmp(keyname, KEY_4, strlen(keyname)) || - !strncmp(keyname, KEY_5, strlen(keyname)) || - !strncmp(keyname, KEY_6, strlen(keyname)) || - !strncmp(keyname, KEY_7, strlen(keyname)) || - !strncmp(keyname, KEY_8, strlen(keyname)) || - !strncmp(keyname, KEY_9, strlen(keyname))) { - if (obj == hour_btn) { - if (data->entry[TIME_HOUR] == 0) { - data->entry[TIME_HOUR]++; - data->time[TIME_HOUR] = atoi(keyname); - } else { - data->entry[TIME_HOUR]++; - data->time[TIME_HOUR] = - (data->time[TIME_HOUR] * 10) + - atoi(keyname); - data->entry[TIME_HOUR] = 0; - - elm_object_focus_next(obj, ELM_FOCUS_NEXT); - } - - _update_time_value(obj, data->time, TIME_HOUR); - } else if (obj == minute_btn) { - if (data->entry[TIME_MINUTE] == 0) { - data->entry[TIME_MINUTE]++; - data->time[TIME_MINUTE] = atoi(keyname); - } else { - data->entry[TIME_MINUTE]++; - data->time[TIME_MINUTE] = - (data->time[TIME_MINUTE] * 10) + - atoi(keyname); - data->entry[TIME_MINUTE] = 0; - - elm_object_focus_next(obj, ELM_FOCUS_NEXT); - } - - _update_time_value(obj, data->time, TIME_MINUTE); - } else { - return; - } - } else if (!strncmp(keyname, KEY_LEFT, strlen(keyname)) || - !strncmp(keyname, KEY_RIGHT, strlen(keyname))) { - if (obj == hour_btn) - data->entry[TIME_HOUR] = 0; - else if (obj == minute_btn) - data->entry[TIME_MINUTE] = 0; - else - return; - } else if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) { - _destroy(data->base); - } -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_spin_click_cb(void *priv, - Evas_Object *obj, void *ei) -{ - struct _time_spin_data *data; - - if (!priv) - return; - - data = (struct _time_spin_data *)priv; - - utils_set_time_value(data->time); - view_ug_clock_refresh(data->ug_base, NULL, data->time); - _destroy(data->base); -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse in event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse in event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_spin_mousein_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - if (!obj) - return; - - elm_object_focus_set(obj, EINA_TRUE); -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse out event. -* -* @param[in]: dt : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse out event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _time_spin_mouseout_cb(void *dt, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operation when needed. */ -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _arrowbtn_clicked_cb(void *priv, Evas_Object *obj, void *ev) -{ - struct _time_spin_data *data; - Evas_Object *cur_btn; - Evas_Object *btn; - Evas_Object *up; - int i; - int idx; - int flag; - - if (!priv || !obj) - return; - - data = (struct _time_spin_data *)priv; - cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID); - if (!cur_btn) - return; - - up = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW); - if (!up) - return; - - if (obj == up) - flag = 1; - else - flag = 0; - - idx = 0; - for (i = TIME_HOUR; i < TIME_MAX; i++) { - btn = (Evas_Object *) eina_array_data_get(data->spin_array, i); - - if (cur_btn == btn) { - idx = i; - break; - } - } - - if (idx != TIME_AMPM) { - if (flag) - data->time[idx]++; - else - data->time[idx]--; - } else { - if (data->time[idx] == 0) - data->time[idx] = 1; - else - data->time[idx] = 0; - } - - _update_time_value(cur_btn, data->time, idx); -} - -/** -* Create arrow buttons for time spin. -* -* @param[in]: data : the user data. -* @param[in]: obj : the corresponding object which the arrow created on. -* @param[in]: flag : 1 - up arrow button, 0 - down arrow button. -* -* @return: the created arrow button. -*/ -static Evas_Object *_add_arrow_btn(struct _time_spin_data *data, - Evas_Object *obj, int flag) -{ - Evas_Object *btn; - - if (!data || !data->base || !obj) - return NULL; - - btn = utils_add_button(data->base); - if (!btn) { - _ERR("utils add button failed."); - return NULL; - } - - elm_object_style_set(btn, BTN_STYLE_ARROW_BTN); - - if (flag == UP_ARROW) - elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn); - else - elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn); - - elm_object_focus_allow_set(btn, EINA_FALSE); - - evas_object_smart_callback_add(btn, "clicked", - _arrowbtn_clicked_cb, data); - - evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj); - evas_object_raise(btn); - evas_object_repeat_events_set(btn, EINA_FALSE); - - return btn; -} - -/** -* Create time spin for 12 hour mode. -* -* @parma[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_time_spin_without_ampm(struct _time_spin_data *data) -{ - Evas_Object *box; - Evas_Object *btn; - Evas_Object *uparrow, *downarrow; - Eina_Array *array; - char buf[BUF_SIZE]; - int idx; - - if (!data || !data->base || !data->spin_box) { - _ERR("invalid argument."); - return -1; - } - - box = data->spin_box; - elm_box_horizontal_set(box, EINA_TRUE); - elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING); - - array = eina_array_new(1); - if (!array) { - _ERR("new eina array failed."); - return -1; - } - - for (idx = TIME_HOUR; idx < TIME_AMPM; idx++) { - btn = utils_add_button(data->base); - if (!btn) { - _ERR("add time spin control button failed."); - return -1; - } - - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - _time_spin_keydown_cb, data); - evas_object_smart_callback_add( - btn, "clicked", _time_spin_click_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _time_spin_mousein_cb, NULL); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _time_spin_mouseout_cb, NULL); - - elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN); - - snprintf(buf, sizeof(buf), "%02d", data->time[idx]); - elm_object_text_set(btn, buf); - - eina_array_push(array, btn); - - elm_box_pack_end(box, btn); - - uparrow = _add_arrow_btn(data, btn, UP_ARROW); - if (!uparrow) { - _ERR("add up arrow button failed."); - evas_object_del(btn); - return -1; - } - - downarrow = _add_arrow_btn(data, btn, DOWN_ARROW); - if (!downarrow) { - _ERR("add down arrow button failed."); - evas_object_del(btn); - evas_object_del(uparrow); - return -1; - } - } - - elm_object_focus_set((Evas_Object *) eina_array_data_get(array, TIME_HOUR), EINA_TRUE); - - data->spin_array = array; - - elm_object_part_content_set( - data->base, SWALLOW_TIME_SPIN_2, box); - - return 0; -} - -/** -* Create time spin for 24 hour mode. -* -* @parma[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_time_spin_with_ampm(struct _time_spin_data *data) -{ - Evas_Object *box; - Evas_Object *btn; - Evas_Object *uparrow, *downarrow; - Eina_Array *array; - char buf[BUF_SIZE]; - int idx; - - if (!data || !data->base || !data->spin_box) { - _ERR("invalid argument."); - return -1; - } - - box = data->spin_box; - elm_box_horizontal_set(box, EINA_TRUE); - elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING); - - array = eina_array_new(1); - if (!array) { - _ERR("new eina array failed."); - return -1; - } - - for (idx = TIME_HOUR; idx < TIME_MAX; idx++) { - btn = utils_add_button(data->base); - if (!btn) { - _ERR("add time spin control button failed."); - return -1; - } - - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - _time_spin_keydown_cb, data); - evas_object_smart_callback_add( - btn, "clicked", _time_spin_click_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _time_spin_mousein_cb, NULL); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _time_spin_mouseout_cb, NULL); - - elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN); - - if (idx != TIME_AMPM) { - snprintf(buf, sizeof(buf), "%02d", data->time[idx]); - elm_object_text_set(btn, buf); - } else { - if (data->time[idx]) - elm_object_text_set(btn, PM); - else - elm_object_text_set(btn, AM); - } - - eina_array_push(array, btn); - - elm_box_pack_end(box, btn); - - uparrow = _add_arrow_btn(data, btn, UP_ARROW); - if (!uparrow) { - _ERR("add up arrow button failed."); - evas_object_del(btn); - return -1; - } - - downarrow = _add_arrow_btn(data, btn, DOWN_ARROW); - if (!downarrow) { - _ERR("add down arrow button failed."); - evas_object_del(btn); - evas_object_del(uparrow); - return -1; - } - } - - elm_object_focus_set((Evas_Object *) eina_array_data_get(array, TIME_HOUR), EINA_TRUE); - - data->spin_array = array; - - elm_object_part_content_set( - data->base, SWALLOW_TIME_SPIN_1, box); - - return 0; -} - -/** -* Create buttons for time spin. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_time_spin_btns(struct _time_spin_data *data) -{ - int mode; - int ret; - - if (!data || !data->base || - !data->spin_box) { - _ERR("invalid argument."); - return -1; - } - - utils_get_time_value(data->time); - - mode = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode); - if (ret != 0) { - _ERR("vconf get value failed."); - return -1; - } - - if (mode) { - ret = _add_time_spin_without_ampm(data); - if (ret != 0) { - _ERR("add buttons without ampm failed."); - return -1; - } - } else { - ret = _add_time_spin_with_ampm(data); - if (ret != 0) { - _ERR("add buttons with ampm failed."); - return -1; - } - } - - return 0; -} - -/** -* Set focus move directions among time spin buttons. -* -* @param[in]: btn_array : eina array of time spin buttons. -* -* @return: void. -*/ -static void _set_time_spin_btn_directions(Eina_Array *btn_array) -{ - Evas_Object *btn; - unsigned int count; - int idx; - - if (!btn_array) { - _ERR("time spin control button array is null."); - return; - } - - count = eina_array_count(btn_array); - - for (idx = TIME_HOUR; idx < count; idx++) { - btn = (Evas_Object *) eina_array_data_get(btn_array, idx); - if (!btn) { - _ERR("there is no button. idx: %d", idx); - return; - } - - elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN); - - if (idx == TIME_HOUR) { - elm_object_focus_next_object_set(btn, btn, - ELM_FOCUS_LEFT); - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx + 1), - ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx + 1), - ELM_FOCUS_NEXT); - } else if (idx == count - 1) { - elm_object_focus_next_object_set(btn, btn, - ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx - 1), - ELM_FOCUS_LEFT); - } else { - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx + 1), - ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx + 1), - ELM_FOCUS_NEXT); - elm_object_focus_next_object_set(btn, - (Evas_Object *) eina_array_data_get(btn_array, idx - 1), - ELM_FOCUS_LEFT); - } - } -} - -/** -* Create time spin. -* -* @param[in]: data : the user data. -* -* @return: 0 - Success, -1 - Fail. -*/ -static int _add_time_spin(struct _time_spin_data *data) -{ - Evas_Object *box; - int ret; - - if (!data || !data->base) { - _ERR("private data is null."); - return -1; - } - - box = utils_add_box(data->base); - if (!box) { - _ERR("add time spin control box failed."); - return -1; - } - data->spin_box = box; - - ret = _add_time_spin_btns(data); - if (ret != 0) { - _ERR("add time spin control buttons failed."); - return -1; - } - - _set_time_spin_btn_directions(data->spin_array); - - return 0; -} - -/** -* Create all UI components of time spin. -* -* @param[in]: data : the user data. -* -* @return: the base layout of time spin. -*/ -static Evas_Object *_create(struct _time_spin_data *data) -{ - Evas_Object *base; - int onoff; - int ret; - - if (!data || !data->win) { - _ERR("window for time spin control base is null."); - return NULL; - } - - base = utils_add_layout(data->win); - if (!base) { - _ERR("add base layout for spin control failed."); - return NULL; - } - data->base = base; - elm_layout_file_set(base, UG_CLOCK_EDJFILE, TIME_SPIN_CTRL_GRP); - - onoff = 0; - ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &onoff); - if (ret != 0) { - _ERR("vconf get value failed."); - return NULL; - } - - if (onoff) - elm_object_signal_emit(base, SIGNAL_NAME_TIME_SPIN_2, - SIGNAL_SOURCE_TIME_SPIN); - else - elm_object_signal_emit(base, SIGNAL_NAME_TIME_SPIN_1, - SIGNAL_SOURCE_TIME_SPIN); - - ret = _add_time_spin(data); - if (ret != 0) { - _ERR("add time spin control failed."); - return NULL; - } - - evas_object_data_set(data->base, TIME_SPIN_DATA_ID, data); - - return base; -} - -/** -* Destroy all the UI componets of time spin. -* -* @param[in]: base : the base layout of time spin. -* -* @return: void. -*/ -void _destroy(Evas_Object *base) -{ - struct _time_spin_data *data; - - if (!base) { - _ERR("invalid argument."); - return; - } - - data = (struct _time_spin_data *)evas_object_data_get(base, TIME_SPIN_DATA_ID); - if (!data) { - _ERR("evas object get data failed. ID: %s", TIME_SPIN_DATA_ID); - return; - } - - _free_time_spin_data(data); -} - -/** -* Entry of creating time spin UI. -* -* @param[in]: win : window. -* @param[in]: ug_base : the base layout of clock UI gadget. -* -* @return: void. -*/ -void view_time_spin_ctrl_create(Evas_Object *win, - Evas_Object *ug_base) -{ - Evas_Object *base; - struct _time_spin_data *data; - - if (!win || !ug_base) { - _ERR("the window of time spin control is null."); - return; - } - - data = (struct _time_spin_data *) calloc(1, sizeof(*data)); - if (!data) { - _ERR("calloc time spin control data memory failed."); - return; - } - - data->win = win; - data->ug_base = ug_base; - - base = _create(data); - if (!base) { - _ERR("create time spin control failed."); - _free_time_spin_data(data); - } -} diff --git a/ug/system/clock/src/ug_clock_utils.cpp b/ug/system/clock/src/util.cpp similarity index 99% rename from ug/system/clock/src/ug_clock_utils.cpp rename to ug/system/clock/src/util.cpp index 34dc0ef..806d4e0 100755 --- a/ug/system/clock/src/ug_clock_utils.cpp +++ b/ug/system/clock/src/util.cpp @@ -18,7 +18,7 @@ #include #include "dbg.h" -#include "ug_clock_utils.h" +#include "util.h" static struct tm *_get_current_time(); static void _set_datetime(struct tm *t); -- 2.7.4 From 98f1dec04c70b17685111d22d81c02cef6c90864 Mon Sep 17 00:00:00 2001 From: Kim Youngjin Date: Tue, 7 Apr 2015 09:03:24 +0900 Subject: [PATCH 06/16] refactoring Change-Id: I649d6d4a0aaf7d3e36c04961f4343dd07ad09fda Signed-off-by: Kim Youngjin --- include/timeout_handler.h | 26 ++- include/view_maincatalog.h | 2 - include/view_sublist.h | 36 ++-- include/view_system_clock.h | 33 ++-- include/view_uigadget.h | 35 +++- src/settingviewmgr.cpp | 56 +++---- src/timeout_handler.cpp | 112 ++++++------- src/view_sublist.cpp | 295 ++++++++++++-------------------- src/view_system_clock.cpp | 398 +++++++++++++++++--------------------------- src/view_uigadget.cpp | 225 ++++++++++++------------- 10 files changed, 534 insertions(+), 684 deletions(-) mode change 100755 => 100644 src/view_uigadget.cpp diff --git a/include/timeout_handler.h b/include/timeout_handler.h index 5b0aaad..ee94854 100644 --- a/include/timeout_handler.h +++ b/include/timeout_handler.h @@ -17,15 +17,33 @@ #ifndef __TIMEOUT_HANDLER_H__ #define __TIMEOUT_HANDLER_H__ + #define TIMEOUT_SECS 60 -struct timeout_handler; + +class CTimeoutHandler { +private: + struct STimeoutHandler *m; + +public: + CTimeoutHandler() : m(0) {} + virtual ~CTimeoutHandler() {} + + bool Create(double val); + virtual void Destroy(void); + + void FreezeTimer(void); + void ThawTimer(void); + void ChangeInterval(double val); +}; +/*struct timeout_handler; void timeout_handler_freeze_timer(struct timeout_handler *data); void timeout_handler_thaw_timer(struct timeout_handler *data); -void timeout_handler_change_interval(struct timeout_handler *data, - double val); +void timeout_handler_change_interval(struct timeout_handler *data, double val); + struct timeout_handler *timeout_handler_init(double val); -void timeout_handler_fini(struct timeout_handler *data); +void timeout_handler_fini(struct timeout_handler *data);*/ + #endif /* __TIMEOUT_HANDLER_H__ */ diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 22ae52b..6ab5aef 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -40,9 +40,7 @@ public: virtual void LangChanged(void); virtual void Frozen(void); virtual void Active(void); - }; -//struct setting_class *view_maincatalog_get_vclass(void); #endif /* __VIEW_MAINMENU_H__ */ diff --git a/include/view_sublist.h b/include/view_sublist.h index 9733191..1f7ffcf 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -19,36 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSublistView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSublistView *m; private: - static void sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemBtnClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); - - static void sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusOut(Evas_Object *obj, void *ev); - - static void sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusIn(Evas_Object *obj, void *ev); - static void sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); - int m_DrawSublist(void); + bool m_DrawSublist(void); void m_ExitView(void); void m_SetSelectedValue(Evas_Object *obj); int m_DrawListItems(Eina_List *list); public: - CSublistView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSublistView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSublistView() {} Evas_Object *Base(void); @@ -57,6 +57,12 @@ public: virtual void Show(void); virtual void Hide(void); virtual void Destroy(void); + +public: + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_system_clock.h b/include/view_system_clock.h index 2881ff5..2ffee89 100644 --- a/include/view_system_clock.h +++ b/include/view_system_clock.h @@ -19,30 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSystemClockView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSystemClockView *m; private: - static void sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev); - void m_OnSubitemClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ei); - static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); void m_ExitView(void); - int m_DrawSysclkSublist(void); - int m_AddSysclkSublistItem(Eina_List *list, const char *selval); + bool m_DrawSysclkSublist(void); + bool m_AddSysclkSublistItem(Eina_List *list, const char *selval); public: - CSystemClockView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSystemClockView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSystemClockView() {} Evas_Object *Base(void); @@ -52,6 +58,13 @@ public: virtual void Refresh(void); virtual void Hide(void); virtual void Destroy(void); + +public: + // If buttons are clicked + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_uigadget.h b/include/view_uigadget.h index 88359e0..367c256 100644 --- a/include/view_uigadget.h +++ b/include/view_uigadget.h @@ -22,17 +22,39 @@ #include "settingviewmgr.h" +class CUiGadget { +private: + ui_gadget_h m_handler; +private: + static void sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); + static void sm_CbResult(ui_gadget_h ug, service_h result, void *priv); + static void sm_CbDestroy(ui_gadget_h ug, void *priv); + static void sm_CbEnd(ui_gadget_h ug, void *priv); + +protected: + + virtual void t_OnLayout(ui_gadget_h ug, ug_mode mode) {} + virtual void t_OnResult(ui_gadget_h ug, service_h result) {} + virtual void t_OnDestroy(ui_gadget_h ug) {} + virtual void t_OnEnd(ui_gadget_h ug) {} + +public: + CUiGadget() : m_handler(0) {} + + bool Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service); + virtual void Destroy(void); +}; + class CUiGadgetView : - public CSettingBaseView { + public CSettingBaseView, + public CUiGadget { private: struct SUiGadgetView *m; -private: - static void sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); - static void sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv); - static void sm_CbUgDestroy(ui_gadget_h ug, void *priv); - void m_OnUgDestroy(ui_gadget_h ug); +protected: + virtual void t_OnDestroy(ui_gadget_h ug); +private: bool m_Load(void); void m_BackToMainview(void); @@ -48,4 +70,5 @@ public: virtual void Destroy(void); }; + #endif /* __VIEW_UIGADGET_H__ */ diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 0666250..674f3bf 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -18,6 +18,7 @@ #include #include "dbg.h" +#include "AppCommon.h" #include "settingviewmgr.h" #include "data_wrapper.h" #include "timeout_handler.h" @@ -41,7 +42,7 @@ struct SSettingMgr { Eina_List *view_list; struct settingmgr_data *data; Eina_Array *item_path; - struct timeout_handler *handler; + CTimeoutHandler *handler; Eina_Bool is_freeze; }; @@ -324,41 +325,25 @@ CSettingMgr *CSettingMgr::instance = NULL; bool CSettingMgr::Initialize(Evas_Object *win) { ASSERT(!instance); - - instance = new CSettingMgr; - if (!instance) { - return false; - } - instance->m = new SSettingMgr; - if (!instance->m) { - delete instance; - return false; - } + ASSERT(win); struct settingmgr_data *data; - struct timeout_handler *handler; + CTimeoutHandler *handler; - if (!win) - return NULL; + _CREATE_BEGIN{ + _CHECK(instance = new CSettingMgr); + _CHECK(instance->m = new SSettingMgr); + _CHECK(data = viewmgr_data_init()); + _CHECK(handler = new CTimeoutHandler); + _CHECK(handler->Create(TIMEOUT_SECS)); - data = viewmgr_data_init(); - if (!data) { - _ERR("viewmgr_data_init failed!"); - delete instance->m; - delete instance; - instance = NULL; - return false; - } - handler = timeout_handler_init(TIMEOUT_SECS); - if (!handler) { - _ERR("Fail to init timeout handler"); - viewmgr_data_fini(data); - delete instance->m; - delete instance; - instance = NULL; - return false; - } + _CHECK_FAIL{ handler->Destroy(); } + _CHECK_FAIL{ delete handler; } + _CHECK_FAIL{ viewmgr_data_fini(data); } + _CHECK_FAIL{ delete instance->m; } + _CHECK_FAIL{ delete instance; instance = NULL; } + } _CREATE_END_AND_CATCH{ return false; } g_func_map[0].style = STYLE_UIGADGET; g_func_map[0].view = new CUiGadgetView(VCLASS_TITLE_UG); @@ -378,7 +363,7 @@ bool CSettingMgr::Initialize(Evas_Object *win) instance->m->win = win; instance->m->depth = 0; instance->m->data = data; - instance->m->handler = handler; + instance->m->handler = handler; instance->m->is_freeze = EINA_FALSE; instance->m->view_list = NULL; instance->m->item_path = NULL; @@ -415,7 +400,8 @@ void CSettingMgr::Finalize(void) eina_array_free(instance->m->item_path); viewmgr_data_fini(instance->m->data); - timeout_handler_fini(instance->m->handler); + instance->m->handler->Destroy(); + delete instance->m->handler; delete instance->m; delete instance; @@ -779,7 +765,7 @@ void CSettingMgr::FreezeTimeout(void) ASSERT(m); m->is_freeze = EINA_TRUE; - timeout_handler_freeze_timer(m->handler); + m->handler->FreezeTimer(); } /** @@ -792,7 +778,7 @@ void CSettingMgr::ThawTimeout(void) { ASSERT(m); - timeout_handler_thaw_timer(m->handler); + m->handler->ThawTimer(); m->is_freeze = EINA_FALSE; } diff --git a/src/timeout_handler.cpp b/src/timeout_handler.cpp index e516484..db39007 100644 --- a/src/timeout_handler.cpp +++ b/src/timeout_handler.cpp @@ -21,9 +21,11 @@ #include "stdbool.h" #include "timeout_handler.h" + #define EVENT_HANDLER_NUM 6 -struct timeout_handler { + +struct STimeoutHandler { Ecore_Event_Handler * event_handler[EVENT_HANDLER_NUM]; Ecore_Timer *timer; }; @@ -45,14 +47,14 @@ struct timeout_handler { */ static Eina_Bool _event_occrued_cb(void *data, int type, void *event) { - struct timeout_handler *handler; + struct STimeoutHandler *handler; if (!data) { _ERR("Invalid argument"); return EINA_FALSE; } - handler = (struct timeout_handler *) data; + handler = (struct STimeoutHandler *) data; ecore_timer_reset(handler->timer); @@ -79,114 +81,104 @@ static Eina_Bool _timer_expired_cb(void *data) /** * Freeze given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_freeze_timer(struct timeout_handler *data) +void CTimeoutHandler::FreezeTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } /** * Thaw given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_thaw_timer(struct timeout_handler *data) +void CTimeoutHandler::ThawTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_thaw(data->timer); - ecore_timer_reset(data->timer); + ecore_timer_thaw(m->timer); + ecore_timer_reset(m->timer); } /** * Change timer interval value. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @param val [in] New interval value to be set. * @return void. */ -void timeout_handler_change_interval(struct timeout_handler *data, - double val) +void CTimeoutHandler::ChangeInterval(double val) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } if (val == 0.0) { - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } else if (val > 0.0) { - ecore_timer_interval_set(data->timer, val); - ecore_timer_reset(data->timer); - ecore_timer_thaw(data->timer); + ecore_timer_interval_set(m->timer, val); + ecore_timer_reset(m->timer); + ecore_timer_thaw(m->timer); } } /** -* Create and init timeout_handler data. +* Create and init STimeoutHandler data. * * @param val [in] Timer interval value. -* @return The timeout_handler data pointer, NULL if error. +* @return The STimeoutHandler data pointer, NULL if error. */ -struct timeout_handler *timeout_handler_init(double val) +bool CTimeoutHandler::Create(double val) { - struct timeout_handler *data; + ASSERT(!m); - data = (struct timeout_handler *) calloc(1, sizeof(*data)); - if (!data) { + m = new STimeoutHandler; + if (!m) { _ERR("Fail to allocate memory for timeout handler"); - return NULL; + return false; } - data->event_handler[0] = ecore_event_handler_add( - ECORE_EVENT_KEY_DOWN, _event_occrued_cb, data); - data->event_handler[1] = ecore_event_handler_add( - ECORE_EVENT_KEY_UP, _event_occrued_cb, data); - data->event_handler[2] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_DOWN, - _event_occrued_cb, data); - data->event_handler[3] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_UP, - _event_occrued_cb, data); - data->event_handler[4] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, data); - data->event_handler[5] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, data); - - data->timer = ecore_timer_add(val, _timer_expired_cb, NULL); - - return data; + m->event_handler[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _event_occrued_cb, m); + m->event_handler[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _event_occrued_cb, m); + m->event_handler[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,_event_occrued_cb, m); + m->event_handler[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _event_occrued_cb, m); + m->event_handler[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, m); + m->event_handler[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, m); + + m->timer = ecore_timer_add(val, _timer_expired_cb, NULL); + + return true; } -/** -* Release given timeout_handler data. -* -* @param data [in] The timeout_handler data pointer. -* @return void. -*/ -void timeout_handler_fini(struct timeout_handler *data) + +void CTimeoutHandler::Destroy(void) { - int i; + ASSERT(m); - if (!data) { - _ERR("Invalid argument"); - return; - } + int i; for (i = 0; i < EVENT_HANDLER_NUM; i++) - ecore_event_handler_del(data->event_handler[i]); + ecore_event_handler_del(m->event_handler[i]); - ecore_timer_del(data->timer); - free(data); + ecore_timer_del(m->timer); + delete m; + m = NULL; } diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index 5c3c6be..fbe642f 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -24,7 +24,11 @@ #include "view_sublist.h" #include "settingviewmgr.h" -#define DATA_ID "SUBLISTDATA" + +enum EId { + ID_BTNS, +}; + #define MAX_ITEMS 8 #define ITEMID "itemdata" @@ -221,125 +225,6 @@ static void _scroll_event_cb(void *data, Evas_Object *obj, void *event) elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_BOTH_ARROW, ""); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object get focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusIn(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusIn(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object lose focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusOut(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusOut(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object be clicked. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemBtnClicked(obj, ev); -} - - -void CSublistView::m_OnSubitemBtnClicked(Evas_Object *obj, void *ev) -{ - if (!obj) - return; - - m_SetSelectedValue(obj); - - m_ExitView(); -} /** * This function is a @Evas_Smart_Cb type callback, it will be invoked if @@ -363,29 +248,6 @@ void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) m_ExitView(); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if occurred -* key press event. -* -* @param data [in] The user data. -* @param e [in] The evas handler. -* @param obj [in] The corresponding object which event occurred. -* @param ei [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemKeyPressed(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSublistView::m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - m_ExitView(); -} /** * This function is invoked to draw ctxpopup layout. @@ -519,14 +381,12 @@ int CSublistView::m_DrawListItems(Eina_List *list) evas_object_data_set(btn, ITEMID, val); - evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, - sm_CbSubitemFocusIn, this); - evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, - sm_CbSubitemFocusOut, this); - evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, - sm_CbSubitemBtnClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeyPressed, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); + + //evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, sm_CbSubitemFocusIn, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, sm_CbSubitemFocusOut, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, sm_CbSubitemBtnClicked, this); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, sm_CbSubitemKeyPressed, this); elm_box_pack_end(m->popup_box, btn); eina_array_push(btns, btn); @@ -551,7 +411,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) * @param data [in] The _sublist_data data pointer. * @return 0 if success, -1 if fail. */ -int CSublistView::m_DrawSublist(void) +bool CSublistView::m_DrawSublist(void) { struct settingview_data *view; Eina_List *list; @@ -561,7 +421,7 @@ int CSublistView::m_DrawSublist(void) if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); - return -1; + return false; } view = m->sublist_view; @@ -570,19 +430,19 @@ int CSublistView::m_DrawSublist(void) list = _get_list_data(view, &cnt); if (!list) { _ERR("Get item list failed"); - return -1; + return false; } m->sub_items_count = cnt; if (_draw_ctxpopup_layout(m) == -1) { _ERR("Fail to draw ctxpopup layout"); - return -1; + return false; } if (m_DrawListItems(list) == -1) { _ERR("Fail to draw list items"); - return -1; + return false; } screen_h = WIN_HEIGHT; @@ -592,7 +452,7 @@ int CSublistView::m_DrawSublist(void) w = param->width; if (w <= 0) { _ERR("Fail to get clicked button width"); - return -1; + return false; } ratio = (w - SUBLIST_WIDTH - SUBLIST_OFFSET) / w; @@ -616,7 +476,7 @@ int CSublistView::m_DrawSublist(void) utils_set_focus_directions(m->sub_btn_array, m->sub_items_count); - return 0; + return true; } @@ -684,9 +544,7 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) m->ctxpopup = ctxpopup; m->sublist_view = view; - evas_object_data_set(base, DATA_ID, m); - - if (m_DrawSublist() == -1) { + if (!m_DrawSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -752,31 +610,96 @@ void CSublistView::Hide(void) evas_object_hide(m->ctxpopup); } -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_SUBLIST, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; -/** -* This function is invoked to get sub list view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_sublist_get_vclass(void) +void CSublistView::OnMouseClicked(int id, Evas_Object *obj) +{ + if (id != ID_BTNS) + return; + + if (!obj) + return; + + m_SetSelectedValue(obj); + + m_ExitView(); +} + + +void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { - return &_vclass; + if (id != ID_BTNS) + return; + + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + m_ExitView(); } -#endif \ No newline at end of file diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp index cf57833..8a3f915 100644 --- a/src/view_system_clock.cpp +++ b/src/view_system_clock.cpp @@ -40,6 +40,10 @@ #define SIG_UNFOCUSED "unfocused" #define SIG_CLICKED "clicked" +enum EId { + ID_BTNS, +}; + struct SSystemClockView { Evas_Object *win; Evas_Object *base; @@ -159,195 +163,7 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj) } } -/** -* Evas_Smart_Cb type callback for handling foucs in event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the foucs in event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusin_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) { - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - } - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling focus out event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the focus out event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusout_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemClicked(obj, ev); -} - -void CSystemClockView::m_OnSubitemClicked(Evas_Object *obj, void *ev) -{ - struct settingitem *item; - Eina_List *list; - char *value; - const char *id; - const char *name; - - if (!obj) - return; - - _set_selected_value(m, obj); - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("get value from obj failed. DATA_ID: %s", ITEMID); - return; - } - - if (!strncmp(value, MANUAL, BUF_SIZE)) { - Hide(); - - list = viewdata_get_childitems_list(m->vdata); - if (!list) { - _ERR("list of clock is null."); - return; - } - - item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); - if (!item) { - _ERR("there is no clock_mode item in list."); - return; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("get item id failed."); - return; - } - - name = settingitem_get_display_name(item); - if (!name) { - _ERR("get display_name failed."); - return; - } - - m->ugd.display_name = name; - - m->mgr->ViewPush(id, (void *)&m->ugd); - } else { - m_ExitView(); - } -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: priv : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemKeypress(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!ev) - return; - - if (!ev->keyname) - return; - - if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) - m_ExitView(); -} /** * Create system clock sublist items. @@ -358,7 +174,7 @@ void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) +bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) { Evas_Object *box, *cp, *btn, *del_btn; Eina_Array *array; @@ -371,7 +187,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!list || !m->ctxpopup || !selval) { _ERR("invalid arguments."); - return -1; + return false; } cp = m->ctxpopup; @@ -379,7 +195,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval box = utils_add_box(cp); if (!box) { _ERR("utils add box to ctxpopup failed."); - return -1; + return false; } elm_object_content_set(cp, box); @@ -388,7 +204,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!array) { _ERR("eina array new failed."); evas_object_del(box); - return -1; + return false; } i = idx = 0; @@ -420,15 +236,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval } evas_object_data_set(btn, ITEMID, value); - - evas_object_smart_callback_add(btn, SIG_FOCUSED, - _subitem_focusin_cb, m); - evas_object_smart_callback_add(btn, SIG_UNFOCUSED, - _subitem_focusout_cb, m); - evas_object_smart_callback_add(btn, SIG_CLICKED, - sm_CbSubitemClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeypress, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); elm_box_pack_end(box, btn); eina_array_push(array, btn); @@ -443,7 +251,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval m->array = array; m->sel_idx = idx; - return 0; + return true; error: EINA_ARRAY_ITER_NEXT(array, j, obj, aiter) { @@ -455,7 +263,7 @@ error: evas_object_del(box); eina_array_free(array); - return -1; + return false; } /** @@ -465,19 +273,19 @@ error: * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_DrawSysclkSublist(void) +bool CSystemClockView::m_DrawSysclkSublist(void) { Evas_Object *ctxpopup; char *selval; struct settingview_data *vdata; struct obj_geometry_data *ogd; Eina_List *itlist; - int xpos, ypos, height, count, r; + int xpos, ypos, height, count; double ratio; if (!m->ctxpopup || !m->ogd || !m->vdata) { _ERR("Invalid argument\n"); - return -1; + return false; } ctxpopup = m->ctxpopup; @@ -488,7 +296,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) itlist = _get_item_list(vdata, &count); if (!itlist) { _ERR("Get item list failed"); - return -1; + return false; } m->count = count; @@ -496,7 +304,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) selval = _get_selected_value(m); if (!selval) { _ERR("Get selected value failed"); - return -1; + return false; } if (count > MAX_ITEMS) { @@ -504,8 +312,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) goto error; } - r = m_AddSysclkSublistItem(itlist, selval); - if (r != 0) { + if (!m_AddSysclkSublistItem(itlist, selval)) { _ERR("add system clock sublist items failed."); goto error; } @@ -530,11 +337,11 @@ int CSystemClockView::m_DrawSysclkSublist(void) provider_release_list_value(selval); - return 0; + return true; error: provider_release_list_value(selval); - return -1; + return false; } /** @@ -566,7 +373,6 @@ void CSystemClockView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) } - Evas_Object* CSystemClockView::Base(void) { ASSERT(m); @@ -575,7 +381,6 @@ Evas_Object* CSystemClockView::Base(void) } - /** * Create all the UI components of system clock sublist view. * @@ -599,6 +404,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) struct obj_geometry_data *ogd; CSettingMgr *mgr = CSettingMgr::GetInstance(); + ugd = (struct evas_obj_data *) prev; ogd = (struct obj_geometry_data *) evas_object_data_get(ugd->cur_btn, DATA_ID); @@ -643,7 +449,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) evas_object_data_set(base, DATA_ID, m); - if (m_DrawSysclkSublist() == -1) { + if (!m_DrawSysclkSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -726,37 +532,141 @@ void CSystemClockView::Refresh(void) } -#if 0 +void CSystemClockView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + char *value; + char *selval; -/** -* view class of system clock view. -*/ -static struct setting_class _vclass = { - VCLASS_TITLE_SYSTEM_CLOCK, - _create, - _show, - NULL, - NULL, - _refresh, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } -/** -* Return view class of system clock view. -* -* @param: void. -* -* @return: the view class of system clock view. -*/ -struct setting_class *view_system_clock_get_vclass(void) + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) { + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + } + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) { - return &_vclass; + char *value; + char *selval; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnMouseClicked(int oid, Evas_Object *obj) +{ + if (oid != ID_BTNS) + return; + + struct settingitem *item; + Eina_List *list; + char *value; + const char *id; + const char *name; + + if (!obj) + return; + + _set_selected_value(m, obj); + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("get value from obj failed. DATA_ID: %s", ITEMID); + return; + } + + if (!strncmp(value, MANUAL, BUF_SIZE)) { + Hide(); + + list = viewdata_get_childitems_list(m->vdata); + if (!list) { + _ERR("list of clock is null."); + return; + } + + item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); + if (!item) { + _ERR("there is no clock_mode item in list."); + return; + } + + id = settingitem_get_id(item); + if (!id) { + _ERR("get item id failed."); + return; + } + + name = settingitem_get_display_name(item); + if (!name) { + _ERR("get display_name failed."); + return; + } + + m->ugd.display_name = name; + + m->mgr->ViewPush(id, (void *)&m->ugd); + } + else { + m_ExitView(); + } +} + + +void CSystemClockView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (id != ID_BTNS) + return; + + if (!ev->keyname) + return; + + if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) + m_ExitView(); } -#endif \ No newline at end of file diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp old mode 100755 new mode 100644 index a3aacde..2f699ff --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -20,7 +20,93 @@ #include "def.h" #include "settingviewmgr.h" -#define DATA_ID "ugdata" + +/** + * This callback function is invoked with base layout for layout arrangement + * after UI Gadget create create operation is completed. + * + * @param ug [in] The handler data representing a UI gadget. + * @param mode [in] The UI gadget mode. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnLayout(ug, mode); +} + + +/** + * After UG module invoke ug_send_message to send result, + * UG library call this callback function registered by calling ug_create. + * + * @param ug [in] The handler data representing a UI gadget. + * @param result [in] The Service handler. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbResult(ui_gadget_h ug, service_h result, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnResult(ug, result); +} + + + +/** + * Send the destroy request, use ug_destroy_me, + * then UG library calls this callback function registered by UG caller. + * + * @param ug [in] The handler data representing a UI gadget. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbDestroy(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnDestroy(ug); +} + + +void CUiGadget::sm_CbEnd(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnEnd(ug); +} + + +bool CUiGadget::Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service) +{ + ASSERT(!m_handler); + + struct ug_cbs cbs = { + sm_CbLayout, + sm_CbResult, + sm_CbDestroy, + sm_CbEnd + }; + cbs.priv = this; + + m_handler = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); + + return m_handler ? true : false; +} + + +void CUiGadget::Destroy(void) +{ + if (!m_handler) + return; + + ug_destroy(m_handler); + m_handler = NULL; +} + struct SUiGadgetView { Evas_Object *win; @@ -30,8 +116,6 @@ struct SUiGadgetView { Evas_Object *subitem_box; const char *display_name; - ui_gadget_h ug_handler; - Eina_Bool ug_is_existed; CSettingMgr *mgr; struct settingview_data *view; }; @@ -62,31 +146,6 @@ void CUiGadgetView::m_BackToMainview(void) m->mgr->ViewPop(); } -/** -* This callback function is invoked with base layout for layout arrangement -* after UI Gadget create create operation is completed. -* -* @param ug [in] The handler data representing a UI gadget. -* @param mode [in] The UI gadget mode. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) -{ -} - -/** -* After UG module invoke ug_send_message to send result, -* UG library call this callback function registered by calling ug_create. -* -* @param ug [in] The handler data representing a UI gadget. -* @param result [in] The Service handler. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv) -{ -} /** * This function is invoked to show sub item buttons evas object. @@ -118,23 +177,8 @@ static void _show_item_btns(Evas_Object *box) eina_list_free(list); } -/** -* Send the destroy request, use ug_destroy_me, -* then UG library calls this callback function registered by UG caller. -* -* @param ug [in] The handler data representing a UI gadget. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgDestroy(ui_gadget_h ug, void *priv) -{ - CUiGadgetView *root = (CUiGadgetView*)priv; - if (root) - root->m_OnUgDestroy(ug); -} - -void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) +void CUiGadgetView::t_OnDestroy(ui_gadget_h ug) { if (!ug) { _ERR("Invalid parameters in ug destroy callback."); @@ -146,8 +190,8 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) elm_object_focus_set(m->subbtn, EINA_TRUE); elm_object_part_text_set(m->base, UG_TITLE_TEXT, ""); - ug_destroy(ug); - m->ug_is_existed = EINA_FALSE; + CUiGadget::Destroy(); + m_BackToMainview(); } @@ -159,37 +203,23 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) */ bool CUiGadgetView::m_Load(void) { - ui_gadget_h ug; const char *name; struct settingitem *parent; - struct ug_cbs cbs = { - sm_CbUgLayout, - sm_CbUgResult, - sm_CbUgDestroy, - NULL - }; - - cbs.priv = this; - parent = viewdata_get_parentitem(m->view); name = settingitem_get_settingui_name(parent); - elm_object_part_text_set(m->base, - UG_TITLE_TEXT, m->display_name); + elm_object_part_text_set(m->base, UG_TITLE_TEXT, m->display_name); - ug = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); - if (!ug) { - _ERR("ug create failed."); + if (!CUiGadget::Create(NULL, name, UG_MODE_FRAMEVIEW, NULL)) { return false; - } else { - m->ug_is_existed = EINA_TRUE; - m->ug_handler = ug; - m->mgr->FreezeTimeout(); } + m->mgr->FreezeTimeout(); + return true; } + /** * This function is invoked to hide sub item buttons evas object. * @@ -223,7 +253,6 @@ static void _hide_item_btns(Evas_Object *box) } - Evas_Object *CUiGadgetView::Base(void) { ASSERT(m); @@ -232,7 +261,6 @@ Evas_Object *CUiGadgetView::Base(void) } - /** * This function is invoked to create UG launcher view layout. * @@ -253,14 +281,10 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) CSettingMgr *mgr = CSettingMgr::GetInstance(); param = (struct evas_obj_data *) prev; - _hide_item_btns(param->subitem_box); win = mgr->Window(); - if (!win) { - _ERR("Invalid argument"); - return NULL; - } + ASSERT(win); m = new SUiGadgetView; if (!m) { @@ -278,16 +302,13 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) elm_layout_file_set(base, EDJ_FILE, UG_GROUP); - m->win = win; + m->win = win; m->base = base; - m->mgr = mgr; + m->mgr = mgr; m->view = view; - m->subitem_box = param->subitem_box; + m->subitem_box = param->subitem_box; m->display_name = param->display_name; - m->subbtn = param->cur_btn; - m->ug_is_existed = EINA_FALSE; - - evas_object_data_set(base, DATA_ID, m); + m->subbtn = param->cur_btn; if (!m_Load()) { _ERR("load ui gadget failed."); @@ -301,12 +322,7 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) return true; } -/** -* This function is invoked to show view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Show(void) { ASSERT(m); @@ -314,18 +330,12 @@ void CUiGadgetView::Show(void) evas_object_show(m->base); } -/** -* This function is invoked to destroy view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Destroy(void) { ASSERT(m); - if (m->ug_is_existed == EINA_TRUE) - ug_destroy(m->ug_handler); + CUiGadget::Destroy(); if (m->view) viewdata_release(m->view); @@ -334,32 +344,3 @@ void CUiGadgetView::Destroy(void) delete m; m = NULL; } - -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_UG, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; - -/** -* This function is invoked to get UI Gadget launcher view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_uigadget_get_vclass(void) -{ - return &_vclass; -} -#endif -- 2.7.4 From 513d46be1e216d12081445afde059377a8941067 Mon Sep 17 00:00:00 2001 From: Kim Youngjin Date: Tue, 7 Apr 2015 09:03:24 +0900 Subject: [PATCH 07/16] refactoring Change-Id: I649d6d4a0aaf7d3e36c04961f4343dd07ad09fda Signed-off-by: Kim Youngjin --- include/timeout_handler.h | 26 ++- include/view_maincatalog.h | 2 - include/view_sublist.h | 36 ++-- include/view_system_clock.h | 33 ++-- include/view_uigadget.h | 35 +++- src/settingviewmgr.cpp | 56 +++---- src/timeout_handler.cpp | 112 ++++++------- src/view_sublist.cpp | 295 ++++++++++++-------------------- src/view_system_clock.cpp | 398 +++++++++++++++++--------------------------- src/view_uigadget.cpp | 225 ++++++++++++------------- 10 files changed, 534 insertions(+), 684 deletions(-) mode change 100755 => 100644 src/view_uigadget.cpp diff --git a/include/timeout_handler.h b/include/timeout_handler.h index 5b0aaad..ee94854 100644 --- a/include/timeout_handler.h +++ b/include/timeout_handler.h @@ -17,15 +17,33 @@ #ifndef __TIMEOUT_HANDLER_H__ #define __TIMEOUT_HANDLER_H__ + #define TIMEOUT_SECS 60 -struct timeout_handler; + +class CTimeoutHandler { +private: + struct STimeoutHandler *m; + +public: + CTimeoutHandler() : m(0) {} + virtual ~CTimeoutHandler() {} + + bool Create(double val); + virtual void Destroy(void); + + void FreezeTimer(void); + void ThawTimer(void); + void ChangeInterval(double val); +}; +/*struct timeout_handler; void timeout_handler_freeze_timer(struct timeout_handler *data); void timeout_handler_thaw_timer(struct timeout_handler *data); -void timeout_handler_change_interval(struct timeout_handler *data, - double val); +void timeout_handler_change_interval(struct timeout_handler *data, double val); + struct timeout_handler *timeout_handler_init(double val); -void timeout_handler_fini(struct timeout_handler *data); +void timeout_handler_fini(struct timeout_handler *data);*/ + #endif /* __TIMEOUT_HANDLER_H__ */ diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 22ae52b..6ab5aef 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -40,9 +40,7 @@ public: virtual void LangChanged(void); virtual void Frozen(void); virtual void Active(void); - }; -//struct setting_class *view_maincatalog_get_vclass(void); #endif /* __VIEW_MAINMENU_H__ */ diff --git a/include/view_sublist.h b/include/view_sublist.h index 9733191..1f7ffcf 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -19,36 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSublistView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSublistView *m; private: - static void sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemBtnClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); - - static void sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusOut(Evas_Object *obj, void *ev); - - static void sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev); - void m_OnSubitemFocusIn(Evas_Object *obj, void *ev); - static void sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); - int m_DrawSublist(void); + bool m_DrawSublist(void); void m_ExitView(void); void m_SetSelectedValue(Evas_Object *obj); int m_DrawListItems(Eina_List *list); public: - CSublistView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSublistView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSublistView() {} Evas_Object *Base(void); @@ -57,6 +57,12 @@ public: virtual void Show(void); virtual void Hide(void); virtual void Destroy(void); + +public: + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_system_clock.h b/include/view_system_clock.h index 2881ff5..2ffee89 100644 --- a/include/view_system_clock.h +++ b/include/view_system_clock.h @@ -19,30 +19,36 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CSystemClockView : - public CSettingBaseView { + public CSettingBaseView, + public IFocusedListener, + public IUnfocusedListener, + public IMouseClickedListener, + public IKeyDownListener, + public CListenerMgr { private: struct SSystemClockView *m; private: - static void sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev); - void m_OnSubitemClicked(Evas_Object *obj, void *ev); - - static void sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei); - void m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ei); - static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); void m_ExitView(void); - int m_DrawSysclkSublist(void); - int m_AddSysclkSublistItem(Eina_List *list, const char *selval); + bool m_DrawSysclkSublist(void); + bool m_AddSysclkSublistItem(Eina_List *list, const char *selval); public: - CSystemClockView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CSystemClockView(const char *pViewId) : + CSettingBaseView(pViewId), + IFocusedListener(this), + IUnfocusedListener(this), + IMouseClickedListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CSystemClockView() {} Evas_Object *Base(void); @@ -52,6 +58,13 @@ public: virtual void Refresh(void); virtual void Hide(void); virtual void Destroy(void); + +public: + // If buttons are clicked + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item); + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/include/view_uigadget.h b/include/view_uigadget.h index 88359e0..367c256 100644 --- a/include/view_uigadget.h +++ b/include/view_uigadget.h @@ -22,17 +22,39 @@ #include "settingviewmgr.h" +class CUiGadget { +private: + ui_gadget_h m_handler; +private: + static void sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); + static void sm_CbResult(ui_gadget_h ug, service_h result, void *priv); + static void sm_CbDestroy(ui_gadget_h ug, void *priv); + static void sm_CbEnd(ui_gadget_h ug, void *priv); + +protected: + + virtual void t_OnLayout(ui_gadget_h ug, ug_mode mode) {} + virtual void t_OnResult(ui_gadget_h ug, service_h result) {} + virtual void t_OnDestroy(ui_gadget_h ug) {} + virtual void t_OnEnd(ui_gadget_h ug) {} + +public: + CUiGadget() : m_handler(0) {} + + bool Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service); + virtual void Destroy(void); +}; + class CUiGadgetView : - public CSettingBaseView { + public CSettingBaseView, + public CUiGadget { private: struct SUiGadgetView *m; -private: - static void sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv); - static void sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv); - static void sm_CbUgDestroy(ui_gadget_h ug, void *priv); - void m_OnUgDestroy(ui_gadget_h ug); +protected: + virtual void t_OnDestroy(ui_gadget_h ug); +private: bool m_Load(void); void m_BackToMainview(void); @@ -48,4 +70,5 @@ public: virtual void Destroy(void); }; + #endif /* __VIEW_UIGADGET_H__ */ diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 0666250..674f3bf 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -18,6 +18,7 @@ #include #include "dbg.h" +#include "AppCommon.h" #include "settingviewmgr.h" #include "data_wrapper.h" #include "timeout_handler.h" @@ -41,7 +42,7 @@ struct SSettingMgr { Eina_List *view_list; struct settingmgr_data *data; Eina_Array *item_path; - struct timeout_handler *handler; + CTimeoutHandler *handler; Eina_Bool is_freeze; }; @@ -324,41 +325,25 @@ CSettingMgr *CSettingMgr::instance = NULL; bool CSettingMgr::Initialize(Evas_Object *win) { ASSERT(!instance); - - instance = new CSettingMgr; - if (!instance) { - return false; - } - instance->m = new SSettingMgr; - if (!instance->m) { - delete instance; - return false; - } + ASSERT(win); struct settingmgr_data *data; - struct timeout_handler *handler; + CTimeoutHandler *handler; - if (!win) - return NULL; + _CREATE_BEGIN{ + _CHECK(instance = new CSettingMgr); + _CHECK(instance->m = new SSettingMgr); + _CHECK(data = viewmgr_data_init()); + _CHECK(handler = new CTimeoutHandler); + _CHECK(handler->Create(TIMEOUT_SECS)); - data = viewmgr_data_init(); - if (!data) { - _ERR("viewmgr_data_init failed!"); - delete instance->m; - delete instance; - instance = NULL; - return false; - } - handler = timeout_handler_init(TIMEOUT_SECS); - if (!handler) { - _ERR("Fail to init timeout handler"); - viewmgr_data_fini(data); - delete instance->m; - delete instance; - instance = NULL; - return false; - } + _CHECK_FAIL{ handler->Destroy(); } + _CHECK_FAIL{ delete handler; } + _CHECK_FAIL{ viewmgr_data_fini(data); } + _CHECK_FAIL{ delete instance->m; } + _CHECK_FAIL{ delete instance; instance = NULL; } + } _CREATE_END_AND_CATCH{ return false; } g_func_map[0].style = STYLE_UIGADGET; g_func_map[0].view = new CUiGadgetView(VCLASS_TITLE_UG); @@ -378,7 +363,7 @@ bool CSettingMgr::Initialize(Evas_Object *win) instance->m->win = win; instance->m->depth = 0; instance->m->data = data; - instance->m->handler = handler; + instance->m->handler = handler; instance->m->is_freeze = EINA_FALSE; instance->m->view_list = NULL; instance->m->item_path = NULL; @@ -415,7 +400,8 @@ void CSettingMgr::Finalize(void) eina_array_free(instance->m->item_path); viewmgr_data_fini(instance->m->data); - timeout_handler_fini(instance->m->handler); + instance->m->handler->Destroy(); + delete instance->m->handler; delete instance->m; delete instance; @@ -779,7 +765,7 @@ void CSettingMgr::FreezeTimeout(void) ASSERT(m); m->is_freeze = EINA_TRUE; - timeout_handler_freeze_timer(m->handler); + m->handler->FreezeTimer(); } /** @@ -792,7 +778,7 @@ void CSettingMgr::ThawTimeout(void) { ASSERT(m); - timeout_handler_thaw_timer(m->handler); + m->handler->ThawTimer(); m->is_freeze = EINA_FALSE; } diff --git a/src/timeout_handler.cpp b/src/timeout_handler.cpp index e516484..db39007 100644 --- a/src/timeout_handler.cpp +++ b/src/timeout_handler.cpp @@ -21,9 +21,11 @@ #include "stdbool.h" #include "timeout_handler.h" + #define EVENT_HANDLER_NUM 6 -struct timeout_handler { + +struct STimeoutHandler { Ecore_Event_Handler * event_handler[EVENT_HANDLER_NUM]; Ecore_Timer *timer; }; @@ -45,14 +47,14 @@ struct timeout_handler { */ static Eina_Bool _event_occrued_cb(void *data, int type, void *event) { - struct timeout_handler *handler; + struct STimeoutHandler *handler; if (!data) { _ERR("Invalid argument"); return EINA_FALSE; } - handler = (struct timeout_handler *) data; + handler = (struct STimeoutHandler *) data; ecore_timer_reset(handler->timer); @@ -79,114 +81,104 @@ static Eina_Bool _timer_expired_cb(void *data) /** * Freeze given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_freeze_timer(struct timeout_handler *data) +void CTimeoutHandler::FreezeTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } /** * Thaw given ecore timer. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @return void. */ -void timeout_handler_thaw_timer(struct timeout_handler *data) +void CTimeoutHandler::ThawTimer(void) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } - ecore_timer_thaw(data->timer); - ecore_timer_reset(data->timer); + ecore_timer_thaw(m->timer); + ecore_timer_reset(m->timer); } /** * Change timer interval value. * -* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer. +* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer. * @param val [in] New interval value to be set. * @return void. */ -void timeout_handler_change_interval(struct timeout_handler *data, - double val) +void CTimeoutHandler::ChangeInterval(double val) { - if (!data || !data->timer) { + ASSERT(m); + + if (!m->timer) { _ERR("Invalid argument"); return; } if (val == 0.0) { - ecore_timer_freeze(data->timer); + ecore_timer_freeze(m->timer); } else if (val > 0.0) { - ecore_timer_interval_set(data->timer, val); - ecore_timer_reset(data->timer); - ecore_timer_thaw(data->timer); + ecore_timer_interval_set(m->timer, val); + ecore_timer_reset(m->timer); + ecore_timer_thaw(m->timer); } } /** -* Create and init timeout_handler data. +* Create and init STimeoutHandler data. * * @param val [in] Timer interval value. -* @return The timeout_handler data pointer, NULL if error. +* @return The STimeoutHandler data pointer, NULL if error. */ -struct timeout_handler *timeout_handler_init(double val) +bool CTimeoutHandler::Create(double val) { - struct timeout_handler *data; + ASSERT(!m); - data = (struct timeout_handler *) calloc(1, sizeof(*data)); - if (!data) { + m = new STimeoutHandler; + if (!m) { _ERR("Fail to allocate memory for timeout handler"); - return NULL; + return false; } - data->event_handler[0] = ecore_event_handler_add( - ECORE_EVENT_KEY_DOWN, _event_occrued_cb, data); - data->event_handler[1] = ecore_event_handler_add( - ECORE_EVENT_KEY_UP, _event_occrued_cb, data); - data->event_handler[2] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_DOWN, - _event_occrued_cb, data); - data->event_handler[3] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_BUTTON_UP, - _event_occrued_cb, data); - data->event_handler[4] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, data); - data->event_handler[5] = ecore_event_handler_add( - ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, data); - - data->timer = ecore_timer_add(val, _timer_expired_cb, NULL); - - return data; + m->event_handler[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _event_occrued_cb, m); + m->event_handler[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _event_occrued_cb, m); + m->event_handler[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,_event_occrued_cb, m); + m->event_handler[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _event_occrued_cb, m); + m->event_handler[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, m); + m->event_handler[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, m); + + m->timer = ecore_timer_add(val, _timer_expired_cb, NULL); + + return true; } -/** -* Release given timeout_handler data. -* -* @param data [in] The timeout_handler data pointer. -* @return void. -*/ -void timeout_handler_fini(struct timeout_handler *data) + +void CTimeoutHandler::Destroy(void) { - int i; + ASSERT(m); - if (!data) { - _ERR("Invalid argument"); - return; - } + int i; for (i = 0; i < EVENT_HANDLER_NUM; i++) - ecore_event_handler_del(data->event_handler[i]); + ecore_event_handler_del(m->event_handler[i]); - ecore_timer_del(data->timer); - free(data); + ecore_timer_del(m->timer); + delete m; + m = NULL; } diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index 5c3c6be..fbe642f 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -24,7 +24,11 @@ #include "view_sublist.h" #include "settingviewmgr.h" -#define DATA_ID "SUBLISTDATA" + +enum EId { + ID_BTNS, +}; + #define MAX_ITEMS 8 #define ITEMID "itemdata" @@ -221,125 +225,6 @@ static void _scroll_event_cb(void *data, Evas_Object *obj, void *event) elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_BOTH_ARROW, ""); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object get focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusIn(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusIn(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusIn(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object lose focus. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemFocusOut(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemFocusOut(obj, ev); -} - - -void CSublistView::m_OnSubitemFocusOut(Evas_Object *obj, void *ev) -{ - char *val, *sel; - - if (!obj) { - _ERR("Invalid arguments\n"); - return; - } - - val = (char *) evas_object_data_get(obj, ITEMID); - if (!val) { - _ERR("Get value from btn failed\n"); - return; - } - - sel = _get_selected_value(m); - if (!sel) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(sel, val, strlen(sel))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(sel); -} - -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object be clicked. -* -* @param data [in] The user data. -* @param obj [in] The corresponding object which event occurred. -* @param ev [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemBtnClicked(void *data, Evas_Object *obj, void *ev) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemBtnClicked(obj, ev); -} - - -void CSublistView::m_OnSubitemBtnClicked(Evas_Object *obj, void *ev) -{ - if (!obj) - return; - - m_SetSelectedValue(obj); - - m_ExitView(); -} /** * This function is a @Evas_Smart_Cb type callback, it will be invoked if @@ -363,29 +248,6 @@ void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) m_ExitView(); } -/** -* This function is a @Evas_Smart_Cb type callback, it will be invoked if occurred -* key press event. -* -* @param data [in] The user data. -* @param e [in] The evas handler. -* @param obj [in] The corresponding object which event occurred. -* @param ei [in] The event infomation. -* @return void. -*/ -void CSublistView::sm_CbSubitemKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei) -{ - CSublistView *root = (CSublistView*)data; - if (root) - root->m_OnSubitemKeyPressed(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSublistView::m_OnSubitemKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - m_ExitView(); -} /** * This function is invoked to draw ctxpopup layout. @@ -519,14 +381,12 @@ int CSublistView::m_DrawListItems(Eina_List *list) evas_object_data_set(btn, ITEMID, val); - evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, - sm_CbSubitemFocusIn, this); - evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, - sm_CbSubitemFocusOut, this); - evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, - sm_CbSubitemBtnClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeyPressed, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); + + //evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, sm_CbSubitemFocusIn, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, sm_CbSubitemFocusOut, this); + //evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, sm_CbSubitemBtnClicked, this); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, sm_CbSubitemKeyPressed, this); elm_box_pack_end(m->popup_box, btn); eina_array_push(btns, btn); @@ -551,7 +411,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) * @param data [in] The _sublist_data data pointer. * @return 0 if success, -1 if fail. */ -int CSublistView::m_DrawSublist(void) +bool CSublistView::m_DrawSublist(void) { struct settingview_data *view; Eina_List *list; @@ -561,7 +421,7 @@ int CSublistView::m_DrawSublist(void) if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); - return -1; + return false; } view = m->sublist_view; @@ -570,19 +430,19 @@ int CSublistView::m_DrawSublist(void) list = _get_list_data(view, &cnt); if (!list) { _ERR("Get item list failed"); - return -1; + return false; } m->sub_items_count = cnt; if (_draw_ctxpopup_layout(m) == -1) { _ERR("Fail to draw ctxpopup layout"); - return -1; + return false; } if (m_DrawListItems(list) == -1) { _ERR("Fail to draw list items"); - return -1; + return false; } screen_h = WIN_HEIGHT; @@ -592,7 +452,7 @@ int CSublistView::m_DrawSublist(void) w = param->width; if (w <= 0) { _ERR("Fail to get clicked button width"); - return -1; + return false; } ratio = (w - SUBLIST_WIDTH - SUBLIST_OFFSET) / w; @@ -616,7 +476,7 @@ int CSublistView::m_DrawSublist(void) utils_set_focus_directions(m->sub_btn_array, m->sub_items_count); - return 0; + return true; } @@ -684,9 +544,7 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) m->ctxpopup = ctxpopup; m->sublist_view = view; - evas_object_data_set(base, DATA_ID, m); - - if (m_DrawSublist() == -1) { + if (!m_DrawSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -752,31 +610,96 @@ void CSublistView::Hide(void) evas_object_hide(m->ctxpopup); } -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_SUBLIST, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; -/** -* This function is invoked to get sub list view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_sublist_get_vclass(void) +void CSublistView::OnMouseClicked(int id, Evas_Object *obj) +{ + if (id != ID_BTNS) + return; + + if (!obj) + return; + + m_SetSelectedValue(obj); + + m_ExitView(); +} + + +void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + if (id != ID_BTNS) + return; + + char *val, *sel; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + val = (char *)evas_object_data_get(obj, ITEMID); + if (!val) { + _ERR("Get value from btn failed\n"); + return; + } + + sel = _get_selected_value(m); + if (!sel) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(sel, val, strlen(sel))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(sel); +} + + +void CSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { - return &_vclass; + if (id != ID_BTNS) + return; + + if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) + m_ExitView(); } -#endif \ No newline at end of file diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp index cf57833..8a3f915 100644 --- a/src/view_system_clock.cpp +++ b/src/view_system_clock.cpp @@ -40,6 +40,10 @@ #define SIG_UNFOCUSED "unfocused" #define SIG_CLICKED "clicked" +enum EId { + ID_BTNS, +}; + struct SSystemClockView { Evas_Object *win; Evas_Object *base; @@ -159,195 +163,7 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj) } } -/** -* Evas_Smart_Cb type callback for handling foucs in event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the foucs in event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusin_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) { - elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, - CTXPOPUPBTN_ICON_SOURCE); - } - - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling focus out event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the focus out event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_focusout_cb(void *priv, Evas_Object *obj, void *ev) -{ - SSystemClockView *data; - char *value; - char *selval; - - if (!obj || !priv) { - _ERR("Invalid arguments\n"); - return; - } - - data = (SSystemClockView *) priv; - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("Get value from btn failed\n"); - return; - } - - selval = _get_selected_value(data); - if (!selval) { - _ERR("_get_selected_value failed\n"); - return; - } - - if (!strncmp(selval, value, strlen(selval))) - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); - else - elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, - CTXPOPUPBTN_BUTTON_SOURCE); - - provider_release_list_value(selval); -} - -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: priv : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemClicked(void *priv, Evas_Object *obj, void *ev) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemClicked(obj, ev); -} - -void CSystemClockView::m_OnSubitemClicked(Evas_Object *obj, void *ev) -{ - struct settingitem *item; - Eina_List *list; - char *value; - const char *id; - const char *name; - - if (!obj) - return; - - _set_selected_value(m, obj); - - value = (char *) evas_object_data_get(obj, ITEMID); - if (!value) { - _ERR("get value from obj failed. DATA_ID: %s", ITEMID); - return; - } - - if (!strncmp(value, MANUAL, BUF_SIZE)) { - Hide(); - - list = viewdata_get_childitems_list(m->vdata); - if (!list) { - _ERR("list of clock is null."); - return; - } - - item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); - if (!item) { - _ERR("there is no clock_mode item in list."); - return; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("get item id failed."); - return; - } - - name = settingitem_get_display_name(item); - if (!name) { - _ERR("get display_name failed."); - return; - } - - m->ugd.display_name = name; - - m->mgr->ViewPush(id, (void *)&m->ugd); - } else { - m_ExitView(); - } -} - -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: priv : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -void CSystemClockView::sm_CbSubitemKeypress(void *priv, Evas *e, Evas_Object *obj, void *ei) -{ - CSystemClockView *root = (CSystemClockView*)priv; - if (root) - root->m_OnSubitemKeypress(e, obj, (Evas_Event_Key_Down*)ei); -} - - -void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!ev) - return; - - if (!ev->keyname) - return; - - if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) - m_ExitView(); -} /** * Create system clock sublist items. @@ -358,7 +174,7 @@ void CSystemClockView::m_OnSubitemKeypress(Evas *e, Evas_Object *obj, Evas_Event * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) +bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval) { Evas_Object *box, *cp, *btn, *del_btn; Eina_Array *array; @@ -371,7 +187,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!list || !m->ctxpopup || !selval) { _ERR("invalid arguments."); - return -1; + return false; } cp = m->ctxpopup; @@ -379,7 +195,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval box = utils_add_box(cp); if (!box) { _ERR("utils add box to ctxpopup failed."); - return -1; + return false; } elm_object_content_set(cp, box); @@ -388,7 +204,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval if (!array) { _ERR("eina array new failed."); evas_object_del(box); - return -1; + return false; } i = idx = 0; @@ -420,15 +236,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval } evas_object_data_set(btn, ITEMID, value); - - evas_object_smart_callback_add(btn, SIG_FOCUSED, - _subitem_focusin_cb, m); - evas_object_smart_callback_add(btn, SIG_UNFOCUSED, - _subitem_focusout_cb, m); - evas_object_smart_callback_add(btn, SIG_CLICKED, - sm_CbSubitemClicked, this); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - sm_CbSubitemKeypress, this); + Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); elm_box_pack_end(box, btn); eina_array_push(array, btn); @@ -443,7 +251,7 @@ int CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval m->array = array; m->sel_idx = idx; - return 0; + return true; error: EINA_ARRAY_ITER_NEXT(array, j, obj, aiter) { @@ -455,7 +263,7 @@ error: evas_object_del(box); eina_array_free(array); - return -1; + return false; } /** @@ -465,19 +273,19 @@ error: * * @return: 0 - Success, -1 - Fail. */ -int CSystemClockView::m_DrawSysclkSublist(void) +bool CSystemClockView::m_DrawSysclkSublist(void) { Evas_Object *ctxpopup; char *selval; struct settingview_data *vdata; struct obj_geometry_data *ogd; Eina_List *itlist; - int xpos, ypos, height, count, r; + int xpos, ypos, height, count; double ratio; if (!m->ctxpopup || !m->ogd || !m->vdata) { _ERR("Invalid argument\n"); - return -1; + return false; } ctxpopup = m->ctxpopup; @@ -488,7 +296,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) itlist = _get_item_list(vdata, &count); if (!itlist) { _ERR("Get item list failed"); - return -1; + return false; } m->count = count; @@ -496,7 +304,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) selval = _get_selected_value(m); if (!selval) { _ERR("Get selected value failed"); - return -1; + return false; } if (count > MAX_ITEMS) { @@ -504,8 +312,7 @@ int CSystemClockView::m_DrawSysclkSublist(void) goto error; } - r = m_AddSysclkSublistItem(itlist, selval); - if (r != 0) { + if (!m_AddSysclkSublistItem(itlist, selval)) { _ERR("add system clock sublist items failed."); goto error; } @@ -530,11 +337,11 @@ int CSystemClockView::m_DrawSysclkSublist(void) provider_release_list_value(selval); - return 0; + return true; error: provider_release_list_value(selval); - return -1; + return false; } /** @@ -566,7 +373,6 @@ void CSystemClockView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) } - Evas_Object* CSystemClockView::Base(void) { ASSERT(m); @@ -575,7 +381,6 @@ Evas_Object* CSystemClockView::Base(void) } - /** * Create all the UI components of system clock sublist view. * @@ -599,6 +404,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) struct obj_geometry_data *ogd; CSettingMgr *mgr = CSettingMgr::GetInstance(); + ugd = (struct evas_obj_data *) prev; ogd = (struct obj_geometry_data *) evas_object_data_get(ugd->cur_btn, DATA_ID); @@ -643,7 +449,7 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev) evas_object_data_set(base, DATA_ID, m); - if (m_DrawSysclkSublist() == -1) { + if (!m_DrawSysclkSublist()) { _ERR("Error in drawing items function\n"); evas_object_del(base); evas_object_del(ctxpopup); @@ -726,37 +532,141 @@ void CSystemClockView::Refresh(void) } -#if 0 +void CSystemClockView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + char *value; + char *selval; -/** -* view class of system clock view. -*/ -static struct setting_class _vclass = { - VCLASS_TITLE_SYSTEM_CLOCK, - _create, - _show, - NULL, - NULL, - _refresh, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } -/** -* Return view class of system clock view. -* -* @param: void. -* -* @return: the view class of system clock view. -*/ -struct setting_class *view_system_clock_get_vclass(void) + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) { + elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED, + CTXPOPUPBTN_ICON_SOURCE); + } + + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) { - return &_vclass; + char *value; + char *selval; + + if (!obj) { + _ERR("Invalid arguments\n"); + return; + } + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("Get value from btn failed\n"); + return; + } + + selval = _get_selected_value(m); + if (!selval) { + _ERR("_get_selected_value failed\n"); + return; + } + + if (!strncmp(selval, value, strlen(selval))) + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT, + CTXPOPUPBTN_BUTTON_SOURCE); + else + elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED, + CTXPOPUPBTN_BUTTON_SOURCE); + + provider_release_list_value(selval); +} + + +void CSystemClockView::OnMouseClicked(int oid, Evas_Object *obj) +{ + if (oid != ID_BTNS) + return; + + struct settingitem *item; + Eina_List *list; + char *value; + const char *id; + const char *name; + + if (!obj) + return; + + _set_selected_value(m, obj); + + value = (char *)evas_object_data_get(obj, ITEMID); + if (!value) { + _ERR("get value from obj failed. DATA_ID: %s", ITEMID); + return; + } + + if (!strncmp(value, MANUAL, BUF_SIZE)) { + Hide(); + + list = viewdata_get_childitems_list(m->vdata); + if (!list) { + _ERR("list of clock is null."); + return; + } + + item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM); + if (!item) { + _ERR("there is no clock_mode item in list."); + return; + } + + id = settingitem_get_id(item); + if (!id) { + _ERR("get item id failed."); + return; + } + + name = settingitem_get_display_name(item); + if (!name) { + _ERR("get display_name failed."); + return; + } + + m->ugd.display_name = name; + + m->mgr->ViewPush(id, (void *)&m->ugd); + } + else { + m_ExitView(); + } +} + + +void CSystemClockView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (id != ID_BTNS) + return; + + if (!ev->keyname) + return; + + if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE)) + m_ExitView(); } -#endif \ No newline at end of file diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp old mode 100755 new mode 100644 index a3aacde..2f699ff --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -20,7 +20,93 @@ #include "def.h" #include "settingviewmgr.h" -#define DATA_ID "ugdata" + +/** + * This callback function is invoked with base layout for layout arrangement + * after UI Gadget create create operation is completed. + * + * @param ug [in] The handler data representing a UI gadget. + * @param mode [in] The UI gadget mode. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnLayout(ug, mode); +} + + +/** + * After UG module invoke ug_send_message to send result, + * UG library call this callback function registered by calling ug_create. + * + * @param ug [in] The handler data representing a UI gadget. + * @param result [in] The Service handler. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbResult(ui_gadget_h ug, service_h result, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnResult(ug, result); +} + + + +/** + * Send the destroy request, use ug_destroy_me, + * then UG library calls this callback function registered by UG caller. + * + * @param ug [in] The handler data representing a UI gadget. + * @param priv [in] The function specific data passed by UG caller. + * @return void. + */ +void CUiGadget::sm_CbDestroy(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnDestroy(ug); +} + + +void CUiGadget::sm_CbEnd(ui_gadget_h ug, void *priv) +{ + CUiGadget *root = (CUiGadget*)priv; + if (root) + root->t_OnEnd(ug); +} + + +bool CUiGadget::Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service) +{ + ASSERT(!m_handler); + + struct ug_cbs cbs = { + sm_CbLayout, + sm_CbResult, + sm_CbDestroy, + sm_CbEnd + }; + cbs.priv = this; + + m_handler = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); + + return m_handler ? true : false; +} + + +void CUiGadget::Destroy(void) +{ + if (!m_handler) + return; + + ug_destroy(m_handler); + m_handler = NULL; +} + struct SUiGadgetView { Evas_Object *win; @@ -30,8 +116,6 @@ struct SUiGadgetView { Evas_Object *subitem_box; const char *display_name; - ui_gadget_h ug_handler; - Eina_Bool ug_is_existed; CSettingMgr *mgr; struct settingview_data *view; }; @@ -62,31 +146,6 @@ void CUiGadgetView::m_BackToMainview(void) m->mgr->ViewPop(); } -/** -* This callback function is invoked with base layout for layout arrangement -* after UI Gadget create create operation is completed. -* -* @param ug [in] The handler data representing a UI gadget. -* @param mode [in] The UI gadget mode. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgLayout(ui_gadget_h ug, enum ug_mode mode, void *priv) -{ -} - -/** -* After UG module invoke ug_send_message to send result, -* UG library call this callback function registered by calling ug_create. -* -* @param ug [in] The handler data representing a UI gadget. -* @param result [in] The Service handler. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgResult(ui_gadget_h ug, service_h result, void *priv) -{ -} /** * This function is invoked to show sub item buttons evas object. @@ -118,23 +177,8 @@ static void _show_item_btns(Evas_Object *box) eina_list_free(list); } -/** -* Send the destroy request, use ug_destroy_me, -* then UG library calls this callback function registered by UG caller. -* -* @param ug [in] The handler data representing a UI gadget. -* @param priv [in] The function specific data passed by UG caller. -* @return void. -*/ -void CUiGadgetView::sm_CbUgDestroy(ui_gadget_h ug, void *priv) -{ - CUiGadgetView *root = (CUiGadgetView*)priv; - if (root) - root->m_OnUgDestroy(ug); -} - -void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) +void CUiGadgetView::t_OnDestroy(ui_gadget_h ug) { if (!ug) { _ERR("Invalid parameters in ug destroy callback."); @@ -146,8 +190,8 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) elm_object_focus_set(m->subbtn, EINA_TRUE); elm_object_part_text_set(m->base, UG_TITLE_TEXT, ""); - ug_destroy(ug); - m->ug_is_existed = EINA_FALSE; + CUiGadget::Destroy(); + m_BackToMainview(); } @@ -159,37 +203,23 @@ void CUiGadgetView::m_OnUgDestroy(ui_gadget_h ug) */ bool CUiGadgetView::m_Load(void) { - ui_gadget_h ug; const char *name; struct settingitem *parent; - struct ug_cbs cbs = { - sm_CbUgLayout, - sm_CbUgResult, - sm_CbUgDestroy, - NULL - }; - - cbs.priv = this; - parent = viewdata_get_parentitem(m->view); name = settingitem_get_settingui_name(parent); - elm_object_part_text_set(m->base, - UG_TITLE_TEXT, m->display_name); + elm_object_part_text_set(m->base, UG_TITLE_TEXT, m->display_name); - ug = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs); - if (!ug) { - _ERR("ug create failed."); + if (!CUiGadget::Create(NULL, name, UG_MODE_FRAMEVIEW, NULL)) { return false; - } else { - m->ug_is_existed = EINA_TRUE; - m->ug_handler = ug; - m->mgr->FreezeTimeout(); } + m->mgr->FreezeTimeout(); + return true; } + /** * This function is invoked to hide sub item buttons evas object. * @@ -223,7 +253,6 @@ static void _hide_item_btns(Evas_Object *box) } - Evas_Object *CUiGadgetView::Base(void) { ASSERT(m); @@ -232,7 +261,6 @@ Evas_Object *CUiGadgetView::Base(void) } - /** * This function is invoked to create UG launcher view layout. * @@ -253,14 +281,10 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) CSettingMgr *mgr = CSettingMgr::GetInstance(); param = (struct evas_obj_data *) prev; - _hide_item_btns(param->subitem_box); win = mgr->Window(); - if (!win) { - _ERR("Invalid argument"); - return NULL; - } + ASSERT(win); m = new SUiGadgetView; if (!m) { @@ -278,16 +302,13 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) elm_layout_file_set(base, EDJ_FILE, UG_GROUP); - m->win = win; + m->win = win; m->base = base; - m->mgr = mgr; + m->mgr = mgr; m->view = view; - m->subitem_box = param->subitem_box; + m->subitem_box = param->subitem_box; m->display_name = param->display_name; - m->subbtn = param->cur_btn; - m->ug_is_existed = EINA_FALSE; - - evas_object_data_set(base, DATA_ID, m); + m->subbtn = param->cur_btn; if (!m_Load()) { _ERR("load ui gadget failed."); @@ -301,12 +322,7 @@ bool CUiGadgetView::Create(struct settingview_data *view, void *prev) return true; } -/** -* This function is invoked to show view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Show(void) { ASSERT(m); @@ -314,18 +330,12 @@ void CUiGadgetView::Show(void) evas_object_show(m->base); } -/** -* This function is invoked to destroy view layout. -* -* @param base [in] The view layout evas object. -* @return void. -*/ + void CUiGadgetView::Destroy(void) { ASSERT(m); - if (m->ug_is_existed == EINA_TRUE) - ug_destroy(m->ug_handler); + CUiGadget::Destroy(); if (m->view) viewdata_release(m->view); @@ -334,32 +344,3 @@ void CUiGadgetView::Destroy(void) delete m; m = NULL; } - -#if 0 - -static struct setting_class _vclass = { - VCLASS_TITLE_UG, - _create, - _show, - NULL, - NULL, - NULL, - NULL, - _hide, - _destroy, - NULL, - NULL, - NULL, - 0 -}; - -/** -* This function is invoked to get UI Gadget launcher view class object. -* -* @return The setting_class data static pointer, NULL on error. -*/ -struct setting_class *view_uigadget_get_vclass(void) -{ - return &_vclass; -} -#endif -- 2.7.4 From 79cd18a995ebce26d65440603c7e1ffc0324ce3e Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Tue, 7 Apr 2015 10:14:32 +0900 Subject: [PATCH 08/16] Fix win32 build error Change-Id: I244b9d91b7fd654c0e2571a3d78579c3565c547e Signed-off-by: JuWan Kim --- ug/system/clock/src/ClockSublistView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 ug/system/clock/src/ClockSublistView.cpp diff --git a/ug/system/clock/src/ClockSublistView.cpp b/ug/system/clock/src/ClockSublistView.cpp old mode 100644 new mode 100755 index 34f72ff..2b75f50 --- a/ug/system/clock/src/ClockSublistView.cpp +++ b/ug/system/clock/src/ClockSublistView.cpp @@ -283,7 +283,7 @@ void CClockSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_ case 101: { Evas_Object *on_btn, *off_btn; - Eina_Array *array; + Eina_Array *array = NULL; int mode; int ret; -- 2.7.4 From 480b4ad8d67839364e2f7fbdae7b574b3521ee95 Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Sat, 11 Apr 2015 11:46:00 +0900 Subject: [PATCH 09/16] Fix seg fault bug * When refactoring, passed wrong parameter Change-Id: I0e3f200df6e2d90b2e16d5bee4457de7cb89e656 Signed-off-by: JuWan Kim --- include/view_sublist.h | 3 +- src/utils.cpp | 29 +++---- src/view_sublist.cpp | 222 +++++++++++++++++++------------------------------ 3 files changed, 100 insertions(+), 154 deletions(-) diff --git a/include/view_sublist.h b/include/view_sublist.h index 1f7ffcf..ba58368 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -36,10 +36,11 @@ private: static void sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev); void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev); + bool m_DrawCtxpopupLayout(void); bool m_DrawSublist(void); void m_ExitView(void); void m_SetSelectedValue(Evas_Object *obj); - int m_DrawListItems(Eina_List *list); + bool m_DrawListItems(Eina_List *list); public: CSublistView(const char *pViewId) : diff --git a/src/utils.cpp b/src/utils.cpp index 39f52c3..01f90e6 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -140,10 +140,8 @@ Evas_Object *utils_add_btn(Evas_Object *base, if (!btn) return NULL; - evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, - EVAS_HINT_FILL); + evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); if (style) elm_object_style_set(btn, style); @@ -152,10 +150,8 @@ Evas_Object *utils_add_btn(Evas_Object *base, elm_object_text_set(btn, utils_get_translation_str(text)); if (event == EINA_TRUE) { - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _btn_mouse_in_cb, NULL); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _btn_mouse_out_cb, NULL); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _btn_mouse_in_cb, NULL); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _btn_mouse_out_cb, NULL); } evas_object_show(btn); @@ -182,17 +178,16 @@ Evas_Object *utils_add_scroller(Evas_Object *base) if (!scroller) return NULL; - evas_object_size_hint_weight_set(scroller, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scroller, - EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); +#if 0 elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, - ELM_SCROLLER_POLICY_OFF); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); elm_object_focus_allow_set(scroller, EINA_FALSE); evas_object_show(scroller); +#endif return scroller; } @@ -216,10 +211,8 @@ Evas_Object *utils_add_box(Evas_Object *base) if (!box) return NULL; - evas_object_size_hint_weight_set(box, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(box, - EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_focus_allow_set(box, EINA_FALSE); evas_object_show(box); diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index fbe642f..1f5b6f2 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "AppCommon.h" #include "dbg.h" #include "def.h" #include "stdbool.h" @@ -71,6 +72,8 @@ struct SSublistView { */ void CSublistView::m_ExitView(void) { + _DBG(); + Hide(); m->mgr->ViewPop(); @@ -237,6 +240,7 @@ static void _scroll_event_cb(void *data, Evas_Object *obj, void *event) */ void CSublistView::sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev) { + _DBG(); CSublistView *root = (CSublistView*)data; if (root) root->m_OnCtxpopupDismissed(obj, ev); @@ -245,6 +249,7 @@ void CSublistView::sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) { + _DBG(); m_ExitView(); } @@ -255,61 +260,51 @@ void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev) * @param data [in] The _sublist_data data pointer. * @return 0 if success, -1 if fail. */ -static int _draw_ctxpopup_layout(SSublistView *data) +bool CSublistView::m_DrawCtxpopupLayout() { - Evas_Object *box, *ctxpopup, *scroller; - - if (!data || !data->ctxpopup) { + _DBG(); + if (!m->ctxpopup) { _ERR("Invalid argument"); - return -1; + return false; } - ctxpopup = data->ctxpopup; - scroller = NULL; - - if (data->sub_items_count > MAX_ITEMS) { - scroller = utils_add_scroller(ctxpopup); - if (!scroller) { - _ERR("elm_scroller_add failed\n"); - return -1; + if (m->sub_items_count > MAX_ITEMS) { + m->scroller = utils_add_scroller(m->ctxpopup); + if (!m->scroller) { + _ERR("elm_scroller_add failed"); + return false; } - elm_object_style_set(scroller, SUBLIST_SCROLLER_STYLE); - elm_object_content_set(ctxpopup, scroller); + //elm_object_style_set(m->scroller, SUBLIST_SCROLLER_STYLE); + elm_object_content_set(m->ctxpopup, m->scroller); - box = utils_add_box(ctxpopup); - if (!box) { - _ERR("elm_box_add failed\n"); - evas_object_del(scroller); - return -1; + m->popup_box = utils_add_box(m->ctxpopup); + if (!m->popup_box) { + _ERR("elm_box_add failed"); + evas_object_del(m->scroller); + return false; } - elm_object_content_set(scroller, box); + elm_object_content_set(m->scroller, m->popup_box); - evas_object_smart_callback_add(scroller, SIG_SCROLL_BOTTOM, - _scroller_bottom_cb, data); - evas_object_smart_callback_add(scroller, SIG_SCROLL_TOP, - _scroller_top_cb, data); - evas_object_smart_callback_add(scroller, SIG_SCROLL, - _scroll_event_cb, data); + evas_object_smart_callback_add(m->scroller, SIG_SCROLL_BOTTOM, _scroller_bottom_cb, m); + evas_object_smart_callback_add(m->scroller, SIG_SCROLL_TOP, _scroller_top_cb, m); + evas_object_smart_callback_add(m->scroller, SIG_SCROLL, _scroll_event_cb, m); - elm_object_signal_emit(ctxpopup, SUBLIST_SHOW_DOWN_ARROW, ""); + elm_object_signal_emit(m->ctxpopup, SUBLIST_SHOW_DOWN_ARROW, ""); } else { - box = utils_add_box(ctxpopup); - if (!box) { - _ERR("elm_box_add failed\n"); - return -1; + m->popup_box = utils_add_box(m->ctxpopup); + if (!m->popup_box) { + _ERR("elm_box_add failed"); + return false; } - elm_object_content_set(ctxpopup, box); + elm_object_content_set(m->ctxpopup, m->popup_box); - elm_object_signal_emit(ctxpopup, SUBLIST_HIDE_BOTH_ARROW, ""); + elm_object_signal_emit(m->ctxpopup, SUBLIST_HIDE_BOTH_ARROW, ""); } - data->popup_box = box; - data->scroller = scroller; - - return 0; + return true; } /** @@ -319,8 +314,9 @@ static int _draw_ctxpopup_layout(SSublistView *data) * @param list [in] The eina list data pointer. * @return 0 if success, -1 if fail. */ -int CSublistView::m_DrawListItems(Eina_List *list) +bool CSublistView::m_DrawListItems(Eina_List *list) { + _DBG(); struct listitem *ldata; void* obj; Eina_List *l; @@ -333,20 +329,20 @@ int CSublistView::m_DrawListItems(Eina_List *list) if (!list || !m->popup_box) { _ERR("Invalid argument"); - return -1; + return false; } sel = _get_selected_value(m); if (!sel) { _ERR("Get selected value failed"); - return -1; + return false; } btns = eina_array_new(1); if (!btns) { - _ERR("Allocate array failed\n"); + _ERR("Allocate array failed"); provider_release_list_value(sel); - return -1; + return false; } i = 0; @@ -357,10 +353,9 @@ int CSublistView::m_DrawListItems(Eina_List *list) ldata = (struct listitem *) obj; name = listitem_get_display_name(ldata); - btn = utils_add_btn(m->popup_box, (char *) CTXPOPUPBTN_STYLE, - name, EINA_TRUE); + btn = utils_add_btn(m->popup_box, (char *) CTXPOPUPBTN_STYLE, name, EINA_TRUE); if (!btn) { - _ERR("Add button failed\n"); + _ERR("Add button failed"); EINA_ARRAY_ITER_NEXT(btns, j, obj, a) { tmp = (Evas_Object *) obj; @@ -368,7 +363,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) } eina_array_free(btns); provider_release_list_value(sel); - return -1; + return false; } val = listitem_get_value(ldata); @@ -402,7 +397,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) provider_release_list_value(sel); - return 0; + return true; } /** @@ -413,7 +408,7 @@ int CSublistView::m_DrawListItems(Eina_List *list) */ bool CSublistView::m_DrawSublist(void) { - struct settingview_data *view; + _DBG(); Eina_List *list; double ratio, w; int cnt, x, y, height, screen_h; @@ -424,10 +419,8 @@ bool CSublistView::m_DrawSublist(void) return false; } - view = m->sublist_view; - cnt = 0; - list = _get_list_data(view, &cnt); + list = _get_list_data(m->sublist_view, &cnt); if (!list) { _ERR("Get item list failed"); return false; @@ -435,44 +428,17 @@ bool CSublistView::m_DrawSublist(void) m->sub_items_count = cnt; - if (_draw_ctxpopup_layout(m) == -1) { + if (!m_DrawCtxpopupLayout()) { _ERR("Fail to draw ctxpopup layout"); return false; } - if (m_DrawListItems(list) == -1) { + if (!m_DrawListItems(list)) { _ERR("Fail to draw list items"); return false; } - screen_h = WIN_HEIGHT; - - param = m->geometry_data; - - w = param->width; - if (w <= 0) { - _ERR("Fail to get clicked button width"); - return false; - } - - ratio = (w - SUBLIST_WIDTH - SUBLIST_OFFSET) / w; - - x = param->x + param->width * ratio; - y = param->y; - - if (m->sub_items_count < MAX_ITEMS) - height = m->sub_items_count * ITEM_HEIGHT; - else - height = MAX_ITEMS * ITEM_HEIGHT + ITEM_OFFSET; - - if (y > screen_h) - { - y = y - height; - _DBG("y > screen_h !!!!!! y = %d", y); - } - - _DBG("x : %d , y : %d, ELM_SCALE = %f, height = %d", x , y , ELM_SCALE, height); - evas_object_move(m->ctxpopup, x * ELM_SCALE, (y * ELM_SCALE) + height); + evas_object_move(m->ctxpopup, m->geometry_data->x + m->geometry_data->width , m->geometry_data->y); utils_set_focus_directions(m->sub_btn_array, m->sub_items_count); @@ -502,59 +468,38 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) ASSERT(!m); ASSERT(view); ASSERT(prev); - - Evas_Object *base, *ctxpopup, *win; - CSettingMgr *mgr = CSettingMgr::GetInstance(); - - win = mgr->Window(); - ASSERT(win); - - m = new SSublistView; - if (!m) { - _ERR("Unable to allocate memory\n"); - return false; - } - - base = elm_layout_add(win); - if (!base) { - delete m; - m = NULL; - return false; - } - - elm_layout_file_set(base, EDJ_FILE, SUBLIST_VIEW_PAGE); - - ctxpopup = utils_add_ctxpopup(win, (char *) SUBLIST_CTXPOPUP_STYLE1); - if (!ctxpopup) { - _ERR("Fail to add ctxpopup"); - evas_object_del(base); - delete m; - m = NULL; - return false; - } - - evas_object_smart_callback_add(ctxpopup, SIG_CTXPOPUP_DISMISSED, - sm_CbCtxpopupDismissed, m); - - m->geometry_data = (struct obj_geometry_data *) prev; - - m->mgr = mgr; - m->win = win; - m->base = base; - m->ctxpopup = ctxpopup; - m->sublist_view = view; - - if (!m_DrawSublist()) { - _ERR("Error in drawing items function\n"); - evas_object_del(base); - evas_object_del(ctxpopup); - if (m->sub_btn_array) - eina_array_free(m->sub_btn_array); - - delete m; - m = NULL; - return false; - } + _DBG(); + + _CREATE_BEGIN { + _CHECK(m = new SSublistView) + _CHECK(m->mgr = CSettingMgr::GetInstance()) + _CHECK(m->win = m->mgr->Window()) + _CHECK(m->base = elm_layout_add(m->win)) + _COMMAND { + elm_layout_file_set(m->base, EDJ_FILE, SUBLIST_VIEW_PAGE); + } + _CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, (char *) SUBLIST_CTXPOPUP_STYLE1)) + _COMMAND { + evas_object_smart_callback_add(m->ctxpopup, SIG_CTXPOPUP_DISMISSED, sm_CbCtxpopupDismissed, this); + m->geometry_data = (struct obj_geometry_data *) prev; + _DBG("m-geometry_data w:%d, h:%d, x:%d, y:%d", + m->geometry_data->width, + m->geometry_data->height, + m->geometry_data->x, + m->geometry_data->y + ); + + m->sublist_view = view; + } + _CHECK(m_DrawSublist()) + _WHEN_SUCCESS { } + _CHECK_FAIL{ if (m->sub_btn_array) eina_array_free(m->sub_btn_array); } + _CHECK_FAIL{ if(m->ctxpopup) evas_object_del(m->ctxpopup); } + _CHECK_FAIL{ if(m->base) evas_object_del(m->base); } + _CHECK_FAIL{/* m->win = m->mgr->Window() */} + _CHECK_FAIL{/* m->mgr = CSettingMgr::GetInstance() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } return true; } @@ -568,6 +513,7 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) void CSublistView::Show(void) { ASSERT(m); + _DBG(); evas_object_show(m->ctxpopup); evas_object_show(m->base); @@ -582,6 +528,7 @@ void CSublistView::Show(void) void CSublistView::Destroy(void) { ASSERT(m); + _DBG(); if (m->sub_btn_array) eina_array_free(m->sub_btn_array); @@ -605,6 +552,7 @@ void CSublistView::Destroy(void) void CSublistView::Hide(void) { ASSERT(m); + _DBG(); evas_object_hide(m->base); evas_object_hide(m->ctxpopup); @@ -613,6 +561,7 @@ void CSublistView::Hide(void) void CSublistView::OnMouseClicked(int id, Evas_Object *obj) { + _DBG(); if (id != ID_BTNS) return; @@ -627,6 +576,7 @@ void CSublistView::OnMouseClicked(int id, Evas_Object *obj) void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) { + _DBG(); if (id != ID_BTNS) return; @@ -662,6 +612,7 @@ void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) { + _DBG(); if (id != ID_BTNS) return; @@ -697,6 +648,7 @@ void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item) void CSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { + _DBG(); if (id != ID_BTNS) return; -- 2.7.4 From f0a1c1151e3dfcacf959cfc5444c2ee0c66c82dd Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Mon, 13 Apr 2015 16:15:19 +0900 Subject: [PATCH 10/16] Fix auto-test bug * Fix btn click callback * Remove Key defines Change-Id: I8a1b442cc2e5a36641b157b60ebbd06b211fad61 Signed-off-by: JuWan Kim --- data/viewer/maincatalog.edc | 1 + include/dbg.h | 2 - include/def.h | 22 ---- include/view_maincatalog.h | 5 + include/view_sublist.h | 5 +- include/view_system_clock.h | 5 +- src/timeout_handler.cpp | 1 + src/view_maincatalog.cpp | 251 +++++++++++++++-------------------------- src/view_need_pwd.cpp | 3 +- src/view_pwd_popup.cpp | 3 +- src/view_sublist.cpp | 13 +-- src/view_system_clock.cpp | 1 + src/view_uigadget.cpp | 1 + ug/channel/CMakeLists.txt | 8 ++ ug/channel/include/defs.h | 4 - ug/network/CMakeLists.txt | 12 ++ ug/network/include/defs.h | 22 ---- ug/proxy/CMakeLists.txt | 11 ++ ug/proxy/include/defs.h | 22 ---- ug/src/NetConMgr.cpp | 1 + ug/src/TVServiceMgr.cpp | 1 + ug/src/WifiDirectMgr.cpp | 1 + ug/src/WifiMgr.cpp | 1 + ug/system/clock/CMakeLists.txt | 6 + ug/system/clock/include/defs.h | 19 ---- ug/wifi-direct/CMakeLists.txt | 11 ++ ug/wifi-direct/include/defs.h | 22 ---- 27 files changed, 167 insertions(+), 287 deletions(-) diff --git a/data/viewer/maincatalog.edc b/data/viewer/maincatalog.edc index 92be2bb..c5c65b0 100755 --- a/data/viewer/maincatalog.edc +++ b/data/viewer/maincatalog.edc @@ -153,6 +153,7 @@ group { to: MAIN_VIEW_PADDING_ICON; } align: 0.0 0.0; + fixed: 1 1; } } part { diff --git a/include/dbg.h b/include/dbg.h index 544a636..b8285d5 100644 --- a/include/dbg.h +++ b/include/dbg.h @@ -19,8 +19,6 @@ #include -#define ASSERT(exp) if (!(exp)) { _DBG(#exp); int* a = 0; *a = 5; } - #ifdef LOG_TAG #undef LOG_TAG #endif diff --git a/include/def.h b/include/def.h index 7b1b383..83af87b 100644 --- a/include/def.h +++ b/include/def.h @@ -266,28 +266,6 @@ #define TEXT_STYLE_MEDIUM "Tizen Sans:style=Medium" #define TEXT_STYLE_BOLD "Tizen Sans:style=Bold" -/* Key defines */ -#define KEY_UP "Up" -#define KEY_DOWN "Down" -#define KEY_LEFT "Left" -#define KEY_RIGHT "Right" -#define KEY_ENTER "Return" -#define KEY_ENTER_REMOTE "KP_Enter" -#define KEY_EXIT "Exit" -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - -#define KEY_0 "0" -#define KEY_1 "1" -#define KEY_2 "2" -#define KEY_3 "3" -#define KEY_4 "4" -#define KEY_5 "5" -#define KEY_6 "6" -#define KEY_7 "7" -#define KEY_8 "8" -#define KEY_9 "9" - /* VCONF KEYS */ /* Proxy */ diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 6ab5aef..11f6661 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -26,6 +26,11 @@ class CMainCatalogView : private: struct SMainCatalog *m; + static void sm_CbViewAniFinish(void *data, Evas_Object *obj, const char *emission, const char *source); + void m_OnViewAniFinish(Evas_Object *obj, const char *emission, const char *source); + + void m_DrawMainItems(void); + public: CMainCatalogView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} virtual ~CMainCatalogView() {} diff --git a/include/view_sublist.h b/include/view_sublist.h index ba58368..32d1138 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -24,11 +24,12 @@ class CSublistView : public CSettingBaseView, + public CListenerMgr, public IFocusedListener, public IUnfocusedListener, public IMouseClickedListener, - public IKeyDownListener, - public CListenerMgr { + public IKeyDownListener +{ private: struct SSublistView *m; diff --git a/include/view_system_clock.h b/include/view_system_clock.h index 2ffee89..65e42dc 100644 --- a/include/view_system_clock.h +++ b/include/view_system_clock.h @@ -24,11 +24,12 @@ class CSystemClockView : public CSettingBaseView, + public CListenerMgr, public IFocusedListener, public IUnfocusedListener, public IMouseClickedListener, - public IKeyDownListener, - public CListenerMgr { + public IKeyDownListener +{ private: struct SSystemClockView *m; diff --git a/src/timeout_handler.cpp b/src/timeout_handler.cpp index db39007..dc9a00f 100644 --- a/src/timeout_handler.cpp +++ b/src/timeout_handler.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "dbg.h" #include "stdlib.h" #include "stdbool.h" diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp index 0e67b27..d7f15b7 100644 --- a/src/view_maincatalog.cpp +++ b/src/view_maincatalog.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "dbg.h" #include "def.h" @@ -1520,114 +1521,64 @@ static int _add_icon_btns(SMainCatalog *data, Eina_List *list) * * @return: 0 - success, -1 - fail. */ -static int _draw_main_items(SMainCatalog *data) +void CMainCatalogView::m_DrawMainItems(void) { - Evas_Object *box, *btn, *tmp, *icon; - Eina_Array *btns, *icons; - Eina_List *list; - int cnt, i; - Eina_Array_Iterator a; - void* obj; - - if (!data || !data->base) - return -1; - - box = utils_add_box(data->base); - if (!box) - return -1; - - data->mainitem_box = box; - - cnt = 0; - list = viewdata_get_childitems_list(data->main_setting_view); - if (list) - cnt = eina_list_count(list); - - if (cnt == 0) { - _ERR("There is no child item"); - evas_object_del(box); - viewdata_free_childitems_list(list); - return -1; - } - - data->main_item_count = cnt; - - btns = eina_array_new(1); - if (!btns) { - _ERR("Create Eina Array failed\n"); - evas_object_del(box); - viewdata_free_childitems_list(list); - return -1; - } - - data->main_item_btn = btns; - - icons = eina_array_new(1); - if (!icons) { - _ERR("new array for icon base failed."); - evas_object_del(box); - viewdata_free_childitems_list(list); - eina_array_free(btns); - return -1; - } - - data->main_icon_base = icons; - - if (_add_icon_btns(data, list) == -1) { - _ERR("Fail to add icon buttons"); - goto error; - } - - elm_object_part_content_set(data->base, MAIN_VIEW_ICON_SWALLOW, box); - - if (!data->item_path) { - btn = (Evas_Object *)eina_array_data_get(btns, 0); - if (!btn) - goto error; - - if (_draw_subitems(data, - (const char *) evas_object_data_get(btn, SETTING_ID)) == -1) - goto error; - - icon = (Evas_Object *)eina_array_data_get(icons, 0); - if (!icon) { - if (data->subsetting_view) - viewdata_release(data->subsetting_view); - goto error; + Evas_Object *btn, *icon; + Eina_List *list = NULL; + bool ret = true; + + _CREATE_BEGIN { + _CHECK(m->mainitem_box = utils_add_box(m->base)) + _CHECK(list = viewdata_get_childitems_list(m->main_setting_view)) + _COMMAND{ + m->main_item_count = 0; + m->main_item_count = eina_list_count(list); } + _CHECK(m->main_item_count) + _CHECK(m->main_item_btn = eina_array_new(1)) + _CHECK(m->main_icon_base = eina_array_new(1)) + _CHECK(_add_icon_btns(m, list) != -1) + _COMMAND { + elm_object_part_content_set(m->base, MAIN_VIEW_ICON_SWALLOW, m->mainitem_box); + + if (!m->item_path) { + btn = (Evas_Object *)eina_array_data_get(m->main_item_btn, 0); + if (btn) { + if (_draw_subitems(m, (const char *) evas_object_data_get(btn, SETTING_ID)) != -1) { + icon = (Evas_Object *)eina_array_data_get(m->main_icon_base, 0); + if (icon) { + elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); + + m->focus_status = FOCUS_MAIN_ITEM; + elm_object_focus_set(btn, EINA_TRUE); + m->focused_main_item_btn = btn; + } + else { + if (m->subsetting_view) + viewdata_release(m->subsetting_view); + ret = false; + } + } + else + ret = false; + } + else + ret = false; + } - elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); - - data->focus_status = FOCUS_MAIN_ITEM; - - elm_object_focus_set(btn, EINA_TRUE); - data->focused_main_item_btn = btn; - } - - utils_set_focus_directions(data->main_item_btn, cnt); - - viewdata_free_childitems_list(list); - - return 0; - -error: - evas_object_del(box); - viewdata_free_childitems_list(list); - EINA_ARRAY_ITER_NEXT(btns, i, obj, a) - { - tmp = (Evas_Object *) obj; - evas_object_del(tmp); - } - eina_array_free(btns); - - EINA_ARRAY_ITER_NEXT(icons, i, obj, a) - { - tmp = (Evas_Object *) obj; - evas_object_del(tmp); - } - eina_array_free(icons); - - return -1; + utils_set_focus_directions(m->main_item_btn, m->main_item_count); + viewdata_free_childitems_list(list); + } + _CHECK(ret) + _WHEN_SUCCESS { } + _CHECK_FAIL{/* ret */} + _CHECK_FAIL{/*_add_icon_btns(m, list) != -1*/} + _CHECK_FAIL{if(m->main_icon_base) eina_array_free(m->main_icon_base);} + _CHECK_FAIL{if(m->main_item_btn) eina_array_free(m->main_item_btn);} + _CHECK_FAIL{/* m->main_item_count */} + _CHECK_FAIL{if(list) viewdata_free_childitems_list(list);} + _CHECK_FAIL{if(m->mainitem_box) evas_object_del(m->mainitem_box);} + } _CREATE_END_AND_CATCH { return; } } /** @@ -1640,21 +1591,21 @@ error: * * @return: void. */ -static void _view_anim_finish(void *data, Evas_Object *obj, - const char *emission, const char *source) +void CMainCatalogView::sm_CbViewAniFinish(void *data, Evas_Object *obj, const char *emission, const char *source) { - _DBG("START ========================================================="); - SMainCatalog *priv; + if(!data){ _ERR("Invalid Param"); return;} + CMainCatalogView *root; + root = (CMainCatalogView *) data; + root->m_OnViewAniFinish(obj, emission, source); +} - if (!data) - return; - priv = (SMainCatalog *)data; - - _draw_main_items(priv); - _DBG("END ========================================================="); +void CMainCatalogView::m_OnViewAniFinish(Evas_Object *obj, const char *emission, const char *source) +{ + m_DrawMainItems(); } + /** * This function moves focus from main item to subitem and * does corresponding operations. @@ -1770,53 +1721,31 @@ bool CMainCatalogView::Create(struct settingview_data *view, void *prev) ASSERT(!m); ASSERT(view); - _DBG("START =================================================================="); - Evas_Object *base, *win; - CSettingMgr *mgr = CSettingMgr::GetInstance(); - - win = mgr->Window(); - ASSERT(win); - - m = (SMainCatalog *) calloc(1, sizeof(*m)); - if (!m) - return false; - - base = elm_layout_add(win); - if (!base) { - delete m; - m = NULL; - return false; - } - - if (!elm_layout_file_set(base, EDJ_FILE, MAIN_VIEW_PAGE)) - goto error; - - m->mgr = mgr; - m->win = win; - m->base = base; - m->main_setting_view = view; - m->subsetting_view = NULL; - m->item_path = mgr->GetItemPath(); - - evas_object_data_set(base, DATA_ID, m); - - elm_object_signal_callback_add(base, MAIN_VIEW_ANIM_FINISH, - MAIN_VIEW_SOURCE, _view_anim_finish, m); - - if (!m->item_path) - elm_object_signal_emit(m->base, MAIN_VIEW_LOAD, ""); - else - _view_anim_finish(m, NULL, NULL, NULL); + _CREATE_BEGIN{ + _CHECK(m = new SMainCatalog) + _CHECK(m->mgr = CSettingMgr::GetInstance()) + _CHECK(m->win = m->mgr->Window()) + _CHECK(m->base = elm_layout_add(m->win)) + _WHEN_SUCCESS { + elm_layout_file_set(m->base, EDJ_FILE, MAIN_VIEW_PAGE); + m->main_setting_view = view; + m->subsetting_view = NULL; + m->item_path = m->mgr->GetItemPath(); + evas_object_data_set(m->base, DATA_ID, m); + elm_object_signal_callback_add(m->base, MAIN_VIEW_ANIM_FINISH, MAIN_VIEW_SOURCE, sm_CbViewAniFinish, this); + + if (!m->item_path) + elm_object_signal_emit(m->base, MAIN_VIEW_LOAD, ""); + else + m_OnViewAniFinish(NULL, NULL, NULL); + } + _CHECK_FAIL{if(m->base) evas_object_del(m->base);} + _CHECK_FAIL{/* m->win = m->mgr->Window() */} + _CHECK_FAIL{/* m->mgr = CSettingMgr::GetInstance() */} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } - _DBG("END =================================================================="); return true; - -error: - _DBG("END-ERROR =================================================================="); - evas_object_del(base); - delete m; - m = NULL; - return false; } @@ -2097,4 +2026,4 @@ struct setting_class *view_maincatalog_get_vclass(void) { return &_vclass; } -#endif \ No newline at end of file +#endif diff --git a/src/view_need_pwd.cpp b/src/view_need_pwd.cpp index 8438ddd..26c9687 100755 --- a/src/view_need_pwd.cpp +++ b/src/view_need_pwd.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "dbg.h" #include "def.h" #include "utils.h" @@ -738,4 +739,4 @@ struct setting_class *view_need_passcode_get_vclass(void) { return &_vclass; } -#endif \ No newline at end of file +#endif diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.cpp index ae64bb4..7226f15 100755 --- a/src/view_pwd_popup.cpp +++ b/src/view_pwd_popup.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "dbg.h" #include "def.h" #include "view_pwd_popup.h" @@ -891,4 +892,4 @@ struct setting_class *view_passcode_popup_get_vclass(void) { return &_vclass; } -#endif \ No newline at end of file +#endif diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index 1f5b6f2..c95546f 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -269,6 +269,7 @@ bool CSublistView::m_DrawCtxpopupLayout() } if (m->sub_items_count > MAX_ITEMS) { + _DBG(); m->scroller = utils_add_scroller(m->ctxpopup); if (!m->scroller) { _ERR("elm_scroller_add failed"); @@ -368,14 +369,13 @@ bool CSublistView::m_DrawListItems(Eina_List *list) val = listitem_get_value(ldata); if (!strncmp(sel, val, strlen(sel))) { - elm_object_signal_emit(btn, - CTXPOPUPBTN_BUTTON_HIGHLIGHT, - CTXPOPUPBTN_BUTTON_SOURCE); + elm_object_signal_emit(btn, CTXPOPUPBTN_BUTTON_HIGHLIGHT, CTXPOPUPBTN_BUTTON_SOURCE); check = i; } evas_object_data_set(btn, ITEMID, val); + _DBG("[%s] Connected", name); Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN); //evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, sm_CbSubitemFocusIn, this); @@ -410,9 +410,7 @@ bool CSublistView::m_DrawSublist(void) { _DBG(); Eina_List *list; - double ratio, w; - int cnt, x, y, height, screen_h; - struct obj_geometry_data *param; + int cnt; if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); @@ -478,7 +476,8 @@ bool CSublistView::Create(struct settingview_data *view, void *prev) _COMMAND { elm_layout_file_set(m->base, EDJ_FILE, SUBLIST_VIEW_PAGE); } - _CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, (char *) SUBLIST_CTXPOPUP_STYLE1)) + //_CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, (char *) SUBLIST_CTXPOPUP_STYLE1)) + _CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, NULL)) _COMMAND { evas_object_smart_callback_add(m->ctxpopup, SIG_CTXPOPUP_DISMISSED, sm_CbCtxpopupDismissed, this); m->geometry_data = (struct obj_geometry_data *) prev; diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp index 8a3f915..f6e22d3 100644 --- a/src/view_system_clock.cpp +++ b/src/view_system_clock.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "dbg.h" #include "def.h" #include "stdbool.h" diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp index 2f699ff..17ddda6 100644 --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "view_uigadget.h" #include "dbg.h" #include "def.h" diff --git a/ug/channel/CMakeLists.txt b/ug/channel/CMakeLists.txt index 02e6c40..66cddc8 100644 --- a/ug/channel/CMakeLists.txt +++ b/ug/channel/CMakeLists.txt @@ -25,6 +25,14 @@ SET(AUTO_PRGM_EDJ_THEME "ug_auto_program_theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(AUTO_PRGM_UG_PKGS REQUIRED + eina + edje + evas + elementary + capi-appfw-application + capi-system-info + aul + ui-gadget-1 ) #tv-service #tv-player-core diff --git a/ug/channel/include/defs.h b/ug/channel/include/defs.h index a02da90..b265101 100644 --- a/ug/channel/include/defs.h +++ b/ug/channel/include/defs.h @@ -97,8 +97,4 @@ #define BORDER_H1 14 #define BORDER_H2 14 -/* Key defines */ -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - #endif /* __DEFS_H__ */ diff --git a/ug/network/CMakeLists.txt b/ug/network/CMakeLists.txt index b930c12..0fac965 100644 --- a/ug/network/CMakeLists.txt +++ b/ug/network/CMakeLists.txt @@ -24,6 +24,18 @@ SET(UG_NETWORK_EDJ_THEME "ug-network-settings-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_NETWORK_PKGS REQUIRED + eina + edje + evas + elementary + aul + glib-2.0 + ui-gadget-1 + vconf + capi-appfw-application + capi-network-wifi + capi-network-connection + application-common ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_NETWORK_PKGS_LDFLAGS}") diff --git a/ug/network/include/defs.h b/ug/network/include/defs.h index 3fe2aa3..866bf11 100644 --- a/ug/network/include/defs.h +++ b/ug/network/include/defs.h @@ -140,28 +140,6 @@ #define POPUP_WIDTH 688 #define POPUP_HEIGHT 411 -/* Key defines */ -#define KEY_UP "Up" -#define KEY_DOWN "Down" -#define KEY_LEFT "Left" -#define KEY_RIGHT "Right" -#define KEY_ENTER "Return" -#define KEY_ENTER_REMOTE "KP_Enter" -#define KEY_EXIT "Exit" -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - -#define KEY_0 "0" -#define KEY_1 "1" -#define KEY_2 "2" -#define KEY_3 "3" -#define KEY_4 "4" -#define KEY_5 "5" -#define KEY_6 "6" -#define KEY_7 "7" -#define KEY_8 "8" -#define KEY_9 "9" - /* Width Height */ #define DEFAULT_WIN_WIDTH 1920 #define DEFAULT_WIN_HEIGHT 1080 diff --git a/ug/proxy/CMakeLists.txt b/ug/proxy/CMakeLists.txt index 5f38a6d..20da480 100644 --- a/ug/proxy/CMakeLists.txt +++ b/ug/proxy/CMakeLists.txt @@ -24,6 +24,17 @@ SET(UG_PROXY_EDJ_THEME "ug-proxy-settings-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_PROXY_PKGS REQUIRED + eina + edje + evas + elementary + aul + glib-2.0 + ui-gadget-1 + vconf + capi-appfw-application + capi-network-wifi + capi-network-connection ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_PROXY_PKGS_LDFLAGS}") diff --git a/ug/proxy/include/defs.h b/ug/proxy/include/defs.h index 1af98cc..1c6621f 100644 --- a/ug/proxy/include/defs.h +++ b/ug/proxy/include/defs.h @@ -107,28 +107,6 @@ #define PART_TEXT_CONTENT "content.txt" #define PART_ENTRY "part.entry" -/* Key defines */ -#define KEY_UP "Up" -#define KEY_DOWN "Down" -#define KEY_LEFT "Left" -#define KEY_RIGHT "Right" -#define KEY_ENTER "Return" -#define KEY_ENTER_REMOTE "KP_Enter" -#define KEY_EXIT "Exit" -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - -#define KEY_0 "0" -#define KEY_1 "1" -#define KEY_2 "2" -#define KEY_3 "3" -#define KEY_4 "4" -#define KEY_5 "5" -#define KEY_6 "6" -#define KEY_7 "7" -#define KEY_8 "8" -#define KEY_9 "9" - /* Width Height */ #define DEFAULT_WIN_WIDTH 1920 #define DEFAULT_WIN_HEIGHT 1080 diff --git a/ug/src/NetConMgr.cpp b/ug/src/NetConMgr.cpp index 9c6f95d..f4ad61c 100644 --- a/ug/src/NetConMgr.cpp +++ b/ug/src/NetConMgr.cpp @@ -1,3 +1,4 @@ +#include #include "dbg.h" #include "NetConMgr.h" diff --git a/ug/src/TVServiceMgr.cpp b/ug/src/TVServiceMgr.cpp index 3c821f8..714a0b5 100644 --- a/ug/src/TVServiceMgr.cpp +++ b/ug/src/TVServiceMgr.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "dbg.h" //#include "tv_service_proxy.h" #include "AppCommon.h" diff --git a/ug/src/WifiDirectMgr.cpp b/ug/src/WifiDirectMgr.cpp index a562129..c6f745b 100644 --- a/ug/src/WifiDirectMgr.cpp +++ b/ug/src/WifiDirectMgr.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "defs.h" #include "dbg.h" #include "WifiMgr.h" diff --git a/ug/src/WifiMgr.cpp b/ug/src/WifiMgr.cpp index 3ae6ad6..3093cfe 100644 --- a/ug/src/WifiMgr.cpp +++ b/ug/src/WifiMgr.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "WifiMgr.h" #define IP_STRING_MAX_SIZE 20 diff --git a/ug/system/clock/CMakeLists.txt b/ug/system/clock/CMakeLists.txt index cd86ddc..2347d14 100755 --- a/ug/system/clock/CMakeLists.txt +++ b/ug/system/clock/CMakeLists.txt @@ -21,6 +21,12 @@ SET(UG_CLOCK_EDJ_THEME "ug_clock_theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_CLOCK_PKGS REQUIRED + eina + edje + evas + elementary + aul + ui-gadget-1 sysman ) diff --git a/ug/system/clock/include/defs.h b/ug/system/clock/include/defs.h index 11ae5f9..a91193c 100755 --- a/ug/system/clock/include/defs.h +++ b/ug/system/clock/include/defs.h @@ -87,23 +87,4 @@ #define SIG_SRC_FOC_HIDE_ICON "focus_hide_icon" #define SIG_NAME_SUBLIST "sublist" -/* Key defines */ -#define KEY_UP "Up" -#define KEY_DOWN "Down" -#define KEY_LEFT "Left" -#define KEY_RIGHT "Right" -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - -#define KEY_0 "0" -#define KEY_1 "1" -#define KEY_2 "2" -#define KEY_3 "3" -#define KEY_4 "4" -#define KEY_5 "5" -#define KEY_6 "6" -#define KEY_7 "7" -#define KEY_8 "8" -#define KEY_9 "9" - #endif /* __UG_CLOCK_DEFINE_H__ */ diff --git a/ug/wifi-direct/CMakeLists.txt b/ug/wifi-direct/CMakeLists.txt index 177c89d..e6717bd 100644 --- a/ug/wifi-direct/CMakeLists.txt +++ b/ug/wifi-direct/CMakeLists.txt @@ -25,6 +25,17 @@ SET(UG_WIFI_DIRECT_EDJ_THEME "ug-wifi-direct-theme.edj") INCLUDE(FindPkgConfig) pkg_check_modules(UG_WIFI_DIRECT_PKGS REQUIRED + eina + edje + evas + elementary + aul + glib-2.0 + ui-gadget-1 + vconf + capi-appfw-application + capi-network-wifi + capi-network-connection wifi-direct ) SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_WIFI_DIRECT_PKGS_LDFLAGS}") diff --git a/ug/wifi-direct/include/defs.h b/ug/wifi-direct/include/defs.h index a8c9156..48db63a 100644 --- a/ug/wifi-direct/include/defs.h +++ b/ug/wifi-direct/include/defs.h @@ -94,26 +94,4 @@ #define SIG_CLICKED "clicked" #define SIG_BTN_SELECTED "btn,selected" -/* Key defines */ -#define KEY_UP "Up" -#define KEY_DOWN "Down" -#define KEY_LEFT "Left" -#define KEY_RIGHT "Right" -#define KEY_ENTER "Return" -#define KEY_ENTER_REMOTE "KP_Enter" -#define KEY_EXIT "Exit" -#define KEY_BACK "Escape" -#define KEY_BACK_REMOTE "XF86Close" - -#define KEY_0 "0" -#define KEY_1 "1" -#define KEY_2 "2" -#define KEY_3 "3" -#define KEY_4 "4" -#define KEY_5 "5" -#define KEY_6 "6" -#define KEY_7 "7" -#define KEY_8 "8" -#define KEY_9 "9" - #endif /* __DEFS_H__ */ -- 2.7.4 From 26594948f6c660fa50af7abe1862746f60d2526a Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Mon, 13 Apr 2015 16:45:15 +0900 Subject: [PATCH 11/16] Fix clock ui bug Change-Id: I5fdb1e7ded296a863fb323eb1cbde942fed6416c Signed-off-by: JuWan Kim --- ug/system/clock/src/ClockMainView.cpp | 4 ++-- ug/system/clock/src/ug_clock.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ug/system/clock/src/ClockMainView.cpp b/ug/system/clock/src/ClockMainView.cpp index e63ca26..53b92eb 100644 --- a/ug/system/clock/src/ClockMainView.cpp +++ b/ug/system/clock/src/ClockMainView.cpp @@ -350,13 +350,13 @@ bool CClockMainView::Create(void *data) _CHECK(m = new SClockMainView) _CHECK(m->win = CViewMgr::GetInstance()->Window()) _CHECK(m->base = utils_add_layout(m->win)) - _CHECK(m_AddCloseBtn()) - _CHECK(m_AddClockSublist()) _COMMAND{ elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, UG_CLOCK_GRP); elm_object_part_text_set(m->base, TEXT_INTRO, STRINGS_INTRO); } + _CHECK(m_AddCloseBtn()) + _CHECK(m_AddClockSublist()) _WHEN_SUCCESS { #if 0 diff --git a/ug/system/clock/src/ug_clock.cpp b/ug/system/clock/src/ug_clock.cpp index 33de881..bb3efad 100755 --- a/ug/system/clock/src/ug_clock.cpp +++ b/ug/system/clock/src/ug_clock.cpp @@ -102,7 +102,7 @@ static void *_on_create(ui_gadget_h ug, return false; } - ugd->pViewMgr->PushView(CLOCK_MAIN_VIEW, NULL); + ugd->pViewMgr->PushView(CLOCK_MAIN_VIEW, ugd->ug); ugd->base = ugd->pClockMainView->Base(); return ugd->base; -- 2.7.4 From 0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Mon, 13 Apr 2015 20:58:53 +0900 Subject: [PATCH 12/16] Refactoring / code clean Change-Id: I075c61762513fb01a7573ed0c44abdbf6a4994f2 Signed-off-by: JuWan Kim --- include/view_maincatalog.h | 27 +- src/settingviewmgr.cpp | 12 +- src/view_maincatalog.cpp | 1190 +++++++++++++------------------------------- src/view_pwd_popup.cpp | 1 + 4 files changed, 389 insertions(+), 841 deletions(-) diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 11f6661..95a3894 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -19,20 +19,39 @@ #include "settingviewmgr.h" +#include "InputHandler.h" class CMainCatalogView : - public CSettingBaseView { + public CSettingBaseView, + public CListenerMgr, + public IMouseClickedListener, + public IKeyUpListener, + public IKeyDownListener +{ private: struct SMainCatalog *m; static void sm_CbViewAniFinish(void *data, Evas_Object *obj, const char *emission, const char *source); void m_OnViewAniFinish(Evas_Object *obj, const char *emission, const char *source); + static void sm_CbMainItemBtnMouseIN(void *data, Evas *e, Evas_Object *obj, void *ei); + void m_OnMainItemMouseIN(Evas *e, Evas_Object *obj, void *ei); + + void m_SubItemClicked(Evas_Object *obj); + bool m_DrawSubItems(const char *name); + void m_MoveFromMainitemToSubitem(Evas_Object *mainbtn); + void m_MoveFromSubitemToMainitem(Evas_Object *btn); + bool m_AddIconBtns(Eina_List *list); void m_DrawMainItems(void); public: - CMainCatalogView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {} + CMainCatalogView(const char *pViewId) : + CSettingBaseView(pViewId), + IMouseClickedListener(this), + IKeyUpListener(this), + IKeyDownListener(this), + m(0) {} virtual ~CMainCatalogView() {} Evas_Object *Base(void); @@ -45,6 +64,10 @@ public: virtual void LangChanged(void); virtual void Frozen(void); virtual void Active(void); + + virtual void OnMouseClicked(int id, Evas_Object *obj); + virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev); + virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); }; diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 674f3bf..66c8379 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -18,7 +18,8 @@ #include #include "dbg.h" -#include "AppCommon.h" +#include +#include #include "settingviewmgr.h" #include "data_wrapper.h" #include "timeout_handler.h" @@ -135,8 +136,7 @@ static struct settingview_data *_build_setting_view( } - -CMainCatalogView g_maincatalog(VCLASS_TITLE_MAIN_VIEW); +CMainCatalogView *g_maincatalog; /** * This function is invoked to get setting_class data pointer, this data stand for a kind of view. * @@ -169,8 +169,10 @@ static CSettingBaseView *_get_view_class(SSettingMgr *mgr, vclass = NULL; if (list && !style) { - if (mgr->depth == 1) - vclass = &g_maincatalog;// view_maincatalog_get_vclass(); + if (mgr->depth == 1){ + g_maincatalog = new CMainCatalogView(VCLASS_TITLE_MAIN_VIEW); + vclass = (CSettingBaseView *) g_maincatalog;// view_maincatalog_get_vclass(); + } } else { size = sizeof(g_func_map) / sizeof(*g_func_map); for (i = 0; i < size; i++) { diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp index d7f15b7..a3e2220 100644 --- a/src/view_maincatalog.cpp +++ b/src/view_maincatalog.cpp @@ -22,6 +22,7 @@ #include "stdbool.h" #include "settingviewmgr.h" #include "utils.h" +#include #include "view_maincatalog.h" #include "data_wrapper.h" #include "settings_provider.h" @@ -45,6 +46,11 @@ #define ENABLED "enabled" #define SIG_CLICKED "clicked" +enum KeyID { + MAIN_ITEM_BTNS, + SUB_ITEM_BTNS +}; + enum focused_state { FOCUS_MAIN_ITEM = 1, FOCUS_SUB_ITEM @@ -79,98 +85,16 @@ struct SMainCatalog { * * @return: void. */ -static void _move_from_subitem_to_main_item(SMainCatalog *data, - Evas_Object *btn) +void CMainCatalogView::m_MoveFromSubitemToMainitem(Evas_Object *btn) { - if (!data || !btn) - return; + if(!btn) return; + m->focus_status = FOCUS_MAIN_ITEM; + m->focused_sub_item_btn = btn; - data->focus_status = FOCUS_MAIN_ITEM; - data->focused_sub_item_btn = btn; - - elm_object_focus_set(data->focused_main_item_btn, EINA_TRUE); + elm_object_focus_set(m->focused_main_item_btn, EINA_TRUE); } -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas canvas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _subitem_key_pressed_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) -{ - Evas_Event_Key_Down *ev; - SMainCatalog *priv; - Evas_Object *pb; - Evas_Object *next; - - if (!data || !ei || !obj) - return; - - ev = (Evas_Event_Key_Down *) ei; - if (!ev->keyname) - return; - - priv = (SMainCatalog *)data; - - if (!strcmp(ev->keyname, KEY_LEFT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { - pb = (Evas_Object *) evas_object_data_get(obj, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); - - _move_from_subitem_to_main_item(priv, obj); - } else if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) { - pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); - - next = elm_object_focus_next_object_get(obj, - ELM_FOCUS_DOWN); - if (!next) { - _ERR("focus next object get failed."); - return; - } - - pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG); - } else if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) { - pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); - - next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP); - if (!next) { - _ERR("focus next object get failed."); - return; - } - - pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG); - } else if (!strncmp(ev->keyname, KEY_EXIT, strlen(ev->keyname))) { - app_efl_exit(); - } -} -/** -* Get geometry data of object such as width, height. -* -* @param[in]: obj : the object which you want to get geometry data from. -* @param[out]: param : the geometry data. -* -* @return: void. -*/ static void _get_geometry_data(Evas_Object *obj, struct obj_geometry_data *param) { @@ -191,501 +115,127 @@ static void _get_geometry_data(Evas_Object *obj, param->height = h; } -/** -* Entry of showing UI gadget views. -* -* param[in]: data : the user data. -* param[in]: item : item data. -* param[in]: obj : object whose next view is UI gadget. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_ug_view(SMainCatalog *data, - struct settingitem *item, Evas_Object *obj) -{ - const char *id; - struct evas_obj_data param; - - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - param.subitem_box = data->subitem_box; - param.display_name = settingitem_get_display_name(item); - param.cur_btn = obj; - - if (!data->mgr->ViewPush(id, (void *)¶m)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing sublist views. -* -* param[in]: data : the user data. -* param[in]: item : item data. -* param[in]: obj : object whose next view is sublist. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_sublist_view(SMainCatalog *data, - struct settingitem *item, Evas_Object *obj) -{ - const char *id; - struct obj_geometry_data ogd; - - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - _get_geometry_data(obj, &ogd); - - if (!data->mgr->ViewPush(id, (void *)&ogd)) { - _ERR("Fail to push view"); - return -1; - } - - elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, - SUBITEMBTN_BUTTON_SOURCE); - - return 0; -} - -/** -* Entry of showing bottom sublist views. -* -* param[in]: data : the user data. -* param[in]: item : item data. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_bottom_sublist_view(SMainCatalog *data, - struct settingitem *item) -{ - const char *id; - - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - if (!data->mgr->ViewPush(id, NULL)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing bottom slider views. -* -* param[in]: data : the user data. -* param[in]: item : item data. -* param[in]: obj : object whose next view bottom slider. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_bottom_slider_view(SMainCatalog *data, - struct settingitem *item, Evas_Object *obj) -{ - const char *id; - Eina_List *list; - Evas_Object *pb; - - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); - if (pb) - elm_object_signal_emit(pb, - SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); - - list = settingitem_get_slider_group_list( - viewdata_get_parentitem(data->subsetting_view), - data->mgr->GetData(), id); - - if (!data->mgr->ViewPush(id, list)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing passcode popup views. -* -* param[in]: data : the user data. -* param[in]: item : item data. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_passcode_popup_view(SMainCatalog *data, - struct settingitem *item) -{ - const char *id; - - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - if (!data->mgr->ViewPush(id, NULL)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing device manager view. -* -* param[in]: data : the user data. -* param[in]: item : item data read from json file. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_device_manager_view(SMainCatalog *data, - struct settingitem *item) -{ - const char *id; - struct evas_obj_data param; - - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } - - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - param.display_name = settingitem_get_display_name(item); - param.subitem_box = data->subitem_box; - - if (!data->mgr->ViewPush(id, ¶m)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing reset popup view. -* -* param[in]: data : the user data. -* param[in]: item : item data read from json file. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_reset_popup_view(SMainCatalog *data, - struct settingitem *item) -{ - const char *id; - - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } - - if (!data->mgr->ViewPush(id, NULL)) { - _ERR("Fail to push view"); - return -1; - } - - return 0; -} - -/** -* Entry of showing software upgrade popup view. -* -* param[in]: data : the user data. -* param[in]: item : item data read from json file. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_upgrade_popup_view(SMainCatalog *data, - struct settingitem *item) +void CMainCatalogView::m_SubItemClicked(Evas_Object *obj) { - const char *id; + const char *style; + struct settingitem *item; - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } + if (m->focus_status != FOCUS_SUB_ITEM) + return; - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; + item =(struct settingitem *) evas_object_data_get(obj, SUBITEM_DATA_ID); + if (!item) { + _ERR("Get sub item failed"); + return; } - if (!data->mgr->ViewPush(id, NULL)) { - _ERR("Fail to push view"); - return -1; + style = settingitem_get_settingui_style(item); + if (!style) { + _ERR("setting-ui style is null."); + return; } - return 0; -} - -/** -* Entry of showing clock sublist view. -* -* param[in]: data : the user data. -* param[in]: item : item data read from json file. -* param[in]: obj : object whose next view is clock sublist view. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_clock_sublist_view(SMainCatalog *data, - struct settingitem *item, Evas_Object *obj) -{ const char *id; - struct evas_obj_data param; - struct obj_geometry_data ogd; - - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } - id = settingitem_get_id(item); if (!id) { _ERR("Fail to get item id"); - return -1; + return ; } - _get_geometry_data(obj, &ogd); + if (!strncmp(style, STYLE_UIGADGET, strlen(style))) { - param.display_name = settingitem_get_display_name(item); - param.subitem_box = data->subitem_box; - param.cur_btn = obj; + struct evas_obj_data param; + param.subitem_box = m->subitem_box; + param.display_name = settingitem_get_display_name(item); + param.cur_btn = obj; - evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd); + if (!m->mgr->ViewPush(id, (void *)¶m)) + _ERR("Fail to push ug view"); - if (!data->mgr->ViewPush(id, ¶m)) { - _ERR("Fail to push view"); - return -1; - } + } else if (!strncmp(style, STYLE_CTXPOPUP, strlen(style))) { - elm_object_signal_emit(obj, - SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); + struct obj_geometry_data ogd; + _get_geometry_data(obj, &ogd); - return 0; -} -/** -* Entry of showing channel lock view. -* -* param[in]: data : the user data. -* param[in]: item : item data read from json file. -* param[in]: obj : the channel lock object. -* -* @return: 0 - success, -1 - fail. -*/ -static int _push_need_passcode_view(SMainCatalog *data, - struct settingitem *item, Evas_Object *obj) -{ - const char *id; - struct obj_geometry_data ogd; - - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } + if (!m->mgr->ViewPush(id, (void *)&ogd)) + _ERR("Fail to push sublist"); + else + elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } + } else if (!strncmp(style, STYLE_BOTTOM_CTXPOPUP, strlen(style))) { - _get_geometry_data(obj, &ogd); + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push view"); - if (!data->mgr->ViewPush(id, &ogd)) { - _ERR("Fail to push view"); - return -1; - } + } else if (!strncmp(style, STYLE_BOTTOMSLIDER, strlen(style)) || !strncmp(style, STYLE_BOTTOM2WAYSLIDER, strlen(style))) { - elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, - SUBITEMBTN_BUTTON_SOURCE); + Eina_List *list; + Evas_Object *pb; + pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); + list = settingitem_get_slider_group_list(viewdata_get_parentitem(m->subsetting_view), m->mgr->GetData(), id); + if (!m->mgr->ViewPush(id, list)) + _ERR("Fail to push bottom slider view"); - return 0; -} + } else if (!strncmp(style, STYLE_PASSCODE_POPUP, strlen(style))) { -/** -* This function will be invoked when subitem is clicked. -* -* @param[in]: data : the user data. -* @param[in]: obj : the subitem object. -* -* @return: void. -*/ -static void _submenu_item_clicked(void *data, Evas_Object *obj) -{ - SMainCatalog *priv; - const char *style; - struct settingitem *item; + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push passcode view"); - if (!data || !obj) { - _ERR("Invalid argument"); - return; - } + } else if (!strncmp(style, STYLE_DEVICE_MANAGER, strlen(style))) { - priv = (SMainCatalog *) data; + struct evas_obj_data param; + param.display_name = settingitem_get_display_name(item); + param.subitem_box = m->subitem_box; - if (priv->focus_status != FOCUS_SUB_ITEM) - return; + if (!m->mgr->ViewPush(id, ¶m)) + _ERR("Fail to push device_manager view"); - item =(struct settingitem *) evas_object_data_get(obj, SUBITEM_DATA_ID); - if (!item) { - _ERR("Get sub item failed"); - return; - } + } else if (!strncmp(style, STYLE_RESET_POPUP, strlen(style))) { - style = settingitem_get_settingui_style(item); - if (!style) { - _ERR("setting-ui style is null."); - return; - } + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push reset_popup view"); - if (!strncmp(style, STYLE_UIGADGET, strlen(style))) { - if (_push_ug_view(priv, item, obj) != 0) - _ERR("Fail to push ug"); - } else if (!strncmp(style, STYLE_CTXPOPUP, - strlen(style))) { - if (_push_sublist_view(priv, item, obj) != 0) - _ERR("Fail to push sublist"); - } else if (!strncmp(style, STYLE_BOTTOM_CTXPOPUP, - strlen(style))) { - if (_push_bottom_sublist_view(priv, item) != 0) - _ERR("Fail to push bottom sublist"); - } else if (!strncmp(style, STYLE_BOTTOMSLIDER, - strlen(style)) || !strncmp(style, - STYLE_BOTTOM2WAYSLIDER, - strlen(style))) { - if (_push_bottom_slider_view(priv, - item, obj) != 0) - _ERR("Fail to push bottom slider"); - } else if (!strncmp(style, STYLE_PASSCODE_POPUP, - strlen(style))) { - if (_push_passcode_popup_view(priv, item) != 0) - _ERR("Fail to push passcode popup"); - } else if (!strncmp(style, STYLE_DEVICE_MANAGER, - strlen(style))) { - if (_push_device_manager_view(priv, item) != 0) - _ERR("Fail to push device mgr view"); - } else if (!strncmp(style, STYLE_RESET_POPUP, - strlen(style))) { - if (_push_reset_popup_view(priv, item) != 0) - _ERR("Fail to push reset popup"); - } else if (!strncmp(style, STYLE_UPGRADE_POPUP, - strlen(style))) { - if (_push_upgrade_popup_view(priv, item) != 0) - _ERR("Fail to push upgrade popup"); - } else if (!strncmp(style, STYLE_CLOCK_CTXPOPUP, - strlen(style))) { - if (_push_clock_sublist_view( - priv, item, obj) != 0) - _ERR("Fail to push clock sublist"); - } else if (!strncmp(style, STYLE_NEED_PASSCODE, - strlen(style))) { - if (_push_need_passcode_view( - priv, item, obj) != 0) - _ERR("Fail to push need passcode view"); - } + } else if (!strncmp(style, STYLE_UPGRADE_POPUP, strlen(style))) { - priv->focused_sub_item_btn = obj; -} + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push reset_popup view"); -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: data : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _subitem_btn_clicked_cb(void *data, - Evas_Object *obj, void *ev) -{ - SMainCatalog *priv; - Evas_Object *icon; + } else if (!strncmp(style, STYLE_CLOCK_CTXPOPUP, strlen(style))) { - if (!data || !obj) { - _ERR("Invalid argument"); - return; - } + struct evas_obj_data param; + struct obj_geometry_data ogd; - priv = (SMainCatalog *)data; + _get_geometry_data(obj, &ogd); - _submenu_item_clicked(priv, obj); + param.display_name = settingitem_get_display_name(item); + param.subitem_box = m->subitem_box; + param.cur_btn = obj; - elm_object_signal_emit(priv->focused_main_item_btn, - MAINICONBTN_FOCUSED_ON_SUBITEM, - MAINICONBTN_MAIN_ITEM_SOURCE); + evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd); - icon = elm_object_part_content_get(priv->focused_main_item_btn, - MAINICONBTN_ICON_SWALLOW); - if (icon) - elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN); + if (!m->mgr->ViewPush(id, ¶m)) + _ERR("Fail to push view"); + else + elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); + + } else if (!strncmp(style, STYLE_NEED_PASSCODE, strlen(style))) { + + struct obj_geometry_data ogd; + _get_geometry_data(obj, &ogd); + + if (!m->mgr->ViewPush(id, &ogd)) + _ERR("Fail to push view"); + else + elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); + + } + + m->focused_sub_item_btn = obj; } -/** -* Get item value from item. -* -* @param[in]: item : the item data read from json file. -* -* @return: the value of item or null if error occurred. -*/ static char *_settingitems_get_value(struct settingitem *item) { char *result; @@ -999,34 +549,7 @@ static int _refresh_subitems(SMainCatalog *data) return 0; } -/** -* Evas_Object_Event_Cb type callback for handling mouse out event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse out event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _subitem_btn_mouse_out_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operations if needed. */ -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse in event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse in event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _subitem_btn_mouse_in_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) +static void _subitem_btn_mouse_in_cb(void *data, Evas *e, Evas_Object *obj, void *ei) { SMainCatalog *priv; Evas_Object *icon, *pb; @@ -1072,28 +595,28 @@ static void _subitem_btn_mouse_in_cb(void *data, Evas *e, * * @return: 0 - success, -1 - fail. */ -static int _draw_subitems(SMainCatalog *data, const char *name) +bool CMainCatalogView::m_DrawSubItems(const char *name) { - Evas_Object *box, *btn, *tmp; struct settingview_data *view; - struct settingitem *item; - void* obj; Eina_List *list, *l; - int cnt; + void* obj; + + Evas_Object *btn, *tmp; + struct settingitem *item; Eina_Array_Iterator a; unsigned int i; const char *style, *status; Eina_Array *enabled; - if (!data || !name || !data->base) { + if (!name) { _ERR("Invalid argument"); - return -1; + return false; } - view = data->mgr->GetView(name); + view = m->mgr->GetView(name); if (!view) { - _ERR("get subview failed\n"); - return -1; + _ERR("get subview failed"); + return false; } list = viewdata_get_childitems_list(view); @@ -1101,15 +624,15 @@ static int _draw_subitems(SMainCatalog *data, const char *name) _ERR("childitem list is empty!"); if (view) viewdata_release(view); - return -1; + return false; } - cnt = eina_list_count(list); + m->sub_item_count = eina_list_count(list); - data->sub_item_btn = eina_array_new(1); + m->sub_item_btn = eina_array_new(1); enabled = eina_array_new(1); - if (!data->sub_item_btn || !enabled) { - _ERR("Create Eina Array failed\n"); + if (!m->sub_item_btn || !enabled) { + _ERR("Create Eina Array failed"); EINA_LIST_FREE(list, obj); { item = (struct settingitem *) obj; @@ -1117,61 +640,56 @@ static int _draw_subitems(SMainCatalog *data, const char *name) } if (view) viewdata_release(view); - return -1; + return false; } - box = utils_add_box(data->base); - if (!box) { - _ERR("Add box failed\n"); + m->subitem_box = utils_add_box(m->base); + if (!m->subitem_box) { + _ERR("Add m->subitem_box failed"); EINA_LIST_FREE(list, obj); { item = (struct settingitem *) obj; free(item); } - eina_array_free(data->sub_item_btn); + eina_array_free(m->sub_item_btn); if (view) viewdata_release(view); - return -1; + return false; } EINA_LIST_FOREACH(list, l, obj) { item = (struct settingitem *) obj; - btn = utils_add_btn(data->base, SUBITEMBTN_STYLE, - settingitem_get_display_name(item), EINA_FALSE); + btn = utils_add_btn(m->base, SUBITEMBTN_STYLE, settingitem_get_display_name(item), EINA_FALSE); if (!btn) { _ERR("Add btn failed"); - evas_object_del(box); + evas_object_del(m->subitem_box); EINA_LIST_FREE(list, obj); { item = (struct settingitem *) obj; free(item); } - EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, obj, a) + EINA_ARRAY_ITER_NEXT(m->sub_item_btn, i, obj, a) { tmp = (Evas_Object *) obj; evas_object_del(tmp); } - eina_array_free(data->sub_item_btn); + eina_array_free(m->sub_item_btn); if (view) viewdata_release(view); - return -1; + return false; } style = settingitem_get_style(item); if (style) - _draw_subitem_with_style(data->base, btn, style, item); + _draw_subitem_with_style(m->base, btn, style, item); - evas_object_smart_callback_add(btn, "clicked", - _subitem_btn_clicked_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - _subitem_key_pressed_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _subitem_btn_mouse_in_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _subitem_btn_mouse_out_cb, data); + Connect(btn, SUB_ITEM_BTNS, TYPE_CLICKED | TYPE_KEY_DOWN); + //evas_object_smart_callback_add(btn, "clicked", _subitem_btn_clicked_cb, data); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _subitem_key_pressed_cb, data); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _subitem_btn_mouse_in_cb, m); - elm_box_pack_end(box, btn); - eina_array_push(data->sub_item_btn, btn); + elm_box_pack_end(m->subitem_box, btn); + eina_array_push(m->sub_item_btn, btn); evas_object_data_set(btn, SUBITEM_DATA_ID, item); @@ -1184,12 +702,9 @@ static int _draw_subitems(SMainCatalog *data, const char *name) } } - data->subsetting_view = view; - data->sub_item_count = cnt; - data->subitem_box = box; - - elm_object_part_content_set(data->base, MAIN_VIEW_SUBITEM_SWALLOW, box); + m->subsetting_view = view; + elm_object_part_content_set(m->base, MAIN_VIEW_SUBITEM_SWALLOW, m->subitem_box); utils_set_focus_directions(enabled, eina_array_count(enabled)); EINA_LIST_FREE(list, obj); @@ -1199,33 +714,24 @@ static int _draw_subitems(SMainCatalog *data, const char *name) } eina_array_free(enabled); - return 0; + return true; } -/** -* This function will be invoked when the main item is clicked. -* -* @param[in]: data : the user data. -* @param[in]: mainbtn : the main item which the clicked event is occurred. -* -* @return: void. -*/ -static void _move_from_main_item_to_subitem(SMainCatalog *data, - Evas_Object *mainbtn) +void CMainCatalogView::m_MoveFromMainitemToSubitem(Evas_Object *mainbtn) { Evas_Object *btn = NULL, *pb, *icon; int i; - if (!data || !mainbtn) + if (!mainbtn) return; - data->focus_status = FOCUS_SUB_ITEM; + m->focus_status = FOCUS_SUB_ITEM; - for (i = 0; i < data->sub_item_count; i++) { - btn = (Evas_Object *) eina_array_data_get(data->sub_item_btn, i); + for (i = 0; i < m->sub_item_count; i++) { + btn = (Evas_Object *) eina_array_data_get(m->sub_item_btn, i); if (!btn) { - _ERR("Get subitem btn failed\n"); - data->focus_status = FOCUS_MAIN_ITEM; + _ERR("Get subitem btn failed"); + m->focus_status = FOCUS_MAIN_ITEM; return; } @@ -1233,8 +739,8 @@ static void _move_from_main_item_to_subitem(SMainCatalog *data, break; } - if (i >= data->sub_item_count) { - data->focus_status = FOCUS_MAIN_ITEM; + if (i >= m->sub_item_count) { + m->focus_status = FOCUS_MAIN_ITEM; return; } @@ -1244,147 +750,37 @@ static void _move_from_main_item_to_subitem(SMainCatalog *data, elm_object_focus_set(btn, EINA_TRUE); - data->focused_main_item_btn = mainbtn; - elm_object_signal_emit(mainbtn, MAINICONBTN_FOCUSED_ON_SUBITEM, - MAINICONBTN_MAIN_ITEM_SOURCE); + m->focused_main_item_btn = mainbtn; + elm_object_signal_emit(mainbtn, MAINICONBTN_FOCUSED_ON_SUBITEM, MAINICONBTN_MAIN_ITEM_SOURCE); icon = elm_object_part_content_get(mainbtn, MAINICONBTN_ICON_SWALLOW); if (icon) elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN); } -/** -* Evas_Object_Event_Cb type callback for handling key press event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the key press event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _main_setting_key_pressed_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) +void CMainCatalogView::sm_CbMainItemBtnMouseIN(void *data, Evas *e, Evas_Object *obj, void *ei) { - Evas_Event_Key_Down *ev; - SMainCatalog *priv; - Evas_Object *next, *icon; - const char *name; - - if (!data || !ei || !obj) - return; - - ev = (Evas_Event_Key_Down *)ei; - if (!ev->keyname) - return; - - priv = (SMainCatalog *)data; - - if (!strcmp(ev->keyname, KEY_DOWN)) { - icon = elm_object_part_content_get(obj, - MAINICONBTN_ICON_SWALLOW); - if (!icon) { - _ERR("part %s content get failed.", - MAINICONBTN_ICON_SWALLOW); - return; - } - - elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN); - - next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN); - if (!next) { - _ERR("next object get failed."); - return; - } - - priv->focused_main_item_btn = next; - - icon = elm_object_part_content_get(next, - MAINICONBTN_ICON_SWALLOW); - if (!icon) { - _ERR("part %s content get failed.", - MAINICONBTN_ICON_SWALLOW); - return; - } - - elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); - - _release_subitems(priv); - - name =(const char *) evas_object_data_get(next, SETTING_ID); - if (name) - _draw_subitems(priv, name); - } else if (!strcmp(ev->keyname, KEY_UP)) { - icon = elm_object_part_content_get(obj, - MAINICONBTN_ICON_SWALLOW); - if (!icon) { - _ERR("part %s content get failed.", - MAINICONBTN_ICON_SWALLOW); - return; - } - - elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN); - - next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP); - if (!next) { - _ERR("next object get failed."); - return; - } - - priv->focused_main_item_btn = next; - - icon = elm_object_part_content_get(next, - MAINICONBTN_ICON_SWALLOW); - if (!icon) { - _ERR("part %s content get failed.", - MAINICONBTN_ICON_SWALLOW); - return; - } - - elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); + CMainCatalogView *instance; - _release_subitems(priv); - - name =(const char *) evas_object_data_get(next, SETTING_ID); - if (name) - _draw_subitems(priv, name); - } else if (!strcmp(ev->keyname, KEY_RIGHT)) { - _move_from_main_item_to_subitem(priv, obj); - } else if (!strcmp(ev->keyname, KEY_EXIT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { - app_efl_exit(); - } + if(!data){_ERR("Invaild Parameter"); return;} + instance = (CMainCatalogView *)data; + instance->m_OnMainItemMouseIN(e, obj, ei); } -/** -* Evas_Object_Event_Cb type callback for handling mouse in event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse in event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _mainitem_btn_mouse_in_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) +void CMainCatalogView::m_OnMainItemMouseIN(Evas *e, Evas_Object *obj, void *ei) { - SMainCatalog *priv; const char *name; Evas_Object *icon; - if (!data || !obj) { + if (!obj) { _ERR("Invalid argument"); return; } - priv = (SMainCatalog *)data; - - if (priv->focus_status == FOCUS_SUB_ITEM) - _move_from_subitem_to_main_item(priv, - priv->focused_sub_item_btn); + if (m->focus_status == FOCUS_SUB_ITEM) + m_MoveFromSubitemToMainitem(m->focused_sub_item_btn); - icon = elm_object_part_content_get(priv->focused_main_item_btn, - MAINICONBTN_ICON_SWALLOW); + icon = elm_object_part_content_get(m->focused_main_item_btn, MAINICONBTN_ICON_SWALLOW); if (icon) elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN); @@ -1392,101 +788,48 @@ static void _mainitem_btn_mouse_in_cb(void *data, Evas *e, if (icon) elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); - _release_subitems(priv); + _release_subitems(m); name =(const char *) evas_object_data_get(obj, SETTING_ID); if (name) - _draw_subitems(priv, name); + m_DrawSubItems(name); elm_object_focus_set(obj, EINA_TRUE); - priv->focused_main_item_btn = obj; -} - -/** -* Evas_Object_Event_Cb type callback for handling mouse out event. -* -* @param[in]: data : the user data. -* @param[in]: e : the evas. -* @param[in]: obj : the corresponding object which the mouse out event occurred. -* @param[in]: ei : event info. -* -* @return: void. -*/ -static void _mainitem_btn_mouse_out_cb(void *data, Evas *e, - Evas_Object *obj, void *ei) -{ - /* TODO: Add necessary operations if needed. */ + m->focused_main_item_btn = obj; } -/** -* Evas_Smart_Cb type callback for handling click event. -* -* @param[in]: data : the user data. -* @param[in]: obj : the corresponding object which the click event occurred. -* @param[in]: ev : event info. -* -* @return: void. -*/ -static void _mainitem_btn_clicked_cb(void *data, - Evas_Object *obj, void *ev) -{ - SMainCatalog *priv; - - if (!data || !obj) { - _ERR("Invalid argument"); - return; - } - - priv = (SMainCatalog *)data; - _move_from_main_item_to_subitem(priv, obj); -} -/** -* Create main items of settings. -* -* @param[in]: data : the user data. -* @param[in]: list : the eina list containing data of main items. -* -* @return: 0 - success, -1 - fail. -*/ -static int _add_icon_btns(SMainCatalog *data, Eina_List *list) +bool CMainCatalogView::m_AddIconBtns(Eina_List *list) { Evas_Object *btn, *icon; const char *id, *name; struct settingitem *item; char buf[BUF_SIZE]; - int i; - if (!data || !list || !data->base) { + if (!list) { _ERR("Invalid argument"); - return -1; + return false; } - for (i = 0; i < data->main_item_count; i++) { - btn = utils_add_btn(data->base, MAINICONBTN_STYLE, - NULL, EINA_FALSE); + for (int i = 0; i < m->main_item_count; i++) { + btn = utils_add_btn(m->base, MAINICONBTN_STYLE, NULL, EINA_FALSE); if (!btn) { - _ERR("Add btn failed\n"); - return -1; + _ERR("Add btn failed"); + return false; } item = (struct settingitem *) eina_list_nth(list, i); if (item) { name = settingitem_get_display_name(item); - elm_object_text_set(btn, - utils_get_translation_str(name)); + elm_object_text_set(btn, utils_get_translation_str(name)); } else { elm_object_text_set(btn, ICON_BUTTON_NO_DISP_NAME); } - evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, - _main_setting_key_pressed_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, - _mainitem_btn_mouse_in_cb, data); - evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, - _mainitem_btn_mouse_out_cb, data); - evas_object_smart_callback_add(btn, SIG_CLICKED, - _mainitem_btn_clicked_cb, data); + Connect(btn, MAIN_ITEM_BTNS, TYPE_CLICKED | TYPE_KEY_DOWN); + evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, sm_CbMainItemBtnMouseIN, this); + //evas_object_smart_callback_add(btn, SIG_CLICKED, _mainitem_btn_clicked_cb, data); + //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _main_setting_key_pressed_cb, data); icon = elm_layout_add(btn); if (icon) { @@ -1494,24 +837,22 @@ static int _add_icon_btns(SMainCatalog *data, Eina_List *list) if (!id) { _ERR("get item name failed."); evas_object_del(btn); - return -1; + return false; } - snprintf(buf, sizeof(buf), "%s/%s.edj", - EDJEDIR, PACKAGE); + snprintf(buf, sizeof(buf), "%s/%s.edj", EDJEDIR, PACKAGE); elm_layout_file_set(icon, buf, id); - elm_object_part_content_set(btn, - MAINICONBTN_ICON_SWALLOW, icon); + elm_object_part_content_set(btn, MAINICONBTN_ICON_SWALLOW, icon); elm_object_signal_emit(icon, MAIN_BTN_NORMAL, MAIN_BTN); - eina_array_push(data->main_icon_base, icon); + eina_array_push(m->main_icon_base, icon); } - elm_box_pack_end(data->mainitem_box, btn); + elm_box_pack_end(m->mainitem_box, btn); evas_object_data_set(btn, SETTING_ID, settingitem_get_id(item)); - eina_array_push(data->main_item_btn, btn); + eina_array_push(m->main_item_btn, btn); } - return 0; + return true; } /** @@ -1537,14 +878,14 @@ void CMainCatalogView::m_DrawMainItems(void) _CHECK(m->main_item_count) _CHECK(m->main_item_btn = eina_array_new(1)) _CHECK(m->main_icon_base = eina_array_new(1)) - _CHECK(_add_icon_btns(m, list) != -1) + _CHECK(m_AddIconBtns(list)) _COMMAND { elm_object_part_content_set(m->base, MAIN_VIEW_ICON_SWALLOW, m->mainitem_box); if (!m->item_path) { btn = (Evas_Object *)eina_array_data_get(m->main_item_btn, 0); if (btn) { - if (_draw_subitems(m, (const char *) evas_object_data_get(btn, SETTING_ID)) != -1) { + if (m_DrawSubItems((const char *) evas_object_data_get(btn, SETTING_ID))) { icon = (Evas_Object *)eina_array_data_get(m->main_icon_base, 0); if (icon) { elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); @@ -1786,7 +1127,7 @@ void CMainCatalogView::Show(void) return; if (!strncmp(name, path, ARRAY_SIZE)) { - _draw_subitems(m, name); + m_DrawSubItems(name); icon = (Evas_Object *)eina_array_data_get( m->main_icon_base, i); @@ -1998,6 +1339,187 @@ void CMainCatalogView::Active(void) } +void CMainCatalogView::OnMouseClicked(int id, Evas_Object *obj) +{ + _DBG(); + if (!obj) { + _ERR("Invalid argument"); + return; + } + + switch(id) { + case MAIN_ITEM_BTNS: + m_MoveFromMainitemToSubitem(obj); + break; + case SUB_ITEM_BTNS: + { + Evas_Object *icon; + m_SubItemClicked(obj); + + elm_object_signal_emit(m->focused_main_item_btn, MAINICONBTN_FOCUSED_ON_SUBITEM, MAINICONBTN_MAIN_ITEM_SOURCE); + + icon = elm_object_part_content_get(m->focused_main_item_btn, MAINICONBTN_ICON_SWALLOW); + if (icon) + elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN); + } + break; + default: + break; + } +} + + +void CMainCatalogView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + switch(id) { + case MAIN_ITEM_BTNS: + { + Evas_Object *next, *icon; + const char *name; + + if (!strcmp(ev->keyname, KEY_UP)) { + icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW); + if (!icon) { + _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW); + return; + } + + elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN); + + next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP); + if (!next) { + _ERR("next object get failed."); + return; + } + + m->focused_main_item_btn = next; + + icon = elm_object_part_content_get(next, MAINICONBTN_ICON_SWALLOW); + if (!icon) { + _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW); + return; + } + + elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); + + _release_subitems(m); + + name =(const char *) evas_object_data_get(next, SETTING_ID); + if (name) + m_DrawSubItems(name); + } + } + break; + default: + break; + } +} + + +void CMainCatalogView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) +{ + if (!ev->keyname) { + _ERR("ev->keyname is NULL."); + return; + } + + switch(id) { + case MAIN_ITEM_BTNS: + { + Evas_Object *next, *icon; + const char *name; + + if (!strcmp(ev->keyname, KEY_DOWN)) { + icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW); + if (!icon) { + _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW); + return; + } + + elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN); + + next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN); + if (!next) { + _ERR("next object get failed."); + return; + } + + m->focused_main_item_btn = next; + + icon = elm_object_part_content_get(next, MAINICONBTN_ICON_SWALLOW); + if (!icon) { + _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW); + return; + } + + elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN); + + _release_subitems(m); + name =(const char *) evas_object_data_get(next, SETTING_ID); + if (name) + m_DrawSubItems(name); + } else if (!strcmp(ev->keyname, KEY_RIGHT)) { + m_MoveFromMainitemToSubitem(obj); + } else if (!strcmp(ev->keyname, KEY_EXIT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { + app_efl_exit(); + } + } + break; + + case SUB_ITEM_BTNS: + { + Evas_Object *pb; + Evas_Object *next; + + if (!strcmp(ev->keyname, KEY_LEFT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) { + pb = (Evas_Object *) evas_object_data_get(obj, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); + + m_MoveFromSubitemToMainitem(obj); + } else if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) { + pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); + + next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN); + if (!next) { + _ERR("focus next object get failed."); + return; + } + + pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG); + } else if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) { + pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG); + + next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP); + if (!next) { + _ERR("focus next object get failed."); + return; + } + + pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA); + if (pb) + elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG); + } else if (!strncmp(ev->keyname, KEY_EXIT, strlen(ev->keyname))) { + app_efl_exit(); + } + } + break; + default: + break; + } +} + + #if 0 static struct setting_class _vclass = { VCLASS_TITLE_MAIN_VIEW, diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.cpp index 7226f15..9f49e37 100755 --- a/src/view_pwd_popup.cpp +++ b/src/view_pwd_popup.cpp @@ -21,6 +21,7 @@ #include "utils.h" #include "settings_provider.h" #include "settingviewmgr.h" +#include #define PWD_DATA_ID "change_passcode_data" #define CTXPOPUP_WIDTH 688 -- 2.7.4 From 35257b47976c3cac732087068e5d6591a7ba3708 Mon Sep 17 00:00:00 2001 From: Kim Youngjin Date: Tue, 14 Apr 2015 09:14:06 +0900 Subject: [PATCH 13/16] WifiAp module is added. Change-Id: I90ade7e2875582b9cf0b54850064568e757dfa62 Signed-off-by: Kim Youngjin --- src/settingviewmgr.cpp | 21 +- src/view_sublist.cpp | 7 +- ug/include/WifiMgr.h | 86 +++-- ug/network/include/NetworkMainView.h | 9 +- ug/network/include/WifiPasscodeView.h | 4 +- ug/network/include/common.h | 5 +- ug/network/src/IpSettingView.cpp | 20 +- ug/network/src/NetworkMainView.cpp | 108 +++--- ug/network/src/WifiPasscodeView.cpp | 63 ++-- ug/proxy/src/ProxyMainView.cpp | 11 +- ug/src/WifiMgr.cpp | 624 +++++++++++++++------------------- 11 files changed, 430 insertions(+), 528 deletions(-) diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 674f3bf..eff41e7 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -327,20 +327,19 @@ bool CSettingMgr::Initialize(Evas_Object *win) ASSERT(!instance); ASSERT(win); - struct settingmgr_data *data; - CTimeoutHandler *handler; + //struct settingmgr_data *data; + //CTimeoutHandler *handler; _CREATE_BEGIN{ _CHECK(instance = new CSettingMgr); _CHECK(instance->m = new SSettingMgr); - _CHECK(data = viewmgr_data_init()); - _CHECK(handler = new CTimeoutHandler); - _CHECK(handler->Create(TIMEOUT_SECS)); - - - _CHECK_FAIL{ handler->Destroy(); } - _CHECK_FAIL{ delete handler; } - _CHECK_FAIL{ viewmgr_data_fini(data); } + _CHECK(instance->m->data = viewmgr_data_init()); + _CHECK(instance->m->handler = new CTimeoutHandler); + _CHECK(instance->m->handler->Create(TIMEOUT_SECS)); + + _CHECK_FAIL{ instance->m->handler->Destroy(); } + _CHECK_FAIL{ delete instance->m->handler; } + _CHECK_FAIL{ viewmgr_data_fini(instance->m->data); } _CHECK_FAIL{ delete instance->m; } _CHECK_FAIL{ delete instance; instance = NULL; } } _CREATE_END_AND_CATCH{ return false; } @@ -362,8 +361,6 @@ bool CSettingMgr::Initialize(Evas_Object *win) instance->m->win = win; instance->m->depth = 0; - instance->m->data = data; - instance->m->handler = handler; instance->m->is_freeze = EINA_FALSE; instance->m->view_list = NULL; instance->m->item_path = NULL; diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index 1f5b6f2..25dfb3c 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -410,9 +410,10 @@ bool CSublistView::m_DrawSublist(void) { _DBG(); Eina_List *list; - double ratio, w; - int cnt, x, y, height, screen_h; - struct obj_geometry_data *param; + //double ratio, w; + int cnt; + //int x, y, height, screen_h; + //struct obj_geometry_data *param; if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); diff --git a/ug/include/WifiMgr.h b/ug/include/WifiMgr.h index 3a1fa1d..ceaea96 100644 --- a/ug/include/WifiMgr.h +++ b/ug/include/WifiMgr.h @@ -4,6 +4,57 @@ #include "UgCommon.h" #include "wifi.h" + +class CWifiAp { + friend class CWifiMgr; +private: + wifi_ap_h m_handle; + +private: + bool m_CheckErr(const char *func, int ret); + +protected: + void t_SetHandle(wifi_ap_h handle); + +public: + CWifiAp(wifi_ap_h handle); + virtual ~CWifiAp(); + + wifi_ap_h Handle(void); + + bool AllocConnectedAp(void); + void Destroy(void); + + bool GetEssid(char *essid, int size); + bool GetConnectionState(wifi_connection_state_e *state); + bool GetSecurityType(wifi_security_type_e *type); + bool SetPassPhrase(const char *passcode); + + bool Connect(void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data); + bool SetIpType(wifi_ip_config_type_e type); + + bool GetIp(char *ip, int size); + bool GetSubnetMask(char *submask); + bool GetGateway(char *gateway); + bool GetDNS(char *dns); + + bool SetIp(char *ip); + bool SetSubnetMask(char *submask); + bool SetGateway(char *gateway); + bool SetDNS(char *dns); + + bool CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin); + + static bool ForgetAP(void); + + bool SetProxyType(EProxyMethod pm); + bool GetProxyType(EProxyMethod *pm); + + bool SetProxyAddr(const char *addr); + bool GetProxyAddr(char **addr); +}; + + class CWifiMgr { private: static CWifiMgr *instance; @@ -18,40 +69,15 @@ public: static void Finalize(void); static CWifiMgr * GetInstance(void); - bool Activate(void(*ActivatedCb)(wifi_error_e err, void *data), void *data); + bool Activate(void(*cbActivated)(wifi_error_e err, void *data), void *data); bool IsActivated(bool *activated); - bool GetConnectedAP(wifi_ap_h *ap); - - bool DestroyAP(wifi_ap_h ap); - bool CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin); - bool RegisterScanCallback(void(*ScanFinishedCb)(wifi_error_e err, void *data), void *data); - bool RegisterFoundAPCallback(bool(*FoundCb)(wifi_ap_h ap, void *data), void *data); + bool Scan(void (*cbFinish)(wifi_error_e err, void *data), void *data); + bool FoundAps(bool(*FoundCb)(CWifiAp *ap, void *data), void *data); - bool SetProxyType(EProxyMethod pm); - bool GetProxyType(EProxyMethod *pm); - bool SetProxyAddr(const char *ip); - bool GetProxyAddr(char **ip); - bool GetESSID(wifi_ap_h ap, char *essid); - bool GetConnectionState(wifi_ap_h ap, wifi_connection_state_e *state); - bool GetSecurityType(wifi_ap_h ap, wifi_security_type_e *type); - bool ForgetAP(void); - bool SetPassPhrase(wifi_ap_h ap, const char *passcode); - - bool Connect(wifi_ap_h ap, void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data); - bool SetIpType(wifi_ap_h ap, wifi_ip_config_type_e type); - - bool GetIp(wifi_ap_h ap, char *ip); - bool GetSubnetMask(wifi_ap_h ap, char *submask); - bool GetGateway(wifi_ap_h ap, char *gateway); - bool GetDNS(wifi_ap_h ap, char *dns); - - bool SetIp(wifi_ap_h ap, char *ip); - bool SetSubnetMask(wifi_ap_h ap, char *submask); - bool SetGateway(wifi_ap_h ap, char *gateway); - bool SetDNS(wifi_ap_h ap, char *dns); - const char * GetErrorMsg(wifi_error_e err); + static const char * ErrorMsg(wifi_error_e err); }; + #endif /* __WIFIMGR_H__ */ diff --git a/ug/network/include/NetworkMainView.h b/ug/network/include/NetworkMainView.h index 6b3a01e..961c900 100644 --- a/ug/network/include/NetworkMainView.h +++ b/ug/network/include/NetworkMainView.h @@ -17,6 +17,9 @@ #ifndef __NETWORK_MAIN_VIEW_H__ #define __NETWORK_MAIN_VIEW_H__ + +#include "WifiMgr.h" + class CNetworkMainView : public CBaseView { private : struct SNetworkMainView *m; @@ -24,11 +27,11 @@ private : static void sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *ei); static Eina_Bool sm_CbSelectConnected(void *data); - static bool sm_CbWifiFoundAP(wifi_ap_h ap, void *data); - void m_OnWifiFoundAP(wifi_ap_h ap); + static bool sm_CbWifiFoundAP(CWifiAp *ap, void *data); + bool m_OnWifiFoundAP(CWifiAp *ap); static void sm_CbWifiScanRequest(wifi_error_e err, void *data); - void m_OnWifiScanRequest(wifi_error_e err, void *data); + void m_OnWifiScanRequest(wifi_error_e err); static void sm_CbConnectionOnlineAsync(bool state, void *data); void m_OnConnectionOnlineAync(bool state); diff --git a/ug/network/include/WifiPasscodeView.h b/ug/network/include/WifiPasscodeView.h index b3746f2..9bc399b 100644 --- a/ug/network/include/WifiPasscodeView.h +++ b/ug/network/include/WifiPasscodeView.h @@ -8,8 +8,8 @@ private : static void sm_CbWifiConnected(wifi_error_e err, void *data); void m_OnWifiConnected(wifi_error_e err); - static bool sm_CbWifiFoundAP(wifi_ap_h ap, void *data); - void m_OnWifiFoundAP(wifi_ap_h ap); + static bool sm_CbWifiFoundAP(CWifiAp *ap, void *data); + void m_OnWifiFoundAP(CWifiAp *ap); static void sm_CbWifiScanRequest(wifi_error_e err, void *data); void m_OnWifiScanRequest(wifi_error_e err, void *data); diff --git a/ug/network/include/common.h b/ug/network/include/common.h index e640778..06b9c4c 100644 --- a/ug/network/include/common.h +++ b/ug/network/include/common.h @@ -17,7 +17,10 @@ #ifndef __NETWORK_COMMON_H__ #define __NETWORK_COMMON_H__ + #include +#include "WifiMgr.h" + #define IP_STRING_MAX_SIZE 20 #define MAX_NAME_SIZE 256 @@ -87,7 +90,7 @@ struct wifi_ap_info { wifi_eap_type_e eap_type; wifi_eap_auth_type_e eap_auth_type; - wifi_ap_h ap; + CWifiAp *ap; void *user_data; }; #endif /* __NETWORK_COMMON_H__ */ diff --git a/ug/network/src/IpSettingView.cpp b/ug/network/src/IpSettingView.cpp index da95996..8ad9fa0 100644 --- a/ug/network/src/IpSettingView.cpp +++ b/ug/network/src/IpSettingView.cpp @@ -75,7 +75,7 @@ struct SIpSettingView { enum connection_setting_enum cur_type; enum network_type_enum network_type; - wifi_ap_h ap; + CWifiAp *ap; char profile_name[MAX_NAME_SIZE]; @@ -186,22 +186,22 @@ bool CIpSettingView::m_GetCurIpInfo(void) } } else if (m->network_type == TYPE_WIRELESS) { if (m->ip_mode == MODE_AUTO) { - result = m->pWifiMgr->GetIp(m->ap, m->info.ip_addr); + result = m->ap->GetIp(m->info.ip_addr, sizeof(m->info.ip_addr)); if(result != true) { _ERR("wifi_mgr_get_ip_info() failed."); return false; } - result = m->pWifiMgr->GetSubnetMask(m->ap, m->info.submask); + result = m->ap->GetSubnetMask(m->info.submask); if(result != true) { _ERR("wifi_mgr_get_ip_info() failed."); return false; } - result = m->pWifiMgr->GetGateway(m->ap, m->info.gateway); + result = m->ap->GetGateway(m->info.gateway); if(result != true) { _ERR("wifi_mgr_get_ip_info() failed."); return false; } - result = m->pWifiMgr->GetDNS(m->ap, m->info.dns); + result = m->ap->GetDNS(m->info.dns); if(result != true) { _ERR("wifi_mgr_get_ip_info() failed."); return false; @@ -928,7 +928,7 @@ bool CIpSettingView::m_ConfigNetworkDynamic(void) break; case TYPE_WIRELESS: - result = m->pWifiMgr->SetIpType(m->ap, WIFI_IP_CONFIG_TYPE_DYNAMIC); + result = m->ap->SetIpType(WIFI_IP_CONFIG_TYPE_DYNAMIC); if(result != false) { _ERR("connection_mgr_ip_dynamic_config() failed."); return false; @@ -980,22 +980,22 @@ bool CIpSettingView::m_ConfigNetworkManually(void) vconf_set_str(WIRED_DNS_KEY, m->info.dns); break; case TYPE_WIRELESS: - result = m->pWifiMgr->SetIp(m->ap, m->info.ip_addr); + result = m->ap->SetIp(m->info.ip_addr); if(result != true) { _ERR("set wifi dns config failed."); return false; } - result = m->pWifiMgr->SetSubnetMask(m->ap, m->info.submask); + result = m->ap->SetSubnetMask(m->info.submask); if(result != true) { _ERR("set wifi dns config failed."); return false; } - result = m->pWifiMgr->SetGateway(m->ap, m->info.gateway); + result = m->ap->SetGateway(m->info.gateway); if(result != true) { _ERR("set wifi dns config failed."); return false; } - result = m->pWifiMgr->SetDNS(m->ap, m->info.dns); + result = m->ap->SetDNS(m->info.dns); if(result != true) { _ERR("set wifi dns config failed."); return false; diff --git a/ug/network/src/NetworkMainView.cpp b/ug/network/src/NetworkMainView.cpp index dcbb21d..49edad3 100644 --- a/ug/network/src/NetworkMainView.cpp +++ b/ug/network/src/NetworkMainView.cpp @@ -52,7 +52,7 @@ struct SNetworkMainView { char profile_name[MAX_NAME_SIZE]; - wifi_ap_h ap; + CWifiAp *ap; char *ap_name; char *ap_pwd; @@ -427,11 +427,11 @@ void CNetworkMainView::sm_CbGenlistItemSelected(void *data, Evas_Object *obj, vo } if (priv->ap) { - priv->pWifiMgr->DestroyAP(priv->ap); + delete priv->ap; priv->ap = NULL; } - priv->pWifiMgr->CloneAP(&priv->ap, ap_info->ap); + priv->ap = new CWifiAp(ap_info->ap->Handle()); if (!priv->ap) { _ERR("ap clone failed."); return; @@ -468,25 +468,20 @@ Eina_Bool CNetworkMainView::sm_CbSelectConnected(void *data) } -bool CNetworkMainView::sm_CbWifiFoundAP(wifi_ap_h ap, void *data) +bool CNetworkMainView::sm_CbWifiFoundAP(CWifiAp *ap, void *data) { - _DBG(); - CNetworkMainView *instance = NULL; + CNetworkMainView *root = (CNetworkMainView*)data; + bool ret = false; - if (!data) { - _ERR("data is NULL."); - return true; - } + if (root) + ret = root->m_OnWifiFoundAP(ap); - instance = (CNetworkMainView *) data; - instance->m_OnWifiFoundAP(ap); - return true; + return ret; } -void CNetworkMainView::m_OnWifiFoundAP(wifi_ap_h ap) +bool CNetworkMainView::m_OnWifiFoundAP(CWifiAp *ap) { - _DBG(); bool ret; bool state; struct wifi_ap_info *ap_info; @@ -495,34 +490,31 @@ void CNetworkMainView::m_OnWifiFoundAP(wifi_ap_h ap) ret = m->pWifiMgr->IsActivated(&state); if (ret != true || state == 0) { _ERR("failt to wifi_is_activated"); - return ; + return false; } - ap_info = (struct wifi_ap_info *) calloc(1, sizeof(*ap_info)); + ap_info = new wifi_ap_info; if (!ap_info) { _ERR("calloc failed"); - return ; + return false; } - ret = m->pWifiMgr->GetESSID(ap, ap_info->essid); - if(ret != true) { + if (!ap->GetEssid(ap_info->essid, sizeof(ap_info->essid))) { _ERR("Fail to get info"); - return ; + return false; } - ret = m->pWifiMgr->GetConnectionState(ap, &ap_info->state); - if(ret != true) { + if (!ap->GetConnectionState(&ap_info->state)) { _ERR("Fail to get info"); - return ; + return false; } - ret = m->pWifiMgr->GetSecurityType(ap, &ap_info->secure_type); - if(ret != true) { + if (!ap->GetSecurityType(&ap_info->secure_type)) { _ERR("Fail to get info"); - return ; + return false; } - ap_info->ap = ap; + ap_info->ap = new CWifiAp(ap->Handle()); ap_info->user_data = m; m->ap_list = eina_list_append(m->ap_list, ap_info); @@ -534,47 +526,45 @@ void CNetworkMainView::m_OnWifiFoundAP(wifi_ap_h ap) item = elm_genlist_item_append(m->genlist, m->lock_ic, ap_info, NULL, ELM_GENLIST_ITEM_NONE, sm_CbGenlistItemSelected, m); if (!item) { _ERR("genlist append item failed."); - return ; + return false; } if (ap_info->state == WIFI_CONNECTION_STATE_CONNECTED) { m->last_item = item; if (m->ap) { - ret = m->pWifiMgr->DestroyAP(m->ap); - if(ret != true) { - _ERR("Fail to destroy AP"); - } + delete m->ap; m->ap = NULL; } - ret = m->pWifiMgr->CloneAP(&m->ap, ap); - if(ret != true) { + m->ap = new CWifiAp(ap->Handle()); + if (!m->ap) { _ERR("Fail to clone AP"); } m->timer = ecore_timer_add(TIMER_INTERNAL, sm_CbSelectConnected, m); if (!m->timer) { _ERR("add timer failed."); - return ; + return false; } } + + return false; } void CNetworkMainView::sm_CbWifiScanRequest(wifi_error_e err, void *data) { - _DBG(); - CNetworkMainView *instance = NULL; - instance = (CNetworkMainView *) data; - instance->m_OnWifiScanRequest(err, data); + CNetworkMainView *root = (CNetworkMainView*)data; + if (root) + root->m_OnWifiScanRequest(err); } -void CNetworkMainView::m_OnWifiScanRequest(wifi_error_e err, void *data) +void CNetworkMainView::m_OnWifiScanRequest(wifi_error_e err) { _DBG(); bool ret = false; - ret = m->pWifiMgr->RegisterFoundAPCallback( sm_CbWifiFoundAP, data); + ret = m->pWifiMgr->FoundAps(sm_CbWifiFoundAP, this); if (ret != true) { _ERR("wifi_mgr_foreach_found_aps() failed."); } @@ -645,11 +635,11 @@ void CNetworkMainView::m_OnWifiActivated(wifi_error_e err) bool ret; if (err != WIFI_ERROR_NONE) { - _ERR("Wi-Fi Activation Failed! error == %s", m->pWifiMgr->GetErrorMsg(err)); + _ERR("Wi-Fi Activation Failed! error == %s", CWifiMgr::ErrorMsg(err)); return; } - ret = m->pWifiMgr->RegisterScanCallback(sm_CbWifiScanRequest, this); + ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this); if (ret != true) { _ERR("wifi_mgr_scan_request() failed."); m_FillContentPart(m->wireless_discon_ly); @@ -921,14 +911,11 @@ bool CNetworkMainView::m_SetWireless() if (activated) { if (m->ap) { - ret = m->pWifiMgr->DestroyAP(m->ap); - if(ret != true) { - _ERR("Fail to destroy AP"); - } + delete m->ap; m->ap = NULL; } - ret = m->pWifiMgr->RegisterScanCallback(sm_CbWifiScanRequest, this); + ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this); if (ret != true) { _ERR("wifi_mgr_scan_request() failed."); goto _wireless_finish; @@ -1230,16 +1217,9 @@ void CNetworkMainView::m_ClearGenlist(void) void CNetworkMainView::sm_CbWifiConnected(wifi_error_e err, void *data) { - _DBG(); - CNetworkMainView *instance; - - if (!data) { - _ERR("Parameter error!"); - return; - } - - instance = (CNetworkMainView *) data; - instance->m_OnWifiConnected(err); + CNetworkMainView *root = (CNetworkMainView*)data; + if (root) + root->m_OnWifiConnected(err); } @@ -1332,21 +1312,21 @@ bool CNetworkMainView::m_WifiConnectAP(int index) return true; } - ret = m->pWifiMgr->ForgetAP(); + ret = CWifiAp::ForgetAP(); if (ret != true) { _ERR("forget last ap failed."); return false; } if (m->ap_pwd) { - ret = m->pWifiMgr->SetPassPhrase(m->ap, m->ap_pwd); + m->ap->SetPassPhrase(m->ap_pwd); if (ret != true) { _ERR("wifi_mgr_set_passphrase() failed."); return false; } } - ret = m->pWifiMgr->Connect(m->ap, sm_CbWifiConnected, this); + ret = m->ap->Connect(sm_CbWifiConnected, this); if (ret != true) { _ERR("Fail to connection request."); return false; @@ -1676,8 +1656,8 @@ bool CNetworkMainView::Create(void *data) } if (m->timer) ecore_timer_del(m->timer); - if (m->ap) - m->pWifiMgr->DestroyAP(m->ap); + + delete m->ap; free(m->ap_name); free(m->ap_pwd); diff --git a/ug/network/src/WifiPasscodeView.cpp b/ug/network/src/WifiPasscodeView.cpp index bfeb80f..8a727a7 100644 --- a/ug/network/src/WifiPasscodeView.cpp +++ b/ug/network/src/WifiPasscodeView.cpp @@ -47,15 +47,10 @@ struct SWifiPasscodeView { void CWifiPasscodeView::sm_CbWifiConnected(wifi_error_e err, void *data) { _DBG(); - CWifiPasscodeView *instance; - - if (!data) { - _ERR("Parameter error!"); - return; - } - - instance = (CWifiPasscodeView *) data; - instance->m_OnWifiConnected(err); + CWifiPasscodeView *root = (CWifiPasscodeView *)data; + + if (root) + root->m_OnWifiConnected(err); } @@ -65,7 +60,7 @@ void CWifiPasscodeView::m_OnWifiConnected(wifi_error_e err) return; if (err!= WIFI_ERROR_NONE) { - _ERR("connect AP failed, ret: %s.", m->pWifiMgr->GetErrorMsg(err)); + _ERR("connect AP failed, ret: %s.", CWifiMgr::ErrorMsg(err)); m_ShowConfirmPopup(); return; } @@ -74,57 +69,48 @@ void CWifiPasscodeView::m_OnWifiConnected(wifi_error_e err) } -bool CWifiPasscodeView::sm_CbWifiFoundAP(wifi_ap_h ap, void *data) +bool CWifiPasscodeView::sm_CbWifiFoundAP(CWifiAp *ap, void *data) { _DBG(); - CWifiPasscodeView *instance = NULL; + CWifiPasscodeView *root = (CWifiPasscodeView *)data; - if (!data) { - _ERR("data is NULL."); - return false; - } + if (root) + root->m_OnWifiFoundAP(ap); - instance = (CWifiPasscodeView *) data; - instance->m_OnWifiFoundAP(ap); return true; } -void CWifiPasscodeView::m_OnWifiFoundAP(wifi_ap_h ap) +void CWifiPasscodeView::m_OnWifiFoundAP(CWifiAp *ap) { bool ret; struct wifi_ap_info ap_info; - if (!ap) { - _ERR("Parameter error!"); - return ; - } - - ret = m->pWifiMgr->GetESSID(ap, ap_info.essid); + ret = ap->GetEssid(ap_info.essid, sizeof(ap_info.essid)); if(ret != true) { _ERR("Fail to get info"); return ; } - ret = m->pWifiMgr->GetConnectionState(ap, &ap_info.state); + ret = ap->GetConnectionState(&ap_info.state); if(ret != true) { _ERR("Fail to get info"); return ; } - ret = m->pWifiMgr->GetSecurityType(ap, &ap_info.secure_type); + ret = ap->GetSecurityType(&ap_info.secure_type); if(ret != true) { _ERR("Fail to get info"); return ; } if (!strncmp(m->ap_name, ap_info.essid, AP_NAME_LENTH)) { - ret = m->pWifiMgr->SetPassPhrase(ap, m->ap_pwd); + ret = ap->SetPassPhrase(m->ap_pwd); if (ret != true) { _ERR("wifi_mgr_set_passphrase() failed."); m_ShowConfirmPopup(); return ; } - ret = m->pWifiMgr->Connect(ap, sm_CbWifiConnected, this); + ret = ap->Connect(sm_CbWifiConnected, this); if (ret != true) { _ERR("Fail to connection request."); m_ShowConfirmPopup(); @@ -137,24 +123,19 @@ void CWifiPasscodeView::m_OnWifiFoundAP(wifi_ap_h ap) void CWifiPasscodeView::sm_CbWifiScanRequest(wifi_error_e err, void *data) { - CWifiPasscodeView *instance; - - if (!data) { - _ERR("data is NULL."); - return; - } + CWifiPasscodeView *root = (CWifiPasscodeView *)data; - instance = (CWifiPasscodeView *) data; - instance->m_OnWifiScanRequest(err, data); + if (root) + root->m_OnWifiScanRequest(err, data); } void CWifiPasscodeView::m_OnWifiScanRequest(wifi_error_e err, void *data) { if(err != WIFI_ERROR_NONE) - _ERR("parameter error = %s", m->pWifiMgr->GetErrorMsg(err)); + _ERR("parameter error = %s", CWifiMgr::ErrorMsg(err)); - if(!m->pWifiMgr->RegisterFoundAPCallback(sm_CbWifiFoundAP, data)) { + if(!m->pWifiMgr->FoundAps(sm_CbWifiFoundAP, data)) { _ERR("wifi_mgr_foreach_found_aps() failed."); m_ShowConfirmPopup(); return; @@ -273,13 +254,13 @@ bool CWifiPasscodeView::m_WifiConnectAP(void) m_ShowProgressPopup(); - ret = m->pWifiMgr->ForgetAP(); + ret = CWifiAp::ForgetAP(); if (ret != true) { _ERR("forget last ap failed."); return false; } - ret = m->pWifiMgr->RegisterScanCallback(sm_CbWifiScanRequest, this); + ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this); if (ret != true) { _ERR("wifi_mgr_scan_request() failed."); return false; diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp index 365307a..7f7eb34 100644 --- a/ug/proxy/src/ProxyMainView.cpp +++ b/ug/proxy/src/ProxyMainView.cpp @@ -188,7 +188,9 @@ bool CProxyMainView::m_SetWifiProxy(void) return false; } - ret = m->pWifiMgr->SetProxyType(m->eMethod); + CWifiAp ap(NULL); + ap.AllocConnectedAp(); + ret = ap.SetProxyType(m->eMethod); if (ret != true) { _ERR("wifi_mgr_get_proxy_type() failed."); return ret; @@ -196,15 +198,16 @@ bool CProxyMainView::m_SetWifiProxy(void) switch (m->eMethod) { case PROXY_METHOD_NONE: - m->pWifiMgr->SetProxyAddr(NULL); + ap.SetProxyAddr(NULL); break; case PROXY_METHOD_MANUAL: if (m->ip) - m->pWifiMgr->SetProxyAddr(m->ip); + ap.SetProxyAddr(m->ip); break; case PROXY_METHOD_AUTO: if (m->url) - m->pWifiMgr->SetProxyAddr(m->url); + ap.SetProxyAddr(m->url); + //m->pWifiMgr->SetProxyAddr(m->url); break; default: return false; diff --git a/ug/src/WifiMgr.cpp b/ug/src/WifiMgr.cpp index 3ae6ad6..28b63ef 100644 --- a/ug/src/WifiMgr.cpp +++ b/ug/src/WifiMgr.cpp @@ -1,354 +1,257 @@ +#include #include #include #include "WifiMgr.h" +#include + #define IP_STRING_MAX_SIZE 20 #define MAX_NAME_SIZE 256 #define CONTENT_TXT_SIZE 500 #define ZERO_IP "0.0.0.0" -CWifiMgr *CWifiMgr::instance = NULL; - -struct SWifiMgr { - wifi_ap_h ap; -}; - -bool CWifiMgr::Initialize(void) +bool CWifiAp::m_CheckErr(const char *func, int ret) { - ASSERT(!instance); - - instance = new CWifiMgr; - if(!instance) - return false; - - int ret; - - instance->m = new SWifiMgr; - if(instance->m == NULL) return false; - - ret = wifi_initialize(); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_initialize. error : %s", instance->GetErrorMsg((wifi_error_e) ret)); - return false; + _ERR("Fail to wifi_get_connected_ap %s", CWifiMgr::ErrorMsg((wifi_error_e)ret)); } - instance->m->ap = NULL; - - return true; + return ret == WIFI_ERROR_NONE ? true : false; } -void CWifiMgr::Finalize(void) +void CWifiAp::t_SetHandle(wifi_ap_h handle) { - if(!instance) - return; - ASSERT(instance->m); + m_handle = handle; +} - if (wifi_deinitialize() != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_deinitialize."); - } - delete instance->m; - delete instance; - instance = NULL; +CWifiAp::CWifiAp(wifi_ap_h handle) +{ + m_handle = handle; + + int ret = wifi_ap_clone(&m_handle, handle); + m_CheckErr(__FUNCTION__, ret); } -CWifiMgr *CWifiMgr::GetInstance(void) +CWifiAp::~CWifiAp() { - return instance; + wifi_ap_destroy(m_handle); + m_handle = NULL; } -bool CWifiMgr::Activate(void(*ActivatedCb)(wifi_error_e err, void *data), void *data) +#define WIFI_CHECK_RET(EXP) return m_CheckErr(__FUNCTION__, EXP); +#define WIFI_CHECK(EXP) m_CheckErr(__FUNCTION__, EXP); + + +wifi_ap_h CWifiAp::Handle(void) { - int ret; + return m_handle; +} - if (!ActivatedCb) { - _ERR("Parameter is invalid"); - return false; - } - ret = wifi_activate(ActivatedCb, data); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_activate %s", GetErrorMsg((wifi_error_e) ret)); - return false; - } +bool CWifiAp::AllocConnectedAp(void) +{ + ASSERT(m_handle == NULL); - return true; + WIFI_CHECK_RET(wifi_get_connected_ap(&m_handle)); } -bool CWifiMgr::IsActivated(bool *activated) +void CWifiAp::Destroy(void) { - int ret; - - ret = wifi_is_activated(activated); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_is_activated %s",GetErrorMsg((wifi_error_e) ret)); - return false; - } + if (m_handle == NULL) + return; - return true; + WIFI_CHECK(wifi_ap_destroy(m_handle)); + m_handle = NULL; } -bool CWifiMgr::GetConnectedAP(wifi_ap_h *ap) +bool CWifiAp::GetEssid(char *essid, int size) { - int ret; + ASSERT(m_handle); - if (!ap) { - _ERR("the param is invalid."); - return false; + char *str = NULL; + int ret = wifi_ap_get_essid(m_handle, &str); + if (ret == WIFI_ERROR_NONE) { + strncpy(essid, str, size); + _DBG("str : %s , ESSID : %s", str, essid); + free(str); } - - ret = wifi_get_connected_ap(ap); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_get_connected_ap %s",GetErrorMsg((wifi_error_e) ret)); - return false; + else { + _ERR("Fail to get ESSID"); } - return true; + return ret == WIFI_ERROR_NONE ? true : false; } -bool CWifiMgr::DestroyAP(wifi_ap_h ap) -{ - int ret; - if (!ap) { - _ERR("the ap is already NULL."); - return true; - } - - ret = wifi_ap_destroy(ap); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_ap_destroy %s",GetErrorMsg((wifi_error_e) ret)); - return false; - } +bool CWifiAp::GetConnectionState(wifi_connection_state_e *state) +{ + ASSERT(m_handle); - return true; + WIFI_CHECK_RET(wifi_ap_get_connection_state(m_handle, state)); } -bool CWifiMgr::CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin) +bool CWifiAp::GetSecurityType(wifi_security_type_e *type) { - int ret; + ASSERT(m_handle); - if (!cloned_ap || !origin) { - _ERR("the param is invalid."); - return false; - } + WIFI_CHECK_RET(wifi_ap_get_security_type(m_handle, type)); +} - ret = wifi_ap_clone(cloned_ap, origin); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_ap_clone %s",GetErrorMsg((wifi_error_e) ret)); - return false; - } - return true; +bool CWifiAp::SetPassPhrase(const char *passcode) +{ + ASSERT(m_handle); + ASSERT(passcode); + + WIFI_CHECK_RET(wifi_ap_set_passphrase(m_handle, passcode)); } -bool CWifiMgr::RegisterScanCallback(void(*ScanFinishedCb)(wifi_error_e err, void* data), void *data) +bool CWifiAp::Connect(void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data) { - int ret; + ASSERT(m_handle); + ASSERT(wifi_connected_cb); - if (!ScanFinishedCb) { - _ERR("Parameter is invalid"); - return false; - } + WIFI_CHECK_RET(wifi_connect(m_handle, wifi_connected_cb, data)); +} - ret = wifi_scan(ScanFinishedCb, data); - if (ret != WIFI_ERROR_NONE) { - _ERR("Scan request failed [%s]", GetErrorMsg((wifi_error_e) ret)); - return false; - } - return true; +bool CWifiAp::SetIpType(wifi_ip_config_type_e type) +{ + ASSERT(m_handle); + + WIFI_CHECK_RET(wifi_ap_set_ip_config_type(m_handle, WIFI_ADDRESS_FAMILY_IPV4, type)); } -bool CWifiMgr::RegisterFoundAPCallback(bool(*FoundCb)(wifi_ap_h ap, void *data), void *data) +bool CWifiAp::GetIp(char *ip, int size) { - int ret; + ASSERT(m_handle); - if (!FoundCb) { - _ERR("Parameter is invalid"); - return false; + char *str_value = NULL; + int ret = wifi_ap_get_ip_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value); + if (ret == WIFI_ERROR_NONE) { + strncpy(ip, str_value, IP_STRING_MAX_SIZE < size); + free(str_value); } - - ret = wifi_foreach_found_aps(FoundCb, data); - if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to get AP list %s.", GetErrorMsg((wifi_error_e) ret)); - return false; + else { + strncpy(ip, ZERO_IP, IP_STRING_MAX_SIZE); + _ERR("Fail to get Gateway"); } - - return true; + return ret == WIFI_ERROR_NONE ? true : false; } -bool CWifiMgr::SetProxyType(EProxyMethod pm) +bool CWifiAp::GetSubnetMask(char *submask) { - ASSERT(m); - - wifi_proxy_type_e type; - wifi_ap_h ap; - - if (wifi_get_connected_ap(&ap) != WIFI_ERROR_NONE) { - _ERR("wifi_get_connected_ap() failed."); - return false; - } + ASSERT(m_handle); - switch (pm) { - case PROXY_METHOD_NONE: - type = WIFI_PROXY_TYPE_DIRECT; - break; - case PROXY_METHOD_MANUAL: - type = WIFI_PROXY_TYPE_MANUAL; - break; - case PROXY_METHOD_AUTO: - type = WIFI_PROXY_TYPE_AUTO; - break; - default: - return false; + char *str_value = NULL; + int ret = wifi_ap_get_subnet_mask(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value); + if (ret == WIFI_ERROR_NONE) { + strncpy(submask, str_value, IP_STRING_MAX_SIZE); + free(str_value); } - - if (wifi_ap_set_proxy_type(ap, type) != WIFI_ERROR_NONE) { - _ERR("wifi_ap_set_proxy_type() failed."); - return false; + else { + strncpy(submask, ZERO_IP, IP_STRING_MAX_SIZE); + _ERR("Fail to get Gateway"); } - - return true; + return ret == WIFI_ERROR_NONE ? true : false; } -bool CWifiMgr::GetProxyType(EProxyMethod *pm) +bool CWifiAp::GetGateway(char *gateway) { - ASSERT(m); - - wifi_proxy_type_e type; - wifi_ap_h ap; - - if (!pm) { - _ERR("parameter is invalid."); - return false; - } + ASSERT(m_handle); - if (wifi_get_connected_ap(&ap) != WIFI_ERROR_NONE) { - _ERR("wifi_get_connected_ap() failed."); - return false; - } + char *str_value; - if (wifi_ap_get_proxy_type(ap, &type) != WIFI_ERROR_NONE) { - _ERR("wifi_ap_get_proxy_type() failed."); - return false; + str_value = NULL; + if (wifi_ap_get_gateway_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { + strncpy(gateway, str_value, IP_STRING_MAX_SIZE); + free(str_value); + return true; } - - switch (type) { - case WIFI_PROXY_TYPE_DIRECT: - *pm = PROXY_METHOD_NONE; - break; - case WIFI_PROXY_TYPE_MANUAL: - *pm = PROXY_METHOD_MANUAL; - break; - case WIFI_PROXY_TYPE_AUTO: - *pm = PROXY_METHOD_AUTO; - break; - default: + else { + strncpy(gateway, ZERO_IP, IP_STRING_MAX_SIZE); + _ERR("Fail to get Gateway"); return false; } - - return true; } -bool CWifiMgr::SetProxyAddr(const char *ip) +bool CWifiAp::GetDNS(char *dns) { - ASSERT(m); + ASSERT(m_handle); - wifi_ap_h ap; + char *str_value; - if (wifi_get_connected_ap(&ap) != WIFI_ERROR_NONE) { - _ERR("wifi_get_connected_ap() failed."); - return false; + str_value = NULL; + if (wifi_ap_get_dns_address(m_handle, 1, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { + strncpy(dns, str_value, IP_STRING_MAX_SIZE); + free(str_value); + return true; } - - if (wifi_ap_set_proxy_address(ap, WIFI_ADDRESS_FAMILY_IPV4, ip) != WIFI_ERROR_NONE) { - _ERR("wifi_ap_set_proxy_address() failed."); + else { + strncpy(dns, ZERO_IP, IP_STRING_MAX_SIZE); + _ERR("Fail to get DNS1"); return false; } - - return true; } -bool CWifiMgr::GetProxyAddr(char **ip) +bool CWifiAp::SetIp(char *ip) { - ASSERT(m); - wifi_ap_h ap; + ASSERT(m_handle); - if (!ip || !*ip) { - _ERR("parameter is invalid."); - return false; - } + WIFI_CHECK_RET(wifi_ap_set_ip_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, ip)); +} - if (wifi_get_connected_ap(&ap) != WIFI_ERROR_NONE) { - _ERR("wifi_get_connected_ap() failed."); - return false; - } - if (wifi_ap_get_proxy_address(ap, WIFI_ADDRESS_FAMILY_IPV4, ip) != WIFI_ERROR_NONE) { - _ERR("wifi_ap_get_proxy_address() failed."); - return false; - } +bool CWifiAp::SetSubnetMask(char *submask) +{ + ASSERT(m_handle); - return true; + WIFI_CHECK_RET(wifi_ap_set_subnet_mask(m_handle, WIFI_ADDRESS_FAMILY_IPV4, submask)); } -bool CWifiMgr::GetESSID(wifi_ap_h ap, char *essid) +bool CWifiAp::SetGateway(char *gateway) { - ASSERT(m); - ASSERT(ap); - - char *str; - str = NULL; - if (wifi_ap_get_essid(ap, &str) == WIFI_ERROR_NONE) { - strncpy(essid, str, 255); - _DBG("str : %s , ESSID : %s", str, essid); - delete (str); - str = NULL; - } else { - _ERR("Fail to get ESSID"); - return false; - } + ASSERT(m_handle); - return true; + WIFI_CHECK_RET(wifi_ap_set_gateway_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, gateway)); } -bool CWifiMgr::GetConnectionState(wifi_ap_h ap, wifi_connection_state_e *state) +bool CWifiAp::SetDNS(char *dns) { - ASSERT(m); - ASSERT(ap); + ASSERT(m_handle); - if (wifi_ap_get_connection_state(ap, state) != WIFI_ERROR_NONE) { - _ERR("Fail to get Connection State"); - return false; - } - - return true; + WIFI_CHECK_RET(wifi_ap_set_dns_address(m_handle, 1, WIFI_ADDRESS_FAMILY_IPV4, dns)); } -bool CWifiMgr::GetSecurityType(wifi_ap_h ap, wifi_security_type_e *type) +bool CWifiAp::CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin) { - ASSERT(m); - ASSERT(ap); + int ret; - if (wifi_ap_get_security_type(ap, type) != WIFI_ERROR_NONE) { - _ERR("Fail to get Security type"); + if (!cloned_ap || !origin) { + _ERR("the param is invalid."); + return false; + } + + ret = wifi_ap_clone(cloned_ap, origin); + if (ret != WIFI_ERROR_NONE) { + _ERR("Fail to wifi_ap_clone %s", CWifiMgr::ErrorMsg((wifi_error_e)ret)); return false; } @@ -356,182 +259,170 @@ bool CWifiMgr::GetSecurityType(wifi_ap_h ap, wifi_security_type_e *type) } -bool CWifiMgr::ForgetAP(void) +bool CWifiAp::ForgetAP(void) { int ret; - wifi_ap_h ap; + wifi_ap_h handle; char *name; - ret = wifi_get_connected_ap(&ap); + ret = wifi_get_connected_ap(&handle); if (ret == WIFI_ERROR_NO_CONNECTION) { return true; - } else if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to get connected AP [%s]", GetErrorMsg((wifi_error_e) ret)); + } + else if (ret != WIFI_ERROR_NONE) { + _ERR("Fail to get connected AP [%s]", CWifiMgr::ErrorMsg((wifi_error_e)ret)); return false; } - ret = wifi_ap_get_essid(ap, &name); + ret = wifi_ap_get_essid(handle, &name); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to wifi_ap_get_essid AP [%s]", GetErrorMsg((wifi_error_e) ret)); - wifi_ap_destroy(ap); + _ERR("Fail to wifi_ap_get_essid AP [%s]", CWifiMgr::ErrorMsg((wifi_error_e)ret)); + wifi_ap_destroy(handle); return false; } - ret = wifi_forget_ap(ap); + ret = wifi_forget_ap(handle); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to forget [%s],[%s].", name, GetErrorMsg((wifi_error_e) ret)); - wifi_ap_destroy(ap); - delete (name); - return false; + _ERR("Fail to forget [%s],[%s].", name, CWifiMgr::ErrorMsg((wifi_error_e)ret)); } - delete (name); + wifi_ap_destroy(handle); + free(name); - return true; + return ret == WIFI_ERROR_NONE ? true : false; } -bool CWifiMgr::SetPassPhrase(wifi_ap_h ap, const char *passcode) +bool CWifiAp::SetProxyType(EProxyMethod pm) { - int ret; + ASSERT(m_handle); - if (!ap || !passcode) { - _ERR("the param is invalid."); - return false; - } + wifi_proxy_type_e type; - ret = wifi_ap_set_passphrase(ap, passcode); - if (ret != WIFI_ERROR_NONE) { - _ERR("failed to set passcode. ret: %s.", GetErrorMsg((wifi_error_e) ret)); + switch (pm) { + case PROXY_METHOD_NONE: + type = WIFI_PROXY_TYPE_DIRECT; + break; + + case PROXY_METHOD_MANUAL: + type = WIFI_PROXY_TYPE_MANUAL; + break; + + case PROXY_METHOD_AUTO: + type = WIFI_PROXY_TYPE_AUTO; + break; + + default: return false; } - return true; + int ret = wifi_ap_set_proxy_type(m_handle, type); + return ret = WIFI_ERROR_NONE ? true : false; } -bool CWifiMgr::Connect(wifi_ap_h ap, void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data) +bool CWifiAp::GetProxyType(EProxyMethod *pm) { - int ret; + ASSERT(m_handle); - if (!wifi_connected_cb || !ap) { - _ERR("the param is invalid."); - return false; - } - - ret = wifi_connect(ap, wifi_connected_cb, data); + wifi_proxy_type_e type; + + int ret = wifi_ap_get_proxy_type(m_handle, &type); if (ret != WIFI_ERROR_NONE) { - _ERR("failed to connect ap. ret: %s.", GetErrorMsg((wifi_error_e) ret)); + _ERR("wifi_ap_get_proxy_type() failed."); return false; } - return true; -} - + switch (type) { + case WIFI_PROXY_TYPE_DIRECT: + *pm = PROXY_METHOD_NONE; + break; -bool CWifiMgr::SetIpType(wifi_ap_h ap, wifi_ip_config_type_e type) -{ - int ret; + case WIFI_PROXY_TYPE_MANUAL: + *pm = PROXY_METHOD_MANUAL; + break; - if (!ap) { - _ERR("the param is invalid."); - return false; - } + case WIFI_PROXY_TYPE_AUTO: + *pm = PROXY_METHOD_AUTO; + break; - ret = wifi_ap_set_ip_config_type(ap, WIFI_ADDRESS_FAMILY_IPV4, type); - if (ret != WIFI_ERROR_NONE) { - _ERR("failed to connect ap. ret: %s.", GetErrorMsg((wifi_error_e) ret)); + default: return false; } - return true; + return ret; } -bool CWifiMgr::GetIp(wifi_ap_h ap, char *ip) +bool CWifiAp::SetProxyAddr(const char *addr) { - ASSERT(ap); + ASSERT(m_handle); - char *str_value; - - str_value = NULL; - if (wifi_ap_get_ip_address(ap, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { - strncpy(ip, str_value, IP_STRING_MAX_SIZE); - delete (str_value); - return true; - } else { - strncpy(ip, ZERO_IP, IP_STRING_MAX_SIZE); - _ERR("Fail to get Gateway"); - return false; - } + WIFI_CHECK_RET(wifi_ap_set_proxy_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, addr)); } -bool CWifiMgr::GetSubnetMask(wifi_ap_h ap, char *submask) +bool CWifiAp::GetProxyAddr(char **addr) { - ASSERT(ap); + ASSERT(m_handle); + ASSERT(addr); - char *str_value; - - str_value = NULL; - if (wifi_ap_get_subnet_mask(ap, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { - strncpy(submask, str_value, IP_STRING_MAX_SIZE); - delete (str_value); - return true; - } else { - strncpy(submask, ZERO_IP, IP_STRING_MAX_SIZE); - _ERR("Fail to get Gateway"); - return false; - } + WIFI_CHECK_RET(wifi_ap_get_proxy_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, addr)); } -bool CWifiMgr::GetGateway(wifi_ap_h ap, char *gateway) +CWifiMgr *CWifiMgr::instance = NULL; + + +struct SWifiMgr { + int a; +}; + + +bool CWifiMgr::Initialize(void) { - ASSERT(ap); + ASSERT(!instance); - char *str_value; + _CREATE_BEGIN{ + _CHECK(instance = new CWifiMgr); + _CHECK(instance->m = new SWifiMgr); + _CHECK(wifi_initialize() == WIFI_ERROR_NONE); - str_value = NULL; - if (wifi_ap_get_gateway_address(ap, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { - strncpy(gateway, str_value, IP_STRING_MAX_SIZE); - delete (str_value); - return true; - } else { - strncpy(gateway, ZERO_IP, IP_STRING_MAX_SIZE); - _ERR("Fail to get Gateway"); - return false; - } + _CHECK_FAIL{ wifi_deinitialize(); } + _CHECK_FAIL{ delete instance->m; } + _CHECK_FAIL{ delete instance; instance = NULL; } + } _CREATE_END_AND_CATCH { return false; } + + return true; } -bool CWifiMgr::GetDNS(wifi_ap_h ap, char *dns) +void CWifiMgr::Finalize(void) { - ASSERT(ap); + ASSERT(instance); + ASSERT(instance->m); - char *str_value; + wifi_deinitialize(); - str_value = NULL; - if (wifi_ap_get_dns_address(ap, 1, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) { - strncpy(dns, str_value, IP_STRING_MAX_SIZE); - delete (str_value); - return true; - } else { - strncpy(dns, ZERO_IP, IP_STRING_MAX_SIZE); - _ERR("Fail to get DNS1"); - return false; - } + delete instance->m; + delete instance; + instance = NULL; } -bool CWifiMgr::SetIp(wifi_ap_h ap, char *ip) + +CWifiMgr *CWifiMgr::GetInstance(void) { - ASSERT(ap); + return instance; +} - int ret; - ret = wifi_ap_set_ip_address(ap, WIFI_ADDRESS_FAMILY_IPV4, ip); +bool CWifiMgr::Activate(void (*cbActivated)(wifi_error_e err, void *data), void *data) +{ + ASSERT(cbActivated); + + int ret = wifi_activate(cbActivated, data); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to set ip address[%s]", GetErrorMsg((wifi_error_e) ret)); + _ERR("Fail to wifi_activate %s", CWifiMgr::ErrorMsg((wifi_error_e) ret)); return false; } @@ -539,15 +430,13 @@ bool CWifiMgr::SetIp(wifi_ap_h ap, char *ip) } -bool CWifiMgr::SetSubnetMask(wifi_ap_h ap, char *submask) +bool CWifiMgr::IsActivated(bool *activated) { - ASSERT(ap); - int ret; - ret = wifi_ap_set_subnet_mask(ap, WIFI_ADDRESS_FAMILY_IPV4, submask); + ret = wifi_is_activated(activated); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to set subnet mask[%s]", GetErrorMsg((wifi_error_e) ret)); + _ERR("Fail to wifi_is_activated %s",CWifiMgr::ErrorMsg((wifi_error_e) ret)); return false; } @@ -555,15 +444,13 @@ bool CWifiMgr::SetSubnetMask(wifi_ap_h ap, char *submask) } -bool CWifiMgr::SetGateway(wifi_ap_h ap, char *gateway) +bool CWifiMgr::Scan(void(*cbFinish)(wifi_error_e err, void* data), void *data) { - ASSERT(ap); + ASSERT(cbFinish); - int ret; - - ret = wifi_ap_set_gateway_address(ap, WIFI_ADDRESS_FAMILY_IPV4, gateway); + int ret = wifi_scan(cbFinish, data); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to set gateway address[%s]", GetErrorMsg((wifi_error_e) ret)); + _ERR("Scan request failed [%s]", CWifiMgr::ErrorMsg((wifi_error_e) ret)); return false; } @@ -571,15 +458,36 @@ bool CWifiMgr::SetGateway(wifi_ap_h ap, char *gateway) } -bool CWifiMgr::SetDNS(wifi_ap_h ap, char *dns) +struct SUserData { - ASSERT(ap); + bool(*cb)(CWifiAp *ap, void *data); + void *data; + SUserData(bool(*c)(CWifiAp *ap, void *data), void *d) { + cb = c; + data = data; + } +}; - int ret; - ret = wifi_ap_set_dns_address(ap, 1, WIFI_ADDRESS_FAMILY_IPV4, dns); +static bool g_CbFound(wifi_ap_h ap, void *data) +{ + SUserData *ud = (SUserData*)data; + CWifiAp ins(ap); + ud->cb(&ins, ud->data); + delete ud; + + return false; +} + + +bool CWifiMgr::FoundAps(bool(*cbFound)(CWifiAp *ap, void *data), void *data) +{ + ASSERT(cbFound); + + SUserData *ud = new SUserData(cbFound, data); + int ret = wifi_foreach_found_aps(g_CbFound, ud); if (ret != WIFI_ERROR_NONE) { - _ERR("Fail to set dns address[%s]", GetErrorMsg((wifi_error_e) ret)); + _ERR("Fail to get AP list %s.", CWifiMgr::ErrorMsg((wifi_error_e) ret)); return false; } @@ -587,7 +495,7 @@ bool CWifiMgr::SetDNS(wifi_ap_h ap, char *dns) } -const char * CWifiMgr::GetErrorMsg(wifi_error_e err_type) +const char * CWifiMgr::ErrorMsg(wifi_error_e err_type) { switch (err_type) { case WIFI_ERROR_NONE: -- 2.7.4 From ff5e99bc2a6b1c754655bc7733c36729d4259a94 Mon Sep 17 00:00:00 2001 From: Kim Youngjin Date: Tue, 14 Apr 2015 09:25:37 +0900 Subject: [PATCH 14/16] Compile error is fixed. Change-Id: I23542073b0445249297a1be56f6eaf705fa1fcc5 Signed-off-by: Kim Youngjin --- src/view_sublist.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index ec216d6..c95546f 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -410,14 +410,7 @@ bool CSublistView::m_DrawSublist(void) { _DBG(); Eina_List *list; -<<<<<<< HEAD - //double ratio, w; int cnt; - //int x, y, height, screen_h; - //struct obj_geometry_data *param; -======= - int cnt; ->>>>>>> 0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b if (!m->sublist_view || !m->geometry_data) { _ERR("Invalid argument\n"); -- 2.7.4 From 49582101c172e0777a1a75ef20bd62293b91066e Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Wed, 15 Apr 2015 11:51:56 +0900 Subject: [PATCH 15/16] Fix ug invisible bug. * All Evas_object should be added on same window to getting visibility stack (using elm_win_resize_object_add(win, base)) Change-Id: I01aeeb4a0706fed8f1fc215c29d6bbaf51ce4132 Signed-off-by: JuWan Kim --- src/view_maincatalog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp index a3e2220..0e3c49a 100644 --- a/src/view_maincatalog.cpp +++ b/src/view_maincatalog.cpp @@ -1067,6 +1067,9 @@ bool CMainCatalogView::Create(struct settingview_data *view, void *prev) _CHECK(m->mgr = CSettingMgr::GetInstance()) _CHECK(m->win = m->mgr->Window()) _CHECK(m->base = elm_layout_add(m->win)) + _COMMAND { + elm_win_resize_object_add(m->win, m->base); + } _WHEN_SUCCESS { elm_layout_file_set(m->base, EDJ_FILE, MAIN_VIEW_PAGE); m->main_setting_view = view; -- 2.7.4 From eda3ace5995b975deb43a7328d68ba4615421bca Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Mon, 20 Apr 2015 15:09:45 +0900 Subject: [PATCH 16/16] Fix build error due to changing app-common Change-Id: I952a9915c30230722805a17ac395d87d2404d7d9 Signed-off-by: JuWan Kim --- include/view_maincatalog.h | 1 - include/view_sublist.h | 1 - include/view_system_clock.h | 1 - src/main.cpp | 4 +--- src/settingviewmgr.cpp | 3 --- src/timeout_handler.cpp | 4 +--- src/view_maincatalog.cpp | 4 +--- src/view_need_pwd.cpp | 2 +- src/view_pwd_popup.cpp | 3 +-- src/view_sublist.cpp | 2 +- src/view_system_clock.cpp | 2 +- src/view_uigadget.cpp | 2 +- ug/channel/src/ChannelMainView.cpp | 6 +----- ug/channel/src/ChannelResultView.cpp | 6 +----- ug/channel/src/ChannelSearchView.cpp | 6 +----- ug/channel/src/ug_auto_program.cpp | 5 +---- ug/network/src/IpSettingView.cpp | 8 +------- ug/network/src/NetworkMainView.cpp | 5 +---- ug/network/src/WifiPasscodeView.cpp | 11 ++--------- ug/network/src/ug_network_settings.cpp | 4 +--- ug/proxy/src/ProxyMainView.cpp | 7 +------ ug/proxy/src/ug_proxy_settings.cpp | 4 +--- ug/src/NetConMgr.cpp | 2 +- ug/src/TVServiceMgr.cpp | 5 ++--- ug/src/WifiDirectMgr.cpp | 4 +--- ug/src/WifiMgr.cpp | 3 +-- ug/system/clock/src/ClockMainView.cpp | 6 +----- ug/system/clock/src/ClockSpinControlView.cpp | 6 +----- ug/system/clock/src/ClockSublistView.cpp | 6 +----- ug/system/clock/src/ClockTimeSpinControlView.cpp | 6 +----- ug/system/clock/src/ug_clock.cpp | 4 +--- ug/wifi-direct/src/WifiDirectMainView.cpp | 8 +------- ug/wifi-direct/src/ug_wifi_direct.cpp | 6 ++---- 33 files changed, 32 insertions(+), 115 deletions(-) diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h index 95a3894..0124b7c 100644 --- a/include/view_maincatalog.h +++ b/include/view_maincatalog.h @@ -19,7 +19,6 @@ #include "settingviewmgr.h" -#include "InputHandler.h" class CMainCatalogView : diff --git a/include/view_sublist.h b/include/view_sublist.h index 32d1138..81dd8c1 100644 --- a/include/view_sublist.h +++ b/include/view_sublist.h @@ -19,7 +19,6 @@ #include "settingviewmgr.h" -#include "InputHandler.h" class CSublistView : diff --git a/include/view_system_clock.h b/include/view_system_clock.h index 65e42dc..80175aa 100644 --- a/include/view_system_clock.h +++ b/include/view_system_clock.h @@ -19,7 +19,6 @@ #include "settingviewmgr.h" -#include "InputHandler.h" class CSystemClockView : diff --git a/src/main.cpp b/src/main.cpp index c9d424a..89d00e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,17 +14,15 @@ * limitations under the License. */ -#include -#include #include #include "dbg.h" #include "def.h" +#include #include "settingviewmgr.h" #include "utils.h" #include "json_marco.h" #include "settings_provider.h" -#include #include #define PARAM_SETTINGS_ITEM "settings-item" diff --git a/src/settingviewmgr.cpp b/src/settingviewmgr.cpp index 6126c85..34f2833 100644 --- a/src/settingviewmgr.cpp +++ b/src/settingviewmgr.cpp @@ -14,12 +14,9 @@ * limitations under the License. */ -#include -#include #include "dbg.h" #include -#include #include "settingviewmgr.h" #include "data_wrapper.h" #include "timeout_handler.h" diff --git a/src/timeout_handler.cpp b/src/timeout_handler.cpp index dc9a00f..78f8007 100644 --- a/src/timeout_handler.cpp +++ b/src/timeout_handler.cpp @@ -14,10 +14,8 @@ * limitations under the License. */ -#include -#include -#include #include "dbg.h" +#include #include "stdlib.h" #include "stdbool.h" #include "timeout_handler.h" diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp index 0e3c49a..c4ae093 100644 --- a/src/view_maincatalog.cpp +++ b/src/view_maincatalog.cpp @@ -14,15 +14,13 @@ * limitations under the License. */ -#include -#include #include "dbg.h" +#include #include "def.h" #include "stdbool.h" #include "settingviewmgr.h" #include "utils.h" -#include #include "view_maincatalog.h" #include "data_wrapper.h" #include "settings_provider.h" diff --git a/src/view_need_pwd.cpp b/src/view_need_pwd.cpp index 26c9687..287d468 100755 --- a/src/view_need_pwd.cpp +++ b/src/view_need_pwd.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#include #include "dbg.h" +#include #include "def.h" #include "utils.h" #include "settings_provider.h" diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.cpp index 9f49e37..e72d94c 100755 --- a/src/view_pwd_popup.cpp +++ b/src/view_pwd_popup.cpp @@ -14,14 +14,13 @@ * limitations under the License. */ -#include #include "dbg.h" +#include #include "def.h" #include "view_pwd_popup.h" #include "utils.h" #include "settings_provider.h" #include "settingviewmgr.h" -#include #define PWD_DATA_ID "change_passcode_data" #define CTXPOPUP_WIDTH 688 diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp index c95546f..8d353a0 100644 --- a/src/view_sublist.cpp +++ b/src/view_sublist.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "AppCommon.h" #include "dbg.h" +#include #include "def.h" #include "stdbool.h" #include "settingviewmgr.h" diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp index f6e22d3..c2a350a 100644 --- a/src/view_system_clock.cpp +++ b/src/view_system_clock.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#include #include "dbg.h" +#include #include "def.h" #include "stdbool.h" #include "settingviewmgr.h" diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp index 17ddda6..02a0382 100644 --- a/src/view_uigadget.cpp +++ b/src/view_uigadget.cpp @@ -15,9 +15,9 @@ */ #include -#include #include "view_uigadget.h" #include "dbg.h" +#include #include "def.h" #include "settingviewmgr.h" diff --git a/ug/channel/src/ChannelMainView.cpp b/ug/channel/src/ChannelMainView.cpp index e42f54c..aa4ce2a 100644 --- a/ug/channel/src/ChannelMainView.cpp +++ b/ug/channel/src/ChannelMainView.cpp @@ -1,14 +1,10 @@ -#include -#include #include -#include "AppCommon.h" #include "dbg.h" +#include #include "util.h" #include "defs.h" #include "TVServiceMgr.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ChannelMainView.h" #define HORIZONTAL_ALIGN 0.5 diff --git a/ug/channel/src/ChannelResultView.cpp b/ug/channel/src/ChannelResultView.cpp index 8335e63..665a0be 100644 --- a/ug/channel/src/ChannelResultView.cpp +++ b/ug/channel/src/ChannelResultView.cpp @@ -1,14 +1,10 @@ -#include -#include #include -#include "AppCommon.h" #include #include "dbg.h" +#include #include "defs.h" #include "util.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ChannelResultView.h" #define RESULT_MSG_SIZE 60 diff --git a/ug/channel/src/ChannelSearchView.cpp b/ug/channel/src/ChannelSearchView.cpp index 7e84dea..4ee478a 100644 --- a/ug/channel/src/ChannelSearchView.cpp +++ b/ug/channel/src/ChannelSearchView.cpp @@ -1,15 +1,11 @@ -#include -#include #include -#include "AppCommon.h" #include #include "dbg.h" +#include #include "defs.h" #include "util.h" #include "TVServiceMgr.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ChannelSearchView.h" #define MAX_BUF_SIZE 30 diff --git a/ug/channel/src/ug_auto_program.cpp b/ug/channel/src/ug_auto_program.cpp index 8944d91..9ab6c8a 100644 --- a/ug/channel/src/ug_auto_program.cpp +++ b/ug/channel/src/ug_auto_program.cpp @@ -18,16 +18,13 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include -#include #include "defs.h" #include "dbg.h" +#include #include "ug_auto_program.h" #include "util.h" #include "TVServiceMgr.h" -#include -#include "BaseView.h" #include "ChannelMainView.h" #if defined (__cplusplus) extern "C" { diff --git a/ug/network/src/IpSettingView.cpp b/ug/network/src/IpSettingView.cpp index 8ad9fa0..6f0890e 100644 --- a/ug/network/src/IpSettingView.cpp +++ b/ug/network/src/IpSettingView.cpp @@ -1,19 +1,13 @@ -#include #include #include "defs.h" #include "dbg.h" +#include #include #include "i18n.h" #include "util.h" #include "common.h" - -#include -#include - #include "WifiMgr.h" #include "NetConMgr.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "IpSettingView.h" diff --git a/ug/network/src/NetworkMainView.cpp b/ug/network/src/NetworkMainView.cpp index 49edad3..985bbc7 100644 --- a/ug/network/src/NetworkMainView.cpp +++ b/ug/network/src/NetworkMainView.cpp @@ -1,6 +1,5 @@ -#include -#include "AppCommon.h" #include "dbg.h" +#include #include "util.h" #include "defs.h" #include "i18n.h" @@ -10,8 +9,6 @@ #include "WifiMgr.h" #include "NetConMgr.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "NetworkMainView.h" static char *action_button[4] = { TXT_CONNECT_BTN, TXT_REFRESH_BTN, TXT_OTHER_BTN, TXT_CLOSE_BTN }; diff --git a/ug/network/src/WifiPasscodeView.cpp b/ug/network/src/WifiPasscodeView.cpp index 8a727a7..10d9a36 100644 --- a/ug/network/src/WifiPasscodeView.cpp +++ b/ug/network/src/WifiPasscodeView.cpp @@ -1,18 +1,11 @@ -#include -#include #include -#include +#include #include "defs.h" #include "dbg.h" +#include #include "i18n.h" #include "util.h" #include "common.h" -#include "util.h" - -#include -#include -#include "BaseView.h" -#include "ViewMgr.h" #include "WifiMgr.h" #include "WifiPasscodeView.h" diff --git a/ug/network/src/ug_network_settings.cpp b/ug/network/src/ug_network_settings.cpp index 7fa91c6..456b9de 100644 --- a/ug/network/src/ug_network_settings.cpp +++ b/ug/network/src/ug_network_settings.cpp @@ -18,16 +18,14 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include #include #include "i18n.h" #include "defs.h" #include "dbg.h" +#include -#include #include "wifi.h" -#include "BaseView.h" #include "NetworkMainView.h" #if defined (__cplusplus) diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp index 7f7eb34..acab271 100644 --- a/ug/proxy/src/ProxyMainView.cpp +++ b/ug/proxy/src/ProxyMainView.cpp @@ -1,8 +1,8 @@ -#include #include #include #include "defs.h" #include "dbg.h" +#include #include "i18n.h" #include "util.h" @@ -10,11 +10,6 @@ #include "WifiMgr.h" #include "NetConMgr.h" -#include -#include - -#include "BaseView.h" -#include "ViewMgr.h" #include "ProxyMainView.h" #define KEY_PRIV "priv" diff --git a/ug/proxy/src/ug_proxy_settings.cpp b/ug/proxy/src/ug_proxy_settings.cpp index db8972e..275e014 100644 --- a/ug/proxy/src/ug_proxy_settings.cpp +++ b/ug/proxy/src/ug_proxy_settings.cpp @@ -18,15 +18,13 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include #include #include "i18n.h" #include "defs.h" #include "dbg.h" +#include -#include #include "wifi.h" -#include "BaseView.h" #include "ProxyMainView.h" #if defined (__cplusplus) diff --git a/ug/src/NetConMgr.cpp b/ug/src/NetConMgr.cpp index f4ad61c..94ea137 100644 --- a/ug/src/NetConMgr.cpp +++ b/ug/src/NetConMgr.cpp @@ -1,5 +1,5 @@ -#include #include "dbg.h" +#include #include "NetConMgr.h" #define IP_STRING_MAX_SIZE 20 diff --git a/ug/src/TVServiceMgr.cpp b/ug/src/TVServiceMgr.cpp index 714a0b5..9973e80 100644 --- a/ug/src/TVServiceMgr.cpp +++ b/ug/src/TVServiceMgr.cpp @@ -1,9 +1,8 @@ -#include +#include #include -#include #include "dbg.h" +#include //#include "tv_service_proxy.h" -#include "AppCommon.h" #include "TVServiceMgr.h" diff --git a/ug/src/WifiDirectMgr.cpp b/ug/src/WifiDirectMgr.cpp index c6f745b..af78a82 100644 --- a/ug/src/WifiDirectMgr.cpp +++ b/ug/src/WifiDirectMgr.cpp @@ -1,8 +1,6 @@ -#include -#include -#include #include "defs.h" #include "dbg.h" +#include #include "WifiMgr.h" #include "WifiDirectMgr.h" diff --git a/ug/src/WifiMgr.cpp b/ug/src/WifiMgr.cpp index b4a5b9e..dceb922 100644 --- a/ug/src/WifiMgr.cpp +++ b/ug/src/WifiMgr.cpp @@ -1,9 +1,8 @@ -#include +#include #include #include #include #include "WifiMgr.h" -#include #define IP_STRING_MAX_SIZE 20 diff --git a/ug/system/clock/src/ClockMainView.cpp b/ug/system/clock/src/ClockMainView.cpp index 53b92eb..4e24df1 100644 --- a/ug/system/clock/src/ClockMainView.cpp +++ b/ug/system/clock/src/ClockMainView.cpp @@ -1,13 +1,9 @@ -#include -#include #include -#include "AppCommon.h" #include "dbg.h" +#include #include "defs.h" #include "util.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ClockMainView.h" #define CLOCK_SUBLIST_NULL_BTNS 2 diff --git a/ug/system/clock/src/ClockSpinControlView.cpp b/ug/system/clock/src/ClockSpinControlView.cpp index c4f9f2d..885a084 100644 --- a/ug/system/clock/src/ClockSpinControlView.cpp +++ b/ug/system/clock/src/ClockSpinControlView.cpp @@ -1,13 +1,9 @@ -#include -#include #include -#include "AppCommon.h" #include "dbg.h" +#include #include "defs.h" #include "util.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ClockSpinControlView.h" #define ARROW_BTN_DATA_ID "arrow_btn_data_id" diff --git a/ug/system/clock/src/ClockSublistView.cpp b/ug/system/clock/src/ClockSublistView.cpp index 2b75f50..4216de0 100755 --- a/ug/system/clock/src/ClockSublistView.cpp +++ b/ug/system/clock/src/ClockSublistView.cpp @@ -1,13 +1,9 @@ -#include -#include #include -#include "AppCommon.h" #include "dbg.h" +#include #include "defs.h" #include "util.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ClockSublistView.h" #define SUBLIST_BTN_NUM 2 diff --git a/ug/system/clock/src/ClockTimeSpinControlView.cpp b/ug/system/clock/src/ClockTimeSpinControlView.cpp index b82cf43..6952a5a 100644 --- a/ug/system/clock/src/ClockTimeSpinControlView.cpp +++ b/ug/system/clock/src/ClockTimeSpinControlView.cpp @@ -1,13 +1,9 @@ -#include -#include #include -#include "AppCommon.h" #include "dbg.h" +#include #include "defs.h" #include "util.h" -#include "BaseView.h" -#include "ViewMgr.h" #include "ClockTimeSpinControlView.h" #define ARROW_BTN_DATA_ID "arrow_btn_data_id" diff --git a/ug/system/clock/src/ug_clock.cpp b/ug/system/clock/src/ug_clock.cpp index bb3efad..8d0809d 100755 --- a/ug/system/clock/src/ug_clock.cpp +++ b/ug/system/clock/src/ug_clock.cpp @@ -18,16 +18,14 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include #include #include "util.h" #include "ug_clock.h" #include "defs.h" #include "dbg.h" +#include -#include -#include "BaseView.h" #include "ClockMainView.h" #include "ClockSublistView.h" diff --git a/ug/wifi-direct/src/WifiDirectMainView.cpp b/ug/wifi-direct/src/WifiDirectMainView.cpp index 3a6b1af..0d4ad54 100755 --- a/ug/wifi-direct/src/WifiDirectMainView.cpp +++ b/ug/wifi-direct/src/WifiDirectMainView.cpp @@ -1,18 +1,12 @@ -#include -#include -#include #include #include "defs.h" #include "dbg.h" +#include #include "util.h" #include "WifiDirectMgr.h" -#include -#include -#include "BaseView.h" -#include "ViewMgr.h" #include "WifiDirectMainView.h" const char *action_button[] = { TXT_REFRESH_BTN, TXT_CLOSE_BTN, TXT_STOP_BTN }; diff --git a/ug/wifi-direct/src/ug_wifi_direct.cpp b/ug/wifi-direct/src/ug_wifi_direct.cpp index 0917376..c554fb1 100644 --- a/ug/wifi-direct/src/ug_wifi_direct.cpp +++ b/ug/wifi-direct/src/ug_wifi_direct.cpp @@ -18,15 +18,13 @@ #define UG_MODULE_API __attribute__ ((visibility("default"))) #endif -#include #include -#include "i18n.h" #include "dbg.h" +#include #include "defs.h" +#include "i18n.h" -#include #include "wifi.h" -#include "BaseView.h" #include "WifiDirectMainView.h" #if defined (__cplusplus) -- 2.7.4