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-reset.h>
22 #include <ITapiModem.h>
23 #include <TapiUtility.h>
24 #include <tapi_common.h>
27 #define UG_MODULE_API __attribute__ ((visibility("default")))
30 static void setting_reset_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
33 SettingResetUG *ad = (SettingResetUG *) data;
34 setting_view_update(&setting_view_reset_main, ad);
37 static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
38 service_h service, void *priv)
40 setting_retvm_if((!priv), NULL, "!priv");
42 SettingResetUG *resetUG = priv;
45 resetUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
46 resetUG->win_get = (Evas_Object *) ug_get_window();
48 evas_object_show(resetUG->win_main_layout);
49 resetUG->evas = evas_object_evas_get(resetUG->win_main_layout);
51 setting_retvm_if(resetUG->win_main_layout == NULL, NULL,
52 "cannot get main window ");
53 setting_create_Gendial_itc("multiline/1text", &(resetUG->itc_1text));
54 setting_create_Gendial_itc("dialogue/bg/1icon", &(resetUG->itc_1icon));
56 /* creating a view. */
57 setting_view_node_table_register(&setting_view_reset_main, NULL);
58 setting_view_node_table_register(&setting_view_reset_settings, &setting_view_reset_main);
59 setting_view_node_set_cur_view(&setting_view_reset_main);
61 setting_view_create(&setting_view_reset_main, (void *)resetUG);
62 evas_object_event_callback_add(resetUG->win_main_layout,
64 setting_reset_ug_cb_resize, resetUG);
65 return resetUG->ly_main;
68 static void setting_reset_ug_on_start(ui_gadget_h ug, service_h service,
73 static void setting_reset_ug_on_pause(ui_gadget_h ug, service_h service,
78 static void setting_reset_ug_on_resume(ui_gadget_h ug, service_h service,
83 static void setting_reset_ug_on_destroy(ui_gadget_h ug, service_h service,
87 setting_retm_if((!priv), "!priv");
88 SettingResetUG *resetUG = priv;
90 evas_object_event_callback_del(resetUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_reset_ug_cb_resize); /* fix flash issue for gallery */
92 /* delete the allocated objects. */
93 setting_view_destroy(&setting_view_reset_settings, resetUG);
94 setting_view_destroy(&setting_view_reset_main, resetUG);
96 if (NULL != ug_get_layout(resetUG->ug)) {
97 evas_object_hide((Evas_Object *) ug_get_layout(resetUG->ug));
98 evas_object_del((Evas_Object *) ug_get_layout(resetUG->ug));
104 static void setting_reset_ug_on_message(ui_gadget_h ug, service_h msg,
105 service_h service, void *priv)
110 static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
111 service_h service, void *priv)
114 setting_retm_if(!priv, "!priv");
115 SettingResetUG *ad = (SettingResetUG *) priv;
117 case UG_EVENT_LOW_MEMORY:
119 case UG_EVENT_LOW_BATTERY:
121 case UG_EVENT_LANG_CHANGE:
123 /* navigation item in reset setting view */
124 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
126 elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR));
128 /* navigation item in reset main view */
129 navi_it = elm_naviframe_bottom_item_get(ad->navi_bar);
131 elm_object_item_text_set(navi_it, _("IDS_COM_BODY_RESET"));
133 if (ad->main_scroller)
135 elm_genlist_realized_items_update(ad->main_scroller);
137 SETTING_TRACE("ad->main_scroller:%p", ad->main_scroller);
141 Elm_Object_Item *item = NULL;
142 item = elm_toolbar_first_item_get(ad->controllbar);
145 #if SUPPORT_BOTTOM_BTNS
146 elm_object_item_text_set(item, _("IDS_COM_BODY_RESET"));
148 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
149 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
150 elm_object_text_set(eo_btn, _("IDS_COM_SK_CANCEL"));
154 item = elm_toolbar_last_item_get(ad->controllbar);
157 #if SUPPORT_BOTTOM_BTNS
158 elm_object_item_text_set(item, _("IDS_COM_SK_CANCEL"));
160 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
161 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
162 elm_object_text_set(eo_btn, _("IDS_COM_BODY_RESET"));
166 Evas_Object *sub_layout = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
169 Evas_Object *select_all_layout = elm_object_part_content_get(sub_layout, "search_bar");
170 if (select_all_layout) {
171 elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
176 elm_genlist_realized_items_update(ad->reset_list);
178 setting_reset_result_popup_update(ad);
183 case UG_EVENT_ROTATE_PORTRAIT:
185 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
187 case UG_EVENT_ROTATE_LANDSCAPE:
189 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
191 case UG_EVENT_REGION_CHANGE:
198 static void setting_reset_ug_on_key_event(ui_gadget_h ug,
199 enum ug_key_event event,
200 service_h service, void *priv)
205 case UG_KEY_EVENT_END:
213 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
216 SettingResetUG *resetUG = calloc(1, sizeof(SettingResetUG));
217 setting_retvm_if(!resetUG, -1, "Create SettingResetUG obj failed");
219 ops->create = setting_reset_ug_on_create;
220 ops->start = setting_reset_ug_on_start;
221 ops->pause = setting_reset_ug_on_pause;
222 ops->resume = setting_reset_ug_on_resume;
223 ops->destroy = setting_reset_ug_on_destroy;
224 ops->message = setting_reset_ug_on_message;
225 ops->event = setting_reset_ug_on_event;
226 ops->key_event = setting_reset_ug_on_key_event;
228 ops->opt = UG_OPT_INDICATOR_ENABLE;
233 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
236 struct SettingResetUG *resetUG;
237 setting_retm_if(!ops, "ops == NULL");
244 /* ***************************************************
248 ***************************************************/
249 static void __ask_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
251 if (btn_type(obj) == POPUP_RESPONSE_OK) {
252 elm_exit();//exit the Setting app
256 SettingResetUG *ad = data;
258 evas_object_del(ad->ask_popup);
259 ad->ask_popup = NULL;
263 void setting_reset_result_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
267 SettingResetUG *ad = data;
268 if (btn_type(obj) == POPUP_RESPONSE_OK) {
271 evas_object_del(ad->notify);
275 if (ad->old_notify) {
276 evas_object_del(ad->old_notify);
277 ad->old_notify = NULL;
281 void setting_reset_result_popup_update(void *data)
285 SettingResetUG *ad = data;
287 elm_object_part_text_set(ad->notify, "title,text", _(RESET_RESULT_STR));
288 Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
291 elm_object_text_set(btn, _("IDS_COM_SK_OK"));
293 Evas_Object *genlist = elm_object_content_get(ad->notify);
296 elm_genlist_realized_items_update(genlist);
297 elm_object_content_set(ad->notify, genlist);
299 //evas_object_show(ad->notify);
304 static void __tapi_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
307 SETTING_TRACE("result:%d", result);
309 int setting_reset_flight_mode()
312 TapiHandle *handle = tel_init(NULL);
314 SETTING_TRACE_ERROR("tel_init error");
317 //if callback is NULL,it will return failed directly.
318 if (tel_set_flight_mode(handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __tapi_flight_mode_cb, NULL) == 0) {
319 #if SUPPORT_RUN_SYSTEM_COMMAND
320 ret = excuteCmd(SETTING_POSTINST_FILE, 1, "flightmode");
322 ret = vconf_set_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, FALSE);
325 SETTING_TRACE_ERROR("tel_set_flight_mode error");
329 if (tel_deinit(handle) != 0) {
330 SETTING_TRACE_ERROR("tel_deinit error");
335 int setting_reset_rotation_lock(void)
337 #if SUPPORT_RUN_SYSTEM_COMMAND
338 return excuteCmd(SETTING_POSTINST_FILE, 1, "rotationLock");
340 return vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, TRUE);