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 ");
54 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
56 setting_create_Gendial_itc("multiline/1text", &(resetUG->itc_1text));
57 setting_create_Gendial_itc("dialogue/bg/1icon", &(resetUG->itc_1icon));
59 /* creating a view. */
60 setting_view_node_table_register(&setting_view_reset_main, NULL);
61 setting_view_node_table_register(&setting_view_reset_settings, &setting_view_reset_main);
62 setting_view_node_set_cur_view(&setting_view_reset_main);
64 setting_view_create(&setting_view_reset_main, (void *)resetUG);
65 evas_object_event_callback_add(resetUG->win_main_layout,
67 setting_reset_ug_cb_resize, resetUG);
68 return resetUG->ly_main;
71 static void setting_reset_ug_on_start(ui_gadget_h ug, service_h service,
76 static void setting_reset_ug_on_pause(ui_gadget_h ug, service_h service,
81 static void setting_reset_ug_on_resume(ui_gadget_h ug, service_h service,
86 static void setting_reset_ug_on_destroy(ui_gadget_h ug, service_h service,
90 setting_retm_if((!priv), "!priv");
91 SettingResetUG *resetUG = priv;
93 evas_object_event_callback_del(resetUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_reset_ug_cb_resize); /* fix flash issue for gallery */
95 /* delete the allocated objects. */
96 setting_view_destroy(&setting_view_reset_settings, resetUG);
97 setting_view_destroy(&setting_view_reset_main, resetUG);
99 if (NULL != ug_get_layout(resetUG->ug)) {
100 evas_object_hide((Evas_Object *) ug_get_layout(resetUG->ug));
101 evas_object_del((Evas_Object *) ug_get_layout(resetUG->ug));
107 static void setting_reset_ug_on_message(ui_gadget_h ug, service_h msg,
108 service_h service, void *priv)
113 static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
114 service_h service, void *priv)
117 setting_retm_if(!priv, "!priv");
118 SettingResetUG *ad = (SettingResetUG *) priv;
120 case UG_EVENT_LOW_MEMORY:
122 case UG_EVENT_LOW_BATTERY:
124 case UG_EVENT_LANG_CHANGE:
126 /* navigation item in reset setting view */
127 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
129 elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR));
131 /* navigation item in reset main view */
132 navi_it = elm_naviframe_bottom_item_get(ad->navi_bar);
134 elm_object_item_text_set(navi_it, _("IDS_COM_BODY_RESET"));
136 if (ad->main_scroller)
138 elm_genlist_realized_items_update(ad->main_scroller);
140 SETTING_TRACE("ad->main_scroller:%p", ad->main_scroller);
144 Elm_Object_Item *item = NULL;
145 item = elm_toolbar_first_item_get(ad->controllbar);
148 #if SUPPORT_BOTTOM_BTNS
149 elm_object_item_text_set(item, _("IDS_COM_BODY_RESET"));
151 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
152 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
153 elm_object_text_set(eo_btn, _("IDS_COM_SK_CANCEL"));
157 item = elm_toolbar_last_item_get(ad->controllbar);
160 #if SUPPORT_BOTTOM_BTNS
161 elm_object_item_text_set(item, _("IDS_COM_SK_CANCEL"));
163 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
164 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
165 elm_object_text_set(eo_btn, _("IDS_COM_BODY_RESET"));
169 Evas_Object *sub_layout = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
172 Evas_Object *select_all_layout = elm_object_part_content_get(sub_layout, "search_bar");
173 if (select_all_layout) {
174 elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
179 elm_genlist_realized_items_update(ad->reset_list);
181 // setting_reset_result_popup_update(ad);
186 case UG_EVENT_ROTATE_PORTRAIT:
188 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
190 case UG_EVENT_ROTATE_LANDSCAPE:
192 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
194 case UG_EVENT_REGION_CHANGE:
201 static void setting_reset_ug_on_key_event(ui_gadget_h ug,
202 enum ug_key_event event,
203 service_h service, void *priv)
208 case UG_KEY_EVENT_END:
216 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
219 SettingResetUG *resetUG = calloc(1, sizeof(SettingResetUG));
220 setting_retvm_if(!resetUG, -1, "Create SettingResetUG obj failed");
222 ops->create = setting_reset_ug_on_create;
223 ops->start = setting_reset_ug_on_start;
224 ops->pause = setting_reset_ug_on_pause;
225 ops->resume = setting_reset_ug_on_resume;
226 ops->destroy = setting_reset_ug_on_destroy;
227 ops->message = setting_reset_ug_on_message;
228 ops->event = setting_reset_ug_on_event;
229 ops->key_event = setting_reset_ug_on_key_event;
231 ops->opt = UG_OPT_INDICATOR_ENABLE;
236 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
239 struct SettingResetUG *resetUG;
240 setting_retm_if(!ops, "ops == NULL");
247 /* ***************************************************
251 ***************************************************/
253 static void __ask_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
255 if (btn_type(obj) == POPUP_RESPONSE_OK) {
256 elm_exit();//exit the Setting app
260 SettingResetUG *ad = data;
262 evas_object_del(ad->ask_popup);
263 ad->ask_popup = NULL;
268 void setting_reset_result_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
272 SettingResetUG *ad = data;
273 if (btn_type(obj) == POPUP_RESPONSE_OK) {
276 evas_object_del(ad->notify);
280 if (ad->old_notify) {
281 evas_object_del(ad->old_notify);
282 ad->old_notify = NULL;
288 * language change makes B/S on resetting "Language&Region UG"
290 void setting_reset_result_popup_update(void *data)
295 SettingResetUG *ad = data;
297 elm_object_part_text_set(ad->notify, "title,text", _(RESET_RESULT_STR));
298 Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
299 elm_object_style_set(btn, "popup_button/default");
302 elm_object_text_set(btn, _("IDS_COM_SK_OK"));
304 Evas_Object *genlist = elm_object_content_get(ad->notify);
307 elm_genlist_realized_items_update(genlist);
308 elm_object_content_set(ad->notify, genlist);
310 //evas_object_show(ad->notify);
316 static void __tapi_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
319 SETTING_TRACE("result:%d", result);
321 int setting_reset_flight_mode()
324 TapiHandle *handle = tel_init(NULL);
326 SETTING_TRACE_ERROR("tel_init error");
329 //if callback is NULL,it will return failed directly.
330 if (tel_set_flight_mode(handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __tapi_flight_mode_cb, NULL) == 0) {
331 #if SUPPORT_RUN_SYSTEM_COMMAND
332 ret = excuteCmd(SETTING_POSTINST_FILE, 1, "flightmode");
334 ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, FALSE);
337 SETTING_TRACE_ERROR("tel_set_flight_mode error");
341 if (tel_deinit(handle) != 0) {
342 SETTING_TRACE_ERROR("tel_deinit error");
347 int setting_reset_rotation_lock(void)
349 #if SUPPORT_RUN_SYSTEM_COMMAND
350 return excuteCmd(SETTING_POSTINST_FILE, 1, "rotationLock");
352 return vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, TRUE);