3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <setting-powersaving-customed.h>
20 static int setting_powersaving_customed_create(void *cb);
21 static int setting_powersaving_customed_destroy(void *cb);
22 static int setting_powersaving_customed_update(void *cb);
23 static int setting_powersaving_customed_cleanup(void *cb);
25 setting_view setting_view_powersaving_customed = {
26 .create = setting_powersaving_customed_create,
27 .destroy = setting_powersaving_customed_destroy,
28 .update = setting_powersaving_customed_update,
29 .cleanup = setting_powersaving_customed_cleanup,
32 /* ***************************************************
36 ***************************************************/
38 static int setting_powersaving_customed_create(void *cb)
41 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
43 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
45 Evas_Object *scroller = NULL;
47 /* add basic layout */
48 setting_push_layout_navi_bar_genlist(ad->win_main_layout,
50 _(KeyStr_Powersaving_Customed),
51 _("IDS_COM_BODY_BACK"),
53 setting_powersaving_customed_click_softkey_cancel_cb,
54 NULL, ad, &scroller, ad->navi_bar);
55 Elm_Object_Item *item = NULL;
57 item = elm_genlist_item_append(scroller, &itc_seperator,
59 ELM_GENLIST_ITEM_NONE, NULL, NULL);
60 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
61 char *str_value = NULL;
63 setting_enable_expandable_genlist(scroller, ad, setting_powersaving_ug_exp_cb,NULL);
64 str_value = get_pa_powersaving_at_str();
66 setting_create_Gendial_exp_parent_field(scroller,
70 KeyStr_Powersaving_AT,
73 if (ad->data_saving_at) {
74 ad->data_saving_at->int_slp_setting_binded =
75 INT_SLP_SETTING_POWERSAVING_AT;
77 SETTING_TRACE_ERROR("ad->data_back is NULL");
79 __BACK_POINTER_SET(ad->data_saving_at);
82 setting_create_Gendial_field_def(scroller, &itc_multiline_text, NULL,
83 ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
85 "Turn off each settings when it is not in use.",
87 elm_genlist_item_select_mode_set(elm_genlist_item_append(scroller, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
88 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
92 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI, &value);
94 SETTING_TRACE_ERROR("Failed to get vconf value");
98 ad->data_wifi_off = setting_create_Gendial_field_def(scroller,
100 setting_powersaving_customed_mouse_up_Gendial_list_cb,
106 setting_powersaving_customed_use_chk_btn_cb);
107 if (ad->data_wifi_off) {
108 __BACK_POINTER_SET(ad->data_wifi_off);
109 ad->data_wifi_off->userdata = ad;
111 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
115 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT, &value);
117 SETTING_TRACE_ERROR("Failed to get vconf value");
120 ad->data_bt_off = setting_create_Gendial_field_def(scroller,
122 setting_powersaving_customed_mouse_up_Gendial_list_cb,
127 setting_powersaving_customed_use_chk_btn_cb);
128 if (ad->data_bt_off) {
129 __BACK_POINTER_SET(ad->data_bt_off);
130 ad->data_bt_off->userdata = ad;
132 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
136 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS, &value);
138 SETTING_TRACE_ERROR("Failed to get vconf value");
141 ad->data_gps_off = setting_create_Gendial_field_def(scroller,
143 setting_powersaving_customed_mouse_up_Gendial_list_cb,
149 setting_powersaving_customed_use_chk_btn_cb);
150 if (ad->data_gps_off) {
151 __BACK_POINTER_SET(ad->data_gps_off);
152 ad->data_gps_off->userdata = ad;
154 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
157 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC, &value);
159 SETTING_TRACE_ERROR("Failed to get vconf value");
162 ad->data_sync_off = setting_create_Gendial_field_def(scroller,
164 setting_powersaving_customed_mouse_up_Gendial_list_cb,
170 setting_powersaving_customed_use_chk_btn_cb);
171 if (ad->data_sync_off) {
172 __BACK_POINTER_SET(ad->data_sync_off);
173 ad->data_sync_off->userdata = ad;
175 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
179 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT, &value);
181 SETTING_TRACE_ERROR("Failed to get vconf value");
184 ad->data_hotspot_off = setting_create_Gendial_field_def(scroller,
186 setting_powersaving_customed_mouse_up_Gendial_list_cb,
192 setting_powersaving_customed_use_chk_btn_cb);
193 if (ad->data_hotspot_off) {
194 __BACK_POINTER_SET(ad->data_hotspot_off);
195 ad->data_hotspot_off->userdata = ad;
197 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
201 item = elm_genlist_item_append(scroller, &itc_seperator,
203 ELM_GENLIST_ITEM_NONE, NULL, NULL);
204 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
206 /* ADJUST BRIGHTNESS */
209 ret = vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS, &value);
211 SETTING_TRACE_ERROR("Failed to get vconf value");
213 adjust_value = value;
215 ad->data_adjust_bright = setting_create_Gendial_field_def(scroller,
217 setting_powersaving_customed_mouse_up_Gendial_list_cb,
219 SWALLOW_Type_1TOGGLE,
221 KeyStr_Adjust_Bright,
223 setting_powersaving_customed_use_chk_btn_cb);
224 if (ad->data_adjust_bright) {
225 __BACK_POINTER_SET(ad->data_adjust_bright);
226 ad->data_adjust_bright->userdata = ad;
228 SETTING_TRACE_ERROR("ad->data_use_tilt is NULL");
233 str_value = setting_powersaving_ug_get_brightness_str();
234 ad->data_brightness =
235 setting_create_Gendial_field_def(scroller, &itc_2text_3,
236 setting_powersaving_customed_mouse_up_Gendial_list_cb,
237 ad, SWALLOW_Type_INVALID, NULL,
238 NULL, 0, KeyStr_Brightness,
240 if (ad->data_brightness) {
241 ad->data_brightness->userdata = ad;
242 __BACK_POINTER_SET(ad->data_screen_timeout);
244 SETTING_TRACE_ERROR("ad->data_br is NULL");
250 item = elm_genlist_item_append(scroller, &itc_seperator,
252 ELM_GENLIST_ITEM_NONE, NULL, NULL);
253 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
257 str_value = get_pa_screen_timeout_str();
258 ad->data_screen_timeout =
259 setting_create_Gendial_exp_parent_field(scroller,
262 SWALLOW_Type_INVALID,
263 KeyStr_Screen_Timeout,
266 if (ad->data_screen_timeout) {
267 ad->data_screen_timeout->int_slp_setting_binded =
268 INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT;
270 SETTING_TRACE_ERROR("ad->data_back is NULL");
272 __BACK_POINTER_SET(ad->data_screen_timeout);
275 if (!adjust_value && ad->data_brightness) {
276 setting_disable_genlist_item(ad->data_brightness->item);
279 setting_view_powersaving_customed.is_create = 1;
281 return SETTING_RETURN_SUCCESS;
284 static int setting_powersaving_customed_destroy(void *cb)
288 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
290 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
292 evas_object_del(ad->popup);
296 elm_naviframe_item_pop(ad->navi_bar);
298 setting_view_powersaving_customed.is_create = 0;
299 return SETTING_RETURN_SUCCESS;
302 static int setting_powersaving_customed_update(void *cb)
306 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
307 SettingPowersavingUG *ad = (SettingPowersavingUG *) cb;
308 if (ad->data_brightness)
310 ad->data_brightness->sub_desc = setting_powersaving_ug_get_brightness_str();
311 elm_object_item_data_set(ad->data_brightness->item, ad->data_brightness);
312 elm_genlist_item_update(ad->data_brightness->item);
314 return SETTING_RETURN_SUCCESS;
318 static int setting_powersaving_customed_cleanup(void *cb)
322 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
323 setting_powersaving_customed_destroy(cb);
325 return SETTING_RETURN_SUCCESS;
328 /* ***************************************************
332 ***************************************************/
334 /* ***************************************************
338 ***************************************************/
341 setting_powersaving_customed_click_softkey_cancel_cb(void *data,
347 retm_if(data == NULL, "Data parameter is NULL");
348 SettingPowersavingUG *ad = (SettingPowersavingUG *) data;
350 setting_view_change(&setting_view_powersaving_customed,
351 &setting_view_powersaving_main, ad);
355 static void setting_powersaving_customed_mouse_up_Gendial_list_cb(void *data,
361 setting_retm_if(data == NULL, "Data parameter is NULL");
363 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
364 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
365 elm_genlist_item_selected_set(item, 0);
366 Setting_GenGroupItem_Data *list_item =
367 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
369 SettingPowersavingUG *ad = (SettingPowersavingUG *) data;
371 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
373 if (!safeStrCmp(KeyStr_Brightness, list_item->keyStr)) {
374 setting_view_change(&setting_view_powersaving_customed,
375 &setting_view_powersaving_brightness, ad);
379 const char *vconf = NULL;
380 if (!safeStrCmp(KeyStr_WIFI_Off, list_item->keyStr)) {
381 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI;
382 } else if (!safeStrCmp(KeyStr_BT_Off, list_item->keyStr)) {
383 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT;
384 } else if (!safeStrCmp(KeyStr_GPS_Off, list_item->keyStr)) {
385 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS;
386 } else if (!safeStrCmp(KeyStr_SYNC_Off, list_item->keyStr)) {
387 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC;
388 } else if (!safeStrCmp(KeyStr_HOTSPOT_Off, list_item->keyStr)) {
389 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT;
390 } else if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr)) {
391 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS;
393 int old_status = elm_check_state_get(list_item->eo_check);
394 int ret = vconf_set_bool(vconf, !old_status);
395 setting_retm_if(0 != ret, "Failed to set vconf [%s]", vconf);
397 list_item->chk_status = !old_status;
398 elm_check_state_set(list_item->eo_check, list_item->chk_status);
399 if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr) && ad->data_brightness) {
400 if (0 == list_item->chk_status) {
401 setting_disable_genlist_item(ad->data_brightness->item);
403 setting_enable_genlist_item(ad->data_brightness->item);
411 setting_powersaving_customed_use_chk_btn_cb(void *data, Evas_Object *obj,
416 retm_if(data == NULL, "Data parameter is NULL");
417 Setting_GenGroupItem_Data *list_item =
418 (Setting_GenGroupItem_Data *) data;
419 SettingPowersavingUG *ad = list_item->userdata;
421 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
423 const char *vconf = NULL;
424 if (!safeStrCmp(KeyStr_WIFI_Off, list_item->keyStr)) {
425 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_WIFI;
426 } else if (!safeStrCmp(KeyStr_BT_Off, list_item->keyStr)) {
427 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BT;
428 } else if (!safeStrCmp(KeyStr_GPS_Off, list_item->keyStr)) {
429 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_GPS;
430 } else if (!safeStrCmp(KeyStr_SYNC_Off, list_item->keyStr)) {
431 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DATASYNC;
432 } else if (!safeStrCmp(KeyStr_HOTSPOT_Off, list_item->keyStr)) {
433 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_HOTSPOT;
434 } else if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr)) {
435 vconf = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_BRT_STATUS;
438 int err = vconf_set_bool(vconf, list_item->chk_status);
439 if (0 != err) { /* rollback */
440 SETTING_TRACE_ERROR("Set vconf Failed");
441 list_item->chk_status = !list_item->chk_status;
442 elm_check_state_set(obj, list_item->chk_status);
444 if (!safeStrCmp(KeyStr_Adjust_Bright, list_item->keyStr) && ad->data_brightness) {
445 if (0 == list_item->chk_status) {
446 setting_disable_genlist_item(ad->data_brightness->item);
448 setting_enable_genlist_item(ad->data_brightness->item);