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 <setting-cfg.h>
23 #include <ITapiModem.h>
24 #include <TapiUtility.h>
25 #include <tapi_common.h>
26 #include <setting-cfg.h>
29 #define UG_MODULE_API __attribute__ ((visibility("default")))
32 static void setting_reset_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
35 SettingResetUG *ad = (SettingResetUG *) data;
36 setting_view_update(&setting_view_reset_main, ad);
39 static void *setting_reset_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
40 app_control_h service, void *priv)
42 setting_retvm_if((!priv), NULL, "!priv");
44 SettingResetUG *resetUG = priv;
47 resetUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
48 resetUG->win_get = (Evas_Object *) ug_get_window();
50 evas_object_show(resetUG->win_main_layout);
51 resetUG->evas = evas_object_evas_get(resetUG->win_main_layout);
53 setting_retvm_if(resetUG->win_main_layout == NULL, NULL,
54 "cannot get main window ");
56 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
58 setting_create_Gendial_itc("multiline_sub", &(resetUG->itc_1text));
59 setting_create_Gendial_itc("1icon", &(resetUG->itc_1icon));
61 /* creating a view. */
62 setting_view_node_table_register(&setting_view_reset_main, NULL);
63 setting_view_node_table_register(&setting_view_reset_settings, &setting_view_reset_main);
64 setting_view_node_set_cur_view(&setting_view_reset_main);
66 setting_view_create(&setting_view_reset_main, (void *)resetUG);
67 evas_object_event_callback_add(resetUG->win_main_layout,
69 setting_reset_ug_cb_resize, resetUG);
70 return resetUG->ly_main;
73 static void setting_reset_ug_on_start(ui_gadget_h ug, app_control_h service,
78 static void setting_reset_ug_on_pause(ui_gadget_h ug, app_control_h service,
83 static void setting_reset_ug_on_resume(ui_gadget_h ug, app_control_h service,
88 static void setting_reset_ug_on_destroy(ui_gadget_h ug, app_control_h service,
92 setting_retm_if((!priv), "!priv");
93 SettingResetUG *resetUG = priv;
95 evas_object_event_callback_del(resetUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_reset_ug_cb_resize); /* fix flash issue for gallery */
97 /* delete the allocated objects. */
98 setting_view_destroy(&setting_view_reset_settings, resetUG);
99 setting_view_destroy(&setting_view_reset_main, resetUG);
101 if (NULL != ug_get_layout(resetUG->ug)) {
102 evas_object_hide((Evas_Object *) ug_get_layout(resetUG->ug));
103 evas_object_del((Evas_Object *) ug_get_layout(resetUG->ug));
109 static void setting_reset_ug_on_message(ui_gadget_h ug, app_control_h msg,
110 app_control_h service, void *priv)
115 static void setting_reset_ug_on_event(ui_gadget_h ug, enum ug_event event,
116 app_control_h service, void *priv)
119 setting_retm_if(!priv, "!priv");
120 SettingResetUG *ad = (SettingResetUG *) priv;
122 case UG_EVENT_LOW_MEMORY:
124 case UG_EVENT_LOW_BATTERY:
126 case UG_EVENT_LANG_CHANGE:
128 /* navigation item in reset setting view */
129 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
131 elm_object_item_text_set(navi_it, _(RESET_SETTINGS_STR));
133 /* navigation item in reset main view */
134 navi_it = elm_naviframe_bottom_item_get(ad->navi_bar);
136 elm_object_item_text_set(navi_it, _("IDS_COM_BODY_RESET"));
138 if (ad->main_scroller)
140 elm_genlist_realized_items_update(ad->main_scroller);
142 SETTING_TRACE("ad->main_scroller:%p", ad->main_scroller);
146 Elm_Object_Item *item = NULL;
147 item = elm_toolbar_first_item_get(ad->controllbar);
150 #if SUPPORT_BOTTOM_BTNS
151 elm_object_item_text_set(item, _("IDS_COM_BODY_RESET"));
153 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
154 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
155 elm_object_text_set(eo_btn, _("IDS_COM_SK_CANCEL"));
159 item = elm_toolbar_last_item_get(ad->controllbar);
162 #if SUPPORT_BOTTOM_BTNS
163 elm_object_item_text_set(item, _("IDS_COM_SK_CANCEL"));
165 Evas_Object *eo_btn = elm_object_item_part_content_get(item, "object");
166 setting_retm_if(eo_btn == NULL, "get eo_lbtn failed");
167 elm_object_text_set(eo_btn, _("IDS_COM_BODY_RESET"));
171 Evas_Object *sub_layout = elm_object_part_content_get(ad->view_layout, "elm.swallow.contents");
174 Evas_Object *select_all_layout = elm_object_part_content_get(sub_layout, "search_bar");
175 if (select_all_layout) {
176 elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
181 elm_genlist_realized_items_update(ad->reset_list);
183 setting_reset_result_popup_update(ad);
188 case UG_EVENT_ROTATE_PORTRAIT:
190 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
192 case UG_EVENT_ROTATE_LANDSCAPE:
194 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
196 case UG_EVENT_REGION_CHANGE:
203 static void setting_reset_ug_on_key_event(ui_gadget_h ug,
204 enum ug_key_event event,
205 app_control_h service, void *priv)
210 case UG_KEY_EVENT_END:
218 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
221 SettingResetUG *resetUG = calloc(1, sizeof(SettingResetUG));
222 setting_retvm_if(!resetUG, -1, "Create SettingResetUG obj failed");
224 ops->create = setting_reset_ug_on_create;
225 ops->start = setting_reset_ug_on_start;
226 ops->pause = setting_reset_ug_on_pause;
227 ops->resume = setting_reset_ug_on_resume;
228 ops->destroy = setting_reset_ug_on_destroy;
229 ops->message = setting_reset_ug_on_message;
230 ops->event = setting_reset_ug_on_event;
231 ops->key_event = setting_reset_ug_on_key_event;
233 ops->opt = UG_OPT_INDICATOR_ENABLE;
239 *@brief callback function for reset UG.the exit the reset mode, it will be called to destory the resource.
241 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
244 struct SettingResetUG *resetUG;
245 setting_retm_if(!ops, "ops == NULL");
253 /* ***************************************************
257 ***************************************************/
259 *@brief callback function for reset result.when you press the button in the popup, it will be called.
261 void setting_reset_result_popup_resp_cb(void *data, Evas_Object *obj, void *event_info)
265 SettingResetUG *ad = data;
266 if (btn_type(obj) == POPUP_RESPONSE_OK) {
269 if(ad->reset_process) {
270 evas_object_del(ad->reset_process);
271 ad->reset_process = NULL;
274 evas_object_del(ad->notify);
278 if (ad->old_notify) {
279 evas_object_del(ad->old_notify);
280 ad->old_notify = NULL;
285 void setting_reset_result_popup_update(void *data)
289 SettingResetUG *ad = data;
291 elm_object_part_text_set(ad->notify, "title,text", _(RESET_SETTINGS_STR));
292 Evas_Object *btn = elm_object_part_content_get(ad->notify, "button1");
293 elm_object_style_set(btn, "popup");
296 elm_object_text_set(btn, _("IDS_COM_SK_OK"));
299 Evas_Object *genlist = elm_object_content_get(ad->notify);
302 elm_genlist_realized_items_update(genlist);
303 elm_object_content_set(ad->notify, genlist);
306 //evas_object_show(ad->notify);
311 *@brief callback function for reset flight mode.when reset the flight mode,it will be called.
313 static void __tapi_flight_mode_cb(TapiHandle *handle, int result, void *data, void *user_data)
316 SETTING_TRACE("result:%d", result);
320 *@brief reset function for reset flight mode.
322 int setting_reset_flight_mode()
325 TapiHandle *handle = tel_init(NULL);
327 SETTING_TRACE_ERROR("tel_init error");
330 //if callback is NULL,it will return failed directly.
331 if (tel_set_flight_mode(handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __tapi_flight_mode_cb, NULL) == 0) {
332 #if SUPPORT_RUN_SYSTEM_COMMAND
333 ret = excuteCmd(SETTING_POSTINST_FILE, 1, "flightmode");
335 ret = vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, FALSE);
339 SETTING_TRACE_ERROR("tel_set_flight_mode error");
343 if (tel_deinit(handle) != 0) {
344 SETTING_TRACE_ERROR("tel_deinit error");
350 * @brief lock the screen,make it does not support rotation.
352 int setting_reset_rotation_lock(void)
354 #if SUPPORT_RUN_SYSTEM_COMMAND
355 return excuteCmd(SETTING_POSTINST_FILE, 1, "rotationLock");
357 return vconf_set_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, TRUE);
361 static Setting_Cfg_Node_T reset_node_array[] = {
362 {"IDS_ST_MBODY_FACTORY_RESET", NULL, "search_key:IDS_ST_MBODY_FACTORY_RESET", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
366 *@brief init function for setting module search,it will add the module name into the search database.
368 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char** applocale)
371 SETTING_TRACE(">> setting-reset-efl DB search code");
373 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
375 Eina_List **pplist = (Eina_List**)priv;
377 int size = sizeof(reset_node_array)/sizeof(reset_node_array[0]);
378 for(i=0;i<size;i++) {
379 Setting_Cfg_Node_T * node = setting_plugin_search_item_subindex_add(reset_node_array[i].key_name, reset_node_array[i].ug_args, IMG_Reset,reset_node_array[i].item_type, reset_node_array[i].data, "Reset");
380 *pplist = eina_list_append(*pplist, node);