4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-privacy.h>
24 #define UG_MODULE_API __attribute__ ((visibility("default")))
27 static void setting_privacy_ug_cb_resize(void *data, Evas *e,
28 Evas_Object *obj, void *event_info)
30 SettingPrivacyUG *ad = (SettingPrivacyUG *) data;
31 setting_view_update(&setting_view_privacy_service, ad);
34 setting_view *__get_privacy_view_to_load(void *data, service_h service)
37 setting_retvm_if((!data), NULL, "data is NULL");
38 SettingPrivacyUG *privacyUG = (SettingPrivacyUG *)data;
40 setting_view_node_table_intialize();
42 // if argument is there, process it first
44 char *output_url = NULL;
45 int ret = service_get_operation(service, &output_url);
47 if(ret == SERVICE_ERROR_NONE
48 && 0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/configure/privacy/service")
49 || 0 == safeStrCmp(output_url, "http://samsung.com/appcontrol/operation/configure/privacy/service"))
51 setting_view_node_table_register(&setting_view_privacy_service, NULL);
52 return &setting_view_privacy_service;
55 SETTING_TRACE("output url : [%s]", output_url);
57 //setting_view_node_table_register(&setting_view_privacy_service, setting_view_privacy_main);
58 //setting_view_node_table_register(&setting_view_privacy_main, NULL);
59 //return &setting_view_privacy_main;
62 // service OK, but there's no argument
63 char *category = NULL;
64 service_get_extra_data(service, "privacy_category", &category);
66 if(0 == safeStrCmp(category, "service"))
68 setting_view_node_table_register(&setting_view_privacy_service, NULL);
69 return &setting_view_privacy_service;
72 SETTING_TRACE("category : [%s]", category);
74 //setting_view_node_table_register(&setting_view_privacy_service, setting_view_privacy_main);
75 //setting_view_node_table_register(&setting_view_privacy_main, NULL);
76 //return &setting_view_privacy_main;
81 static void *setting_privacy_ug_on_create(ui_gadget_h ug,
82 enum ug_mode mode, service_h service,
86 setting_retvm_if((!priv), NULL, "!priv");
87 SettingPrivacyUG *privacyUG = priv;
89 privacyUG->bundle_data = service;
90 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
92 /* register view node table */
93 //setting_view_node_table_intialize();
94 //setting_view_node_table_register(&setting_view_privacy_main, NULL);
96 privacyUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
97 privacyUG->win_get = (Evas_Object *) ug_get_window();
99 evas_object_show(privacyUG->win_main_layout);
100 privacyUG->evas = evas_object_evas_get(privacyUG->win_main_layout);
102 setting_retvm_if(privacyUG->win_main_layout == NULL, NULL,
103 "cannot get main window ");
106 privacyUG->bg = elm_bg_add(privacyUG->win_get);
107 elm_object_style_set(privacyUG->bg, "dialogue_field");
108 evas_object_size_hint_weight_set(privacyUG->bg, EVAS_HINT_EXPAND,
111 privacyUG->view_to_load = __get_privacy_view_to_load(privacyUG, service);
112 setting_retvm_if(NULL == privacyUG->view_to_load, NULL, "NULL == fontUG->view_to_load");
115 setting_view_node_set_cur_view(privacyUG->view_to_load);
116 setting_view_create(privacyUG->view_to_load, (void *)privacyUG);
117 evas_object_event_callback_add(privacyUG->win_main_layout,
118 EVAS_CALLBACK_RESIZE,
119 setting_privacy_ug_cb_resize, privacyUG);
121 //----------------------------------------------------------------
124 //----------------------------------------------------------------
125 setting_create_Gendial_itc("dialogue/2text.3", &(privacyUG->itc_2text_2));
127 return privacyUG->ly_main;
130 static void setting_privacy_ug_on_start(ui_gadget_h ug, service_h service,
135 static void setting_privacy_ug_on_pause(ui_gadget_h ug, service_h service,
140 static void setting_privacy_ug_on_resume(ui_gadget_h ug, service_h service,
145 static void setting_privacy_ug_on_destroy(ui_gadget_h ug, service_h service,
149 setting_retm_if((!priv), "!priv");
150 SettingPrivacyUG *privacyUG = priv;
151 evas_object_event_callback_del(privacyUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_privacy_ug_cb_resize); //fix flash issue for gallery
154 evas_object_del(privacyUG->bg);
156 privacyUG->bg = NULL;
158 // called when this shared gadget is terminated. similar with app_exit
159 setting_view_destroy(&setting_view_privacy_service, privacyUG);
161 if (NULL != ug_get_layout(privacyUG->ug)) {
162 evas_object_hide((Evas_Object *) ug_get_layout(privacyUG->ug));
163 evas_object_del((Evas_Object *) ug_get_layout(privacyUG->ug));
167 static void setting_privacy_ug_on_message(ui_gadget_h ug, service_h msg,
168 service_h service, void *priv)
173 static void setting_privacy_ug_on_event(ui_gadget_h ug,
174 enum ug_event event, service_h service,
179 case UG_EVENT_LOW_MEMORY:
181 case UG_EVENT_LOW_BATTERY:
183 case UG_EVENT_LANG_CHANGE:
185 case UG_EVENT_ROTATE_PORTRAIT:
187 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
189 case UG_EVENT_ROTATE_LANDSCAPE:
191 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
193 case UG_EVENT_REGION_CHANGE:
200 static void setting_privacy_ug_on_key_event(ui_gadget_h ug,
201 enum ug_key_event event,
202 service_h service, void *priv)
205 SettingPrivacyUG *ad = (SettingPrivacyUG *) priv;
208 case UG_KEY_EVENT_END:
210 if (elm_naviframe_top_item_get(ad->navi_bar) ==
211 elm_naviframe_bottom_item_get(ad->
216 setting_view_cb_at_endKey(ad);
225 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
228 SettingPrivacyUG *privacyUG = calloc(1, sizeof(SettingPrivacyUG));
229 setting_retvm_if(!privacyUG, -1, "Create SettingPrivacyUG obj failed");
231 ops->create = setting_privacy_ug_on_create;
232 ops->start = setting_privacy_ug_on_start;
233 ops->pause = setting_privacy_ug_on_pause;
234 ops->resume = setting_privacy_ug_on_resume;
235 ops->destroy = setting_privacy_ug_on_destroy;
236 ops->message = setting_privacy_ug_on_message;
237 ops->event = setting_privacy_ug_on_event;
238 ops->key_event = setting_privacy_ug_on_key_event;
239 ops->priv = privacyUG;
240 ops->opt = UG_OPT_INDICATOR_ENABLE;
244 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
247 struct SettingPrivacyUG *privacyUG;
248 setting_retm_if(!ops, "ops == NULL");
250 privacyUG = ops->priv;
256 /* ***************************************************
260 ** **************************************************/
263 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG