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.
22 #include <setting-reset-main.h>
26 #define RESULT_FONT_SIZE 28//18
27 #define ITEM_NAME_FONT_SIZE 35//22
29 static int setting_reset_main_create(void *cb);
30 static int setting_reset_main_destroy(void *cb);
31 static int setting_reset_main_update(void *cb);
32 static int setting_reset_main_cleanup(void *cb);
34 setting_view setting_view_reset_main = {
35 .create = setting_reset_main_create,
36 .destroy = setting_reset_main_destroy,
37 .update = setting_reset_main_update,
38 .cleanup = setting_reset_main_cleanup,
41 static void setting_reset_main_click_softkey_cancel_cb(void *data,
44 #if SUPPORT_RESET_DETAILS
45 static void setting_reset_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info);
48 /* ***************************************************
52 ***************************************************/
53 static int setting_reset_main_create(void *cb)
57 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
59 SettingResetUG *ad = (SettingResetUG *) cb;
60 Evas_Object *scroller = NULL;
61 #if SIMPLY_SUPPORT_ALL_RESET
63 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
65 _("IDS_COM_BODY_RESET"),
66 _("IDS_COM_BODY_BACK"), NULL,
67 setting_reset_main_click_softkey_cancel_cb,
71 setting_create_Gendial_field_def(scroller, &(ad->itc_1text), NULL,
72 ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
73 NULL, NULL, 0, RESET_ALL_DESC,
75 elm_genlist_item_select_mode_set(elm_genlist_item_append(scroller, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
76 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
78 Setting_GenGroupItem_Data *item_data =
79 (Setting_GenGroupItem_Data *) calloc(1,
81 (Setting_GenGroupItem_Data));
82 setting_retvm_if(!item_data, SETTING_RETURN_FAIL, "calloc failed");
83 item_data->userdata = ad;
84 item_data->keyStr = (char *)g_strdup(RESET_ALL);
85 item_data->swallow_type = SWALLOW_Type_1BUTTON;
87 item_data->chk_change_cb = __reset_all_button_cb;
88 item_data->item = elm_genlist_item_append(scroller, &(ad->itc_1icon), item_data, NULL,
89 ELM_GENLIST_ITEM_NONE,
91 setting_view_reset_main.is_create = 1;
92 ad->main_scroller = scroller;
93 return SETTING_RETURN_SUCCESS;
96 #if SUPPORT_RESET_DETAILS
98 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
100 _("IDS_COM_BODY_RESET"),
101 _("IDS_COM_BODY_BACK"), NULL,
102 setting_reset_main_click_softkey_cancel_cb,
106 Elm_Object_Item *item = NULL;;
109 elm_genlist_item_append(scroller, &itc_seperator, NULL, NULL,
110 ELM_GENLIST_ITEM_NONE, NULL, NULL);
111 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
113 /* 1. Reset settings */
114 setting_create_Gendial_field_def(scroller, &itc_1text,
115 setting_reset_main_mouse_up_Gendial_list_cb,ad,
116 SWALLOW_Type_INVALID,
118 0, RESET_SETTINGS_STR, NULL, NULL);
119 #if SUPPORT_SIM_CARD_PROFILE
120 /* 2. SIM card profile settings */
122 int is_sim_profile_enabled = csc_svc_sim_auto_setting_chk_feature_enable();
124 int value = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
125 setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
126 if (is_sim_profile_enabled && VCONFKEY_TELEPHONY_SIM_INSERTED == value) {
127 setting_create_Gendial_field_def(scroller, &itc_1text,
128 setting_reset_main_mouse_up_Gendial_list_cb,ad,
129 SWALLOW_Type_INVALID,
131 0, SIM_CARD_PROFILE_SETTINGS_STR, NULL, NULL);
133 SETTING_TRACE("is_sim_profile_enabled:%d", is_sim_profile_enabled);
134 SETTING_TRACE("value:%d", value);
137 SETTING_TRACE("TARGET MACRO disabled");
144 setting_create_Gendial_field_def(scroller, &itc_multiline_text, NULL,
145 ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
146 NULL, NULL, 0, RESET_ALL_DESC,
149 setting_view_reset_main.is_create = 1;
150 ad->main_scroller = scroller;
151 return SETTING_RETURN_SUCCESS;
155 #if SUPPORT_RESET_OLD
156 Evas_Object *navi_bar = NULL;
158 Evas_Object *controllbar = NULL;
160 Evas_Object *view_layout = elm_layout_add(ad->win_main_layout);
161 elm_layout_file_set(view_layout, SETTING_THEME_EDJ_NAME,
163 evas_object_size_hint_weight_set(view_layout, EVAS_HINT_EXPAND, 0.0);
165 /* Evas_Object * win_layout, Evas_Object * win_obj */
167 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
168 _("IDS_COM_BODY_RESET"),
169 _("IDS_COM_SK_CANCEL"),
170 _("IDS_COM_BODY_RESET"), NULL,
171 setting_reset_main_click_softkey_cancel_cb,
172 setting_reset_main_click_softkey_reset_cb,
173 NULL, ad, view_layout, &navi_bar,
175 elm_object_item_disabled_set(elm_toolbar_last_item_get
176 (controllbar), EINA_TRUE);
178 /* ******************************************create frame */
179 Setting_Done_List_Data *list_data = &(ad->list_data); /* define a handle */
181 list_data->win_main = ad->ly_main;
182 list_data->UG_data = ad;
183 list_data->ly_parent = view_layout;
184 list_data->controllbar = controllbar;
187 list_data->chk_items[idx++].item_name = KeyStr_Select_All;
194 for (; i < setting_cfg_get_category_length(); i++) {
195 SETTING_TRACE("group is:%s", _(setting_cfg_get_category_name(i)));
197 for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
198 /*SETTING_TRACE("i:%d\tj:%d", i, j);*/
199 if (Cfg_Item_unResetable ==
200 setting_cfg_get_resetable_flag_idx(i, j))
204 list_data->chk_items[idx].ug_args = ug_args =
205 setting_cfg_get_ug_args_idx(i, j);
206 list_data->chk_items[idx].item_name = item_name =
207 setting_cfg_get_keyname_idx(i, j);
209 SETTING_TRACE("process %s:\t%s",_(item_name), ug_args);
214 list_data->cur_item_num = idx;
215 SETTING_TRACE("list_data->cur_item_num:%d", list_data->cur_item_num);
216 scroller = setting_create_done_list(list_data);
217 elm_object_part_content_set(view_layout, "elm.swallow.contents", scroller);
219 ad->view_layout = view_layout;
220 ad->navi_bar = navi_bar;
221 ad->controllbar = controllbar;
222 /* *******************************************update info */
224 setting_view_reset_main.is_create = 1;
225 ad->itc_1text.func.text_get = __result_gl_text_get;
226 return SETTING_RETURN_SUCCESS;
230 static int setting_reset_main_destroy(void *cb)
234 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
236 SettingResetUG *ad = (SettingResetUG *) cb;
238 evas_object_del(ad->notify);
241 if (ad->old_notify) {
242 evas_object_del(ad->old_notify);
243 ad->old_notify = NULL;
245 if (ad->pop_progress)
247 evas_object_del(ad->pop_progress);
248 ad->pop_progress = NULL;
253 evas_object_del(ad->ask_popup);
254 ad->ask_popup = NULL;
258 ecore_animator_del(ad->animator);
262 if (ad->ly_main != NULL) {
263 evas_object_del(ad->ly_main);
264 setting_view_reset_main.is_create = 0;
267 return SETTING_RETURN_SUCCESS;
270 static int setting_reset_main_update(void *cb)
274 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
276 SettingResetUG *ad = (SettingResetUG *) cb;
278 if (ad->ly_main != NULL) {
279 evas_object_show(ad->ly_main);
282 return SETTING_RETURN_SUCCESS;
285 static int setting_reset_main_cleanup(void *cb)
289 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
291 SettingResetUG *ad = (SettingResetUG *) cb;
293 if (ad->ly_main != NULL) {
294 evas_object_hide(ad->ly_main);
297 return SETTING_RETURN_SUCCESS;
300 static void setting_reset_reboot_resp_cb(void *data, Evas_Object *obj,
304 int response_type = btn_type(obj);
305 if (POPUP_RESPONSE_OK == response_type) { // OK cliked
306 csc_svc_sim_auto_setting_clear_active_operator();
308 sysman_request_reboot();
310 } else if (POPUP_RESPONSE_CANCEL == response_type) { // cancel clicked
314 SettingResetUG *ad = data;
317 evas_object_del(ad->pop);
322 #if SUPPORT_RESET_DETAILS
324 setting_reset_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
327 setting_retm_if(data == NULL, "Data parameter is NULL");
329 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
330 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
331 elm_genlist_item_selected_set(item, 0);
333 Setting_GenGroupItem_Data *list_item =
334 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
336 SettingResetUG *ad = (SettingResetUG *) data;
338 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
340 if (!safeStrCmp(RESET_SETTINGS_STR, list_item->keyStr))
342 setting_view_change(&setting_view_reset_main, &setting_view_reset_settings, ad);
344 #if SUPPORT_SIM_CARD_PROFILE
345 else if (!safeStrCmp(SIM_CARD_PROFILE_SETTINGS_STR, list_item->keyStr))
347 SETTING_TRACE("SIM-CARD PROFILE");
349 ad->pop = setting_create_popup_with_btn(ad, ad->win_get, NULL,
350 _("IDS_ST_BODY_RESET_SIM_CARD_PROFILE_SETTINGS_TO_DEFAULT_AND_SELECT_ANOTHER_SERVICE_PROVIDER_MSG"),
351 //setting_time_reboot_resp_cb,
352 setting_reset_reboot_resp_cb,
354 dgettext("sys_string", "IDS_COM_SK_OK"),
355 _("IDS_COM_SK_CANCEL"));
364 setting_reset_main_click_softkey_cancel_cb(void *data, Evas_Object *obj,
369 retm_if(data == NULL, "Data parameter is NULL");
371 SettingResetUG *ad = (SettingResetUG *) data;
372 if (ad->list_data.selInfoPop) {
373 evas_object_del(ad->list_data.selInfoPop);
374 ad->list_data.selInfoPop = NULL;
376 /* Send destroy request */
377 ug_destroy_me(ad->ug);