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-powersaving-customed.h>
24 static int setting_powersaving_customed_create(void *cb);
25 static int setting_powersaving_customed_destroy(void *cb);
26 static int setting_powersaving_customed_update(void *cb);
27 static int setting_powersaving_customed_cleanup(void *cb);
29 setting_view setting_view_powersaving_customed = {
30 .create = setting_powersaving_customed_create,
31 .destroy = setting_powersaving_customed_destroy,
32 .update = setting_powersaving_customed_update,
33 .cleanup = setting_powersaving_customed_cleanup,
36 /* ***************************************************
40 ***************************************************/
42 static int setting_powersaving_customed_create(void *cb)
45 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
47 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
49 Evas_Object *scroller = NULL;
51 /* add basic layout */
52 setting_push_layout_navi_bar_genlist(ad->win_main_layout,
54 _(KeyStr_Powersaving_Customed),
55 _("IDS_COM_BODY_BACK"),
57 setting_powersaving_customed_click_softkey_cancel_cb,
58 NULL, ad, &scroller, ad->navi_bar);
59 Elm_Object_Item *item = NULL;
61 item = elm_genlist_item_append(scroller, &itc_seperator,
63 ELM_GENLIST_ITEM_NONE, NULL, NULL);
64 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
65 char *str_value = NULL;
67 setting_enable_expandable_genlist(scroller, ad, setting_powersaving_ug_exp_cb,NULL);
68 str_value = get_pa_powersaving_at_str();
70 setting_create_Gendial_exp_parent_field(scroller,
74 KeyStr_Powersaving_AT,
77 if (ad->data_saving_at) {
78 ad->data_saving_at->int_slp_setting_binded =
79 INT_SLP_SETTING_POWERSAVING_AT;
81 SETTING_TRACE_ERROR("ad->data_back is NULL");
83 __BACK_POINTER_SET(ad->data_saving_at);
86 setting_create_Gendial_field_def(scroller, &itc_multiline_text, NULL,
87 ad, SWALLOW_Type_LAYOUT_SPECIALIZTION,
89 "Turn off each settings when it is not in use.",
94 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI, &value);
96 SETTING_TRACE_ERROR("Failed to get vconf value");
100 ad->data_wifi_off = setting_create_Gendial_field_def(scroller,
102 setting_powersaving_customed_mouse_up_Gendial_list_cb,
108 setting_powersaving_customed_use_chk_btn_cb);
109 if (ad->data_wifi_off) {
110 __BACK_POINTER_SET(ad->data_wifi_off);
111 ad->data_wifi_off->userdata = ad;
113 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
117 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT, &value);
119 SETTING_TRACE_ERROR("Failed to get vconf value");
122 ad->data_bt_off = setting_create_Gendial_field_def(scroller,
124 setting_powersaving_customed_mouse_up_Gendial_list_cb,
129 setting_powersaving_customed_use_chk_btn_cb);
130 if (ad->data_bt_off) {
131 __BACK_POINTER_SET(ad->data_bt_off);
132 ad->data_bt_off->userdata = ad;
134 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
138 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS, &value);
140 SETTING_TRACE_ERROR("Failed to get vconf value");
143 ad->data_gps_off = setting_create_Gendial_field_def(scroller,
145 setting_powersaving_customed_mouse_up_Gendial_list_cb,
151 setting_powersaving_customed_use_chk_btn_cb);
152 if (ad->data_gps_off) {
153 __BACK_POINTER_SET(ad->data_gps_off);
154 ad->data_gps_off->userdata = ad;
156 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
159 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC, &value);
161 SETTING_TRACE_ERROR("Failed to get vconf value");
164 ad->data_sync_off = setting_create_Gendial_field_def(scroller,
166 setting_powersaving_customed_mouse_up_Gendial_list_cb,
172 setting_powersaving_customed_use_chk_btn_cb);
173 if (ad->data_sync_off) {
174 __BACK_POINTER_SET(ad->data_sync_off);
175 ad->data_sync_off->userdata = ad;
177 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
181 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT, &value);
183 SETTING_TRACE_ERROR("Failed to get vconf value");
186 ad->data_hotspot_off = setting_create_Gendial_field_def(scroller,
188 setting_powersaving_customed_mouse_up_Gendial_list_cb,
194 setting_powersaving_customed_use_chk_btn_cb);
195 if (ad->data_hotspot_off) {
196 __BACK_POINTER_SET(ad->data_hotspot_off);
197 ad->data_hotspot_off->userdata = ad;
199 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
203 item = elm_genlist_item_append(scroller, &itc_seperator,
205 ELM_GENLIST_ITEM_NONE, NULL, NULL);
206 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
208 /* ADJUST BRIGHTNESS */
211 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS, &value);
213 SETTING_TRACE_ERROR("Failed to get vconf value");
215 adjust_value = value;
217 ad->data_adjust_bright = setting_create_Gendial_field_def(scroller,
219 setting_powersaving_customed_mouse_up_Gendial_list_cb,
221 SWALLOW_Type_1TOGGLE,
223 KeyStr_Adjust_Bright,
225 setting_powersaving_customed_use_chk_btn_cb);
226 if (ad->data_adjust_bright) {
227 __BACK_POINTER_SET(ad->data_adjust_bright);
228 ad->data_adjust_bright->userdata = ad;
230 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
235 str_value = setting_powersaving_ug_get_brightness_str();
236 ad->data_brightness =
237 setting_create_Gendial_field_def(scroller, &itc_2text_3,
238 setting_powersaving_customed_mouse_up_Gendial_list_cb,
239 ad, SWALLOW_Type_INVALID, NULL,
240 NULL, 0, KeyStr_Brightness,
242 if (ad->data_brightness) {
243 ad->data_brightness->userdata = ad;
244 __BACK_POINTER_SET(ad->data_screen_timeout);
246 SETTING_TRACE_ERROR("ad->data_br is NULL");
252 item = elm_genlist_item_append(scroller, &itc_seperator,
254 ELM_GENLIST_ITEM_NONE, NULL, NULL);
255 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
259 str_value = get_pa_screen_timeout_str();
260 ad->data_screen_timeout =
261 setting_create_Gendial_exp_parent_field(scroller,
264 SWALLOW_Type_INVALID,
265 KeyStr_Screen_Timeout,
268 if (ad->data_screen_timeout) {
269 ad->data_screen_timeout->int_slp_setting_binded =
270 INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT;
272 SETTING_TRACE_ERROR("ad->data_back is NULL");
274 __BACK_POINTER_SET(ad->data_screen_timeout);
277 if (!adjust_value && ad->data_brightness) {
278 setting_disable_genlist_item(ad->data_brightness->item);
281 setting_view_powersaving_customed.is_create = 1;
283 return SETTING_RETURN_SUCCESS;
286 static int setting_powersaving_customed_destroy(void *cb)
290 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
292 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
294 evas_object_del(ad->popup);
298 elm_naviframe_item_pop(ad->navi_bar);
300 setting_view_powersaving_customed.is_create = 0;
301 return SETTING_RETURN_SUCCESS;
304 static int setting_powersaving_customed_update(void *cb)
308 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
309 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
310 if (ad->data_brightness)
312 ad->data_brightness->sub_desc = setting_powersaving_ug_get_brightness_str();
313 elm_object_item_data_set(ad->data_brightness->item, ad->data_brightness);
314 elm_genlist_item_update(ad->data_brightness->item);
316 return SETTING_RETURN_SUCCESS;
320 static int setting_powersaving_customed_cleanup(void *cb)
324 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
325 setting_powersaving_customed_destroy(cb);
327 return SETTING_RETURN_SUCCESS;
330 /* ***************************************************
334 ***************************************************/
336 /* ***************************************************
340 ***************************************************/
343 setting_powersaving_customed_click_softkey_cancel_cb(void *data,
349 retm_if(data == NULL, "Data parameter is NULL");
350 SettingPowersavingUG *ad = (SettingPowersavingUG *) data;
352 setting_view_change(&setting_view_powersaving_customed,
353 &setting_view_powersaving_main, ad);
357 static void setting_powersaving_customed_mouse_up_Gendial_list_cb(void *data,
363 setting_retm_if(data == NULL, "Data parameter is NULL");
365 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
366 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
367 elm_genlist_item_selected_set(item, 0);
368 Setting_GenGroupItem_Data *list_item =
369 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
371 SettingPowersavingUG *ad = (SettingPowersavingUG *) data;
373 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
375 if (!safeStrCmp(KeyStr_Brightness, list_item->keyStr)) {
376 setting_view_change(&setting_view_powersaving_customed,
377 &setting_view_powersaving_brightness, ad);
381 const char *vconf = NULL;
382 if (!safeStrCmp(KeyStr_WIFI_Off, list_item->keyStr)) {
383 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI;
384 } else if (!safeStrCmp(KeyStr_BT_Off, list_item->keyStr)) {
385 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT;
386 } else if (!safeStrCmp(KeyStr_GPS_Off, list_item->keyStr)) {
387 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS;
388 } else if (!safeStrCmp(KeyStr_SYNC_Off, list_item->keyStr)) {
389 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC;
390 } else if (!safeStrCmp(KeyStr_HOTSPOT_Off, list_item->keyStr)) {
391 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT;
392 } else if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr)) {
393 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS;
395 int old_status = elm_check_state_get(list_item->eo_check);
396 int ret = vconf_set_bool(vconf, !old_status);
397 setting_retm_if(0 != ret, "Failed to set vconf [%s]", vconf);
399 list_item->chk_status = !old_status;
400 elm_check_state_set(list_item->eo_check, list_item->chk_status);
401 if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr) && ad->data_brightness) {
402 if (0 == list_item->chk_status) {
403 setting_disable_genlist_item(ad->data_brightness->item);
405 setting_enable_genlist_item(ad->data_brightness->item);
413 setting_powersaving_customed_use_chk_btn_cb(void *data, Evas_Object *obj,
418 retm_if(data == NULL, "Data parameter is NULL");
419 Setting_GenGroupItem_Data *list_item =
420 (Setting_GenGroupItem_Data *) data;
421 SettingPowersavingUG *ad = list_item->userdata;
423 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
425 const char *vconf = NULL;
426 if (!safeStrCmp(KeyStr_WIFI_Off, list_item->keyStr)) {
427 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI;
428 } else if (!safeStrCmp(KeyStr_BT_Off, list_item->keyStr)) {
429 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT;
430 } else if (!safeStrCmp(KeyStr_GPS_Off, list_item->keyStr)) {
431 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS;
432 } else if (!safeStrCmp(KeyStr_SYNC_Off, list_item->keyStr)) {
433 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC;
434 } else if (!safeStrCmp(KeyStr_HOTSPOT_Off, list_item->keyStr)) {
435 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT;
436 } else if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr)) {
437 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS;
440 int err = vconf_set_bool(vconf, list_item->chk_status);
441 if (0 != err) { /* rollback */
442 SETTING_TRACE_ERROR("Set vconf Failed");
443 list_item->chk_status = !list_item->chk_status;
444 elm_check_state_set(obj, list_item->chk_status);
446 if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr) && ad->data_brightness) {
447 if (0 == list_item->chk_status) {
448 setting_disable_genlist_item(ad->data_brightness->item);
450 setting_enable_genlist_item(ad->data_brightness->item);