4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 * This file is part of org.tizen.setting
7 * Written by Hyejin Kim <hyejin0906.kim@samsung.com>
9 * PROPRIETARY/CONFIDENTIAL
11 * This software is the confidential and proprietary information of
12 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
13 * disclose such Confidential Information and shall use it only in
14 * accordance with the terms of the license agreement you entered
15 * into with SAMSUNG ELECTRONICS.
17 * SAMSUNG make no representations or warranties about the suitability
18 * of the software, either express or implied, including but not limited
19 * to the implied warranties of merchantability, fitness for a particular
20 * purpose, or non-infringement. SAMSUNG shall not be liable for any
21 * damages suffered by licensee as a result of using, modifying or
22 * distributing this software or its derivatives.
25 #include <setting-common-view.h>
27 #include <Elementary.h>
29 #include <setting-common-data-error.h>
30 #include <setting-debug.h>
32 #define MAX_VIEWNODE_NUM 15
33 typedef struct _SettingViewNode {
35 setting_view *topview;
37 static setting_view *g_cur_view;; /* use by 'End Key' process */
38 static SettingViewNode g_view_node_table[MAX_VIEWNODE_NUM];
39 static int g_view_node_table_cur_size = 0;
41 int setting_view_node_set_cur_view(setting_view *view)
47 setting_view *setting_view_node_get_cur_view()
52 int setting_view_node_table_intialize()
55 g_view_node_table_cur_size = 0;
60 setting_view_node_table_register(setting_view *view, setting_view *topview)
63 if (g_view_node_table_cur_size >= MAX_VIEWNODE_NUM) {
64 return SETTING_RETURN_FAIL;
67 g_view_node_table[g_view_node_table_cur_size].view = view;
68 g_view_node_table[g_view_node_table_cur_size].topview = topview;
69 g_view_node_table_cur_size++;
73 int setting_view_cb_at_endKey(void *cb)
77 SettingViewNode *viewnode = NULL;
78 for (; idx < g_view_node_table_cur_size; idx++) {
79 if (g_cur_view == g_view_node_table[idx].view) {
80 viewnode = &(g_view_node_table[idx]);
84 if (viewnode && viewnode->view && viewnode->topview) {
85 setting_view_change(viewnode->view, viewnode->topview, cb);
90 setting_view *setting_view_get_topview(setting_view *view)
93 retv_if(NULL == view, NULL);
95 SettingViewNode *viewnode = NULL;
96 for (; idx < g_view_node_table_cur_size; idx++) {
97 if (view == g_view_node_table[idx].view) {
98 viewnode = &(g_view_node_table[idx]);
102 if (viewnode && viewnode->topview) {
103 return viewnode->topview;
111 int setting_view_create(setting_view *view, void *cb)
114 setting_retvm_if(!view || !cb , SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "Invalid arguement");
116 int ret = SETTING_RETURN_FAIL;
118 if (!view->is_create && view->create) {//error handle:create only when the view doesn't exit
119 ret = view->create(cb);
125 int setting_view_destroy(setting_view *view, void *cb)
128 setting_retvm_if(!view || !cb , SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "Invalid arguement");
130 int ret = SETTING_RETURN_FAIL;
132 if (view->is_create && view->destroy) {//error handle:destroy only when the view exits
133 ret = view->destroy(cb);
139 int setting_view_update(setting_view *view, void *cb)
142 setting_retvm_if(!view || !cb , SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "Invalid arguement");
144 int ret = SETTING_RETURN_FAIL;
146 if (view->is_create && view->update) {//error handle:update only when the view exits
147 ret = view->update(cb);
153 int setting_view_cleanup(setting_view *view, void *cb)
156 setting_retvm_if(!view || !cb , SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "Invalid arguement");
158 int ret = SETTING_RETURN_FAIL;
160 if (view->is_create && view->cleanup) {//error handle:cleanup only when the view exits
161 ret = view->cleanup(cb);
168 setting_view_change(setting_view *from_view, setting_view *to_view, void *cb)
171 setting_retvm_if(!from_view || !to_view || !cb ,
172 SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
173 "Invalid arguement");
175 int ret = SETTING_RETURN_SUCCESS;
176 if (from_view == setting_view_get_topview(to_view)) {
177 //from a parent view to his child view, don't need cleanup parent view
179 //from a child view to his parent view, need cleanup child view
180 ret = setting_view_cleanup(from_view, cb);
183 if (ret == SETTING_RETURN_FAIL) {
184 return SETTING_RETURN_FAIL;
187 if (to_view->is_create == 1) {
188 ret = setting_view_update(to_view, cb);
190 ret = setting_view_create(to_view, cb);
192 g_cur_view = to_view; /* compute new value of g_cur_view. */