summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKim Youngjin <yj21c.kim@samsung.com>2015-03-30 15:12:28 +0900
committerKim Youngjin <yj21c.kim@samsung.com>2015-03-30 15:15:16 +0900
commit454badf837e5d8c9b0035b55a1ef2b67035e54fe (patch)
treee155ea1585c2b6e56b5debceef5e8afdff424182 /src
parentf88267a386f0ece9ddbe09738ed0a408266cd80d (diff)
downloadsettings-454badf837e5d8c9b0035b55a1ef2b67035e54fe.tar.gz
settings-454badf837e5d8c9b0035b55a1ef2b67035e54fe.tar.bz2
settings-454badf837e5d8c9b0035b55a1ef2b67035e54fe.zip
viewmgr is changed to class module.
Change-Id: I9bd106203acedb2160554202669f7e4cd470bd0e Signed-off-by: Kim Youngjin <yj21c.kim@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp20
-rw-r--r--src/view_maincatalog.cpp57
-rw-r--r--src/view_need_pwd.cpp16
-rw-r--r--src/view_pwd_popup.cpp19
-rw-r--r--src/view_sublist.cpp9
-rw-r--r--src/view_system_clock.cpp14
-rw-r--r--src/view_uigadget.cpp11
-rw-r--r--src/viewmgr.cpp281
8 files changed, 210 insertions, 217 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fda34a6..e043aad 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -55,7 +55,7 @@ class CApp : public CBaseApp {
struct _appdata {
Evas_Object *win;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
const char *name;
char *item;
unsigned int app_control;
@@ -135,7 +135,8 @@ protected:
virtual void OnTerminate(void)
{
- settingmgr_fini(ad.mgr);
+ CSettingMgr::Finalize();
+ ad.mgr = NULL;
provider_fini();
@@ -148,7 +149,7 @@ protected:
virtual void OnAppControl(app_control_h app_control)
{
_DBG(" ******************* OnAppControl *********************");
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
int r;
char *param;
unsigned int relaunch, refresh;
@@ -168,31 +169,30 @@ protected:
}
if (relaunch) {
- settingmgr_fini(ad.mgr);
+ CSettingMgr::Finalize();
} else {
if (refresh)
{
if (!ad.mgr)
return;
- settingmgr_view_refresh(ad.mgr);
+ ad.mgr->ViewRefresh();
}
}
}
- mgr = settingmgr_init(ad.win);
- if (!mgr)
+ if (!CSettingMgr::Initialize(ad.win))
app_efl_exit();
+ mgr = CSettingMgr::GetInstance();
r = app_control_get_extra_data(app_control, PARAM_SETTINGS_ITEM, &param);
if (r == APP_CONTROL_ERROR_NONE && param) {
- r = settingmgr_launch_item(mgr, param);
- if (r != 0) {
+ if (!mgr->LaunchItem(param)) {
_ERR("the item is not exist.");
app_efl_exit();
}
} else {
- settingmgr_view_push(mgr, MAIN_CATALOG, NULL);
+ mgr->ViewPush(MAIN_CATALOG, NULL);
}
ad.mgr = mgr;
diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp
index 42d58a6..277740c 100644
--- a/src/view_maincatalog.cpp
+++ b/src/view_maincatalog.cpp
@@ -24,6 +24,7 @@
#include "view_maincatalog.h"
#include "data_wrapper.h"
#include "settings_provider.h"
+#include "viewmgr.h"
#define DATA_ID "main_setting_data"
#define SUBITEM_DATA_ID "subitem_data_id"
@@ -64,7 +65,7 @@ struct _view_data {
int main_item_count;
int sub_item_count;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
struct settingview_data *main_setting_view;
struct settingview_data *subsetting_view;
};
@@ -203,7 +204,6 @@ static int _push_ug_view(struct _view_data *data,
{
const char *id;
struct evas_obj_data param;
- int r;
if (!data || !item || !obj) {
_ERR("Invalid argument");
@@ -220,8 +220,7 @@ static int _push_ug_view(struct _view_data *data,
param.display_name = settingitem_get_display_name(item);
param.cur_btn = obj;
- r = settingmgr_view_push(data->mgr, id, (void *)&param);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, (void *)&param)) {
_ERR("Fail to push view");
return -1;
}
@@ -242,7 +241,6 @@ static int _push_sublist_view(struct _view_data *data,
struct settingitem *item, Evas_Object *obj)
{
const char *id;
- int r;
struct obj_geometry_data ogd;
if (!data || !item || !obj) {
@@ -258,8 +256,7 @@ static int _push_sublist_view(struct _view_data *data,
_get_geometry_data(obj, &ogd);
- r = settingmgr_view_push(data->mgr, id, (void *)&ogd);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, (void *)&ogd)) {
_ERR("Fail to push view");
return -1;
}
@@ -282,7 +279,6 @@ static int _push_bottom_sublist_view(struct _view_data *data,
struct settingitem *item)
{
const char *id;
- int r;
if (!data || !item) {
_ERR("Invalid argument");
@@ -295,8 +291,7 @@ static int _push_bottom_sublist_view(struct _view_data *data,
return -1;
}
- r = settingmgr_view_push(data->mgr, id, NULL);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, NULL)) {
_ERR("Fail to push view");
return -1;
}
@@ -317,7 +312,6 @@ static int _push_bottom_slider_view(struct _view_data *data,
struct settingitem *item, Evas_Object *obj)
{
const char *id;
- int r;
Eina_List *list;
Evas_Object *pb;
@@ -339,10 +333,9 @@ static int _push_bottom_slider_view(struct _view_data *data,
list = settingitem_get_slider_group_list(
viewdata_get_parentitem(data->subsetting_view),
- settingmgr_get_data(data->mgr), id);
+ data->mgr->GetData(), id);
- r = settingmgr_view_push(data->mgr, id, list);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, list)) {
_ERR("Fail to push view");
return -1;
}
@@ -362,7 +355,6 @@ static int _push_passcode_popup_view(struct _view_data *data,
struct settingitem *item)
{
const char *id;
- int r;
if (!data || !item) {
_ERR("Invalid argument");
@@ -375,8 +367,7 @@ static int _push_passcode_popup_view(struct _view_data *data,
return -1;
}
- r = settingmgr_view_push(data->mgr, id, NULL);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, NULL)) {
_ERR("Fail to push view");
return -1;
}
@@ -397,7 +388,6 @@ static int _push_device_manager_view(struct _view_data *data,
{
const char *id;
struct evas_obj_data param;
- int r;
if (!data || !item) {
_ERR("Invalid argument");
@@ -413,8 +403,7 @@ static int _push_device_manager_view(struct _view_data *data,
param.display_name = settingitem_get_display_name(item);
param.subitem_box = data->subitem_box;
- r = settingmgr_view_push(data->mgr, id, &param);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, &param)) {
_ERR("Fail to push view");
return -1;
}
@@ -434,7 +423,6 @@ static int _push_reset_popup_view(struct _view_data *data,
struct settingitem *item)
{
const char *id;
- int r;
if (!data || !item) {
_ERR("Invalid argument");
@@ -447,8 +435,7 @@ static int _push_reset_popup_view(struct _view_data *data,
return -1;
}
- r = settingmgr_view_push(data->mgr, id, NULL);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, NULL)) {
_ERR("Fail to push view");
return -1;
}
@@ -468,7 +455,6 @@ static int _push_upgrade_popup_view(struct _view_data *data,
struct settingitem *item)
{
const char *id;
- int r;
if (!data || !item) {
_ERR("Invalid argument");
@@ -481,8 +467,7 @@ static int _push_upgrade_popup_view(struct _view_data *data,
return -1;
}
- r = settingmgr_view_push(data->mgr, id, NULL);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, NULL)) {
_ERR("Fail to push view");
return -1;
}
@@ -505,7 +490,6 @@ static int _push_clock_sublist_view(struct _view_data *data,
const char *id;
struct evas_obj_data param;
struct obj_geometry_data ogd;
- int r;
if (!data || !item || !obj) {
_ERR("Invalid argument");
@@ -526,8 +510,7 @@ static int _push_clock_sublist_view(struct _view_data *data,
evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd);
- r = settingmgr_view_push(data->mgr, id, &param);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, &param)) {
_ERR("Fail to push view");
return -1;
}
@@ -550,7 +533,6 @@ static int _push_need_passcode_view(struct _view_data *data,
struct settingitem *item, Evas_Object *obj)
{
const char *id;
- int r;
struct obj_geometry_data ogd;
if (!data || !item || !obj) {
@@ -566,8 +548,7 @@ static int _push_need_passcode_view(struct _view_data *data,
_get_geometry_data(obj, &ogd);
- r = settingmgr_view_push(data->mgr, id, &ogd);
- if (r != 0) {
+ if (!data->mgr->ViewPush(id, &ogd)) {
_ERR("Fail to push view");
return -1;
}
@@ -1108,7 +1089,7 @@ static int _draw_subitems(struct _view_data *data, const char *name)
return -1;
}
- view = settingmgr_get_view(data->mgr, name);
+ view = data->mgr->GetView(name);
if (!view) {
_ERR("get subview failed\n");
return -1;
@@ -1775,7 +1756,7 @@ static void _change_buttons_name(Eina_List *list,
*
* @return: the base layout of settings or null if error occurred.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
_DBG("START ==================================================================");
@@ -1787,7 +1768,7 @@ static Evas_Object *_create(struct setting_mgr *mgr,
return NULL;
}
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
if (!win) {
_ERR("Fail to get win");
return NULL;
@@ -1811,7 +1792,7 @@ static Evas_Object *_create(struct setting_mgr *mgr,
data->base = base;
data->main_setting_view = view;
data->subsetting_view = NULL;
- data->item_path = settingmgr_get_item_path(mgr);
+ data->item_path = mgr->GetItemPath();
evas_object_data_set(base, DATA_ID, data);
@@ -1984,8 +1965,8 @@ static void _refresh(Evas_Object *base)
SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
}
- if (settingmgr_get_timeout_freeze_state(data->mgr) == EINA_TRUE)
- settingmgr_thaw_timeout(data->mgr);
+ if (data->mgr->GetTimeoutFreezeState() == EINA_TRUE)
+ data->mgr->ThawTimeout();
}
/**
diff --git a/src/view_need_pwd.cpp b/src/view_need_pwd.cpp
index 042f151..d314894 100644
--- a/src/view_need_pwd.cpp
+++ b/src/view_need_pwd.cpp
@@ -62,7 +62,7 @@ struct _chnllock_data {
char passcode[BUF_SIZE];
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
struct settingview_data *view;
struct obj_geometry_data gd;
};
@@ -173,7 +173,7 @@ static void _cancel_btn_clicked_cb(void *priv, Evas_Object *obj,
data = (struct _chnllock_data *) priv;
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -259,7 +259,7 @@ static void _push_next_view(struct _chnllock_data *data)
if (!id)
return;
- settingmgr_view_push(data->mgr, id, &data->gd);
+ data->mgr->ViewPush(id, &data->gd);
}
/**
@@ -308,7 +308,7 @@ static void _key_down_cb(void *priv, Evas *e, Evas_Object *obj,
return;
if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) {
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
} else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
elm_object_focus_set(data->cancel_btn, EINA_TRUE);
} else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
@@ -532,7 +532,7 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -545,7 +545,7 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
* @return: the base layout of channel lock view or null
* if error occurred.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
Evas_Object *win, *base, *bg;
@@ -560,7 +560,7 @@ static Evas_Object *_create(struct setting_mgr *mgr,
return NULL;
}
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
if (!win) {
_ERR("settings manager get window failed.");
return NULL;
@@ -727,7 +727,7 @@ static void _refresh(Evas_Object *base)
if (!data)
return;
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.cpp
index 13a54b7..592614b 100644
--- a/src/view_pwd_popup.cpp
+++ b/src/view_pwd_popup.cpp
@@ -19,6 +19,7 @@
#include "view_pwd_popup.h"
#include "utils.h"
#include "settings_provider.h"
+#include "viewmgr.h"
#define PWD_DATA_ID "change_passcode_data"
#define CTXPOPUP_WIDTH 688
@@ -68,7 +69,7 @@ struct _pwd_data {
int renew_flag;
int wrong_flag;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
struct settingview_data *view;
};
@@ -176,7 +177,7 @@ static void _cancelbtn_clicked_cb(void *priv, Evas_Object *obj, void *ev)
data = (struct _pwd_data *) priv;
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -483,7 +484,7 @@ static void _entry_keypress_cb(void *priv, Evas *e,
}
if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) {
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
} else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
elm_object_focus_set(data->cancel_btn, EINA_TRUE);
} else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
@@ -543,7 +544,7 @@ static void _entry_keypress_cb(void *priv, Evas *e,
data->new_flag = 0;
data->renew_flag = 0;
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
} else {
_update_pwd_ui(data, PART_UPTEXT,
MSGID_DIFFER_PWD);
@@ -697,7 +698,7 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -710,9 +711,11 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
* @return: the base layout of change passcode view or null
* if error occurred.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
+ ASSERT(mgr);
+
Evas_Object *base, *bg;
Evas_Object *win;
Evas_Object *cancel_btn;
@@ -722,12 +725,12 @@ static Evas_Object *_create(struct setting_mgr *mgr,
int width, height;
int xpos, ypos;
- if (!mgr || !view) {
+ if (!view) {
_ERR("invalid argument.");
return NULL;
}
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
if (!win) {
_ERR("settingmgr get window failed.");
return NULL;
diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp
index 39399e5..9f538ab 100644
--- a/src/view_sublist.cpp
+++ b/src/view_sublist.cpp
@@ -22,6 +22,7 @@
#include "data_wrapper.h"
#include "settings_provider.h"
#include "view_sublist.h"
+#include "viewmgr.h"
#define DATA_ID "SUBLISTDATA"
#define MAX_ITEMS 8
@@ -52,7 +53,7 @@ struct _sublist_data {
int selected_index;
struct obj_geometry_data *geometry_data;
struct settingview_data *sublist_view;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
};
static void _destroy(Evas_Object *base);
@@ -70,7 +71,7 @@ static void _exit_view(struct _sublist_data *data)
return;
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -616,7 +617,7 @@ static int _draw_sublist(struct _sublist_data *data)
* @param prev [in] The parameter data which passed by prev view or NULL.
* @return View layout evas object, NULL on error.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
Evas_Object *base, *ctxpopup, *win;
@@ -627,7 +628,7 @@ static Evas_Object *_create(struct setting_mgr *mgr,
return NULL;
}
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
if (!win) {
_ERR("Fail to get win");
return NULL;
diff --git a/src/view_system_clock.cpp b/src/view_system_clock.cpp
index eeb4cb5..e396d26 100644
--- a/src/view_system_clock.cpp
+++ b/src/view_system_clock.cpp
@@ -50,7 +50,7 @@ struct _sysclk_data {
int count;
int sel_idx;
struct settingview_data *vdata;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
struct evas_obj_data ugd;
struct obj_geometry_data *ogd;
@@ -73,7 +73,7 @@ static void _exit_view(struct _sysclk_data *data)
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -311,7 +311,7 @@ static void _subitem_clicked_cb(void *priv, Evas_Object *obj, void *ev)
data->ugd.display_name = name;
- settingmgr_view_push(data->mgr, id, (void *)&data->ugd);
+ data->mgr->ViewPush(id, (void *)&data->ugd);
} else {
_exit_view(data);
}
@@ -556,7 +556,7 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -569,7 +569,7 @@ static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
* @return: the base layout of system clock view or null
* if error occurred.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
Evas_Object *base;
@@ -587,7 +587,8 @@ static Evas_Object *_create(struct setting_mgr *mgr,
ugd = (struct evas_obj_data *) prev;
ogd = (struct obj_geometry_data *) evas_object_data_get(ugd->cur_btn, DATA_ID);
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
+
if (!win) {
_ERR("settingmgr get window failed.");
return NULL;
@@ -781,3 +782,4 @@ struct setting_class *view_system_clock_get_vclass(void)
{
return &_vclass;
}
+
diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp
index 92c0a8c..715d7f0 100644
--- a/src/view_uigadget.cpp
+++ b/src/view_uigadget.cpp
@@ -18,6 +18,7 @@
#include "view_uigadget.h"
#include "dbg.h"
#include "def.h"
+#include "viewmgr.h"
#define DATA_ID "ugdata"
@@ -31,7 +32,7 @@ struct _data {
const char *display_name;
ui_gadget_h ug_handler;
Eina_Bool ug_is_existed;
- struct setting_mgr *mgr;
+ CSettingMgr *mgr;
struct settingview_data *view;
};
@@ -61,7 +62,7 @@ static void _back_to_mainview(struct _data *data)
return;
_hide(data->base);
- settingmgr_view_pop(data->mgr);
+ data->mgr->ViewPop();
}
/**
@@ -187,7 +188,7 @@ static int _load_uigadget(struct _data *data)
} else {
data->ug_is_existed = EINA_TRUE;
data->ug_handler = ug;
- settingmgr_freeze_timeout(data->mgr);
+ data->mgr->FreezeTimeout();
}
return 0;
@@ -233,7 +234,7 @@ static void _hide_item_btns(Evas_Object *box)
* @param prev [in] The parameter data which passed by prev view or NULL.
* @return View layout evas object, NULL on error.
*/
-static Evas_Object *_create(struct setting_mgr *mgr,
+static Evas_Object *_create(CSettingMgr *mgr,
struct settingview_data *view, void *prev)
{
Evas_Object *win, *base;
@@ -250,7 +251,7 @@ static Evas_Object *_create(struct setting_mgr *mgr,
_hide_item_btns(param->subitem_box);
- win = settingmgr_get_win(mgr);
+ win = mgr->Window();
if (!win) {
_ERR("Invalid argument");
return NULL;
diff --git a/src/viewmgr.cpp b/src/viewmgr.cpp
index a103874..bc98edd 100644
--- a/src/viewmgr.cpp
+++ b/src/viewmgr.cpp
@@ -26,6 +26,7 @@
#include "view_pwd_popup.h"
#include "view_system_clock.h"
#include "view_need_pwd.h"
+#include "viewmgr.h"
#define MAINCATALOG "maincatalog"
#define PATH_FACTOR 3
@@ -278,49 +279,66 @@ void _active_view_in_list(struct setting_mgr *mgr)
}
}
+
+
+CSettingMgr *CSettingMgr::instance = NULL;
+
/**
* This function is invoked to initialize setting manager.
*
* @param win [in] The window's evas object.
* @return The setting_mgr data pointer.
*/
-struct setting_mgr *settingmgr_init(Evas_Object *win)
+bool CSettingMgr::Initialize(Evas_Object *win)
{
- struct setting_mgr *mgr;
+ ASSERT(!instance);
+
+ instance = new CSettingMgr;
+ if (!instance) {
+ return false;
+ }
+ instance->m = new setting_mgr;
+ if (!instance->m) {
+ delete instance;
+ return false;
+ }
+
struct settingmgr_data *data;
struct timeout_handler *handler;
if (!win)
return NULL;
- mgr = (struct setting_mgr *)calloc(1, sizeof(*mgr));
- if (!mgr)
- return NULL;
-
data = viewmgr_data_init();
if (!data) {
_ERR("viewmgr_data_init failed!");
- free(mgr);
- return NULL;
+ 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);
- free(mgr);
- return NULL;
+ delete instance->m;
+ delete instance;
+ instance = NULL;
+ return false;
}
- mgr->win = win;
- mgr->depth = 0;
- mgr->data = data;
- mgr->handler = handler;
- mgr->is_freeze = EINA_FALSE;
- return mgr;
+ instance->m->win = win;
+ instance->m->depth = 0;
+ instance->m->data = data;
+ instance->m->handler = handler;
+ instance->m->is_freeze = EINA_FALSE;
+
+ return true;
}
+
/**
* This function is invoked to destroy all views stored in view list and release
* setting_mgr data structure.
@@ -328,34 +346,41 @@ struct setting_mgr *settingmgr_init(Evas_Object *win)
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_fini(struct setting_mgr *mgr)
+void CSettingMgr::Finalize(void)
{
+ ASSERT(instance);
+ ASSERT(instance->m);
+
struct _settinginfo *sinfo;
void* obj;
- if (!mgr) {
- _ERR("Parameter error!");
- return;
- }
+ _hide_view_in_list(instance->m);
+ _destroy_views_in_list(instance->m);
- _hide_view_in_list(mgr);
- _destroy_views_in_list(mgr);
-
- EINA_LIST_FREE(mgr->view_list, obj)
+ EINA_LIST_FREE(instance->m->view_list, obj)
{
sinfo = (struct _settinginfo *)obj;
free(sinfo);
}
- if (mgr->item_path)
- eina_array_free(mgr->item_path);
+ if (instance->m->item_path)
+ eina_array_free(instance->m->item_path);
+
+ viewmgr_data_fini(instance->m->data);
+ timeout_handler_fini(instance->m->handler);
+
+ delete instance->m;
+ delete instance;
+ instance = NULL;
+}
- viewmgr_data_fini(mgr->data);
- timeout_handler_fini(mgr->handler);
- free(mgr);
+CSettingMgr *CSettingMgr::GetInstance(void)
+{
+ return instance;
}
+
/**
* This function is invoked to push a view with specific name and data.
*
@@ -367,45 +392,44 @@ void settingmgr_fini(struct setting_mgr *mgr)
* @param data [in] The function specific data passed by caller.
* @return 0 if success, -1 if fail.
*/
-int settingmgr_view_push(struct setting_mgr *mgr,
- const char *name, void *data)
+bool CSettingMgr::ViewPush(const char *name, void *data)
{
+ ASSERT(m);
+ ASSERT(name);
+
Evas_Object *base;
struct _settinginfo *sinfo;
struct setting_class *sclass;
struct settingview_data *view;
- if (!mgr || !name)
- return -1;
-
- mgr->depth++;
+ m->depth++;
- sinfo = (struct _settinginfo *)calloc(1, sizeof(*sinfo));
+ sinfo = new _settinginfo;
if (!sinfo)
- return -1;
+ return false;
- view = _build_setting_view(mgr, name);
+ view = _build_setting_view(m, name);
if (!view) {
_ERR("Build setting view data failed\n");
goto error;
}
- sclass = _get_view_class(mgr, view);
+ sclass = _get_view_class(m, view);
if (!sclass) {
_ERR("failed to get view class.");
goto error;
}
- base = sclass->create(mgr, view, data);
+ base = sclass->create(this, view, data);
if (!base) {
_ERR("failed to create base layout.");
goto error;
}
- _frozen_view_in_list(mgr);
+ _frozen_view_in_list(m);
if (sclass->hide_view)
- _hide_view_in_list(mgr);
+ _hide_view_in_list(m);
if (sclass->show)
sclass->show(base);
@@ -414,12 +438,12 @@ int settingmgr_view_push(struct setting_mgr *mgr,
sinfo->sclass = sclass;
sinfo->sview = view;
- mgr->view_list = eina_list_prepend(mgr->view_list, sinfo);
+ m->view_list = eina_list_prepend(m->view_list, sinfo);
return 0;
error:
- mgr->depth--;
+ m->depth--;
free(sinfo);
viewdata_release(view);
@@ -435,21 +459,18 @@ error:
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_view_pop(struct setting_mgr *mgr)
+void CSettingMgr::ViewPop(void)
{
+ ASSERT(m);
+
struct _settinginfo *sinfo, *prev;
struct setting_class *sclass;
int hide;
char *item;
const char *title;
- if (!mgr) {
- _ERR("Invalid arguments\n");
- return;
- }
-
- mgr->depth--;
- sinfo = (struct _settinginfo *) eina_list_data_get(mgr->view_list);
+ m->depth--;
+ sinfo = (struct _settinginfo *) eina_list_data_get(m->view_list);
if (!sinfo) {
_DBG("get sinfo failed\n");
return;
@@ -467,13 +488,13 @@ void settingmgr_view_pop(struct setting_mgr *mgr)
if (sclass->destroy && sinfo->base)
sclass->destroy(sinfo->base);
- mgr->view_list = eina_list_remove_list(mgr->view_list, mgr->view_list);
+ m->view_list = eina_list_remove_list(m->view_list, m->view_list);
free(sinfo);
- if (!mgr->view_list)
+ if (!m->view_list)
return;
- prev = (struct _settinginfo *) eina_list_data_get(mgr->view_list);
+ prev = (struct _settinginfo *) eina_list_data_get(m->view_list);
if (!prev || !prev->sclass)
return;
@@ -488,10 +509,10 @@ void settingmgr_view_pop(struct setting_mgr *mgr)
if (sclass->update)
sclass->update(prev->base);
- _active_view_in_list(mgr);
+ _active_view_in_list(m);
if (hide)
- _show_view_in_list(mgr);
+ _show_view_in_list(m);
}
/**
@@ -500,12 +521,11 @@ void settingmgr_view_pop(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return The window's evas object, NULL on error.
*/
-Evas_Object *settingmgr_get_win(struct setting_mgr *mgr)
+Evas_Object *CSettingMgr::Window(void)
{
- if (!mgr)
- return NULL;
+ ASSERT(m);
- return mgr->win;
+ return m->win;
}
/**
@@ -515,10 +535,11 @@ Evas_Object *settingmgr_get_win(struct setting_mgr *mgr)
* @param name [in] The view name to be got.
* @return The settingview_data data pointer, NULL on error.
*/
-struct settingview_data *settingmgr_get_view(struct setting_mgr *mgr,
- const char *name)
+settingview_data *CSettingMgr::GetView(const char *name)
{
- return _build_setting_view(mgr, name);
+ ASSERT(m);
+
+ return _build_setting_view(m, name);
}
/**
@@ -527,14 +548,11 @@ struct settingview_data *settingmgr_get_view(struct setting_mgr *mgr,
* @param mgr [in] The setting_mgr data pointer.
* @return The settingmgr_data data pointer, NULL on error.
*/
-struct settingmgr_data *settingmgr_get_data(struct setting_mgr *mgr)
+settingmgr_data *CSettingMgr::GetData(void)
{
- if (!mgr) {
- _ERR("Parameter error!");
- return NULL;
- }
+ ASSERT(m);
- return mgr->data;
+ return m->data;
}
/**
@@ -543,14 +561,12 @@ struct settingmgr_data *settingmgr_get_data(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return The Eina_List data pointer, NULL on error.
*/
-Eina_List *settingmgr_get_view_list(struct setting_mgr *mgr)
+Eina_List *CSettingMgr::GetViewList(void)
{
- if (!mgr) {
- _ERR("Parameter error!");
- return NULL;
- }
+ ASSERT(m);
- return mgr->view_list;
+
+ return m->view_list;
}
/**
@@ -563,21 +579,20 @@ Eina_List *settingmgr_get_view_list(struct setting_mgr *mgr)
* @param name [in] The item name.
* @return 0 if success, -1 if fail.
*/
-int settingmgr_launch_item(struct setting_mgr *mgr,
- const char *name)
+bool CSettingMgr::LaunchItem(const char *name)
{
+ ASSERT(m);
+ ASSERT(name);
+
const char *parent;
struct settingitem *item;
Eina_Array *path;
int i, cnt;
- if (!mgr || !name)
- return -1;
-
path = eina_array_new(1);
if (!path) {
_ERR("new eina array failed.");
- return -1;
+ return false;
}
eina_array_push(path, name);
@@ -586,15 +601,15 @@ int settingmgr_launch_item(struct setting_mgr *mgr,
if (!parent) {
_ERR("get parent item name failed.");
eina_array_free(path);
- return -1;
+ return false;
}
eina_array_push(path, parent);
do {
- viewmgr_data_read_jsonfile_into_hash(mgr->data, parent);
+ viewmgr_data_read_jsonfile_into_hash(m->data, parent);
- item = viewmgr_data_get_settingitem(mgr->data, parent);
+ item = viewmgr_data_get_settingitem(m->data, parent);
if (!item)
break;
@@ -602,16 +617,18 @@ int settingmgr_launch_item(struct setting_mgr *mgr,
eina_array_push(path, parent);
} while (parent && strncmp(parent, MAINCATALOG, strlen(parent)));
- mgr->item_path = path;
+ m->item_path = path;
+
+
+ ViewPush(MAINCATALOG, NULL);
- settingmgr_view_push(mgr, MAINCATALOG, NULL);
cnt = eina_array_count(path);
for (i = cnt - PATH_FACTOR; i > 0; i--)
- settingmgr_view_push(mgr,(const char *) eina_array_data_get(path, i), NULL);
+ ViewPush((const char *) eina_array_data_get(path, i), NULL);
- return 0;
+ return true;
}
/**
@@ -623,12 +640,11 @@ int settingmgr_launch_item(struct setting_mgr *mgr,
* @param mgr [in] The setting_mgr data pointer.
* @return The Eina_Array data pointer, NULL on error.
*/
-Eina_Array *settingmgr_get_item_path(struct setting_mgr *mgr)
+Eina_Array *CSettingMgr::GetItemPath(void)
{
- if (!mgr || !mgr->item_path)
- return NULL;
+ ASSERT(m);
- return mgr->item_path;
+ return m->item_path;
}
/**
@@ -637,15 +653,17 @@ Eina_Array *settingmgr_get_item_path(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_view_refresh(struct setting_mgr *mgr)
+void CSettingMgr::ViewRefresh(void)
{
+ ASSERT(m);
+
struct _settinginfo *info;
struct setting_class *vclass;
- if (!mgr || !mgr->view_list)
+ if (!m->view_list)
return;
- info = (struct _settinginfo *) eina_list_data_get(mgr->view_list);
+ info = (struct _settinginfo *) eina_list_data_get(m->view_list);
if (!info)
return;
@@ -665,13 +683,11 @@ void settingmgr_view_refresh(struct setting_mgr *mgr)
* @param val [in] The value to be set.
* @return void.
*/
-void settingmgr_set_refresh_flag(struct setting_mgr *mgr,
- unsigned int val)
+void CSettingMgr::SetRefreshFlag(unsigned int val)
{
- if (!mgr)
- return;
+ ASSERT(m);
- mgr->refresh = val;
+ m->refresh = val;
}
/**
@@ -680,12 +696,11 @@ void settingmgr_set_refresh_flag(struct setting_mgr *mgr,
* @param mgr [in] The setting_mgr data pointer.
* @return The refresh flag value, -1 if fail.
*/
-unsigned int settingmgr_get_refresh_flag(struct setting_mgr *mgr)
+unsigned int CSettingMgr::GetRefreshFlag(void)
{
- if (!mgr)
- return -1;
+ ASSERT(m);
- return mgr->refresh;
+ return m->refresh;
}
/**
@@ -695,13 +710,11 @@ unsigned int settingmgr_get_refresh_flag(struct setting_mgr *mgr)
* @param val [in] The value to be set.
* @return void.
*/
-void settingmgr_set_relaunch_flag(struct setting_mgr *mgr,
- unsigned int val)
+void CSettingMgr::SetRelaunchFlag(unsigned int val)
{
- if (!mgr)
- return;
+ ASSERT(m);
- mgr->relaunch = val;
+ m->relaunch = val;
}
/**
@@ -710,12 +723,11 @@ void settingmgr_set_relaunch_flag(struct setting_mgr *mgr,
* @param mgr [in] The setting_mgr data pointer.
* @return The refresh flag value, -1 if fail.
*/
-unsigned int settingmgr_get_relaunch_flag(struct setting_mgr *mgr)
+unsigned int CSettingMgr::GetRelaunchFlag(void)
{
- if (!mgr)
- return -1;
+ ASSERT(m);
- return mgr->relaunch;
+ return m->relaunch;
}
/**
@@ -724,15 +736,12 @@ unsigned int settingmgr_get_relaunch_flag(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_freeze_timeout(struct setting_mgr *mgr)
+void CSettingMgr::FreezeTimeout(void)
{
- if (!mgr) {
- _ERR("Invalid argument");
- return;
- }
+ ASSERT(m);
- mgr->is_freeze = EINA_TRUE;
- timeout_handler_freeze_timer(mgr->handler);
+ m->is_freeze = EINA_TRUE;
+ timeout_handler_freeze_timer(m->handler);
}
/**
@@ -741,15 +750,12 @@ void settingmgr_freeze_timeout(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_thaw_timeout(struct setting_mgr *mgr)
+void CSettingMgr::ThawTimeout(void)
{
- if (!mgr) {
- _ERR("Invalid argument");
- return;
- }
+ ASSERT(m);
- timeout_handler_thaw_timer(mgr->handler);
- mgr->is_freeze = EINA_FALSE;
+ timeout_handler_thaw_timer(m->handler);
+ m->is_freeze = EINA_FALSE;
}
/**
@@ -759,14 +765,11 @@ void settingmgr_thaw_timeout(struct setting_mgr *mgr)
* @return EINA_TRUE if current state is frozen
* EINA_FALSE if current state is normal or occurred error.
*/
-Eina_Bool settingmgr_get_timeout_freeze_state(struct setting_mgr *mgr)
+Eina_Bool CSettingMgr::GetTimeoutFreezeState(void)
{
- if (!mgr) {
- _ERR("Invalid argument");
- return EINA_FALSE;
- }
+ ASSERT(m);
- return mgr->is_freeze;
+ return m->is_freeze;
}
/**
@@ -775,18 +778,20 @@ Eina_Bool settingmgr_get_timeout_freeze_state(struct setting_mgr *mgr)
* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void settingmgr_lang_changed(struct setting_mgr *mgr)
+void CSettingMgr::LangChanged(void)
{
+ ASSERT(m);
+
struct _settinginfo *sinfo;
Eina_List *l;
void* obj;
- if (!mgr || !mgr->view_list) {
+ if (!m->view_list) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FOREACH(mgr->view_list, l, obj) {
+ EINA_LIST_FOREACH(m->view_list, l, obj) {
sinfo = (struct _settinginfo *) obj;
if (!sinfo || !sinfo->sclass) {
_ERR("settings info is NULL");