diff options
author | JuWan Kim <juwan.kim@samsung.com> | 2015-04-13 20:58:53 +0900 |
---|---|---|
committer | JuWan Kim <juwan.kim@samsung.com> | 2015-04-13 21:02:12 +0900 |
commit | 0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b (patch) | |
tree | 525c58308bf445e771ff889cdc799ebedc560a82 /src | |
parent | 26594948f6c660fa50af7abe1862746f60d2526a (diff) | |
download | settings-0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b.tar.gz settings-0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b.tar.bz2 settings-0d3aa5eb2be096066a3ce6d2a3c8b0f72f40cb5b.zip |
Refactoring / code clean
Change-Id: I075c61762513fb01a7573ed0c44abdbf6a4994f2
Signed-off-by: JuWan Kim <juwan.kim@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/settingviewmgr.cpp | 12 | ||||
-rw-r--r-- | src/view_maincatalog.cpp | 1178 | ||||
-rwxr-xr-x | src/view_pwd_popup.cpp | 1 |
3 files changed, 358 insertions, 833 deletions
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 <Eina.h> #include "dbg.h" -#include "AppCommon.h" +#include <AppCommon.h> +#include <InputHandler.h> #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 <InputHandler.h> #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) +void CMainCatalogView::m_SubItemClicked(Evas_Object *obj) { - const char *id; - struct evas_obj_data param; + 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; } - 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; + style = settingitem_get_settingui_style(item); + if (!style) { + _ERR("setting-ui style is null."); + return; } - 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 ; } - 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) -{ - const char *id; - - if (!data || !item) { - _ERR("Invalid argument"); - return -1; - } + if (!strncmp(style, STYLE_UIGADGET, strlen(style))) { - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } + struct evas_obj_data param; + param.subitem_box = m->subitem_box; + param.display_name = settingitem_get_display_name(item); + param.cur_btn = obj; - if (!data->mgr->ViewPush(id, NULL)) { - _ERR("Fail to push view"); - return -1; - } + if (!m->mgr->ViewPush(id, (void *)¶m)) + _ERR("Fail to push ug view"); - return 0; -} + } else if (!strncmp(style, STYLE_CTXPOPUP, strlen(style))) { -/** -* 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; + struct obj_geometry_data ogd; + _get_geometry_data(obj, &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"); - param.display_name = settingitem_get_display_name(item); - param.subitem_box = data->subitem_box; - param.cur_btn = obj; + } else if (!strncmp(style, STYLE_BOTTOMSLIDER, strlen(style)) || !strncmp(style, STYLE_BOTTOM2WAYSLIDER, strlen(style))) { - evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd); + 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"); - if (!data->mgr->ViewPush(id, ¶m)) { - _ERR("Fail to push view"); - return -1; - } + } else if (!strncmp(style, STYLE_PASSCODE_POPUP, strlen(style))) { - elm_object_signal_emit(obj, - SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push passcode view"); - 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; + } else if (!strncmp(style, STYLE_DEVICE_MANAGER, strlen(style))) { - if (!data || !item || !obj) { - _ERR("Invalid argument"); - return -1; - } + struct evas_obj_data param; + param.display_name = settingitem_get_display_name(item); + param.subitem_box = m->subitem_box; - id = settingitem_get_id(item); - if (!id) { - _ERR("Fail to get item id"); - return -1; - } + if (!m->mgr->ViewPush(id, ¶m)) + _ERR("Fail to push device_manager view"); - _get_geometry_data(obj, &ogd); + } else if (!strncmp(style, STYLE_RESET_POPUP, strlen(style))) { - if (!data->mgr->ViewPush(id, &ogd)) { - _ERR("Fail to push view"); - return -1; - } + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push reset_popup view"); - elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, - SUBITEMBTN_BUTTON_SOURCE); + } else if (!strncmp(style, STYLE_UPGRADE_POPUP, strlen(style))) { - return 0; -} + if (!m->mgr->ViewPush(id, NULL)) + _ERR("Fail to push reset_popup view"); -/** -* 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; + } 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); - if (priv->focus_status != FOCUS_SUB_ITEM) - return; + param.display_name = settingitem_get_display_name(item); + param.subitem_box = m->subitem_box; + param.cur_btn = obj; - item =(struct settingitem *) evas_object_data_get(obj, SUBITEM_DATA_ID); - if (!item) { - _ERR("Get sub item failed"); - return; - } + evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd); - style = settingitem_get_settingui_style(item); - if (!style) { - _ERR("setting-ui style is null."); - return; - } + if (!m->mgr->ViewPush(id, ¶m)) + _ERR("Fail to push view"); + else + elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); - 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_NEED_PASSCODE, strlen(style))) { - priv->focused_sub_item_btn = obj; -} + struct obj_geometry_data ogd; + _get_geometry_data(obj, &ogd); -/** -* 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; + if (!m->mgr->ViewPush(id, &ogd)) + _ERR("Fail to push view"); + else + elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE); - if (!data || !obj) { - _ERR("Invalid argument"); - return; } - priv = (SMainCatalog *)data; - - _submenu_item_clicked(priv, obj); - - elm_object_signal_emit(priv->focused_main_item_btn, - MAINICONBTN_FOCUSED_ON_SUBITEM, - MAINICONBTN_MAIN_ITEM_SOURCE); - - 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); + 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; + CMainCatalogView *instance; - 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_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; + m->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. */ -} - -/** -* 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 <InputHandler.h> #define PWD_DATA_ID "change_passcode_data" #define CTXPOPUP_WIDTH 688 |