tizen 2.3 release
[apps/home/settings.git] / setting-syspopup / src / mode-syspopup.c
1 /*
2  * mode-syspopup
3  *
4  * Copyright 2012  Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.tizenopensource.org/license
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <unistd.h>
23 #include <efl_assist.h>
24
25 #include <appcore-efl.h>
26 #include <Ecore_X.h>
27 #include <aul.h>
28 #include <pkgmgr-info.h>
29 //#include <package-manager.h>
30
31 #include <syspopup.h>
32 #include <mode-syspopup.h>
33 #include <mode-syspopup-alarmmgr.h>
34 #include <dd-haptic.h>
35 #include <dd-led.h>
36 #include <tapi_common.h>
37 #include <ITapiSim.h>
38 #include <ITapiModem.h>
39 #include <TapiUtility.h>
40 #include <TelPower.h>
41 #include <sound_manager.h>
42 #include <app_preference.h>
43 //#include <ode.h>
44
45 static bool is_recovery = false;
46 static int normal_settings[22] = {-1, -1, -1, -1, -1, -1, -1, -3, -1, -1, -1, -1, -1 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
47 static int powerful_settings_def[22] = {0, 0, 0, 20, 0, 15, 0, 0, 0, 1, 1, -1, -1 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
48 static int powerful_settings[22] = {-2, -2, -2, -2, -2, -2, -2, -4, -2, -2, -2, -2, -2 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
49 static int emergency_settings[22] = {0, 0, 0, 20, 0, 15, 0, 0, 1, 1, 1, 1, 1 /*and pws profile*/, 0, 0, 0, 0, 0, 0, 0, 1, 1};
50 //brightness default as 20 changed 20131127
51 //lcd freq default as 1 in setting spec
52
53 /* default value for power saving
54 * Power saving mode default
55 Haptic feedback : Off
56 Apps opening effect : Off
57 Use GPS satellites : Off
58 ----------------------------------------
59 Brightness : 30%
60 Screen rotation: Off
61 Screen timeout : 15sec
62 Smart stay : off
63 Touch key light duration : Always off
64 Greyscale mode: Off
65 ----------------------------------------
66 CPU max frequency limit : On
67 Screen output : On
68 Eco wallpaper : Off
69 */
70
71
72 static Eina_List *mini_list;
73 static int __mode_reboot_noti_method();
74 static int __mode_syspopup_app_terminate(void *data);
75
76
77 /*dbus for CPU freq control*/
78 static int __append_param(DBusMessage *msg, const char *sig, char *param[])
79 {
80         DBusMessageIter iter;
81         DBusMessageIter cont_iter;
82         char *ch;
83         char *str_type;
84         int int_type;
85         int i;
86         if (sig == NULL || param == NULL)
87                 return 0;
88
89         dbus_message_iter_init_append(msg, &iter);
90         for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch)
91         {
92                 _DBG("sig : %c", *ch);
93                 switch (*ch)
94                 {
95                         case 'i':
96                                 int_type = atoi(param[i]);
97                                 _DBG("param[%2d] : %d", i, int_type);
98                                 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &int_type);
99                                 break;
100                         case 's':
101                                 str_type = param[i];
102                                 _DBG("param[%2d] : %s", i, str_type);
103                                 dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str_type);
104                                 break;
105                         default:
106                                 break;
107                 }
108         }
109         return 0;
110 }
111
112 static DBusMessage* __invoke_dbus_method(const char *dest, const char *path,
113                                                                         const char *interface, const char *method,
114                                                                         const char *sig, char *param[])
115 {
116         DBusError err;
117         DBusConnection *conn;
118         DBusMessage *reply;
119         DBusMessage *msg;
120         int r;
121
122         conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
123         if (conn == NULL)
124         {
125                 _DBG("dbus_bus_get error");
126                 return NULL;
127         }
128         msg = dbus_message_new_method_call(dest, path, interface, method);
129         if (msg == NULL)
130         {
131                 _DBG("dbus_message_new_method_call error");
132                 return NULL;
133         }
134         r = __append_param(msg, sig, param);
135         if (r < 0)
136         {
137                 _DBG("append_param error");
138                 return NULL;
139         }
140         dbus_error_init(&err);
141         reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
142         dbus_message_unref(msg);
143         if (dbus_error_is_set(&err))
144         {
145                 _DBG("dbus_connection_send_with_reply_and_block error");
146                 _DBG("error [%s:%s]", err.name, err.message);
147                 dbus_error_free(&err);
148                 return NULL;
149         }
150         return reply;
151 }
152
153 int __set_LCD_freq_control(int value)
154 {
155         int ret = 0;
156         int state;
157         DBusMessage *msg;
158         DBusError err;
159         char *arr[4] = {0,};
160         char temp1[2] = {0,};
161         char temp[3] = {0,};
162
163         e_dbus_init();
164         dbus_error_init(&err);
165
166         snprintf(temp1, 2, "%1d", 0);   //kernal parsing setting with value 0
167         temp1[1] = '\0';
168         _DBG("set as [%s]", temp1);
169
170         snprintf(temp, 3, "%1d", value);
171         temp[2] = '\0';
172         _DBG("set as [%s]", temp);
173         arr[0] = temp1;
174         arr[1] = temp;
175
176         msg = __invoke_dbus_method(BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_NAME, "ii", arr);
177         if(msg)
178         {
179                 if(!dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID))
180                 {
181                         _DBG("no message : [%s:%s]", err.name, err.message);
182                         ret = -1;       //RETURN FAIL
183                 }
184                 else
185                 {
186                         _DBG("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_NAME, state);
187                 }
188                 dbus_message_unref(msg);
189         }
190         e_dbus_shutdown();
191
192         return ret;     //succuess
193 }
194
195 static Eina_Bool _LCD_freq_ctrl(void *data){
196         struct appdata *ad = data;
197         _DBG("_LCD_freq_ctrl");
198
199         //lcd freq ctrl, it effect flickering while progressing on change home
200         //get master key psmode
201         int m_key;
202         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
203
204         _DBG("ad->type: %s, vconfkey : %d", ad->type, m_key);
205         if (!strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY) || !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SETTING))
206         {
207                 if(ad->is_lcd_ctrl){
208                         //normal -> emergency
209                         _DBG("set LCD FRQ ON, 40");
210                         __set_LCD_freq_control(LCD_FRQ_CONTROL_ON);
211                 }
212         }
213         else if(!strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL) || !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL_SETTING))
214         {
215                 //except powerful -> normal
216                 if(!ad->is_lcd_ctrl){
217                         //emergency -> normal
218                         _DBG("set LCD FRQ OFF, 60");
219                         __set_LCD_freq_control(LCD_FRQ_CONTROL_OFF);
220                 }
221         }
222         return FALSE;
223 }
224
225 static Eina_Bool _LCD_freq_ctrl_handler(void *data){
226         struct appdata *ad = data;
227         _DBG("_LCD_freq_ctrl_handler");
228
229         _LCD_freq_ctrl(ad);
230
231         ad->lcd_freq_timer = NULL;
232         return FALSE;
233 }
234
235 /*mini app term start*/
236 typedef struct {
237         char *appid;
238         int pid;
239 } pid_s;
240
241 void list_destroy_running_pid(Evas_Object *win)
242 {
243         ret_if(NULL == win);
244
245         Eina_List *list = evas_object_data_del(win, DATA_KEY_RUNNING_LIST);
246         if (NULL == list) return;
247
248         pid_s *p = NULL;
249         EINA_LIST_FREE(list, p) {
250                 if (NULL == p) continue;
251                 if (p->appid) free(p->appid);
252                 free(p);
253         }
254
255         eina_list_free(list);
256 }
257
258 static int _running_app_info_cb(const aul_app_info *ainfo, void *data)
259 {
260         retv_if(NULL == ainfo, 0);
261         retv_if(NULL == ainfo->pkg_name, 0);
262         retv_if(NULL == data, 0);
263
264         Evas_Object *win = data;
265         pid_s *p = calloc(1, sizeof(pid_s));
266         retv_if(NULL == p, 0);
267
268         char *appid = strdup(ainfo->pkg_name);
269         goto_if(NULL == appid, ERROR);
270
271         p->appid = appid;
272         p->pid = ainfo->pid;
273
274         Eina_List *rlist = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
275         rlist = eina_list_append(rlist, p);
276         evas_object_data_set(win, DATA_KEY_RUNNING_LIST, rlist);
277
278         return 1;
279
280 ERROR:
281         if (p) free(p);
282         return 0;
283 }
284
285 int list_create_running_pid(Evas_Object *win)
286 {
287         _DBG("list_create_running_pid");
288         list_destroy_running_pid(win);
289 #if 0 // Proc
290         if (AUL_R_OK != aul_app_get_running_app_info(_running_app_info_cb, win)) {
291 #else // DB
292     if (AUL_R_OK != aul_get_running_app_info_from_memory(_running_app_info_cb, win)) {
293 #endif
294                 _DBG("Cannot get the running apps' info");
295                 return -1;
296         }
297         return 0;
298 }
299
300 int list_get_running_pid(Evas_Object *win, const char* appid)
301 {
302         Eina_List *list = NULL;
303         const Eina_List *l = NULL;
304         const Eina_List *ln = NULL;
305         pid_s *p = NULL;
306
307         retv_if(NULL == win, -1);
308         retv_if(NULL == appid, -1);
309
310         list = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
311         if (!list) {
312                 retv_if(0 != list_create_running_pid(win), -1);
313                 list = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
314                 /* It's possible to be no running apps */
315                 if (NULL == list) return -1;
316         }
317
318         EINA_LIST_FOREACH_SAFE(list, l, ln, p) {
319                 if (NULL == p) continue;
320                 if (NULL == p->appid) continue;
321                 if (!strcmp(p->appid, appid)) return p->pid;
322         }
323
324         return -1;
325 }
326
327 #define APPID_PHONE "org.tizen.phone"
328 #define APPID_CONTACTS "org.tizen.contacts"     //it is different appid in 'Phone' mini app P140623-06536
329 int _mini_apps_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
330 {
331         retv_if(NULL == handle, 0);
332
333         char *appid = NULL;
334         pkgmgrinfo_appinfo_get_appid(handle, &appid);
335         retv_if(NULL == appid, 0);
336
337         _DBG("appid[%s]", appid);
338         if (appid && !strcmp(appid, APPID_PHONE)) {
339                 mini_list = eina_list_append(mini_list, strdup(APPID_CONTACTS));
340         }
341         else{
342                 mini_list = eina_list_append(mini_list, strdup(appid));
343         }
344         return 0;
345 }
346
347 #define MINIAPP_CATEGORY "http://samsung.com/category/floatingapp"
348 Eina_List *_miniapp_create(void)
349 {
350         /* Get info from AIL */
351         pkgmgrinfo_appinfo_filter_h filter = NULL;
352         int ret = 0;
353         int count = -1;
354
355         ret = pkgmgrinfo_appinfo_filter_create(&filter);
356         if(ret > 0)
357         {
358                 _DBG("pkgmgrinfo_appinfo_filter_create() failed");
359         }
360         ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_CATEGORY, MINIAPP_CATEGORY);
361         ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, _mini_apps_cb, NULL);
362         ret = pkgmgrinfo_appinfo_filter_count(filter, &count);
363
364         if(count <= 0)
365         {
366                 pkgmgrinfo_appinfo_filter_destroy(filter);
367                 filter = NULL;
368         }
369
370         free(filter);
371         return mini_list;
372 }
373
374 void _mini_terminate(int pid)
375 {
376         _DBG("Terminate: (%d)", pid);
377         if (0 < pid) {
378                 if (aul_terminate_pid(pid) < 0) {
379                         _ERR("aul_terminate_pid fail");
380                 }
381         }
382 }
383
384 void _mini_destroy(void)
385 {
386         mini_list = eina_list_free(mini_list);
387 }
388
389 void _terminate_miniapp(void* data)
390 {
391         struct appdata *ad = data;
392         mini_list = _miniapp_create();  //list create
393         ret_if(NULL == mini_list);
394
395         Eina_List *l = NULL;
396         char *appid = NULL;
397         EINA_LIST_FOREACH(mini_list, l, appid) {
398                 _DBG("terminate miniapp [%s]", appid);
399                 if (!appid) continue;
400                 int pid = list_get_running_pid(ad->win, appid);
401                 if(pid) _mini_terminate(pid);
402         }
403 }
404 /*mini app term end*/
405
406 /* private mode, unmount, PLM P140707-03137*/
407 void _unmount_fs(void)
408 {
409         int val;
410         vconf_get_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, &val);
411         if(val){
412                 #if 0
413                 if(ode_init() == 0)
414                 {
415                         if(pse_unmount() != 0) _DBG("pse unmount fail");
416                         if(ode_deinit() != 0) _DBG("ode deint fail");
417                         if(vconf_set_bool(VCONFKEY_SETAPPL_PERSONAL_MODE_STATUS_BOOL, FALSE) != 0) _DBG("vconf set fail");
418                 }
419                 else
420                 {
421                         _DBG("ode init fail");
422                 }
423                 #endif
424         }
425 }
426 /*unmount end*/
427
428
429 //help api
430 static void __help_popup_language_change_cb(void *data, Evas_Object * obj, void *source)
431 {
432         /*char *string_id = (char *)data;
433         char *message = _(string_id);
434         helpui_set_popup_text(obj, message);*/
435 }
436
437 static void syspop_help_popup_circle_unblock_create(Evas_Object * parent, Evas_Object ** circle,
438         Evas_Object ** popup, char *string_id, int x, int y)
439 {
440         /**circle = helpui_add_circle(parent, HELP_CIRCLE_BIG);
441         evas_object_move(*circle, x, y);
442         char *message = _(string_id);
443         *popup = helpui_add_popup(parent, message, HELP_POPUP_WITH_ARROW, NULL, NULL);
444         helpui_set_popup_language_changed_cb(*popup, __help_popup_language_change_cb,
445                 string_id);
446         evas_object_move(*popup, x, y + 8);*/
447 }
448
449 static void syspop_help_popup_circle_block_create(Evas_Object *win, Evas_Object * parent, Evas_Object ** circle,
450         Evas_Object ** popup, char *string_id, int x, int y, Evas_Coord_Rectangle * rect)
451 {
452         /*helpui_set_block_win(win);
453         syspop_help_popup_circle_unblock_create(parent, circle, popup, string_id, x, y);
454         helpui_set_unblock_rect(win, rect);*/
455 }
456
457 int launching_effect_set(Evas_Object *win, int flag)
458 {
459         Ecore_X_Window xwin, root;
460         Ecore_X_Atom effect_enable_atom;
461         int is_enable = flag;
462         root = ecore_x_window_root_first_get();
463         effect_enable_atom = ecore_x_atom_get ("_NET_CM_EFFECT_ENABLE");
464         if (!effect_enable_atom) {
465                 _DBG("Cannot create _NET_CM_EFFECT_ENABLE atom... \n\n");
466                 return -1;
467         }
468
469         /* is_enable  (0: effect disable, 1: effect enable) */
470         ecore_x_window_prop_card32_set (root, effect_enable_atom, &is_enable, 1);
471
472         return 0;
473 }
474
475 int launching_effect_get(Evas_Object *win, int* flag)
476 {
477         Ecore_X_Window xwin, root;
478         Ecore_X_Atom effect_enable_atom;
479         int is_enable = 0;
480         root = ecore_x_window_root_first_get();
481         effect_enable_atom = ecore_x_atom_get ("_NET_CM_EFFECT_ENABLE");
482         if (!effect_enable_atom) {
483                 _DBG("Cannot create _NET_CM_EFFECT_ENABLE atom... \n\n");
484                 return -1;
485         }
486
487         /* is_enable  (0: effect disable, 1: effect enable) */
488         (void)ecore_x_window_prop_card32_get (root, effect_enable_atom, &is_enable, 1);
489         *flag = is_enable;
490
491         return 0;
492 }
493
494  static void mode_remove_noti(void *data, char *package)
495 {
496         struct appdata *ad = data;
497         notification_error_e ret = NOTIFICATION_ERROR_NONE;
498         ret = notification_delete_all_by_type(package, NOTIFICATION_TYPE_ONGOING);      //pkg ex : "setting-blockingmode-efl"
499         if (ret != NOTIFICATION_ERROR_NONE) {
500                 _DBG("Fail to notification_delete_all_by_type [%d]", ret);
501                 return;
502         }
503 }
504
505  static void mode_create_noti(void *data,const char *key_str,const char *package,const char *title)
506 {
507         struct appdata *ad = data;
508         notification_h noti = NULL;
509         notification_error_e ret = NOTIFICATION_ERROR_NONE;
510
511         /* remove noti */
512         mode_remove_noti(ad, package);
513
514         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
515                         NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
516         if (!noti) {
517                 _DBG("Fail to notification_new [%d]", ret);
518                 return;
519         }
520
521         ret = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
522         if (ret != NOTIFICATION_ERROR_NONE) {
523                 _DBG("Fail to notification_set_layout [%d]", ret);
524                 goto FAIL;
525         }
526
527         if(!strcmp(PKG_BLOCKING_MODE, package)){
528                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_BlockingMode);
529                 if (ret != NOTIFICATION_ERROR_NONE) {
530                         _DBG("Fail to notification_set_image [%d]", ret);
531                         goto FAIL;
532                 }
533                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_BlockingMode);
534                 if (ret != NOTIFICATION_ERROR_NONE) {
535                         _DBG("Fail to notification_set_image [%d]", ret);
536                         goto FAIL;
537                 }
538         }
539         else if(!strcmp(PKG_DRIVING_MODE, package)){
540                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_DrivingMode);
541                 if (ret != NOTIFICATION_ERROR_NONE) {
542                         _DBG("Fail to notification_set_image [%d]", ret);
543                         goto FAIL;
544                 }
545                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_DrivingMode);
546                 if (ret != NOTIFICATION_ERROR_NONE) {
547                         _DBG("Fail to notification_set_image [%d]", ret);
548                         goto FAIL;
549                 }
550         }
551         else if(!strcmp("setting-firewall-efl", package)){
552                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_Firewall);
553                 if (ret != NOTIFICATION_ERROR_NONE) {
554                         _DBG("Fail to notification_set_image [%d]", ret);
555                         goto FAIL;
556                 }
557                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_Firewall);
558                 if (ret != NOTIFICATION_ERROR_NONE) {
559                         _DBG("Fail to notification_set_image [%d]", ret);
560                         goto FAIL;
561                 }
562         }
563
564         ret = notification_set_text(noti,
565                         NOTIFICATION_TEXT_TYPE_TITLE,
566                         title,
567                         title, NOTIFICATION_VARIABLE_TYPE_NONE);
568         if (ret != NOTIFICATION_ERROR_NONE) {
569                 _DBG("Fail to notification_set_text [%d]", ret);
570                 goto FAIL;
571         }
572
573         ret = notification_set_text(noti,
574                         NOTIFICATION_TEXT_TYPE_CONTENT,
575                         key_str,
576                         key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
577         if (ret != NOTIFICATION_ERROR_NONE) {
578                 _DBG("Fail to notification_set_text [%d]", ret);
579                 goto FAIL;
580         }
581
582         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
583         if (ret != NOTIFICATION_ERROR_NONE) {
584                 _DBG("Fail to notification_set_text [%d]", ret);
585                 goto FAIL;
586         }
587
588         ret = notification_set_pkgname(noti, package);  //pkg ex : "setting-blockingmode-efl"
589         if (ret != NOTIFICATION_ERROR_NONE) {
590                 _DBG("Fail to notification_set_pkgname [%d]", ret);
591                 goto FAIL;
592         }
593
594         ret = notification_set_application(noti, package);      //pkg ex : "setting-blockingmode-efl"
595         if (ret != NOTIFICATION_ERROR_NONE) {
596                 _DBG("Fail to notification_set_application [%d]", ret);
597                 goto FAIL;
598         }
599
600         ret = notification_insert(noti, &ad->noti_id);
601         if (ret != NOTIFICATION_ERROR_NONE) {
602                 _DBG("Fail to notification_insert [%d]", ret);
603                 goto FAIL;
604         }
605
606         ret = notification_free(noti);
607         if (ret != NOTIFICATION_ERROR_NONE) {
608                 _DBG("Fail to notification_free [%d]", ret);
609                 goto FAIL;
610         }
611
612         return;
613
614 FAIL:
615         ret = notification_free(noti);
616         if (ret != NOTIFICATION_ERROR_NONE) {
617                 _DBG("Fail to notification_free [%d]", ret);
618         }
619         return;
620 }
621
622  static void mode_create_noti_with_no_msg(void *data,const char *key_str,const char *package,const char *title)
623 {
624         struct appdata *ad = data;
625         notification_h noti = NULL;
626         notification_error_e ret = NOTIFICATION_ERROR_NONE;
627
628         /* remove noti */
629         mode_remove_noti(ad, package);
630
631         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
632                         NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
633         if (!noti) {
634                 _DBG("Fail to notification_new [%d]", ret);
635                 return;
636         }
637
638         ret = notification_set_layout(noti, NOTIFICATION_LY_NOTI_THUMBNAIL);
639         if (ret != NOTIFICATION_ERROR_NONE) {
640                 _DBG("Fail to notification_set_layout [%d]", ret);
641                 goto FAIL;
642         }
643
644         if(!strcmp(PKG_BLOCKING_MODE, package)){
645                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_BlockingMode);
646                 if (ret != NOTIFICATION_ERROR_NONE) {
647                         _DBG("Fail to notification_set_image [%d]", ret);
648                         goto FAIL;
649                 }
650                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_BlockingMode);
651                 if (ret != NOTIFICATION_ERROR_NONE) {
652                         _DBG("Fail to notification_set_image [%d]", ret);
653                         goto FAIL;
654                 }
655         }
656         else if(!strcmp(PKG_DRIVING_MODE, package)){
657                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_DrivingMode);
658                 if (ret != NOTIFICATION_ERROR_NONE) {
659                         _DBG("Fail to notification_set_image [%d]", ret);
660                         goto FAIL;
661                 }
662                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_DrivingMode);
663                 if (ret != NOTIFICATION_ERROR_NONE) {
664                         _DBG("Fail to notification_set_image [%d]", ret);
665                         goto FAIL;
666                 }
667         }
668
669         ret = notification_set_text(noti,
670                         NOTIFICATION_TEXT_TYPE_TITLE,
671                         title,
672                         title, NOTIFICATION_VARIABLE_TYPE_NONE);
673         if (ret != NOTIFICATION_ERROR_NONE) {
674                 _DBG("Fail to notification_set_text [%d]", ret);
675                 goto FAIL;
676         }
677
678         ret = notification_set_text(noti,
679                         NOTIFICATION_TEXT_TYPE_CONTENT,
680                         key_str,
681                         key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
682         if (ret != NOTIFICATION_ERROR_NONE) {
683                 _DBG("Fail to notification_set_text [%d]", ret);
684                 goto FAIL;
685         }
686
687         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
688         if (ret != NOTIFICATION_ERROR_NONE) {
689                 _DBG("Fail to notification_set_text [%d]", ret);
690                 goto FAIL;
691         }
692
693         ret = notification_set_pkgname(noti, package);  //pkg ex : "setting-blockingmode-efl"
694         if (ret != NOTIFICATION_ERROR_NONE) {
695                 _DBG("Fail to notification_set_pkgname [%d]", ret);
696                 goto FAIL;
697         }
698
699         ret = notification_set_application(noti, package);      //pkg ex : "setting-blockingmode-efl"
700         if (ret != NOTIFICATION_ERROR_NONE) {
701                 _DBG("Fail to notification_set_application [%d]", ret);
702                 goto FAIL;
703         }
704
705         ret = notification_insert(noti, &ad->noti_id);
706         if (ret != NOTIFICATION_ERROR_NONE) {
707                 _DBG("Fail to notification_insert [%d]", ret);
708                 goto FAIL;
709         }
710
711         ret = notification_free(noti);
712         if (ret != NOTIFICATION_ERROR_NONE) {
713                 _DBG("Fail to notification_free [%d]", ret);
714                 goto FAIL;
715         }
716
717         return;
718
719 FAIL:
720         ret = notification_free(noti);
721         if (ret != NOTIFICATION_ERROR_NONE) {
722                 _DBG("Fail to notification_free [%d]", ret);
723         }
724         return;
725 }
726
727 static char* _get_time_str_from_vconf(char* keyStr)
728 {
729         int hour = 0;
730         int min = 0;
731         char time[128] = { 0 };
732         int ret, value, err;
733         _DBG("keyStr : %s", keyStr);    //#1 "IDS_ST_BODY_FROM_M_TIME" , #2 IDS_ST_BODY_TO_M_PERIOD
734         if (!strcmp("IDS_ST_BODY_FROM_M_TIME", keyStr)){
735                 ret = vconf_get_int(VCONFKEY_SETAPPL_BM_START_HOUR, &hour);
736                 if (ret != 0) {
737                         _DBG("get vconf failed");
738                         hour = 0;
739                 }
740                 ret = vconf_get_int(VCONFKEY_SETAPPL_BM_START_MIN, &min);
741                 if (ret != 0) {
742                         _DBG("get vconf failed");
743                         min = 0;
744                 }
745                 ret = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &value);
746                 if (ret != 0) {
747                         _DBG("get vconf failed");
748                         value = VCONFKEY_TIME_FORMAT_12;
749                 }
750
751                 if(value == VCONFKEY_TIME_FORMAT_12){
752                         if(hour > 12){
753                                 hour = hour - 12;
754                                 snprintf(time, sizeof(time), "%s %02d:%02d",_("IDS_ST_BODY_PM"),hour,min);
755                         }
756                         else{
757                                 snprintf(time, sizeof(time), "%s %02d:%02d",_("IDS_ST_BODY_AM"),hour,min);
758                         }
759                 }
760                 else{
761                         //default and VCONFKEY_TIME_FORMAT_24
762                         snprintf(time, sizeof(time), "%02d:%02d",hour,min);
763                 }
764
765                 return (char *)g_strdup(time);
766         }
767         else     if(!strcmp("IDS_ST_BODY_TO_M_PERIOD", keyStr)){
768                 ret = vconf_get_int(VCONFKEY_SETAPPL_BM_END_HOUR, &hour);
769                 if (ret != 0) {
770                         _DBG("get vconf failed");
771                         hour = 0;
772                 }
773                 ret = vconf_get_int(VCONFKEY_SETAPPL_BM_END_MIN, &min);
774                 if (ret != 0) {
775                         _DBG("get vconf failed");
776                         min = 0;
777                 }
778                 ret = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &value);
779                 if (ret != 0) {
780                         _DBG("get vconf failed");
781                         value = VCONFKEY_TIME_FORMAT_12;
782                 }
783
784                 if(value == VCONFKEY_TIME_FORMAT_12){
785                         if(hour > 12){
786                                 hour = hour - 12;
787                                 snprintf(time, sizeof(time), "%s %02d:%02d",_("IDS_ST_BODY_PM"),hour,min);
788                         }
789                         else{
790                                 snprintf(time, sizeof(time), "%s %02d:%02d",_("IDS_ST_BODY_AM"),hour,min);
791                         }
792                 }
793                 else{
794                         //default and VCONFKEY_TIME_FORMAT_24
795                         snprintf(time, sizeof(time), "%02d:%02d",hour,min);
796                 }
797
798                 return (char *)g_strdup(time);
799         }
800 }
801
802
803 static void _mode_vconf_change_cb(keynode_t *key, void *data)
804 {
805         _DBG("_mode_vconf_change_cb");
806         struct appdata *ad = data;
807         int status = vconf_keynode_get_bool(key);
808         char *vconf_name = vconf_keynode_get_name(key);
809
810         if (!strcmp(vconf_name, VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE)) {
811                 _DBG("status:%d", status);
812                 if(status){
813                         //ON
814                         if(ad->all_day){
815                                 mode_create_noti(ad, "IDS_ST_BODY_BLOCKING_MODE_IS_ENABLED", PKG_BLOCKING_MODE, "IDS_ST_BODY_BLOCKING_MODE");
816                         }
817                         else{
818                                 if(!ad->in_range){
819                                         //no msg type
820                                         mode_create_noti_with_no_msg(ad, "IDS_ST_BODY_BLOCKING_MODE_IS_ENABLED", PKG_BLOCKING_MODE, "IDS_ST_BODY_BLOCKING_MODE");
821                                 }
822                                 else{
823                                         //#2, msg for alarm time
824                                         char *StartTimeStr = NULL;
825                                         char *EndTimeStr = NULL;
826                                         char NotiStr[128];
827                                         StartTimeStr = _get_time_str_from_vconf("IDS_ST_BODY_FROM_M_TIME");
828                                         EndTimeStr = _get_time_str_from_vconf("IDS_ST_BODY_TO_M_PERIOD");
829                                         snprintf(NotiStr, sizeof(NotiStr), "%s - %s  %s",StartTimeStr, EndTimeStr,_("IDS_ST_BODY_BLOCKING_MODE_IS_ENABLED"));
830                                         mode_create_noti(ad,NotiStr, PKG_BLOCKING_MODE, "IDS_ST_BODY_BLOCKING_MODE");
831
832                                         g_free(StartTimeStr);
833                                         g_free(EndTimeStr);
834                                 }
835                         }
836                 }
837                 else{
838                         //OFF
839                         mode_remove_noti(ad, PKG_BLOCKING_MODE);
840                 }
841         } else if (!strcmp(vconf_name, VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE)) {
842                 _DBG("status:%d", status);
843                 if(status){
844                         //ON
845                         /*regist noti*/
846                         int sound, vib;
847                         vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound);
848                         vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib);
849
850                         if(sound){
851                                 vconf_set_int(VCONFKEY_SETAPPL_HANDSFREE_SOUND_REMINDER, SETTING_HANDSFREE_SOUND_ON);   //sound on to skip set
852                         }
853                         else {
854                                 if(vib){
855                                         vconf_set_int(VCONFKEY_SETAPPL_HANDSFREE_SOUND_REMINDER, SETTING_HANDSFREE_SOUND_VIB);
856                                 }
857                                 else{
858                                         vconf_set_int(VCONFKEY_SETAPPL_HANDSFREE_SOUND_REMINDER, SETTING_HANDSFREE_SOUND_MUTE);
859                                 }
860                                 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, status);     //sound on after backup sound status
861                         }
862                         mode_create_noti(ad, "IDS_ST_BODY_INCOMING_CALLS_AND_NEW_NOTIFICATIONS_WILL_BE_READ_OUT_AUTOMATICALLY", PKG_DRIVING_MODE, "IDS_VC_MBODY_NOTIFICATION_READ_OUT");
863                 }
864                 else{
865                         //OFF
866                         /* remove noti */
867                         int b_val;
868                         vconf_get_int(VCONFKEY_SETAPPL_HANDSFREE_SOUND_REMINDER, &b_val);
869                         if(b_val == SETTING_HANDSFREE_SOUND_MUTE){
870                                 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 0);
871                                 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 0);
872                         }
873                         else if(b_val == SETTING_HANDSFREE_SOUND_VIB){
874                                 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 0);
875                                 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 1);
876                         }
877                         else{
878                                 //
879                         }
880                         mode_remove_noti(ad, PKG_DRIVING_MODE);
881                 }
882         } else {
883                 _DBG("vconf_name is wrong");
884         }
885
886         elm_exit();
887 }
888
889 void _mode_backup_settings(void *data) {
890
891         struct appdata *ad = data;
892
893         int val, ret;
894         char* str1;
895         char* str2;
896
897         //PSMODE #0
898         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val);
899         _DBG("VCONFKEY_SETAPPL_PSMODE [%d]", val);
900         ret = preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, val);
901         _DBG("PREFKEY_SAVINGPOWER_BACKUP_PSMODE [%d]", ret);
902
903         //CPU
904         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &val);
905         _DBG("VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU [%d]", val);
906         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF, val);
907         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF [%d]", ret);
908
909         //Wallpaper change
910         str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
911         ret = preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HOMESCREEN_PATH, str1);
912         free(str1);
913         str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
914         ret = preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LOCKSCREEN_PATH, str2);
915         free(str2);
916 #if 0
917         //Wi-Fi
918         vconf_get_int(VCONFKEY_WIFI_STATE, &val);
919         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_WIFI, val);
920         setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] VCONFKEY_WIFI_STATE ***");
921         //BT
922         vconf_get_int(VCONFKEY_BT_STATUS, &val);
923         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BT, val);
924         setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BT ***");
925 #endif
926         //time out
927         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &val);
928         _DBG("VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL [%d]", val);
929         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT, val);
930         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT [%d]", ret);
931         //Auto Brightness : ON/OFF
932         vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &val);
933         _DBG("VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT [%d]", val);
934         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT, val);
935         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT [%d]", ret);
936         //Brightness
937         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &val);
938         _DBG("VCONFKEY_SETAPPL_LCD_BRIGHTNESS [%d]", val);
939         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT, val);
940         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT [%d]", ret);
941         //Auto rotate screen
942         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &val);
943         _DBG("VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL [%d]", val);
944         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE, val);
945         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE [%d]", ret);
946         //Smart screen
947         vconf_get_int(VCONFKEY_SETAPPL_SMARTSCREEN_SMARTSTAY_STATUS, &val);
948         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_SMART_SCREEN, val);
949         vconf_get_bool(VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION, &val);
950         _DBG("VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION [%d]", val);
951         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_SMART_ROTATE, val);
952         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_SMART_ROTATE [%d]", ret);
953         //Haptic feedback
954         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &val);
955         _DBG("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL [%d]", val);
956         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK, val);       //on/off
957         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK [%d]", ret);
958 #if 0
959         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &val);
960         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NOTI, val);
961         vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &val);
962         _DBG("VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT [%d]", val);
963         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC, val);
964         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC [%d]", ret);
965 #endif
966         //Launching effect
967         launching_effect_get(ad->win, &val);
968         _DBG("launching_effect_get [%d]", val);
969         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT, val);
970         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT [%d]", ret);
971
972         //LCD freq
973         /*
974         vconf_get_bool(VCONFKEY_SETAPPL_LCD_FREQ_CONTROL, &val);
975         _DBG("VCONFKEY_SETAPPL_LCD_FREQ_CONTROL [%d]", val);
976         ret = preference_set_boolean(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LCD_FREQ_CONTROL, val);
977         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LCD_FREQ_CONTROL [%d]", ret);
978         */
979         //pkg backup : cluster or easy
980         char *pkg_home = NULL;
981        pkg_home = vconf_get_str(VCONF_PKG_PATH);
982        _DBG("pkghome [%s]", pkg_home);
983        ret =preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, pkg_home);
984        _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME [%d]", ret);
985
986         //vconf_get_int(VCONF_FAKE_KEY, &val);
987         //ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FAKE_EFFECT, val);
988         //setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FAKE_EFFECT ***");
989
990         //GREYSCALE TONE
991         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &val);
992         _DBG("VCONFKEY_SETAPPL_WINDOW_GRAYTONE [%d]", val);
993         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE, val);
994         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE [%d]", ret);
995
996         //SCREEN OUTPUT
997         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &val);
998         _DBG("VCONFKEY_SETAPPL_WINDOW_FPS [%d]", val);
999         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS, val);
1000         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS [%d]", ret);
1001
1002         //GPS
1003         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &val);
1004         _DBG("VCONFKEY_LOCATION_ENABLED [%d]", val);
1005         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS, val);
1006         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS [%d]", ret);
1007
1008         //touch key ligh duration
1009         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &val);
1010         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION [%d]", val);
1011         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT, val);
1012         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT [%d]", ret);
1013
1014         //end for power saving profile
1015
1016         //LED indicator - VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS (bool) #14
1017         vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, &val);
1018         _DBG("VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS [%d]", val);
1019         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LED_INDICATOR_NOTI, val);
1020         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LED_INDICATOR_NOTI [%d]", ret);
1021
1022         //Battery level display - VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL #15
1023         vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &val);
1024         _DBG("VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL [%d]", val);
1025         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BATTERY_PERCENTAGE, val);
1026         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BATTERY_PERCENTAGE [%d]", ret);
1027
1028         //Voice control - VCONFKEY_VOICE_CONTROL_ENABLED #16
1029         vconf_get_bool(VCONFKEY_VOICE_CONTROL_ENABLED, &val);
1030         _DBG("VCONFKEY_VOICE_CONTROL_ENABLED [%d]", val);
1031         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_VOICE_CONTROL, val);
1032         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_VOICE_CONTROL [%d]", ret);
1033
1034         //Multi window - VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED #17
1035         vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &val);
1036         _DBG("VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED [%d]", val);
1037         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_MULTIWINDOW, val);
1038         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_MULTIWINDOW [%d]", ret);
1039
1040         //Hands-free mode - syspopup #18
1041         vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &val);
1042         _DBG("VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE [%d]", val);
1043         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HANDS_FREE_MODE, val);
1044         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HANDS_FREE_MODE [%d]", ret);
1045
1046         //Blocking mode - syspopup #19
1047         vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, &val);
1048         _DBG("VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE [%d]", val);
1049         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BLOCKING_MODE, val);
1050         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BLOCKING_MODE [%d]", ret);
1051
1052         //Net-restriction mode - syspopup #20
1053         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &val);
1054         _DBG("VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE [%d]", val);
1055         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE, val);
1056         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE [%d]", ret);
1057
1058         //default power saving need 1 time
1059         ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &val);
1060         _DBG("PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR : ret [%d], val [%d]",ret, val);
1061         if(ret!=PREFERENCE_ERROR_NONE) {
1062                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 1);
1063         }
1064 }
1065
1066 void _mode_power_backup_settings(void *data) {
1067
1068         struct appdata *ad = data;
1069
1070         int val, ret;
1071         char* str1;
1072         char* str2;
1073
1074         //PSMODE #0
1075         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val);
1076         _DBG("VCONFKEY_SETAPPL_PSMODE [%d]", val);
1077         ret = preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, val);
1078         _DBG("PREFKEY_SAVINGPOWER_BACKUP_PSMODE [%d]", ret);
1079
1080         //CPU
1081         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &val);
1082         _DBG("VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU [%d]", val);
1083         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF, val);
1084         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF [%d]", ret);
1085
1086         //Wallpaper change
1087         str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
1088         ret = preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH, str1);
1089         //setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH ***");
1090         free(str1);
1091         str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
1092         ret = preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH, str2);
1093         //setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH ***");
1094         free(str2);
1095
1096         //time out
1097         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &val);
1098         _DBG("VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL [%d]", val);
1099         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT, val);
1100         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT [%d]", ret);
1101         //Auto Brightness : ON/OFF
1102         vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &val);
1103         _DBG("VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT [%d]", val);
1104         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT, val);
1105         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT [%d]", ret);
1106         //Brightness
1107         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &val);
1108         _DBG("VCONFKEY_SETAPPL_LCD_BRIGHTNESS [%d]", val);
1109         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT, val);
1110         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT [%d]", ret);
1111         //Auto rotate screen
1112         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &val);
1113         _DBG("VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL [%d]", val);
1114         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE, val);
1115         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE [%d]", ret);
1116         //Smart screen
1117         vconf_get_int(VCONFKEY_SETAPPL_SMARTSCREEN_SMARTSTAY_STATUS, &val);
1118         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_SMART_SCREEN, val);
1119         vconf_get_bool(VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION, &val);
1120         _DBG("VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION [%d]", val);
1121         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_SMART_ROTATE, val);
1122         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_SMART_ROTATE [%d]", ret);
1123         //Haptic feedback
1124         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &val);
1125         _DBG("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL [%d]", val);
1126         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK, val);        //on/off
1127         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK [%d]", ret);
1128
1129         //Launching effect
1130         launching_effect_get(ad->win, &val);
1131         _DBG("launching_effect_get [%d]", val);
1132         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT, val);
1133         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT [%d]", ret);
1134
1135         //pkg backup : cluster or easy
1136         char *pkg_home = NULL;
1137        pkg_home = vconf_get_str(VCONF_PKG_PATH);
1138        _DBG("pkghome [%s]", pkg_home);
1139        ret =preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_PKG_HOME, pkg_home);
1140        _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_PKG_HOME [%d]", ret);
1141
1142         //GREYSCALE TONE
1143         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &val);
1144         _DBG("VCONFKEY_SETAPPL_WINDOW_GRAYTONE [%d]", val);
1145         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE, val);
1146         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE [%d]", ret);
1147
1148         //SCREEN OUTPUT
1149         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &val);
1150         _DBG("VCONFKEY_SETAPPL_WINDOW_FPS [%d]", val);
1151         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS, val);
1152         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS [%d]", ret);
1153
1154         //GPS
1155         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &val);
1156         _DBG("VCONFKEY_LOCATION_ENABLED [%d]", val);
1157         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS, val);
1158         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS [%d]", ret);
1159
1160         //touch key ligh duration
1161         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &val);
1162         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION [%d]", val);
1163         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT, val);
1164         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT [%d]", ret);
1165
1166         //end for power saving profile
1167
1168         //LED indicator - VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS (bool) #14
1169         vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, &val);
1170         _DBG("VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS [%d]", val);
1171         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LED_INDICATOR_NOTI, val);
1172         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_LED_INDICATOR_NOTI [%d]", ret);
1173
1174         //Battery level display - VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL #15
1175         vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &val);
1176         _DBG("VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL [%d]", val);
1177         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BATTERY_PERCENTAGE, val);
1178         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_BATTERY_PERCENTAGE [%d]", ret);
1179
1180         //Voice control - VCONFKEY_VOICE_CONTROL_ENABLED #16
1181         vconf_get_bool(VCONFKEY_VOICE_CONTROL_ENABLED, &val);
1182         _DBG("VCONFKEY_VOICE_CONTROL_ENABLED [%d]", val);
1183         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_VOICE_CONTROL, val);
1184         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_VOICE_CONTROL [%d]", ret);
1185
1186         //Multi window - VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED #17
1187         vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &val);
1188         _DBG("VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED [%d]", val);
1189         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_MULTIWINDOW, val);
1190         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_MULTIWINDOW [%d]", ret);
1191
1192         //Hands-free mode - syspopup #18
1193         vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &val);
1194         _DBG("VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE [%d]", val);
1195         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HANDS_FREE_MODE, val);
1196         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_HANDS_FREE_MODE [%d]", ret);
1197
1198         //Blocking mode - syspopup #19
1199         vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, &val);
1200         _DBG("VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE [%d]", val);
1201         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BLOCKING_MODE, val);
1202         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_BLOCKING_MODE [%d]", ret);
1203
1204         //Net-restriction mode - syspopup #20
1205         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &val);
1206         _DBG("VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE [%d]", val);
1207         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE, val);
1208         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE [%d]", ret);
1209 }
1210
1211
1212 void _mode_apply_settings(void *data, int *set) {
1213
1214
1215         //static int normal_settings[22] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
1216         //static int powerful_settings_def[22] = {0, 0, 0, 20, 0, 15, 0, 0, 0, 1, 1, -1, -1 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
1217         //static int powerful_settings[22] = {-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2 /*and pws profile*/, -1, -1, -1, -1, -1, -1, -1, 0, 0};
1218         //static int emergency_settings[22] = {0, 0, 0, 20, 0, 15, 0, 0, 1, 1, 1, 1, 1 /*and pws profile*/, 0, 0, 0, 0, 0, 0, 0, 1, 1};
1219
1220         struct appdata *ad = data;
1221         int val, crt_val, ret;
1222
1223
1224         /////////////////////////////////
1225         /* power saving mode content order */
1226         /////////////////////////////////
1227
1228         //Haptic feedback #1
1229         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &crt_val);
1230         val = set[0];
1231         if (val == -1) {
1232                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK, &val);
1233         }
1234         else if (val == -2) {
1235                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK, &val);
1236         }
1237         if (val != crt_val) {
1238                 vconf_set_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, val);
1239                 _DBG("set haptic  feedback : %d", val);
1240         }
1241
1242         //Launching effect #2
1243         launching_effect_get(ad->win, &crt_val);
1244         val = set[1];
1245         if (val == -1) {
1246                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT, &val);
1247         }
1248         if (val == -2) {
1249                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT, &val);
1250         }
1251         if (val != crt_val) {
1252                 launching_effect_set(ad->win, val);
1253                 _DBG("set launching effect %d", val);
1254         }
1255
1256         //GPS #3
1257         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &crt_val);
1258         _DBG("get GPS %d", crt_val);
1259         val = set[2];
1260         if (val == -1) {
1261                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS, &val);
1262                 _DBG("get GPS %d", val);
1263         }
1264         if (val == -2) {
1265                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS, &val);
1266                 _DBG("get GPS %d", val);
1267         }
1268         if (val != crt_val) {
1269                 vconf_set_int(VCONFKEY_LOCATION_ENABLED, val);
1270                 _DBG("set GPS %d", val);
1271         }
1272
1273         //Brightness #4
1274         //add check auto brightness routine
1275         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &crt_val);
1276         val = set[3];
1277         if (val == -1) {
1278                 int auto_br=0;
1279                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT, &auto_br);
1280                 // * 0 : Off
1281                 // * 1 : On
1282                 // * 2 : Pause
1283                 _DBG("check1 auto_br [%d]", auto_br);
1284                 if(auto_br == SETTING_BRIGHTNESS_AUTOMATIC_ON){
1285                         //prev : auto on, fix to auto status last
1286                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
1287
1288                 }
1289                 else if(auto_br == SETTING_BRIGHTNESS_AUTOMATIC_OFF){
1290                         //auto to off and set bright
1291                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
1292                         ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT, &val);
1293                 }
1294         }
1295         else if (val == -2) {
1296                 int auto_br=0;
1297                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT, &auto_br);
1298                 // * 0 : Off
1299                 // * 1 : On
1300                 // * 2 : Pause
1301                 _DBG("check1 auto_br [%d]", auto_br);
1302                 if(auto_br == SETTING_BRIGHTNESS_AUTOMATIC_ON){
1303                         //prev : auto on, fix to auto status last
1304                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
1305
1306                 }
1307                 else if(auto_br == SETTING_BRIGHTNESS_AUTOMATIC_OFF){
1308                         //auto to off and set bright
1309                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
1310                         ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT, &val);
1311                 }
1312         }
1313         else{
1314                 //normal to power saving or emergency(val != -1), get auto brightness off
1315                 ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
1316         }
1317
1318         if (val != -1 && val != -2) {
1319                 ret = display_set_brightness_with_setting(val);
1320                 _DBG("set Brightness %d, ret = %d", val, ret);
1321                 ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, val);
1322         }
1323
1324         //Auto rotate screen #5
1325         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &crt_val);
1326         val = set[4];
1327         if (val == -1) {
1328                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE, &val);
1329         }
1330         if (val == -2) {
1331                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE, &val);
1332         }
1333         if (val != crt_val) {
1334                 vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, val);
1335                 _DBG("set Auto rotate screen  %d", val);
1336         }
1337
1338         //time out #6
1339         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &crt_val);
1340         val = set[5];
1341         if (val == -1) {
1342                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT, &val);
1343         }
1344         if (val == -2) {
1345                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT, &val);
1346         }
1347         if (val != crt_val) {
1348                 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, val);
1349                 _DBG("set time out %d", val);
1350         }
1351
1352         //Smart screen #7
1353         int val1,val2,crt_val2;
1354         val = set[6];
1355         if (val == -1) {
1356                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_SMART_SCREEN, &val1);
1357                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_SMART_ROTATE, &val2);
1358         }else if (val == -2) {
1359                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_SMART_SCREEN, &val1);
1360                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_SMART_ROTATE, &val2);
1361         } else {
1362                 val1 = val;
1363                 val2 = val;
1364         }
1365         vconf_get_int(VCONFKEY_SETAPPL_SMARTSCREEN_SMARTSTAY_STATUS, &crt_val);
1366         vconf_get_bool(VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION, &crt_val2);
1367         if (val1 != crt_val) {
1368                 vconf_set_int(VCONFKEY_SETAPPL_SMARTSCREEN_SMARTSTAY_STATUS, val1);
1369                 _DBG("set Smart screen %d", val1);
1370         }
1371         if (val2 != crt_val2) {
1372                 vconf_set_bool(VCONFKEY_SETAPPL_SMARTSCREEN_SMART_ROTATION, val2);
1373                 _DBG("set Smart screen rotation %d", val2);
1374         }
1375
1376         //Touch key light duration #8
1377         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &crt_val);
1378         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION %d", crt_val);
1379         val = set[7];
1380         if (val == -3) {
1381                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT, &val);
1382                 _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT %d", val);
1383         }
1384         if (val == -4) {
1385                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT, &val);
1386                 _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT %d", val);
1387         }
1388         if (val != crt_val) {
1389                 vconf_set_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, val);
1390                 _DBG("set Touch key light duration %d", val);
1391         }
1392
1393         //gray scale tone #9
1394         //gray scale tone for power saving mode!
1395         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &crt_val);
1396         val = set[8];
1397         if (val == -1) {
1398                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE, &val);
1399         }
1400         if (val == -2) {
1401                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE, &val);
1402         }
1403         if (val != crt_val) {
1404                 vconf_set_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, val);
1405                 _DBG("set gray scale tone %d", val);
1406         }
1407
1408         //CPU max freq #10
1409         //cpu limit on for power saving mode!
1410         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &crt_val);
1411         val = set[9];
1412         if (val == -1) {
1413                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF, &val);
1414         }
1415         if (val == -2) {
1416                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF, &val);
1417         }
1418
1419         if (val != crt_val) {
1420                 vconf_set_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, val);
1421                 _DBG("set CPU frequency limit %d", val);
1422         }
1423
1424         //Screen Output (D.FPS) #11
1425         //screen output for power saving mode!
1426         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &crt_val);
1427         val = set[10];
1428         if (val == -1) {
1429                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS, &val);
1430         }
1431         if (val == -2) {
1432                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS, &val);
1433         }
1434         if (val != crt_val) {
1435                 vconf_set_bool(VCONFKEY_SETAPPL_WINDOW_FPS, val);
1436                 _DBG("set FPS %d", val);
1437         }
1438
1439         //Eco. wallpaper (Wallpaper change) #12
1440         char *str1;
1441         char *str2;
1442         char *crt_str1;
1443         char *crt_str2;
1444         val = set[11];
1445         crt_str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
1446         crt_str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
1447         if (val == -1) {
1448                 ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HOMESCREEN_PATH, &str1);
1449                 ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LOCKSCREEN_PATH, &str2);
1450         } else if (val == -2) {
1451                 ret = preference_get_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH, &str1);
1452                 ret = preference_get_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH, &str2);
1453         } else { // value ==1 and other cases -> set to default value
1454                 str1 = strdup(HOMESCREEN_FILE);
1455                 str2 = strdup(LOCKSCREEN_FILE);
1456         }
1457
1458         if (strcmp(str1, crt_str1) != 0) {
1459                 vconf_set_str(VCONF_HOMESCREEN_PATH, str1);
1460                 _DBG("set eco home screen wallpaper");
1461         }
1462         if (strcmp(str2, crt_str2) != 0) {
1463                 vconf_set_str(VCONF_LOCKSCREEN_PATH, str2);
1464                 _DBG("set eco lock screen wallpaper");
1465         }
1466         free(str1);
1467         free(str2);
1468         free(crt_str1);
1469         free(crt_str2);
1470
1471         //END of the Power saving profile set
1472
1473         //pkghome -for HOMESCREEN #13
1474         char *str=NULL;
1475         char *crt_str=NULL;
1476         val = set[12];
1477         crt_str = vconf_get_str(VCONF_PKG_PATH);
1478         if (val == -1) {
1479                 int chk_easy=0;
1480                 vconf_get_bool(VCONFKEY_SETAPPL_HOMESCREEN_EASYMODE_BOOL, &chk_easy);
1481                 if(chk_easy){
1482                         //easy-mode :on -> off mode did not go back to current, just keep easy home state
1483                         str = strdup(PKG_EASYHOME);     //get curren pkg home path -> easy-mode
1484                 }
1485                 else{
1486                         //off on easy-mode
1487                         //ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, &str);
1488                         str = strdup(PKG_CLUSTERHOME);
1489                 }
1490         }else if (val == -2) {
1491                 int chk_easy=0;
1492                 vconf_get_bool(VCONFKEY_SETAPPL_HOMESCREEN_EASYMODE_BOOL, &chk_easy);
1493                 if(chk_easy){
1494                         //easy-mode :on -> off mode did not go back to current, just keep easy home state
1495                         str = strdup(PKG_EASYHOME);     //get curren pkg home path -> easy-mode
1496                 }
1497                 else{
1498                         //off on easy-mode
1499                         //ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, &str);
1500                         str = strdup(PKG_CLUSTERHOME);
1501                 }
1502         } else if (val == 1) {
1503                 str = strdup(PKG_EMERGENCY);
1504         }
1505
1506         if (str != NULL && strcmp(str, crt_str) != 0) {
1507                 vconf_set_str(VCONF_PKG_PATH, str);
1508         }
1509         free(str);
1510         free(crt_str);
1511
1512         //LED indicator - VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS (bool) #14
1513         vconf_get_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, &crt_val);
1514         val = set[13];
1515         if (val == -1) {
1516                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LED_INDICATOR_NOTI, &val);
1517         }
1518         if (val == -2) {
1519                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LED_INDICATOR_NOTI, &val);
1520         }
1521
1522         if (val != crt_val) {
1523                 vconf_set_bool(VCONFKEY_SETAPPL_LED_INDICATOR_NOTIFICATIONS, val);
1524                 _DBG("set LED indicator%d", val);
1525         }
1526         //ENDOF POWER SAVING PROFILES
1527
1528         //OTHERS
1529         //Battery level display - VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL #15
1530         vconf_get_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, &crt_val);
1531         val = set[14];
1532         if (val == -1) {
1533                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BATTERY_PERCENTAGE, &val);
1534         }
1535         if (val == -2) {
1536                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BATTERY_PERCENTAGE, &val);
1537         }
1538
1539         if (val != crt_val) {
1540                 vconf_set_bool(VCONFKEY_SETAPPL_BATTERY_PERCENTAGE_BOOL, val);
1541                 _DBG("set battery percent %d", val);
1542         }
1543
1544         //Voice control - VCONFKEY_VOICE_CONTROL_ENABLED #16
1545         vconf_get_bool(VCONFKEY_VOICE_CONTROL_ENABLED, &crt_val);
1546         val = set[15];
1547         if (val == -1) {
1548                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_VOICE_CONTROL, &val);
1549         }
1550         if (val == -2) {
1551                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_VOICE_CONTROL, &val);
1552         }
1553
1554         if (val != crt_val) {
1555                 vconf_set_bool(VCONFKEY_VOICE_CONTROL_ENABLED, val);
1556                 _DBG("set voice control %d", val);
1557         }
1558         //Multi window - VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED #17
1559         vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &crt_val);
1560         val = set[16];
1561         if (val == -1) {
1562                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_MULTIWINDOW, &val);
1563         }
1564         if (val == -2) {
1565                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_MULTIWINDOW, &val);
1566         }
1567
1568         if (val != crt_val) {
1569                 vconf_set_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, val);
1570                 _DBG("set Multi window %d", val);
1571         }
1572         //Hands-free mode - syspopup : VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE #18
1573         vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &crt_val);
1574         val = set[17];
1575         if (val == -1) {
1576                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HANDS_FREE_MODE, &val);
1577         }
1578         if (val == -2) {
1579                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HANDS_FREE_MODE, &val);
1580         }
1581
1582         if (val != crt_val) {
1583                 vconf_set_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, val);
1584                 //todo mode-syspopup
1585                 _DBG("set Hands-free mode %d", val);
1586         }
1587         //Blocking mode - syspopup #19
1588         vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, &crt_val);
1589         val = set[18];
1590         if (val == -1) {
1591                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BLOCKING_MODE, &val);
1592         }
1593         if (val == -2) {
1594                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BLOCKING_MODE, &val);
1595         }
1596
1597         if (val != crt_val) {
1598                 vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, val);
1599         }
1600
1601         //Net-restriction mode - syspopup #20
1602         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &crt_val);
1603         val = set[19];
1604         if (val == -1) {
1605                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE, &val);
1606         }
1607         if (val == -2) {
1608                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE, &val);
1609         }
1610
1611         if (val != crt_val) {
1612                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, val);
1613                 //todo mode-syspopup
1614                 _DBG("set Net-restriction mode %d", val);
1615         }
1616
1617         //mini app terminate - syspopup #21
1618         val = set[20];
1619         if (val == 1) {
1620                 _DBG("emergency terminate mini");
1621                 _terminate_miniapp(ad);
1622         }
1623
1624         //unmount for private mode - syspopup #22
1625         val = set[21];
1626         if (val == 1) {
1627                 _DBG("unmount for private mode");
1628                 _unmount_fs();
1629         }
1630 }
1631
1632 ///////////////////
1633 /// blocking mode ///
1634 ///////////////////
1635 void mode_syspopup_layout_ug_cb(ui_gadget_h ug, enum ug_mode mode,
1636                                   void *priv)
1637 {
1638         Evas_Object *base;
1639
1640         if (!priv){
1641                 return;
1642         }
1643
1644         base = (Evas_Object *) ug_get_layout(ug);
1645         if (!base){
1646                 return;
1647         }
1648
1649         switch (mode) {
1650         case UG_MODE_FULLVIEW:
1651                 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
1652                                                  EVAS_HINT_EXPAND);
1653                 evas_object_show(base);
1654                 break;
1655         default:
1656                 break;
1657         }
1658 }
1659
1660 void mode_syspopup_destroy_font_ug_cb(ui_gadget_h ug, void *priv)
1661 {
1662         if (!priv){
1663                 return;
1664         }
1665         struct appdata *ad =  priv;
1666         elm_win_lower(ad->win);
1667         if (ug) {
1668                 ug_destroy(ug);
1669                 ad->ug = NULL;
1670         }
1671 }
1672
1673 //blocking mode alarm on/off
1674 static void __set_on_alarm(int start_h, int start_m, int end_h, int end_m)
1675 {
1676         MODE_BM_AData *start_alarm = (MODE_BM_AData *)calloc(1, sizeof(MODE_BM_AData));
1677         MODE_BM_AData *end_alarm = (MODE_BM_AData *)calloc(1, sizeof(MODE_BM_AData));
1678
1679         //alarm server regist
1680         //on
1681         start_alarm->hour = start_h;
1682         start_alarm->min = start_m;
1683         end_alarm->hour = end_h;
1684         end_alarm->min = end_m;
1685
1686         int start_block_id, end_block_id = -1;
1687         vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, &start_block_id);
1688         vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, &end_block_id);
1689         start_alarm->alarm_mgr_id = start_block_id;
1690         end_alarm->alarm_mgr_id = end_block_id;
1691         int nErr = mode_syspopup_alarmmgr_update(start_alarm);
1692         if(!nErr)
1693         {
1694                 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, start_alarm->alarm_mgr_id);
1695         }
1696         nErr = mode_syspopup_alarmmgr_update(end_alarm);
1697         if(!nErr)
1698         {
1699                 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, end_alarm->alarm_mgr_id);
1700         }
1701
1702         free(start_alarm);
1703         free(end_alarm);
1704 }
1705
1706 static void __set_off_alarm()
1707 {
1708         MODE_BM_AData *start_alarm = (MODE_BM_AData *)calloc(1, sizeof(MODE_BM_AData));
1709         MODE_BM_AData *end_alarm = (MODE_BM_AData *)calloc(1, sizeof(MODE_BM_AData));
1710
1711         //alarm server delete
1712         //off
1713         //with id, not time
1714         int start_block_id, end_block_id = -1;
1715         vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, &start_block_id);
1716         vconf_get_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, &end_block_id);
1717         start_alarm->alarm_mgr_id = start_block_id;
1718         end_alarm->alarm_mgr_id = end_block_id;
1719         int nErr = mode_syspopup_alarmmgr_remove(start_alarm);
1720         if(!nErr)
1721         {
1722                 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_START, -1);
1723         }
1724         nErr = mode_syspopup_alarmmgr_remove(end_alarm);
1725         if(!nErr)
1726         {
1727                 vconf_set_int(VCONFKEY_SETAPPL_BM_ALARM_ID_END, -1);
1728         }
1729
1730         free(start_alarm);
1731         free(end_alarm);
1732 }
1733
1734
1735 static int _blockingmode_get_status(void *data)
1736 {
1737         struct appdata *ad = data;
1738         int ret = 0;
1739         int all_day, call, noti, alarmNtimer, led = 0;
1740         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALLDAY, &all_day);
1741         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, &call);
1742         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, &noti);
1743         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, &alarmNtimer);
1744         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, &led);
1745         int b_call, b_noti, b_alarmNtimer, b_led = 0;
1746         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_INCOMING_CALL, &b_call);
1747         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_NOTIFICATIONS, &b_noti);
1748         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_ALARM_AND_TIMER, &b_alarmNtimer);
1749         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_LED_INDICATOR, &b_led);
1750
1751         ad->all_day = all_day;
1752         ad->call = call;
1753         ad->noti = noti;
1754         ad->alarmNtimer = alarmNtimer;
1755         ad->led = led;
1756         ad->b_call = b_call;
1757         ad->b_noti = b_noti;
1758         ad->b_alarmNtimer = b_alarmNtimer;
1759         ad->b_led = b_led;
1760
1761         return ret;
1762 }
1763
1764 static bool __check_drivingmode_sub_item()
1765 {
1766         _DBG("__check_drivingmode_sub_item");
1767         //if zero cnt with master on, then it showed popup to rollback it(back btn)
1768         int vcnf_ret  = 0;
1769         int ret  = FALSE;
1770         int sub_item_value = 0;
1771
1772         /* check VCONFKEY_SETAPPL_DM_INCOMING_CALL */
1773         vcnf_ret = vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_INCOMINGCALL, &sub_item_value);  //backup
1774         if (sub_item_value) {
1775                 ret = TRUE;
1776         }else {
1777         }
1778
1779         /* check VCONFKEY_SETAPPL_DM_MESSAGE */
1780         vcnf_ret = vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_MESSAGE, &sub_item_value);       //backup
1781         if (sub_item_value) {
1782                 ret = TRUE;
1783         }else {
1784         }
1785
1786         /* check VCONFKEY_SETAPPL_DM_ALARM */
1787         vcnf_ret = vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_ALARM, &sub_item_value); //backup
1788         if (sub_item_value) {
1789                 ret = TRUE;
1790         }else {
1791         }
1792
1793         /* check VCONFKEY_SETAPPL_DM_SCHEDULE */
1794         vcnf_ret = vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_SCHEDULE, &sub_item_value);      //backup
1795         if (sub_item_value) {
1796                 ret = TRUE;
1797         }else {
1798         }
1799
1800         _DBG("ret : [%d]",ret);
1801         return ret;
1802 }
1803
1804 static int _range_chk_with_set_block_alarm(void *data)
1805 {
1806         struct appdata *ad = data;
1807         //range check with current time
1808         if(!ad->all_day){
1809                 struct tm cur_t;
1810                 memset(&cur_t, 0, sizeof(struct tm));
1811                 time_t cur_time = time(0);
1812                 if (NULL == localtime_r(&cur_time, &cur_t)) {
1813                         _DBG("fail to call localtime_r");
1814                         return;
1815                 }
1816                 _DBG("%d:%d", cur_t.tm_hour, cur_t.tm_min);
1817                 int start_h,start_m,end_h,end_m;
1818                 vconf_get_int(VCONFKEY_SETAPPL_BM_START_HOUR, &start_h);
1819                 vconf_get_int(VCONFKEY_SETAPPL_BM_START_MIN, &start_m);
1820                 vconf_get_int(VCONFKEY_SETAPPL_BM_END_HOUR, &end_h);
1821                 vconf_get_int(VCONFKEY_SETAPPL_BM_END_MIN, &end_m);
1822
1823                 int start = 60*start_h+start_m;
1824                 int end = 60*end_h+end_m;
1825                 int cur = 60*cur_t.tm_hour + cur_t.tm_min;
1826
1827                 int ret = 0;
1828                 int call, noti, alarmNtimer, led = 0;
1829                 ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_INCOMING_CALL, &call);
1830                 ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_NOTIFICATIONS, &noti);
1831                 ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_ALARM_AND_TIMER, &alarmNtimer);
1832                 ret |= vconf_get_bool(VCONFKEY_SETAPPL_BM_INTER_LED_INDICATOR, &led);
1833
1834                 ad->in_range = FALSE;
1835                 if(start < end)
1836                 {
1837                         if(start <= cur && cur < end)
1838                         {
1839                                 ad->in_range = TRUE;
1840                                 if(call)
1841                                 {
1842                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, TRUE);
1843                                 }
1844                                 if(noti)
1845                                 {
1846                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, TRUE);
1847                                 }
1848                                 if(alarmNtimer)
1849                                 {
1850                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, TRUE);
1851                                 }
1852                                 if(led)
1853                                 {
1854                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, TRUE);
1855                                 }
1856                         }
1857                         else
1858                         {
1859                                 if(call)
1860                                 {
1861                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, FALSE);
1862                                 }
1863                                 if(noti)
1864                                 {
1865                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, FALSE);
1866                                 }
1867                                 if(alarmNtimer)
1868                                 {
1869                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, FALSE);
1870                                 }
1871                                 if(led)
1872                                 {
1873                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, FALSE);
1874                                 }
1875                         }
1876                 }else{
1877                         if(start <= cur || cur < end)
1878                         {
1879                                 ad->in_range = TRUE;
1880                                 if(call)
1881                                 {
1882                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, TRUE);
1883                                 }
1884                                 if(noti)
1885                                 {
1886                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, TRUE);
1887                                 }
1888                                 if(alarmNtimer)
1889                                 {
1890                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, TRUE);
1891                                 }
1892                                 if(led)
1893                                 {
1894                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, TRUE);
1895                                 }
1896                         }
1897                         else
1898                         {
1899                                 if(call)
1900                                 {
1901                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, FALSE);
1902                                 }
1903                                 if(noti)
1904                                 {
1905                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, FALSE);
1906                                 }
1907                                 if(alarmNtimer)
1908                                 {
1909                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, FALSE);
1910                                 }
1911                                 if(led)
1912                                 {
1913                                         ret |=vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, FALSE);
1914                                 }
1915                         }
1916                 }
1917                 ad->start_h = start_h;
1918                 ad->start_m = start_m;
1919                 ad->end_h = end_h;
1920                 ad->end_m = end_m;
1921                 return TRUE;
1922         }
1923         else
1924         {
1925                 //not need to set for allday
1926                 return FALSE;
1927         }
1928 }
1929
1930 static int _blockingmode_btn_change_set(void *data, int set_value)
1931 {
1932         struct appdata *ad = data;
1933         const char *vconf_key = NULL;
1934         const char *pref_key = NULL;
1935         int ret = 0;
1936
1937         vconf_key = VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE;
1938
1939         if (set_value) {
1940                 //ON
1941                 if(ad->b_call){
1942                         if(ad->all_day){
1943                                 //all day 1 to set on
1944                                 vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, TRUE);
1945                         }
1946                 }
1947                 if(ad->b_noti){
1948                         if(ad->all_day){
1949                                 vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, TRUE);
1950                         }
1951                 }
1952                 if(ad->b_alarmNtimer){
1953                         if(ad->all_day){
1954                                 vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, TRUE);
1955                         }
1956                 }
1957                 if(ad->b_led){
1958                         if(ad->all_day){
1959                                 vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, TRUE);
1960                         }
1961                 }
1962                 //regist alarm
1963                 if(_range_chk_with_set_block_alarm(ad) == TRUE){
1964                         __set_on_alarm(ad->start_h, ad->start_m, ad->end_h, ad->end_m);
1965                 }
1966                 else{
1967                         //not need to set for allday
1968                 }
1969         } else {
1970                 /* when BM is FALSE all app vconf need to change FALSE */
1971                 if(ad->b_call){
1972                         vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_INCOMINGCALL, FALSE);
1973                 }
1974                 if(ad->b_noti){
1975                         vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_NOTIFICATIONS, FALSE);
1976                 }
1977                 if(ad->b_alarmNtimer){
1978                         vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_ALARM_AND_TIMER, FALSE);
1979                 }
1980                 if(ad->b_led){
1981                         vconf_set_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_LED_INDICATOR, FALSE);
1982                 }
1983                 //unregist alarm
1984                 __set_off_alarm();
1985         }
1986
1987         //set toogle to vconf
1988         if(vconf_key){
1989                 ret = vconf_set_bool(vconf_key, set_value);
1990         }
1991         _DBG("ret:%d", ret);
1992
1993         /*todo*/
1994         //range check with current time
1995         return ret;
1996 }
1997
1998
1999 void __set_gray_tone(int opposite) {
2000
2001 #if 0 //The function will cause KERNAL PANNIC
2002         unsigned int val;
2003         Ecore_X_Window rootWin;
2004         Ecore_X_Atom atomHighContrast;
2005         rootWin = ecore_x_window_root_first_get();
2006         atomHighContrast = ecore_x_atom_get("_E_ACC_ENABLE_HIGH_CONTRAST_");
2007
2008         val = opposite;
2009         ecore_x_window_prop_card32_set(rootWin, atomHighContrast, &val, 1);
2010 #endif  
2011 }
2012
2013 // rotation policy with lock screen
2014 static void lcd_state_changed(keynode_t *key, void *data)
2015 {
2016         int state;
2017         struct appdata *ad = data;
2018
2019         if (!key || !ad)
2020                 return;
2021
2022         state = vconf_keynode_get_int(key);
2023         if (state != VCONFKEY_PM_STATE_LCDOFF)
2024                 return;
2025
2026         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
2027                 _DBG("vconf key ignore failed");
2028
2029         elm_exit();
2030 }
2031
2032 //popup handling
2033 static void __def_response_cb(void *data, Evas_Object *obj,
2034                                      void *event_info)
2035 {
2036         _DBG(" REMOVE THE POPUP OBJECT BY THIS FUNCTION ");
2037         if (obj) {
2038                 evas_object_del(obj);
2039                 obj = NULL;
2040         }
2041 }
2042
2043 void __popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
2044 {
2045         _DBG("__popup_del_cb");
2046         Ecore_X_Display *disp = ecore_x_display_get();
2047         Ecore_X_Window xwin = elm_win_xwindow_get(obj);
2048         int ret = utilx_ungrab_key(disp, xwin, KEY_HOME);
2049         if (ret) {
2050                 _DBG("KEY_HOME ungrab error ret[%d]", ret);
2051         }
2052
2053         ret = utilx_ungrab_key(disp, xwin, KEY_BACK);
2054         if (ret) {
2055                   _DBG("KEY_BACK ungrab error ret[%d]", ret);
2056         }
2057
2058         ret = utilx_ungrab_key(disp, xwin, KEY_POWER);
2059         if (ret) {
2060                  _DBG("KEY_POWER ungrab error ret[%d]", ret);
2061         }
2062
2063         ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEUP);
2064         if (ret) {
2065                  _DBG("KEY_VOLUMEUP ungrab error ret[%d]", ret);
2066         }
2067
2068         ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEDOWN);
2069         if (ret) {
2070                  _DBG("KEY_VOLUMEDOWN ungrab error ret[%d]", ret);
2071         }
2072 }
2073
2074 static void __popup_event_set(Evas_Object *popup, void *data,
2075                                          _cb_func response_cb,
2076                                          int timeout,//to control the timeout time
2077                                          bool blocked_flag,//to control whether to block the screen
2078                                          bool keygrab_flag//to control whether to block the 'Home key'
2079                                          )
2080 {
2081         _DBG("__popup_event_set");
2082         if (timeout > 0) {
2083                 if (response_cb) {
2084                         evas_object_smart_callback_add(popup, "timeout", response_cb, data);
2085                 } else {
2086                         evas_object_smart_callback_add(popup, "timeout", __def_response_cb, data);
2087                 }
2088         }
2089
2090         if (!blocked_flag) {//not blocked_flag == TRUE !!!
2091                 if (response_cb) {
2092                         evas_object_smart_callback_add(popup, "block,clicked", response_cb, data);
2093                 } else {
2094                         evas_object_smart_callback_add(popup, "block,clicked", __def_response_cb, data);
2095                 }
2096         }
2097
2098         if (keygrab_flag) {
2099                 Ecore_X_Display *disp = ecore_x_display_get();
2100                 Ecore_X_Window xwin = elm_win_xwindow_get(popup);
2101                 int ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
2102                 if (ret) {
2103                         _DBG("KEY_HOME grab error ret[%d]", ret);
2104                 }
2105
2106                 ret = utilx_grab_key(disp, xwin, KEY_BACK, TOP_POSITION_GRAB);
2107                 if (ret) {
2108                          _DBG("KEY_BACK grab error ret[%d]", ret);
2109                 }
2110
2111                 ret = utilx_grab_key(disp, xwin, KEY_POWER, TOP_POSITION_GRAB);
2112                 if (ret) {
2113                          _DBG("KEY_POWER grab error ret[%d]", ret);
2114                 }
2115
2116                 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEUP, TOP_POSITION_GRAB);
2117                 if (ret) {
2118                          _DBG("KEY_VOLUMEUP grab error ret[%d]", ret);
2119                 }
2120
2121                 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEDOWN, TOP_POSITION_GRAB);
2122                 if (ret) {
2123                          _DBG("KEY_VOLUMEDOWN grab error ret[%d]", ret);
2124                 }
2125
2126                 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __popup_del_cb, NULL);
2127         }
2128 }
2129
2130 static Evas_Object *__add_progressbar(void *data, Evas_Object *parent,
2131                                           char *progressbar_style,
2132                                           char *progressbar_title,
2133                                           char *progressbar_lable)
2134 {
2135         _DBG("__add_progressbar");
2136 #if 0
2137         Evas_Object *popup;
2138         Evas_Object *progressbar;
2139         struct appdata *ad;
2140         Evas_Object *layout;
2141
2142         ad = (struct appdata *) data;
2143         popup = ea_center_popup_add(parent);
2144
2145         layout = elm_layout_add(popup);
2146         elm_layout_file_set(layout, POPUP_EDJ, "popup_processingview_1button"); //u can use add button or not
2147         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2148
2149         // [UI] progress icon
2150         progressbar = elm_progressbar_add(popup);
2151         elm_progressbar_pulse(progressbar, EINA_TRUE);
2152         elm_object_style_set(progressbar, progressbar_style);
2153         elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2154         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
2155         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2156         evas_object_show(progressbar);
2157
2158         elm_object_part_content_set(layout, "elm.swallow.content", progressbar);
2159         // [UI] text
2160         elm_object_part_text_set(layout, "elm.text", progressbar_lable);
2161
2162         elm_object_content_set(popup, layout);
2163         return popup;
2164 #endif
2165         Evas_Object *popup;
2166         Evas_Object *progressbar;
2167         Evas_Object *layout;
2168         Evas_Object *label;
2169         int change_ang = 0;
2170
2171         popup = elm_popup_add(parent);
2172         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2173
2174         Evas_Object *box = elm_box_add(popup);
2175         elm_box_horizontal_set(box, EINA_TRUE);
2176         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2177         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2178         elm_box_align_set(box, 0.5, 0.5);
2179         elm_box_padding_set(box, 16, 0);
2180
2181         progressbar = elm_progressbar_add(popup);
2182         elm_progressbar_pulse(progressbar, EINA_TRUE);
2183         elm_object_style_set(progressbar, "process_large");
2184         evas_object_show(progressbar);
2185         elm_box_pack_end(box, progressbar);
2186
2187         label = elm_label_add(popup);
2188         elm_object_text_set(label, progressbar_lable);
2189         evas_object_show(label);
2190         elm_box_pack_end(box, label);
2191
2192         Evas_Object *table = elm_table_add(popup);
2193         evas_object_show(table);
2194         elm_table_homogeneous_set(table, EINA_FALSE);
2195
2196         Evas_Object *rect_up;
2197         rect_up = evas_object_rectangle_add(evas_object_evas_get(popup));
2198         evas_object_size_hint_min_set(rect_up, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(32));
2199
2200         Evas_Object *rect_down;
2201         rect_down = evas_object_rectangle_add(evas_object_evas_get(popup));
2202         evas_object_size_hint_min_set(rect_down, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(37));
2203
2204         // box
2205         elm_table_pack(table, rect_up, 0, 0, 1, 1);// rect as a padding
2206         elm_table_pack(table, box, 0, 1, 1, 1);
2207         elm_table_pack(table, rect_down, 0, 2, 1, 1);// rect as a padding
2208         evas_object_show(box);
2209         elm_object_content_set(popup, table);
2210
2211         evas_object_show(popup);
2212         return popup;
2213 }
2214
2215 static Evas_Object *__add_double_line_progressbar(void *data, Evas_Object *parent,
2216                                           char *progressbar_style,
2217                                           char *progressbar_title,
2218                                           char *progressbar_lable)
2219 {
2220         _DBG("__add_double_line_progressbar");
2221         Evas_Object *popup;
2222         Evas_Object *label;
2223         Evas_Object *layout;
2224         Evas_Object *progressbar;
2225         popup = ea_center_popup_add(parent);
2226         // [UI] add lable
2227         if (progressbar_lable) {
2228                 label = elm_label_add(popup);
2229                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
2230                 elm_object_text_set(label, _(progressbar_lable));
2231                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
2232                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
2233                 evas_object_show(label);
2234         }
2235         layout = elm_layout_add(popup);
2236         elm_layout_file_set(layout, POPUP_EDJ, "popup_processingview");
2237         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2238
2239         // [UI] progress icon
2240         if (progressbar_style) {
2241                 progressbar = elm_progressbar_add(popup);
2242                 elm_progressbar_pulse(progressbar, EINA_TRUE);
2243                 elm_object_style_set(progressbar, progressbar_style);
2244                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
2245                 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
2246                 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2247                 evas_object_show(progressbar);
2248         }
2249
2250         elm_object_part_content_set(layout, "elm.swallow.content", progressbar);
2251         elm_object_part_content_set(layout, "elm.swallow.text", label);
2252
2253         elm_object_content_set(popup, layout);
2254         return popup;
2255 }
2256
2257
2258 Evas_Object *__popup_with_progressbar(void *data, Evas_Object *popup,
2259                                                   Evas_Object *parent,
2260                                                   char *progressbar_style,
2261                                                   char *title,
2262                                                   char *text,
2263                                                   _cb_func response_cb,
2264                                                   int timeout,
2265                                                   bool blocked_flag,
2266                                                   bool keygrab_flag,
2267                                                   bool dobule_line_flag)
2268 {
2269         if(dobule_line_flag){
2270                 popup = __add_double_line_progressbar(data, parent, progressbar_style,
2271                                           title, text);
2272         }else{
2273                 popup = __add_progressbar(data, parent, progressbar_style,
2274                                           title, text);
2275                 elm_object_style_set(popup, "no_effect");
2276         }
2277
2278         if (timeout > 0) {
2279                 elm_popup_timeout_set(popup, timeout);
2280         }
2281         __popup_event_set(popup, data, response_cb, timeout, blocked_flag, keygrab_flag);
2282         evas_object_show(popup);
2283         return popup;
2284 }
2285
2286 Evas_Object *_create_bg(Evas_Object *parent,Evas_Object *win, const char *bg_style)
2287 {
2288         char *path = NULL;
2289         if (parent == NULL) {
2290                 return "NULL";
2291         }
2292         Evas_Object *bg = elm_bg_add(parent);
2293
2294         if (bg == NULL) {
2295                 return "NULL";
2296         }
2297         elm_object_style_set(bg, bg_style);
2298         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
2299                                          EVAS_HINT_EXPAND);
2300         elm_win_resize_object_add(parent, bg);  //regarding window resize
2301         //elm_bg_file_set(bg, DEFAULT_BG_PATH, NULL);
2302         evas_object_show(bg);
2303         return bg;
2304 }
2305
2306 char *mode_syspopup_gettext(const char *s)
2307 {
2308          /* fisrt find in app pg */
2309          if (s == NULL) {
2310                  return "NULL";
2311          }
2312
2313          char *p = dgettext(PACKAGE, s);
2314
2315          if (p && !strcmp(s, p)) {        /* not found */
2316                  /* find in system pkg */
2317                  p = dgettext("sys_string", s);
2318          }
2319
2320          if (p && !strcmp(s, p)) {        /* not found */
2321                  /* find in system pkg */
2322                  p = dgettext("setting", s);
2323          }
2324          return p;
2325 }
2326
2327 int myterm(bundle * b, void *data)
2328 {
2329         return 0;
2330 }
2331
2332 int mytimeout(bundle * b, void *data)
2333 {
2334         return 0;
2335 }
2336
2337 syspopup_handler handler = {
2338         .def_term_fn = myterm,
2339         .def_timeout_fn = mytimeout
2340 };
2341
2342 #if 0
2343 static void __mode_syspopup_regist_keys(struct appdata *ad)
2344 {
2345         //work with notification regsters contents
2346         vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, _mode_vconf_change_cb, ad);
2347         vconf_notify_key_changed(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, _mode_vconf_change_cb, ad);
2348         //PM state
2349         vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_changed, ad);
2350 }
2351
2352 static void __mode_syspopup_ignore_keys(struct appdata *ad)
2353 {
2354         vconf_ignore_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, _mode_vconf_change_cb);
2355         vconf_ignore_key_changed(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, _mode_vconf_change_cb);
2356
2357         //PM state
2358         vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed);
2359 }
2360 #endif
2361
2362
2363 /* Release evas object */
2364 void release_evas_object(Evas_Object **obj)
2365 {
2366         if (!obj || !(*obj))
2367                 return;
2368         evas_object_del(*obj);
2369         *obj = NULL;
2370 }
2371
2372
2373 static void ea_popup_back_cb_overide(void *data, Evas_Object *obj, void *event_info)
2374 {
2375         ea_popup_back_cb(data, obj, event_info);
2376
2377         if(NULL == data) return;
2378         struct appdata *ad = data;
2379         __mode_syspopup_app_terminate(ad);
2380 }
2381
2382 static void timeout_response_cb(void *data, Evas_Object *obj, void *event_info)
2383 {
2384         ea_popup_back_cb(data, obj, event_info);
2385
2386         if(NULL == data) return;
2387         struct appdata *ad = data;
2388
2389         if (ad->popup) {
2390                 evas_object_del(ad->popup);
2391                 ad->popup = NULL;
2392         }
2393         __mode_syspopup_app_terminate(ad);
2394 }
2395
2396 static void __progress_popup_cb(void *data, Evas_Object *obj, void *event_info)
2397 {
2398         if(NULL == data) return;
2399         struct appdata *ad = data;
2400         _DBG("progress popup cb");
2401
2402         // have operating delay in emergency to cluster, exit point was after progress
2403         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
2404                 _DBG("vconf key ignore failed");
2405
2406         is_recovery = false;
2407
2408         //refresh indicator
2409         __mode_reboot_noti_method();
2410
2411         elm_exit();
2412 }
2413
2414 Eina_Bool
2415 play_timeout_update_cb(void *data)
2416 {
2417         if(NULL == data) return EINA_FALSE;
2418         struct appdata *ad = data;
2419         play_text(ad, _("IDS_ST_BODY_A_PERSON_YOU_HAVE_GRANTED_AUTHORITY_TO_IS_TRYING_TO_REMOTELY_ENABLE_EMERGENCY_MODE_ON_THIS_DEVICE_MSG"));
2420         ad->play_timer = NULL;
2421         return EINA_FALSE;
2422 }
2423
2424
2425 static void __mode_syspopup_emergency_cb(void *data, Evas_Object * obj, void *event_info)
2426 {
2427         struct appdata *ad = data;
2428
2429         if (!ad)
2430                 return;
2431
2432         //delete old help
2433         if (ad->help_type != HELP_NONE) {
2434                 if (ad->help_circle) {
2435                         evas_object_del(ad->help_circle);
2436                         ad->help_circle = NULL;
2437                 }
2438                 if (ad->help_popup) {
2439                         evas_object_del(ad->help_popup);
2440                         ad->help_popup = NULL;
2441                 }
2442         }
2443
2444         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2445         if(!strcmp(btn_str, _("IDS_COM_SK_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))){
2446                 //make complete flag
2447                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2448                 if(ret) _ERR("check export xml");
2449
2450                 int m_key;
2451                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2452                 if(m_key == SETTING_PSMODE_NORMAL){
2453                         //backup
2454                         _mode_backup_settings(ad);
2455                 }
2456                 else if(m_key == SETTING_PSMODE_POWERFUL){
2457                         //backup
2458                         _mode_power_backup_settings(ad);
2459                 }
2460                 release_evas_object(&(ad->popup));
2461                 ad->bg = _create_bg(ad->win, NULL, "group_list");
2462                 //progress bar
2463                ad->enable_popup = __popup_with_progressbar(ad, ad->enable_popup, ad->win, PROGRESSBAR_STYLE,
2464                 NULL, _("IDS_ST_POP_ENABLING_EMERGENCY_MODE_ING"), __progress_popup_cb, 3/*0*/, TRUE, TRUE, TRUE);      // 2 seconds to wait in maximum
2465
2466                 //assistive light off, P140422-06240
2467                 ret = led_set_brightness_with_noti(0, TRUE);
2468                 if (0 != ret){
2469                         _DBG(">>>led SET TO ZERO err [%d]", ret);
2470                 }
2471                 else{
2472                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2473                         if(ret != 0){
2474                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",ret);
2475                                 }
2476                 }
2477
2478                 /*set emergency*/
2479                 _mode_apply_settings(ad, emergency_settings);
2480                 //set gray tone
2481                 __set_gray_tone(2);
2482                if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
2483                         _DBG("set on SETTING_PSMODE_EMERGENCY");
2484                 }
2485                 free(btn_str);
2486         } else if (!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
2487                 _DBG("CANCEL");
2488                 free(btn_str);
2489                 elm_exit();
2490         } else {
2491                 free(btn_str);
2492         }
2493         //evas_object_del(ad->win);
2494 }
2495
2496 static void __mode_syspopup_powerful_cb(void *data, Evas_Object * obj, void *event_info)
2497 {
2498         struct appdata *ad = data;
2499
2500         if (!ad)
2501                 return;
2502
2503         //delete old help
2504         if (ad->help_type != HELP_NONE) {
2505                 if (ad->help_circle) {
2506                         evas_object_del(ad->help_circle);
2507                         ad->help_circle = NULL;
2508                 }
2509                 if (ad->help_popup) {
2510                         evas_object_del(ad->help_popup);
2511                         ad->help_popup = NULL;
2512                 }
2513         }
2514
2515         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2516         if(!strcmp(btn_str, _("IDS_COM_SK_OK"))){
2517                 int m_key, first;
2518                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2519                 if(m_key == SETTING_PSMODE_NORMAL){
2520                         //backup
2521                         _mode_backup_settings(ad);
2522                 }
2523                 _DBG("OK OK");
2524                 /*set normal sub*/
2525                 int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
2526
2527                 if(first){
2528                         _mode_apply_settings(ad, powerful_settings_def);
2529                         preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
2530                 }
2531                 else{
2532                         _mode_apply_settings(ad, powerful_settings);
2533                         _DBG("right to set powerful");
2534                 }
2535                /* set to default */
2536                int opposite;
2537                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2538                 if(ret) _DBG("vconf_get_bool failed");
2539                 __set_gray_tone(opposite);
2540                 //emergency mode -> normal
2541                 if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
2542                         _DBG("set on SETTING_PSMODE_POWERFUL");
2543                 }
2544         }
2545         else if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
2546                 _DBG("CANCEL");
2547         }
2548         //evas_object_del(ad->win);
2549         free(btn_str);
2550         elm_exit();
2551 }
2552
2553 static void __mode_syspopup_netrestrictionmode_change_on_cb(void *data, Evas_Object * obj, void *event_info)
2554 {
2555         struct appdata *ad = data;
2556
2557         if (!ad)
2558                 return;
2559
2560         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2561
2562         if(!strcmp(btn_str, _("IDS_COM_SK_OK")))
2563         {
2564                 _DBG("OK button");
2565
2566                 if(vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, 1) == 0)
2567                 {
2568                         _DBG("network_restrict_mode vconf set 1");
2569                 }
2570                 else
2571                 {
2572                         _DBG("network_restrict_mode vconf set failed");
2573                 }
2574         }
2575         else
2576         if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL")))
2577         {
2578                 _DBG("Cancel button");
2579         }
2580
2581         free(btn_str);
2582
2583         elm_exit();
2584 }
2585
2586 static void __mode_syspopup_netrestrictionmode_change_off_cb(void *data, Evas_Object * obj, void *event_info)
2587 {
2588         struct appdata *ad = data;
2589
2590         if (!ad)
2591                 return;
2592
2593         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2594
2595         if(!strcmp(btn_str, _("IDS_COM_SK_OK")))
2596         {
2597                 _DBG("OK button");
2598
2599                 if(vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, 0) == 0)
2600                 {
2601                         _DBG("network_restrict_mode vconf set 0");
2602                 }
2603                 else
2604                 {
2605                         _DBG("network_restrict_mode vconf set failed");
2606                 }
2607         }
2608         else
2609         if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL")))
2610         {
2611                 _DBG("Cancel button");
2612         }
2613
2614         free(btn_str);
2615
2616         elm_exit();
2617 }
2618
2619 static void __mode_syspopup_normal_cb(void *data, Evas_Object * obj, void *event_info)
2620 {
2621         _DBG("__mode_syspopup_normal_cb");
2622         struct appdata *ad = data;
2623
2624         if (!ad)
2625                 return;
2626
2627         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2628         if(!strcmp(btn_str, _("IDS_COM_SK_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_DISABLE"))){
2629                 //using normal cb as 1) emergency -> normal or 2) emergency -> powerful , after[K] concept back_mode needed
2630                 int back_mode;
2631                 preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, &back_mode);
2632
2633                 int m_key;
2634                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2635                 if(m_key == SETTING_PSMODE_POWERFUL){
2636                         //backup
2637                         _mode_power_backup_settings(ad);
2638                 }
2639                 //evas_object_hide(ad->popup);
2640                 release_evas_object(&(ad->popup));
2641                 ad->bg = _create_bg(ad->win, NULL, "group_list");
2642                 //progress bar
2643                ad->disable_popup = __popup_with_progressbar(ad, ad->disable_popup, ad->win, PROGRESSBAR_STYLE,
2644                 NULL, _(KeyStr_Loading), __progress_popup_cb, 3/*0*/, TRUE, TRUE, FALSE);       // 2 seconds to wait in maximum
2645
2646
2647                 /*set normal sub*/
2648                 if(back_mode == SETTING_PSMODE_NORMAL){
2649                         //make complete flag
2650                         int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2651                         if(ret) _ERR("check export xml");
2652                         //torch light off with diable emergency/ups mode, P140507-03841
2653                         int t_ret = led_set_brightness_with_noti(0, TRUE);
2654                         if (0 != t_ret){
2655                             _DBG(">>>led SET TO ZERO err [%d]", t_ret);
2656                         }
2657                         else{
2658                             vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2659                             if(t_ret != 0){
2660                                     _DBG("*** [ERR] Failed to disable popup off reminder %d***",t_ret);
2661                                 }
2662                         }
2663                       int b_network_lcd_off;
2664                         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
2665                         if( b_network_lcd_off ){
2666                                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
2667                         }
2668                         _mode_apply_settings(ad, normal_settings);
2669                 }
2670
2671                 /*set power sub*/
2672                 if(back_mode == SETTING_PSMODE_POWERFUL){
2673                         int first;
2674                         /*set normal sub*/
2675                         int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
2676                         if(first){
2677                                 _mode_apply_settings(ad, powerful_settings_def);
2678                                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
2679                         }
2680                         else{
2681                                 _mode_apply_settings(ad, powerful_settings);
2682                                 _DBG("right to set powerful");
2683                         }
2684                 }
2685
2686                /* set to default */
2687                int opposite;
2688                 int ret = 0;
2689                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2690                 if(ret) _DBG("vconf_get_bool failed");
2691                 __set_gray_tone(opposite);
2692                 if(back_mode == SETTING_PSMODE_NORMAL){
2693                         //emergency mode -> normal
2694                         if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
2695                                 _DBG("set on SETTING_PSMODE_NORMAL");
2696                         }
2697                 }else if(back_mode == SETTING_PSMODE_POWERFUL){
2698                         //emergency mode -> power saving
2699                         if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
2700                                 _DBG("set on SETTING_PSMODE_POWERFUL");
2701                         }
2702                 }
2703                 free(btn_str);
2704
2705                 //
2706 #if LCD_FREQ_CTRL
2707                 if (ad->lcd_freq_timer) {
2708                         ecore_timer_del(ad->lcd_freq_timer);
2709                         ad->lcd_freq_timer = NULL;
2710                 }
2711                 ad->is_lcd_ctrl = EINA_FALSE;
2712                 ad->lcd_freq_timer = ecore_timer_add(2.7, (Ecore_Task_Cb)_LCD_freq_ctrl_handler, ad);
2713 #endif
2714
2715                 _DBG("OK end");
2716         } else if (!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))) {
2717                 _DBG("CANCEL");
2718                 free(btn_str);
2719                 elm_exit();
2720         } else {
2721                 free(btn_str);
2722         }
2723         //evas_object_del(ad->win);
2724 }
2725
2726 static void __mode_blockingmode_popup_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *data)
2727 {
2728         struct appdata *ad = data;
2729         _DBG("__mode_blockingmode_popup_cb");
2730         if (ad->popup)
2731         {
2732                 evas_object_del(ad->popup);
2733                 ad->popup = NULL;
2734         }
2735 }
2736
2737 static void __mode_syspopup_blockingmode_cb(void *data, Evas_Object * obj, void *event_info)
2738 {
2739         struct appdata *ad = data;
2740
2741         if (!ad)
2742                 return;
2743
2744         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2745         if(!strcmp(btn_str, _("IDS_COM_SK_OK"))){
2746                 _DBG("OK OK");
2747
2748                 app_control_h app_control = NULL;
2749                 app_control_create(&app_control);
2750                 if (app_control == NULL) {
2751                         _DBG("the app_control is NULL");
2752                         free(btn_str);
2753                         return;
2754                 }
2755                 int ret;
2756                 ret = app_control_set_app_id(app_control, "setting-blockingmode-efl");
2757                 if (ret != APP_CONTROL_ERROR_NONE) {
2758                         _DBG("app_control_set_app_id fail : %d", ret);
2759                 }
2760                 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
2761                 ret = app_control_send_launch_request(app_control, NULL, NULL);
2762                 if (ret != APP_CONTROL_ERROR_NONE) {
2763                         _DBG("app_control_send_launch_request fail : %d", ret);
2764                 }
2765                 app_control_destroy(app_control);
2766         }
2767         else if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
2768                 _DBG("CANCEL");
2769         }
2770         if (ad->popup) {
2771                 evas_object_del(ad->popup);
2772                 ad->popup = NULL;
2773         }
2774         //evas_object_del(ad->win);
2775         free(btn_str);
2776         elm_exit();
2777 }
2778
2779 static void __mode_syspopup_drivingmode_cb(void *data, Evas_Object * obj, void *event_info)
2780 {
2781         struct appdata *ad = data;
2782
2783         if (!ad)
2784                 return;
2785
2786         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2787         if(!strcmp(btn_str, _("IDS_COM_SK_OK"))){
2788                 _DBG("OK OK");
2789
2790                 app_control_h app_control = NULL;
2791                 app_control_create(&app_control);
2792                 if (app_control == NULL) {
2793                         _DBG("the app_control is NULL");
2794                         free(btn_str);
2795                         return;
2796                 }
2797                 int ret;
2798                 ret = app_control_set_app_id(app_control, "setting-drivingmode-efl");
2799                 if (ret != APP_CONTROL_ERROR_NONE) {
2800                         _DBG("app_control_set_app_id fail : %d", ret);
2801                 }
2802                 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
2803                 ret = app_control_send_launch_request(app_control, NULL, NULL);
2804                 if (ret != APP_CONTROL_ERROR_NONE) {
2805                         _DBG("app_control_send_launch_request fail : %d", ret);
2806                 }
2807                 app_control_destroy(app_control);
2808         }
2809         else if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
2810                 _DBG("CANCEL");
2811         }
2812         if (ad->popup) {
2813                 evas_object_del(ad->popup);
2814                 ad->popup = NULL;
2815         }
2816         //evas_object_del(ad->win);
2817         free(btn_str);
2818         elm_exit();
2819 }
2820
2821
2822 static void __mode_syspopup_mobiledata_cb(void *data, Evas_Object * obj, void *event_info)
2823 {
2824         struct appdata *ad = data;
2825
2826         if (!ad)
2827                 return;
2828
2829         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2830         if(!strcmp(btn_str, _("IDS_COM_SK_OK"))){
2831                 _DBG("OK OK");
2832
2833                 int ret;
2834                 if(ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_ON)) {
2835                         /*enable mobile data */
2836                         ret = vconf_set_bool(VCONFKEY_3G_ENABLE,1);
2837                         if(ret != 0){
2838                                 _DBG("*** [ERR] Failed to enable mobile data with error code %d***",ret);
2839                         }
2840                         if (ad->popup_chk && elm_check_state_get(ad->popup_chk)) {
2841                                 ret = vconf_set_bool(VCONFKEY_SETAPPL_MOBILE_DATA_ON_REMINDER, 0);
2842                                 if(ret != 0){
2843                                         _DBG("*** [ERR] Failed to disable popup on reminder %d***",ret);
2844                                 }
2845                         }
2846
2847                 } else {
2848                         /*disable mobile data*/
2849                         ret = vconf_set_bool(VCONFKEY_3G_ENABLE,0);
2850                         if(ret != 0){
2851                                 _DBG("*** [ERR] Failed to enable mobile data with error code %d***",ret);
2852                         }
2853                         if (ad->popup_chk && elm_check_state_get(ad->popup_chk)) {
2854                                 ret = vconf_set_bool(VCONFKEY_SETAPPL_MOBILE_DATA_OFF_REMINDER, 0);
2855                                 if(ret != 0){
2856                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",ret);
2857                                 }
2858                         }
2859                 }
2860
2861         }
2862         else if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
2863                 _DBG("CANCEL");
2864
2865         }
2866         free(btn_str);
2867         elm_exit();
2868 }
2869
2870 static void __mode_syspopup_flightmode_tapi_event_cb(TapiHandle *handle, int result, void *data, void *user_data)
2871 {
2872         _DBG("flight mode result:%d", result);
2873         elm_exit();
2874 }
2875
2876 static void __mode_syspopup_flightmode_cb(void *data, Evas_Object * obj, void *event_info)
2877 {
2878         struct appdata *ad = data;
2879
2880         if (!ad)
2881                 return;
2882
2883         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2884         if(!strcmp(btn_str, _("IDS_COM_SK_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))){
2885                 _DBG("OK OK");
2886
2887                 int ret;
2888                 TapiHandle* tapi_handle = tel_init(NULL);
2889                 if (!tapi_handle) {
2890                         _DBG("*** [ERR] tel_init failed ***");
2891                         free(btn_str);
2892                         elm_exit();
2893                         return;
2894                 }
2895
2896                 int firewall_state;
2897                 vconf_get_bool(VCONFKEY_SETAPPL_FIREWALL_KEY, &firewall_state);
2898                 if(ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_ON)) {
2899                         /*enable flight mode on*/
2900                         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_ENTER,__mode_syspopup_flightmode_tapi_event_cb,ad);
2901                         if(ret != TAPI_API_SUCCESS){
2902                                 _DBG("*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
2903                         }
2904
2905
2906                         if(firewall_state)
2907                         {
2908                                 mode_remove_noti(ad, "setting-firewall-efl");
2909                         }
2910                 } else {
2911                         /*disable flight mode*/
2912                         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE,__mode_syspopup_flightmode_tapi_event_cb,ad);
2913                         if(ret != TAPI_API_SUCCESS){
2914                                 _DBG("*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
2915                         }
2916                         if(firewall_state)
2917                         {
2918                                 mode_create_noti(ad, "IDS_ST_BODY_CONFIGURE_FIREWALL_SETTINGS", "setting-firewall-efl", "IDS_ST_BODY_FIREWALL_ENABLED_ABB");
2919                         }
2920                 }
2921
2922                 if ((ret = tel_deinit(tapi_handle)) != TAPI_API_SUCCESS) {
2923                         _DBG("failed to deinitialized tapi handler:%d", ret);
2924                 }
2925
2926         }
2927         else if(!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
2928                 _DBG("CANCEL");
2929
2930         }
2931         //evas_object_del(ad->win);
2932         free(btn_str);
2933         elm_exit();
2934 }
2935
2936
2937 static void _text_rotation_changed(void *data, Evas_Object *obj, void *event_info )
2938 {
2939         int rot = -1;
2940         Evas_Object *win = obj;
2941         Evas_Object *layout = data;
2942
2943         rot = elm_win_rotation_get(win);
2944         if (rot == 90 || rot == 270)
2945                 elm_layout_file_set(layout, POPUP_EDJ, "label_layout_landscape");
2946         else
2947                 elm_layout_file_set(layout, POPUP_EDJ, "label_layout");
2948 }
2949
2950 static Eina_Bool _help_handler(void *data){
2951         struct appdata *ad = data;
2952         Evas_Coord_Rectangle rect = {0,};
2953                 evas_object_geometry_get(ad->help_eo, &rect.x,&rect.y,&rect.w,&rect.h);
2954         if (ad->help_type != HELP_NONE) {
2955                 syspop_help_popup_circle_block_create(ad->win, ad->popup,
2956                                                                 &ad->help_circle, &ad->help_popup,
2957                                                                 _(MODE_SYSTEM_POPUP_MSG),
2958                                                                 rect.x + rect.w/2, rect.y + rect.h/2, &rect);
2959         }
2960         ad->help_timer = NULL;
2961         return FALSE;
2962 }
2963
2964 static void _help_rotation_changed(void *data, Evas_Object *obj, void *event_info )
2965 {
2966         struct appdata *ad = (struct appdata *)data;
2967         //delete old help
2968         if (ad->help_circle) {
2969                 evas_object_del(ad->help_circle);
2970                 ad->help_circle = NULL;
2971         }
2972         if (ad->help_popup) {
2973                 evas_object_del(ad->help_popup);
2974                 ad->help_popup = NULL;
2975         }
2976         //update help
2977         if (ad->help_type != HELP_NONE) {
2978                 if (ad->help_timer) {
2979                         ecore_timer_del(ad->help_timer);
2980                         ad->help_timer = NULL;
2981                 }
2982                 ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
2983         }
2984 }
2985
2986 static void _ultra_popup_cb(void *data, Evas_Object * obj, void *event_info)
2987 {
2988         struct appdata *ad = data;
2989
2990         if (!ad)
2991                 return;
2992
2993         //delete old help
2994         if (ad->help_type != HELP_NONE) {
2995                 if (ad->help_circle) {
2996                         evas_object_del(ad->help_circle);
2997                         ad->help_circle = NULL;
2998                 }
2999                 if (ad->help_popup) {
3000                         evas_object_del(ad->help_popup);
3001                         ad->help_popup = NULL;
3002                 }
3003         }
3004
3005         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
3006         if(!strcmp(btn_str, _("IDS_COM_SK_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))){
3007                 //make complete flag
3008                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3009                 if(ret) _ERR("check export xml");
3010                 int m_key;
3011                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
3012                 if(m_key == SETTING_PSMODE_NORMAL){
3013                         //backup
3014                         _mode_backup_settings(ad);
3015                 }
3016                 else if(m_key == SETTING_PSMODE_POWERFUL){
3017                         //backup
3018                         _mode_power_backup_settings(ad);
3019                 }
3020                 _DBG("OK OK");
3021                 release_evas_object(&(ad->popup));
3022                 ad->bg = _create_bg(ad->win, NULL, "group_list");
3023                 //progress bar
3024                ad->enable_popup = __popup_with_progressbar(ad, ad->enable_popup, ad->win, PROGRESSBAR_STYLE,
3025                 NULL, _("IDS_ST_TPOP_ENABLING_ULTRA_POWER_SAVING_MODE_ING"), __progress_popup_cb, 3/*0*/, TRUE, TRUE, TRUE);    // 2 seconds to wait in maximum
3026
3027                 //assistive light off, P140422-06240
3028                 ret = led_set_brightness_with_noti(0, TRUE);
3029                 if (0 != ret){
3030                         _DBG(">>>led SET TO ZERO err [%d]", ret);
3031                 }
3032                 else{
3033                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
3034                         if(ret != 0){
3035                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",ret);
3036                                 }
3037                 }
3038
3039                 /*set ultra == emergency*/
3040                 _mode_apply_settings(ad, emergency_settings);
3041                 //set gray tone
3042                 __set_gray_tone(2);
3043                if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
3044                         _DBG("set upsm, in indicator");
3045                 }
3046                 free(btn_str);
3047         } else if (!strcmp(btn_str, _("IDS_COM_SK_CANCEL"))){
3048                 _DBG("CANCEL");
3049                 free(btn_str);
3050                 elm_exit();
3051         } else {
3052                 free(btn_str);
3053         }
3054 }
3055
3056 void _set_battery(Evas_Object *battery, int percent)
3057 {
3058         int stage = ((double) percent) / 100 * 35;
3059         stage = stage == 0 ? 1 : stage;
3060
3061         char stage_txt[16] = { '\0' };
3062         snprintf(stage_txt, sizeof(stage_txt), "%02d", stage);
3063
3064         char percent_txt[16] = { '\0' };
3065         snprintf(percent_txt, sizeof(percent_txt), "%d%%", percent);
3066
3067         //batt level image set
3068         elm_object_signal_emit(battery, stage_txt, "batt_image");
3069
3070         //batt percent text
3071         elm_object_part_text_set(battery, "text2", percent_txt);
3072 }
3073
3074 void _set_stand_by_time(Evas_Object *stand_by_time, int percent)
3075 {
3076         int stage = ((double) percent) / 100 * 36;      //battery percent value
3077         double sbt_val = ((double) percent) * 2.80f;    //estimated time value
3078
3079         stage = stage == 0 ? 1 : stage;
3080
3081         char stage_txt[16] = { '\0' };
3082         snprintf(stage_txt, sizeof(stage_txt), "%02d", stage);
3083
3084         char percent_txt[16] = { '\0' };
3085         if(sbt_val > 24) {
3086                 double decimal = sbt_val/24.0f - (int)sbt_val/24.0f;
3087                 if(decimal == 0.0) {
3088                         snprintf(percent_txt, sizeof(percent_txt), "%d%s", (int)(sbt_val/24.0f), _("IDS_COM_POP_DAYS"));
3089                 } else {
3090                         snprintf(percent_txt, sizeof(percent_txt), "%.1f%s", sbt_val/24.0f, _("IDS_COM_POP_DAYS"));
3091                 }
3092         } else if (sbt_val > 1) {
3093                 snprintf(percent_txt, sizeof(percent_txt), "%dh%dm", (int)sbt_val, (int)(sbt_val/0.6f));
3094         } else {
3095                 snprintf(percent_txt, sizeof(percent_txt), "%dm", (int)(sbt_val/0.6f));
3096         }
3097
3098         elm_object_signal_emit(stand_by_time, stage_txt, "standby_lev_img");
3099         elm_object_part_text_set(stand_by_time, "text_r3", percent_txt);
3100 }
3101
3102 Evas_Object *_ultra_popup_with_btn(void *data,
3103                                           Evas_Object *parent,
3104                                           char *title,
3105                                           char *text,
3106                                           _cb_func response_cb,
3107                                           int timeout, int btn_num)
3108 {
3109         _DBG("_ultra_popup_with_btn");
3110         struct appdata *ad = data;
3111         if (!ad)
3112                 return;
3113
3114         Evas_Object *popup = ad->popup;
3115
3116         if (text) {
3117                 Evas_Object *layout = elm_layout_add(popup);
3118                 int rotation = elm_win_rotation_get(parent);
3119                 if (rotation == 90 || rotation == 270)
3120                         elm_layout_file_set(layout, UPMS_EDJ, "label_layout_landscape");
3121                 else
3122                         elm_layout_file_set(layout, UPMS_EDJ, "label_layout");
3123                 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3124
3125                 Evas_Object *inner_layout = elm_layout_add(popup);
3126                 elm_layout_file_set(inner_layout, UPMS_EDJ, "inner_layout");
3127                 evas_object_size_hint_weight_set(inner_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3128
3129                 Evas_Object *scroller = elm_scroller_add(layout);
3130                 elm_object_style_set(scroller, "list_effect");
3131                 elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
3132                 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
3133                 evas_object_show(scroller);
3134                 elm_object_content_set(scroller, inner_layout);
3135
3136                 //1) battery image, text
3137                 //text
3138                elm_object_part_text_set(inner_layout, "text1" ,_("IDS_ST_BODY_BATTERY_PERCENTAGE_ABB"));
3139                 //image
3140                 Evas_Object *img = NULL;
3141                 img = elm_image_add(inner_layout);
3142                 elm_image_file_set(img, "/usr/apps/org.tizen.setting/res/icons/savingpower/popup/battery/A01-11_popup_battery_bg.png", NULL);
3143                 elm_object_part_content_set(inner_layout, "def_image", img);
3144                //batt level image, text
3145                int percent;
3146                if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &percent))
3147                         _DBG("Cannot get the vconf value for VCONFKEY_SYSMAN_BATTERY_CAPACITY");
3148                 _set_battery(inner_layout, percent);
3149
3150                //2) standby time image, text
3151                 //text r1, r2 -> text r1
3152                elm_object_part_text_set(inner_layout, "text_r1" ,_("IDS_ST_BODY_ESTIMATED_MAX_STANDBY_TIME_ABB"));
3153                //elm_object_part_text_set(inner_layout, "text_r2" ,"standby time");
3154                 //image
3155                 Evas_Object *standby_img = NULL;
3156                 standby_img = elm_image_add(inner_layout);
3157                 elm_image_file_set(standby_img, "/usr/apps/org.tizen.setting/res/icons/savingpower/popup/standby_time/A01-11_popup_time_bg.png", NULL);
3158                 elm_object_part_content_set(inner_layout, "standby_image", standby_img);
3159                //standby time image, text
3160                _set_stand_by_time(inner_layout, percent);
3161
3162                 // label for long typing popup
3163                 Evas_Object *label = elm_label_add(popup);
3164                 elm_object_style_set(label, "popup/default");
3165                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
3166
3167                 char ultra_desc[1024] = {0, };
3168                 snprintf(ultra_desc, sizeof(ultra_desc), "%s", text);
3169                 elm_object_text_set(label, ultra_desc);
3170                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
3171                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
3172                 evas_object_show(label);
3173
3174                 elm_object_part_content_set(inner_layout, "guide_text", label);
3175
3176                 elm_object_part_content_set(layout, "elm.swallow.content", scroller);
3177
3178                 elm_object_content_set(popup, layout);
3179                 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _text_rotation_changed, layout);
3180         }
3181         if (title) {
3182                 elm_object_part_text_set(popup, "title,text", _(title));
3183         }
3184         if (timeout > 0) {
3185                 elm_popup_timeout_set(popup, timeout);
3186         }
3187         if (btn_num > 0) { //the case popup has button or buttons
3188                 Evas_Object *btn1 = elm_button_add(popup);
3189                 elm_object_style_set(btn1, "popup");
3190                 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3191                 elm_object_part_content_set(popup, "button1", btn1);    //right
3192                 evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
3193                 Evas_Object *btn2 = elm_button_add(popup);
3194                 elm_object_style_set(btn2, "popup");
3195                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
3196                 elm_object_part_content_set(popup, "button2", btn2);    //left
3197                 evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);
3198                 evas_object_show(popup);
3199         }
3200         evas_object_show(popup);
3201         return popup;
3202  }
3203
3204
3205 static Evas_Object *mode_syspopup_create_popup_with_label_check(void *data,
3206                                              Evas_Object *parent,
3207                                              char *title,
3208                                              char *content,
3209                                              char *check_str,
3210                                              Evas_Object **check,
3211                                              Evas_Smart_Cb response_cb,
3212                                              int timeout,
3213                                              const char *btn_left,const char *btn_right)
3214 {
3215         _DBG("ENTER mode_syspopup_create_popup_with_label_check");
3216         struct appdata *ad = data;
3217         if (!ad) return NULL;
3218         Evas_Object *popup = elm_popup_add(parent);
3219 #if 0   
3220         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
3221         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3222         if (title) {
3223                 elm_object_part_text_set(popup, "title,text", _(title));
3224         }
3225         if(btn_left){
3226                 Evas_Object *btn1 = elm_button_add(popup);
3227                 elm_object_style_set(btn1, "popup");
3228                 elm_object_text_set(btn1, _(btn_left));
3229                 elm_object_part_content_set(popup, "button1", btn1);
3230                 if(response_cb){
3231                         evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
3232                 }
3233         }
3234         if(btn_right){
3235                 Evas_Object *btn2 = elm_button_add(popup);
3236                 elm_object_style_set(btn2, "popup");
3237                 elm_object_text_set(btn2, _(btn_right));
3238                 elm_object_part_content_set(popup, "button2", btn2);
3239                 if(response_cb){
3240                         evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);}
3241         }
3242         evas_object_show(popup);
3243         return popup;
3244 #endif
3245         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
3246         //setting_add_hardkey_features(popup, data);
3247         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3248
3249         if (title) {
3250                 elm_object_part_text_set(popup, "title,text", _(title));
3251         }
3252
3253         if (timeout > 0) {
3254                 elm_popup_timeout_set(popup, timeout);
3255         }
3256
3257         Evas_Object *label = NULL;
3258         label = elm_label_add(popup);
3259         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
3260 #if 1
3261         char arr[2048] = {'\0',};
3262         snprintf(arr, 2048, "<color=#000000>%s</color>",_(content));
3263         elm_object_text_set(label, arr);
3264 #else
3265         evas_object_color_set(label, 0, 0, 0, 255);
3266         evas_object_show(label);
3267 #endif
3268         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
3269         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
3270
3271         Evas_Object *layout = elm_layout_add(popup);
3272         elm_layout_file_set(layout, MODE_POPUP_EDJ, "popup_checkview_setting");
3273         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3274
3275         if(check) {
3276                 *check = elm_check_add(popup);
3277 #if 1
3278                 elm_object_style_set(*check, "multiline");
3279                 if (check_str) {
3280                         elm_object_text_set(*check, _(check_str));
3281                 }
3282 #else
3283                 elm_object_style_set(*check, "multiline");
3284                 elm_object_text_set(*check, "Don't ask again Don't ask again  Don't ask again  Don't ask again  Don't ask again Don't ask again  ");
3285 #endif
3286                 evas_object_size_hint_align_set(*check, EVAS_HINT_FILL, EVAS_HINT_FILL);
3287                 evas_object_size_hint_weight_set(*check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3288                 evas_object_show(*check);
3289
3290                 Evas_Object* box = elm_box_add(popup);
3291                 elm_box_horizontal_set(box, EINA_TRUE);
3292                 elm_box_pack_end(box, *check);
3293
3294                 // add text
3295                 Evas_Object* lbl = elm_label_add(popup);
3296                 elm_object_text_set(lbl, _(check_str));
3297                 evas_object_show(lbl);
3298                 elm_box_pack_end(box, lbl);
3299
3300                 elm_box_padding_set(box, 30, 0);
3301                 evas_object_show(box);
3302
3303                 elm_object_part_content_set(layout, "elm.swallow.end", box);
3304         }
3305
3306         elm_object_part_content_set(layout, "elm.swallow.content", label);
3307
3308
3309         elm_object_content_set(popup, layout);
3310         evas_object_data_set(popup, "check_str", check_str);
3311         Evas_Object *btn1;
3312         Evas_Object *btn2;
3313
3314         if(btn_left){
3315                 btn1 = elm_button_add(popup);
3316                 elm_object_style_set(btn1, "popup");
3317                 elm_object_text_set(btn1, _(btn_left));
3318                 elm_object_part_content_set(popup, "button1", btn1);
3319                 if(response_cb){
3320                         evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
3321                 }
3322         }
3323         if(btn_right){
3324                 btn2 = elm_button_add(popup);
3325                 elm_object_style_set(btn2, "popup");
3326                 elm_object_text_set(btn2, _(btn_right));
3327                 elm_object_part_content_set(popup, "button2", btn2);
3328                 if(response_cb){
3329                         evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);}
3330         }
3331         evas_object_show(popup);
3332         return popup;
3333 }
3334
3335 void fini_tts(struct appdata *ad){
3336         _INFO("fini tts");
3337         if (ad->tts)
3338         {
3339                 int result = 0;
3340                 tts_state_e current_state;
3341                 tts_get_state(ad->tts, &current_state);
3342
3343                 if (TTS_STATE_READY == current_state)
3344                 {
3345                         result = tts_unprepare(ad->tts);
3346                         if (TTS_ERROR_NONE != result)
3347                         {
3348                                 _ERR("Fail to prepare function : ret(%d)\n", result);
3349                         }
3350                     }
3351
3352                 result = tts_destroy(ad->tts);
3353                 if (TTS_ERROR_NONE != result)
3354                 {
3355                         _ERR("Fail to destroy handle : result(%d)", result);
3356                 }
3357                 ad->tts = NULL;
3358         }
3359 }
3360
3361 void __tts_completed_cb(tts_h tts, int utt_id, void *user_data)
3362 {
3363         fini_tts(user_data);
3364 }
3365
3366 void init_tts(struct appdata *ad)
3367 {
3368         _INFO("init tts");
3369         int result = tts_create(&(ad->tts));
3370         if (TTS_ERROR_NONE != result)
3371         {
3372                 _ERR("Fail to get handle : result(%d)", result);
3373                 ad->tts = NULL;
3374         }
3375         else
3376         {
3377                 result = tts_set_utterance_completed_cb(ad->tts, __tts_completed_cb, ad);
3378                 if (TTS_ERROR_NONE != result)
3379                 {
3380                         _ERR("Fail to set callback : ret(%d)\n", result);
3381                 }
3382                 result = tts_set_mode(ad->tts, TTS_MODE_DEFAULT);
3383                 if (TTS_ERROR_NONE != result)
3384                 {
3385                         _ERR("Fail to set tts mode : ret(%d)\n", result);
3386                 }
3387                 result = tts_prepare(ad->tts);//async API,need to wait until TTS_STATE_READY
3388                 if (TTS_ERROR_NONE != result)
3389                 {
3390                         _ERR("Fail to prepare function : ret(%d)\n", result);
3391                 }
3392         }
3393 }
3394
3395 void play_text(struct appdata *ad, const char *text) {
3396         //paly prompts
3397         _INFO("play text");
3398         if (!ad || !ad->tts) {
3399                 _ERR("ad or tts == NULL");
3400         }
3401         int ret = 0;
3402         ret = tts_stop(ad->tts);
3403         if (TTS_ERROR_NONE != ret) {
3404                 _ERR("failed to call tts_stop: %d", ret);
3405         }
3406         int utt_id;
3407         ret = tts_add_text(ad->tts, text, NULL,
3408                         TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &utt_id);
3409         if (TTS_ERROR_NONE != ret) {
3410                 _ERR("failed to call tts_add_text: %d", ret);
3411         }
3412
3413         ret = tts_play(ad->tts);
3414         if (TTS_ERROR_NONE != ret) {
3415                 _ERR("failed to call tts_play: %d", ret);
3416         }
3417 }
3418
3419
3420 static void __mode_syspopup_add(struct appdata *ad)
3421 {
3422         if (!ad)
3423                 return;
3424
3425         Evas_Object *popup;
3426         Evas_Object *btn1;
3427         Evas_Object *btn2;
3428
3429         //evas_object_show(ad->win);
3430         if(ad->win){
3431                 popup = elm_popup_add(ad->win);
3432                 ad->popup = popup;
3433
3434                 if (popup == NULL) {
3435                         _ERR("elm_popup_add failed..!!");
3436                         return;
3437                 }
3438         }
3439         int m_key;
3440         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
3441         if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY)) {
3442                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_EMERGENCY);
3443                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Enable_emergency_Mode));
3444                 Evas_Object *layout = elm_layout_add(popup);
3445                 int rotation = elm_win_rotation_get(ad->win);
3446                 if (rotation == 90 || rotation == 270)
3447                         elm_layout_file_set(layout, POPUP_EDJ, "label_layout_landscape");
3448                 else
3449                         elm_layout_file_set(layout, POPUP_EDJ, "label_layout");
3450                 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3451 // label for long typing popup
3452                 Evas_Object *label = elm_label_add(popup);
3453                 elm_object_style_set(label, "popup/default");
3454                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
3455                 elm_object_text_set(label, _(KeyStr_Survivor_Mode_POP_DESC));
3456                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
3457                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
3458                 evas_object_show(label);
3459
3460                 Evas_Object *scroller = elm_scroller_add(layout);
3461                 elm_object_style_set(scroller, "list_effect");
3462                 elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
3463                 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
3464                 evas_object_show(scroller);
3465                 elm_object_content_set(scroller, label);
3466
3467                 elm_object_part_content_set(layout, "elm.swallow.content", scroller);
3468
3469                 elm_object_content_set(popup, layout);
3470                 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _text_rotation_changed, layout);
3471
3472                 btn1 = elm_button_add(popup);
3473                 elm_object_style_set(btn1, "popup");
3474                 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3475                 elm_object_part_content_set(popup, "button1", btn1);    //right
3476                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_emergency_cb, ad);
3477                 btn2 = elm_button_add(popup);
3478                 elm_object_style_set(btn2, "popup");
3479                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
3480                 elm_object_part_content_set(popup, "button2", btn2);    //left
3481                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_emergency_cb, ad);
3482                 evas_object_show(popup);
3483
3484                 //help
3485                 if (ad->help_type != HELP_NONE) {
3486                         if (ad->help_timer) {
3487                                 ecore_timer_del(ad->help_timer);
3488                                 ad->help_timer = NULL;
3489                         }
3490                         ad->help_eo = btn2;
3491                         ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
3492                 }
3493         }
3494         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_ULTRA)) {
3495                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_ULTRA_POWER_SAVING);
3496                 char ultra_desc[1024] = {0, };
3497                 snprintf(ultra_desc, sizeof(ultra_desc), "- %s<br>- %s<br>- %s<br>- %s",
3498                                 _(KeyStr_Survivor_Mode_POP_DESC1),
3499                                 _(KeyStr_Survivor_Mode_POP_DESC2),
3500                                 _(KeyStr_Survivor_Mode_POP_DESC3),
3501                                 _(KeyStr_Survivor_Mode_POP_DESC4));
3502                 _ultra_popup_with_btn(ad, ad->win, "IDS_ST_HEADER_ULTRA_POWER_SAVING_MODE",
3503                                                                          ultra_desc,
3504                                                                          _ultra_popup_cb, 0,
3505                                                                          2);
3506         }
3507         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SETTING)) {
3508                 //upsm in setting
3509                 //make complete flag
3510                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3511                 if(ret) _ERR("check export xml");
3512                 //ultra power saving mode !!
3513                 if (popup) {
3514                         evas_object_del(popup);
3515                         popup = NULL;
3516                 }
3517
3518                 if(m_key == SETTING_PSMODE_NORMAL){
3519                         //backup
3520                         _mode_backup_settings(ad);
3521                 }
3522                 else if(m_key == SETTING_PSMODE_POWERFUL){
3523                         //backup
3524                         _mode_power_backup_settings(ad);
3525                 }
3526 #if LCD_FREQ_CTRL
3527                 ad->is_lcd_ctrl = EINA_TRUE;
3528                 _LCD_freq_ctrl(ad);
3529 #endif
3530                 //assistive light off, P140422-06240
3531                 ret = led_set_brightness_with_noti(0, TRUE);
3532                 if (0 != ret){
3533                         _DBG(">>>led SET TO ZERO err [%d]", ret);
3534                 }
3535                 else{
3536                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
3537                         if(ret != 0){
3538                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",ret);
3539                                 }
3540                 }
3541                 _mode_apply_settings(ad, emergency_settings);
3542                 #if 1 //---------following two invoking will cause KERNAL PANNIC
3543                 //set gray tone
3544                 __set_gray_tone(1);
3545                //if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0)
3546                {
3547                         _DBG("set ultra power saving mode in setting");
3548                 }
3549                #endif
3550                _ERR("111111");
3551                 //elm_exit();
3552                 _ERR("111111");
3553         }
3554         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SAFETY)) {
3555                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_EMERGENCY);
3556
3557                 //make complete flag
3558                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3559                 if(ret) _ERR("check export xml");
3560                 if (popup) {
3561                         evas_object_del(popup);
3562                         popup = NULL;
3563                 }
3564
3565                 if(m_key == SETTING_PSMODE_NORMAL){
3566                         //backup
3567                         _mode_backup_settings(ad);
3568                 }
3569                 else if(m_key == SETTING_PSMODE_POWERFUL){
3570                         //backup
3571                         _mode_power_backup_settings(ad);
3572                 }
3573
3574                 //assistive light off, P140422-06240
3575                 ret = led_set_brightness_with_noti(0, TRUE);
3576                 if (0 != ret){
3577                         _DBG(">>>led SET TO ZERO err [%d]", ret);
3578                 }
3579                 else{
3580                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
3581                         if(ret != 0){
3582                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",ret);
3583                                 }
3584                 }
3585
3586                 _mode_apply_settings(ad, emergency_settings);
3587                 //set gray tone
3588                 __set_gray_tone(2);
3589                if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
3590                         _DBG("set on SETTING_PSMODE_EMERGENCY");
3591                 }
3592                 elm_exit();
3593         }
3594                 if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL)) {
3595                 elm_object_style_set(popup, "transparent");
3596                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3597
3598                 int ultra_emergency;
3599                 vconf_get_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, &ultra_emergency);
3600
3601                 /*
3602                 EMERGENCY_UIKEY
3603                 #define VCONF_KEY_MODE "file/private/org.tizen.emergency-home/mode"
3604                 enum {
3605                     MODE_EMERGENCY = 1,
3606                     MODE_ULTRA_POWER_SAVING,
3607                     MODE_MAX,
3608                 };
3609                 */
3610
3611                 if(ultra_emergency == 1){
3612                         elm_object_text_set(popup, _(KeyStr_Emergency_off_Mode_POP_DESC));
3613                         elm_object_part_text_set(popup, "title,text", _("IDS_ST_HEADER_DISABLE_EMERGENCY_MODE_ABB"));
3614                 }
3615                 else if(ultra_emergency == 2){
3616                         elm_object_text_set(popup, _(KeyStr_Ultra_off_Mode_POP_DESC));
3617                         elm_object_part_text_set(popup, "title,text", _("IDS_ST_HEADER_ULTRA_POWER_SAVING_MODE"));
3618                 }
3619
3620                 if(is_recovery){
3621                         release_evas_object(&(ad->popup));
3622                         ad->bg = _create_bg(ad->win, NULL, "group_list");
3623
3624                         //progress bar
3625                        ad->disable_popup = __popup_with_progressbar(ad, ad->disable_popup, ad->win, PROGRESSBAR_STYLE,
3626                         NULL, _(KeyStr_Loading), __progress_popup_cb, 3/*0*/, TRUE, TRUE, FALSE);       // 2 seconds to wait in maximum
3627
3628                         /*set normal sub*/
3629                         //make complete flag
3630                         int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3631                         if(ret) _ERR("check export xml");
3632                         //torch light off with diable emergency/ups mode, P140507-03841
3633                         int t_ret = led_set_brightness_with_noti(0, TRUE);
3634                         if (0 != t_ret){
3635                             _DBG(">>>led SET TO ZERO err [%d]", t_ret);
3636                         }
3637                         else{
3638                             vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
3639                             if(t_ret != 0){
3640                                     _DBG("*** [ERR] Failed to disable popup off reminder %d***",t_ret);
3641                                 }
3642                         }
3643
3644                       int b_network_lcd_off;
3645                         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
3646                         if( b_network_lcd_off ){
3647                                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
3648                         }
3649                         _mode_apply_settings(ad, normal_settings);
3650
3651                        /* set to default */
3652                        int opposite;
3653                         ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
3654                         if(ret) _DBG("vconf_get_bool failed");
3655                         __set_gray_tone(opposite);
3656                         if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
3657                                 _DBG("set on SETTING_PSMODE_NORMAL");
3658                         }
3659                 }
3660                 else{
3661                         btn1 = elm_button_add(popup);
3662                         elm_object_style_set(btn1, "popup");
3663                         elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3664                         elm_object_part_content_set(popup, "button1", btn1);    //right
3665                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_normal_cb, ad);
3666                         btn2 = elm_button_add(popup);
3667                         elm_object_style_set(btn2, "popup");
3668                         elm_object_text_set(btn2, _("IDS_ST_BUTTON_DISABLE"));
3669                         elm_object_part_content_set(popup, "button2", btn2);    //left
3670                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_normal_cb, ad);
3671                         evas_object_show(popup);
3672
3673                         if (vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_changed, ad) != 0)
3674                                 _DBG("vconf key notify failed");
3675                 }
3676         }
3677         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_REMOVE_FLAG)) {
3678                 int ret = remove_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3679                 if(ret) _ERR("check remove xml");
3680                 if (popup) {
3681                         evas_object_del(popup);
3682                         popup = NULL;
3683                 }
3684                 elm_exit();
3685         }
3686         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL)) {
3687                 int flight;
3688                 int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight);
3689                 if(ret) _DBG("vconf_get_bool failed");
3690
3691                 if(flight == EINA_TRUE){
3692                         //cannot set with flight mode on
3693                         elm_object_style_set(popup, "transparent");
3694                         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3695                         elm_object_text_set(popup, _("IDS_IM_POP_THIS_FEATURE_IS_NOT_AVAILABLE_WHILE_FLIGHT_MODE_IS_ON"));
3696
3697                         elm_popup_timeout_set(popup, 2.0);
3698                         evas_object_smart_callback_add(popup, "block,clicked", timeout_response_cb, ad);
3699                         evas_object_smart_callback_add(popup, "timeout", timeout_response_cb, ad);
3700
3701                         evas_object_show(popup);
3702                 }
3703                 else{
3704                         if (popup) {
3705                                 evas_object_del(popup);
3706                                 popup = NULL;
3707                         }
3708                         int m_key, first;
3709                         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
3710                         if(m_key == SETTING_PSMODE_NORMAL){
3711                                 //backup
3712                                 _mode_backup_settings(ad);
3713                         }
3714
3715                         /*set normal sub*/
3716                         int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
3717
3718                         if(first){
3719                                 _mode_apply_settings(ad, powerful_settings_def);
3720                                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
3721                         }
3722                         else{
3723                                 _mode_apply_settings(ad, powerful_settings);
3724                                 _DBG("right to set powerful");
3725                         }
3726                        /* set to default */
3727                        int opposite;
3728                         ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
3729                         if(ret) _DBG("vconf_get_bool failed");
3730                         __set_gray_tone(opposite);
3731                         //emergency mode -> normal
3732                         if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
3733                                 _DBG("set on SETTING_PSMODE_POWERFUL");
3734                         }
3735
3736                         evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _help_rotation_changed, ad);
3737
3738                         //help
3739                         if (ad->help_type != HELP_NONE) {
3740                                 if (ad->help_timer) {
3741                                         ecore_timer_del(ad->help_timer);
3742                                         ad->help_timer = NULL;
3743                                 }
3744                                 ad->help_eo = btn2;
3745                                 ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
3746                         }
3747
3748                         if (vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_changed, ad) != 0)
3749                                 _DBG("vconf key notify failed");
3750                         elm_exit();
3751                 }
3752         }
3753         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL_SETTING)) {
3754                 if (popup) {
3755                         evas_object_del(popup);
3756                         popup = NULL;
3757                 }
3758
3759                 if(m_key == SETTING_PSMODE_NORMAL){
3760                         //backup
3761                         _mode_backup_settings(ad);
3762                 }
3763
3764                 int first;
3765                 /*set normal sub*/
3766                 int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
3767                 if(first){
3768                         _mode_apply_settings(ad, powerful_settings_def);
3769                         preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
3770                 }
3771                 else{
3772                         _mode_apply_settings(ad, powerful_settings);
3773                         _DBG("right to set powerful");
3774                 }
3775
3776                /* set to default */
3777                int opposite;
3778                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
3779                 if(ret) _DBG("vconf_get_bool failed");
3780                 __set_gray_tone(opposite);
3781                 //emergency mode -> normal
3782                 if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
3783                         _DBG("set on SETTING_PSMODE_POWERFUL");
3784                 }
3785                 elm_exit();
3786         }
3787         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL_SETTING)) {
3788                 //make complete flag
3789                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
3790                 if(ret) _ERR("check export xml");
3791
3792                 if(m_key == SETTING_PSMODE_POWERFUL){
3793                         //backup
3794                         _mode_power_backup_settings(ad);
3795                 }
3796                 //torch light off with diable emergency/ups mode, P140507-03841
3797                 int t_ret = led_set_brightness_with_noti(0, TRUE);
3798                 if (0 != t_ret){
3799                         _DBG(">>>led SET TO ZERO err [%d]", t_ret);
3800                 }
3801                 else{
3802                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
3803                         if(t_ret != 0){
3804                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***",t_ret);
3805                                 }
3806                 }
3807
3808                 int b_network_lcd_off;
3809                 vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
3810                 if( b_network_lcd_off ){
3811                         vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
3812                 }
3813
3814                 /*set normal sub*/
3815                _mode_apply_settings(ad, normal_settings);
3816                /* set to default */
3817                int opposite;
3818                 ret = 0;
3819                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
3820                 if(ret) _DBG("vconf_get_bool failed");
3821                 __set_gray_tone(opposite);
3822                 //emergency mode -> normal
3823                 if(vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
3824                         _DBG("set on SETTING_PSMODE_NORMAL");
3825                 }
3826                 elm_exit();
3827         }
3828         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BACKUP_SETTING)) {
3829                 if (popup) {
3830                         evas_object_del(popup);
3831                         popup = NULL;
3832                 }
3833                 /*backup*/
3834                _mode_backup_settings(ad);
3835                 elm_exit();
3836         }
3837         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_ON)) {
3838                 /* todo */
3839                 /* blockingmode ON */
3840                 int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, _mode_vconf_change_cb, ad);
3841                 if (ret != 0) {
3842                         _DBG("call vconf_notify_key_changed failed");
3843                 }
3844
3845                 ret = _blockingmode_get_status(ad);
3846                 if(ret) _DBG("vconf get reminder failed");
3847
3848                 if(ad->b_call || ad->b_noti || ad->b_alarmNtimer || ad->b_led){
3849                         if (popup) {
3850                                 evas_object_del(popup);
3851                                 popup = NULL;
3852                         }
3853                         _blockingmode_btn_change_set(ad, EINA_TRUE);
3854                 }
3855                 else{
3856                         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb_overide, NULL);
3857                         //sub check routine insert
3858                         _DBG("sub check else");
3859                         elm_object_style_set(popup, "transparent");
3860                         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3861
3862                         elm_object_text_set(popup, _(KeyStr_Blocking_Mode_POP_DESC));
3863                         //elm_popup_timeout_set(popup, 2.0);
3864                         //evas_object_smart_callback_add(popup, "block,clicked", timeout_response_cb, ad);
3865                         //evas_object_smart_callback_add(popup, "timeout", timeout_response_cb, ad);
3866                         //
3867                         elm_object_part_text_set(popup, "title,text", _(keystr_Blockingmode));
3868 #if 1
3869                         btn1 = elm_button_add(popup);
3870                         elm_object_style_set(btn1, "popup");
3871                         elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3872                         elm_object_part_content_set(popup, "button1", btn1);    //right
3873                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_blockingmode_cb, ad);
3874                         btn2 = elm_button_add(popup);
3875                         elm_object_style_set(btn2, "popup");
3876                         elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
3877                         elm_object_part_content_set(popup, "button2", btn2);    //left
3878                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_blockingmode_cb, ad);
3879 #endif
3880                         evas_object_show(popup);
3881                 }
3882         }
3883         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_OFF)) {
3884                 if (popup) {
3885                         evas_object_del(popup);
3886                         popup = NULL;
3887                 }
3888                 /* todo */
3889                 /* blockingmode OFF */
3890                 int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, _mode_vconf_change_cb, ad);
3891                 if (ret != 0) {
3892                         _DBG("call vconf_notify_key_changed failed");
3893                 }
3894
3895                 ret = _blockingmode_get_status(ad);
3896                 if(ret) _DBG("vconf get reminder failed");
3897                 _blockingmode_btn_change_set(ad, EINA_FALSE);
3898         }
3899         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_ON)) {
3900                 /* todo */
3901                 /* drivingmode ON */
3902                 //just notifications be needed
3903                 int ret;
3904                 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, _mode_vconf_change_cb, ad);
3905                 if (ret != 0) {
3906                         _DBG("call vconf_notify_key_changed failed");
3907                 }
3908                 if(__check_drivingmode_sub_item()){
3909                         if (popup) {
3910                                 evas_object_del(popup);
3911                                 popup = NULL;
3912                         }
3913                         ret = vconf_set_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, EINA_TRUE);
3914                         if (ret != 0) {
3915                                 _DBG("call vconf_set_bool failed");
3916                         }
3917                 }
3918                 else{
3919                         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb_overide, NULL);
3920                         //sub check routine insert
3921                         _DBG("sub check else");
3922                         elm_object_style_set(popup, "transparent");
3923                         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3924
3925                         elm_object_text_set(popup, _("IDS_ST_POP_TO_ENABLE_HANDS_FREE_MODE_ENABLE_AT_LEAST_ONE_RELEVANT_FUNCTION"));
3926                         elm_object_part_text_set(popup, "title,text", _("IDS_VC_MBODY_NOTIFICATION_READ_OUT"));
3927 #if 1
3928                         btn1 = elm_button_add(popup);
3929                         elm_object_style_set(btn1, "popup");
3930                         elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3931                         elm_object_part_content_set(popup, "button1", btn1);    //right
3932                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_drivingmode_cb, ad);
3933                         btn2 = elm_button_add(popup);
3934                         elm_object_style_set(btn2, "popup");
3935                         elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
3936                         elm_object_part_content_set(popup, "button2", btn2);    //left
3937                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_drivingmode_cb, ad);
3938 #endif
3939                         evas_object_show(popup);
3940                 }
3941         }
3942         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_OFF)) {
3943                 if (popup) {
3944                         evas_object_del(popup);
3945                         popup = NULL;
3946                 }
3947                 /* todo */
3948                 /* drivingmode OFF */
3949                 //just notifications be needed
3950                 int ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, _mode_vconf_change_cb, ad);
3951                 if (ret != 0) {
3952                         _DBG("call vconf_notify_key_changed failed");
3953                 }
3954                 ret = vconf_set_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, EINA_FALSE);
3955                 if (ret != 0) {
3956                         _DBG("call vconf_set_bool failed");
3957                 }
3958         }else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_ON)) {
3959
3960                 setting_set_i18n(MODE_SYSPOPUP_PACKAGE, MODE_SYSPOPUP_LOCALEDIR);
3961                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3962
3963                 _DBG("--------------------------------------------------------------");
3964                 _DBG("--------------------------------------------------------------");
3965                 elm_object_text_set(popup, _(KeyStr_Fligtmode_Popup_On_Text));
3966                 _DBG("--------------------------------------------------------------");
3967                 _DBG("--------------------------------------------------------------");
3968
3969                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Fligtmode_Popup_Title));
3970                 btn1 = elm_button_add(popup);
3971                 elm_object_style_set(btn1, "popup");
3972                 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3973                 elm_object_part_content_set(popup, "button1", btn1);    //right
3974                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_flightmode_cb, ad);
3975                 btn2 = elm_button_add(popup);
3976                 elm_object_style_set(btn2, "popup");
3977                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
3978                 elm_object_part_content_set(popup, "button2", btn2);    //left
3979                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_flightmode_cb, ad);
3980                 evas_object_show(popup);
3981
3982         }else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_OFF)) {
3983
3984                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3985
3986                 elm_object_text_set(popup, _(KeyStr_Fligtmode_Popup_Off_Text));
3987
3988                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Fligtmode_Popup_Title));
3989                 btn1 = elm_button_add(popup);
3990                 elm_object_style_set(btn1, "popup");
3991                 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
3992                 elm_object_part_content_set(popup, "button1", btn1);    //right
3993                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_flightmode_cb, ad);
3994                 btn2 = elm_button_add(popup);
3995                 elm_object_style_set(btn2, "popup");
3996                 elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
3997                 elm_object_part_content_set(popup, "button2", btn2);    //left
3998                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_flightmode_cb, ad);
3999                 evas_object_show(popup);
4000
4001         }
4002         else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NETRESTRICTIONMODE_CHANGE)) {
4003
4004                 /* Network restriction mode change */
4005                 int vconf_value;
4006                 int ret = vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &vconf_value);
4007                 if (ret != 0)
4008                 {
4009                         _DBG("network_restrict_mode vconf get failed");
4010                 }
4011                 else
4012                 {
4013                         _DBG("network_restrict_mode vconf get %d", vconf_value);
4014                 }
4015
4016                 elm_object_style_set(popup, "transparent");
4017                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4018
4019                 if (vconf_value)
4020                 {
4021                         // on -> off
4022                         elm_object_text_set(popup, _( "IDS_QP_POP_NETWORK_RESTRICTION_MODE_WILL_BE_DISABLED_JPN" ));
4023                 }
4024                 else
4025                 {
4026                         // off -> on
4027                         elm_object_text_set(popup, _( "IDS_QP_POP_IN_NETWORK_RESTRICTION_MODE_YOU_CAN_USE_ALL_YOUR_APPLICATIONS_WITHOUT_CONNECTING_TO_THE_NETWORK_YOU_CAN_ALSO_RECEIVE_CALLS_AND_SMS_MESSAGES_MSG_JPN" ));
4028                 }
4029                 elm_object_part_text_set(popup, "title,text", _( "IDS_ST_HEADER_NETWORK_RESTRICTION_MODE_ABB_JPN" ));
4030                 btn1 = elm_button_add(popup);
4031                 elm_object_style_set(btn1, "popup");
4032                 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
4033                 elm_object_part_content_set(popup, "button1", btn1);    //right
4034
4035                 btn2 = elm_button_add(popup);
4036                 elm_object_style_set(btn2, "popup");
4037                 elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
4038                 elm_object_part_content_set(popup, "button2", btn2);    //left
4039
4040                 if (vconf_value)
4041                 {
4042                         // on -> off
4043                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_netrestrictionmode_change_off_cb, popup);
4044                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_netrestrictionmode_change_off_cb, popup);
4045                 }
4046                 else
4047                 {
4048                         // off -> on
4049                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_netrestrictionmode_change_on_cb, popup);
4050                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_netrestrictionmode_change_on_cb, popup);
4051                 }
4052
4053                 evas_object_show(popup);
4054         }else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_ON)) {
4055                 if (ad->popup) {
4056                         evas_object_del(ad->popup);
4057                         ad->popup = NULL;
4058                 }
4059                 ad->popup = mode_syspopup_create_popup_with_label_check(ad, ad->win, NULL,
4060                                          _(Data_packet_Popup_desc),
4061                                          KeyStr_DO_NOT_ASK_AGAIN,
4062                                          &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
4063                                          "IDS_COM_SK_CANCEL","IDS_COM_SK_OK");
4064
4065
4066         }else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_OFF)) {
4067                 if (ad->popup) {
4068                         evas_object_del(ad->popup);
4069                         ad->popup = NULL;
4070                 }
4071                 ad->popup = mode_syspopup_create_popup_with_label_check(ad, ad->win, NULL,
4072                                          KeyStr_MOBILEDATA_Popup_Off_Text,
4073                                          KeyStr_DO_NOT_ASK_AGAIN,
4074                                          &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
4075                                          "IDS_COM_SK_CANCEL","IDS_COM_SK_OK");
4076         }
4077 }
4078
4079 static int __mode_syspopup_reset(bundle * b, void *data)
4080 {
4081         struct appdata *ad = data;
4082         const char *val;
4083         int ret = 0;
4084
4085         if(is_recovery){
4086                 _DBG("recovery");
4087                 //recovery normal
4088                 ad->type=strdup(MODE_SYSTEM_POPUP_NORMAL);
4089                 evas_object_show(ad->win);
4090                 __mode_syspopup_add(ad);
4091
4092                 return 0;
4093         }
4094
4095         ad->b = bundle_dup(b);
4096
4097         /* When syspopup is already loaded, remove the popup and load new popup */
4098         if (syspopup_has_popup(b)) {
4099                 syspopup_reset(b);
4100         } else {
4101                 ret = syspopup_create(b, &handler, ad->win, ad);
4102                 _DBG("ret = %d", ret);
4103
4104                 char *help = NULL;
4105                 help = bundle_get_val(b, "help_type");
4106                 if (help != NULL)
4107                         ad->help_type = HELP_PS_MODE;
4108
4109                 if (ret == 0) {
4110                         val = bundle_get_val(b, "_MODE_SYSTEM_POPUP_TYPE_");
4111                         if (val) {
4112                                 ad->type=strdup(val);
4113                                 _INFO("type :%s", ad->type);
4114                                 if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_ON)){
4115                                         ret = _blockingmode_get_status(ad);
4116                                         if(ret) _DBG("vconf get reminder failed");
4117
4118                                         if(!ad->b_call && !ad->b_noti && !ad->b_alarmNtimer && !ad->b_led){
4119                                                 evas_object_show(ad->win);
4120                                         }
4121                                 }
4122                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_OFF)){
4123                                 }
4124                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_ON)){
4125                                         if(!__check_drivingmode_sub_item()){
4126                                                 evas_object_show(ad->win);
4127                                         }
4128                                 }
4129                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_OFF)){
4130                                 }
4131                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BACKUP_SETTING)){
4132                                 }
4133                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL_SETTING)){
4134                                 }
4135                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL_SETTING)){
4136                                 }
4137                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL)){
4138                                         int flight;
4139                                         int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight);
4140                                         if(ret) _DBG("vconf_get_bool failed");
4141
4142                                         if(flight){
4143                                                 evas_object_show(ad->win);
4144                                         }
4145                                 }
4146                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SETTING)){
4147                                 }
4148                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SAFETY)){
4149                                 }
4150                                 else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_REMOVE_FLAG)){
4151                                 }
4152                                 else{
4153                                         evas_object_show(ad->win);
4154                                 }
4155                         }
4156                 } else {
4157                         _ERR("Unknown popup type");
4158                         elm_exit();
4159                 }
4160                 __mode_syspopup_add(ad);
4161
4162                 return 0;
4163         }
4164
4165         return 0;
4166 }
4167
4168 static int mode_reboot_create_noti_only(const char *key_str,const char *package,const char *title)
4169 {
4170         notification_h noti = NULL;
4171         notification_error_e ret = NOTIFICATION_ERROR_NONE;
4172
4173         /* not need to remove noti */
4174         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
4175                         NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
4176         if (!noti) {
4177                 _DBG("Fail to notification_new [%d]", ret);
4178                 return;
4179         }
4180
4181         ret = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
4182         if (ret != NOTIFICATION_ERROR_NONE) {
4183                 _DBG("Fail to notification_set_layout [%d]", ret);
4184                 goto FAIL;
4185         }
4186
4187         if(!strcmp(PKG_BLOCKING_MODE, package)){
4188                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_BlockingMode);
4189                 if (ret != NOTIFICATION_ERROR_NONE) {
4190                         _DBG("Fail to notification_set_image [%d]", ret);
4191                         goto FAIL;
4192                 }
4193                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_BlockingMode);
4194                 if (ret != NOTIFICATION_ERROR_NONE) {
4195                         _DBG("Fail to notification_set_image [%d]", ret);
4196                         goto FAIL;
4197                 }
4198         }
4199         else if(!strcmp(PKG_DRIVING_MODE, package)){
4200                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_DrivingMode);
4201                 if (ret != NOTIFICATION_ERROR_NONE) {
4202                         _DBG("Fail to notification_set_image [%d]", ret);
4203                         goto FAIL;
4204                 }
4205                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_DrivingMode);
4206                 if (ret != NOTIFICATION_ERROR_NONE) {
4207                         _DBG("Fail to notification_set_image [%d]", ret);
4208                         goto FAIL;
4209                 }
4210         }
4211         else if(!strcmp(PKG_FIREWALL, package)){
4212                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_Firewall);
4213                 if (ret != NOTIFICATION_ERROR_NONE) {
4214                         _DBG("Fail to notification_set_image [%d]", ret);
4215                         goto FAIL;
4216                 }
4217                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_Firewall);
4218                 if (ret != NOTIFICATION_ERROR_NONE) {
4219                         _DBG("Fail to notification_set_image [%d]", ret);
4220                         goto FAIL;
4221                 }
4222         }
4223
4224         ret = notification_set_text(noti,
4225                         NOTIFICATION_TEXT_TYPE_TITLE,
4226                         title,
4227                         title, NOTIFICATION_VARIABLE_TYPE_NONE);
4228         if (ret != NOTIFICATION_ERROR_NONE) {
4229                 _DBG("Fail to notification_set_text [%d]", ret);
4230                 goto FAIL;
4231         }
4232
4233         ret = notification_set_text(noti,
4234                         NOTIFICATION_TEXT_TYPE_CONTENT,
4235                         key_str,
4236                         key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
4237         if (ret != NOTIFICATION_ERROR_NONE) {
4238                 _DBG("Fail to notification_set_text [%d]", ret);
4239                 goto FAIL;
4240         }
4241
4242         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
4243         if (ret != NOTIFICATION_ERROR_NONE) {
4244                 _DBG("Fail to notification_set_text [%d]", ret);
4245                 goto FAIL;
4246         }
4247
4248         ret = notification_set_pkgname(noti, package);  //pkg ex : "setting-blockingmode-efl"
4249         if (ret != NOTIFICATION_ERROR_NONE) {
4250                 _DBG("Fail to notification_set_pkgname [%d]", ret);
4251                 goto FAIL;
4252         }
4253
4254         ret = notification_set_application(noti, package);      //pkg ex : "setting-blockingmode-efl"
4255         if (ret != NOTIFICATION_ERROR_NONE) {
4256                 _DBG("Fail to notification_set_application [%d]", ret);
4257                 goto FAIL;
4258         }
4259
4260         int noti_id=0;
4261         ret = notification_insert(noti, &noti_id);
4262         if (ret != NOTIFICATION_ERROR_NONE) {
4263                 _DBG("Fail to notification_insert [%d]", ret);
4264                 goto FAIL;
4265         }
4266
4267         ret = notification_free(noti);
4268         if (ret != NOTIFICATION_ERROR_NONE) {
4269                 _DBG("Fail to notification_free [%d]", ret);
4270                 goto FAIL;
4271         }
4272
4273         return 0 ;
4274
4275 FAIL:
4276         ret = notification_free(noti);
4277         if (ret != NOTIFICATION_ERROR_NONE) {
4278                 _DBG("Fail to notification_free [%d]", ret);
4279         }
4280         return 1;
4281 }
4282
4283 /*
4284  * Check whether file existed or not
4285  *
4286  * @param       pszFilePathName [in] : File path (/Folder)
4287  * @return      TRUE on success, FALSE on failure
4288  */
4289 static int __is_file_exist( char* pszFilePathName )
4290 {
4291         FILE*   pFile = NULL;
4292
4293         pFile = fopen( pszFilePathName, "r" );
4294         if ( pFile == NULL )
4295         {
4296                 _DBG( "fopen('%s')=NULL, File not existed.", pszFilePathName );
4297                 return 0;
4298         }
4299
4300         _DBG( "fopen('%s')!=NULL, File existed.", pszFilePathName );
4301
4302         fclose( pFile );
4303         pFile = NULL;
4304
4305         return 1;
4306 }
4307
4308 static int __mode_reboot_noti_method()
4309 {
4310         //get vconf to notif register
4311         //blockingmode, drivingmode, flightmode
4312         int block, driving, firewall, ret;
4313         ret = 0;
4314         ret |= vconf_get_bool(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, &block);
4315         ret |= vconf_get_bool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &driving);
4316         ret |= vconf_get_bool(VCONFKEY_SETAPPL_FIREWALL_KEY, &firewall);
4317         //ret |= vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight);
4318         _DBG("__mode_reboot_noti_method");
4319         printf("noti method start\n");
4320         if(ret){
4321                 printf("mode get vconf failed\n");
4322                 return ret;
4323         }
4324         //set noti for on status
4325         if(block)
4326                 ret |= mode_reboot_create_noti_only("IDS_ST_BODY_BLOCKING_MODE_IS_ENABLED", PKG_BLOCKING_MODE, "IDS_ST_BODY_BLOCKING_MODE");
4327         if(driving)
4328                 ret |= mode_reboot_create_noti_only("IDS_ST_BODY_INCOMING_CALLS_AND_NEW_NOTIFICATIONS_WILL_BE_READ_OUT_AUTOMATICALLY", PKG_DRIVING_MODE, "IDS_VC_MBODY_NOTIFICATION_READ_OUT");
4329         if(firewall)
4330                 ret |= mode_reboot_create_noti_only("IDS_ST_BODY_CONFIGURE_FIREWALL_SETTINGS", PKG_FIREWALL, "IDS_ST_BODY_FIREWALL_ENABLED_ABB");
4331         //if(flight) mode_reboot_create_noti_only ... not need to
4332
4333         return ret;     //zero for success
4334 }
4335 static void __win_del(void *data, Evas_Object * obj, void *event)
4336 {
4337         elm_exit();
4338 }
4339
4340 static Evas_Object *__create_win(const char *name)
4341 {
4342         _DBG("ENTER __create_win");
4343         Evas_Object *eo;
4344         int w;
4345         int h;
4346         Ecore_X_Window xwin;
4347         unsigned int val = 1;
4348
4349         eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
4350         if (eo)
4351         {
4352                 elm_win_title_set(eo, name);
4353                 elm_win_borderless_set(eo, EINA_TRUE);
4354                 elm_win_alpha_set(eo, EINA_TRUE);
4355                 elm_win_raise(eo);
4356                 evas_object_smart_callback_add(eo, "delete,request", __win_del, NULL);
4357                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
4358                 evas_object_resize(eo, w, h);
4359
4360                 xwin = elm_win_xwindow_get(eo);
4361                 ecore_x_window_prop_card32_set(xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
4362         }
4363
4364         return eo;
4365 }
4366
4367 static int __mode_syspopup_app_create(void *data)
4368 {
4369         _DBG("ENTER __mode_syspopup_app_create");
4370         struct appdata *ad = data;
4371         int r;
4372
4373         /* create window */
4374         ad->win = __create_win(PACKAGE);
4375         if (ad->win == NULL) {
4376                 _ERR("Create win error");
4377                 return -1;
4378         }
4379
4380         ad->ly_main = elm_layout_add(ad->win);
4381         evas_object_size_hint_weight_set(ad->ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4382         elm_layout_theme_set(ad->ly_main, "layout", "application", "default");
4383
4384         /*
4385         Evas_Object *conform = elm_conformant_add(ad->win);
4386         evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
4387         evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
4388         elm_win_resize_object_add(ad->win, conform);
4389         elm_object_content_set(conform, ad->ly_main);
4390         evas_object_show(conform);
4391         elm_win_conformant_set(ad->win, EINA_TRUE);
4392         */
4393         evas_object_show(ad->ly_main);
4394         elm_win_resize_object_add(ad->win, ad->ly_main);
4395         evas_object_show(ad->win);
4396
4397         /* init internationalization */
4398         setting_set_i18n(MODE_SYSPOPUP_PACKAGE, MODE_SYSPOPUP_LOCALEDIR);
4399 //#define TEST
4400 #ifdef TEST
4401         mode_syspopup_create_popup_with_label_check(ad, ad->ly_main, NULL,
4402                                                  KeyStr_MOBILEDATA_Popup_Off_Text,
4403                                                  KeyStr_DO_NOT_ASK_AGAIN,
4404                                                  &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
4405                                                  "IDS_COM_SK_CANCEL","IDS_COM_SK_OK");
4406
4407 #endif
4408         return 0;
4409 }
4410
4411 static int __mode_syspopup_app_terminate(void *data)
4412 {
4413         _DBG("__mode_syspopup_app_terminate");
4414         struct appdata *ad = data;
4415
4416         _DBG("11111111");
4417
4418         if(ad->tts) {
4419                 fini_tts(ad);
4420         }
4421         _DBG("11111111");
4422
4423         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
4424                 _DBG("vconf key ignore failed");
4425         _DBG("11111111");
4426
4427         int ret = 0;
4428         if (ad->type && (!strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_ON) || !strcmp(ad->type, MODE_SYSTEM_POPUP_BLOCKINGMODE_OFF))) {
4429                 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_BLOCKINGMODE_BLOCKINGMODE, _mode_vconf_change_cb);
4430                 if (ret != 0) {
4431                         _DBG("call vconf_ignore_key_changed failed");
4432                 }
4433         }
4434         _DBG("11111111");
4435
4436         if (ad->type && (!strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_ON) || !strcmp(ad->type, MODE_SYSTEM_POPUP_DRIVINGMODE_OFF))) {
4437                 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, _mode_vconf_change_cb);
4438                 if (ret != 0) {
4439                         _DBG("call vconf_ignore_key_changed failed");
4440                 }
4441         }
4442         _DBG("11111111");
4443
4444         _mini_destroy();
4445         _DBG("11111111");
4446
4447         if (ad->win){
4448                 evas_object_del(ad->win);
4449                 ad->win = NULL;
4450         }
4451         _DBG("11111111");
4452
4453         if (ad->lcd_freq_timer) {
4454                 ecore_timer_del(ad->lcd_freq_timer);
4455                 ad->lcd_freq_timer = NULL;
4456         }
4457         _DBG("11111111");
4458
4459         if (ad->play_timer) {
4460                 ecore_timer_del(ad->play_timer);
4461                 ad->play_timer = NULL;
4462         }
4463         _DBG("11111111");
4464
4465         if (ad->disable_popup) {
4466                 evas_object_del(ad->disable_popup);
4467                 ad->disable_popup = NULL;
4468         }
4469         _DBG("11111111");
4470
4471         if (ad->enable_popup) {
4472                 evas_object_del(ad->enable_popup);
4473                 ad->enable_popup = NULL;
4474         }
4475         _DBG("11111111");
4476
4477         elm_exit();
4478         _DBG("11111111");
4479         return 0;
4480 }
4481
4482 static int __mode_syspopup_app_pause(void *data)
4483 {
4484         //struct appdata *ad = data;
4485
4486         return 0;
4487 }
4488
4489 static int __mode_syspopup_resume(void *data)
4490 {
4491         //struct appdata *ad = data;
4492
4493         return 0;
4494 }
4495
4496 int main(int argc, char *argv[])
4497 {
4498         _DBG("ENTER main");
4499 #if REBOOT_METHOD_FROM_SHELL
4500         int i = 0;
4501         //for(; i < argc;i++) _DBG("argv[%d]:%s", i, argv[i]);
4502         int command = 99;
4503         int res = 77;
4504         if(argc >= 2) command = atoi(argv[1]);
4505         //_DBG("[0]%s [1]%s [2]%s command=%d , argc = %d",argv[0], argv[1],argv[2],command, argc);
4506         switch (command)
4507         {
4508                 case 1:// from sh
4509                         sleep(1);       //notification_is_service_ready
4510                         //function for vconf get and notification register
4511                         if(!__mode_reboot_noti_method()){
4512                                 //success
4513                                 res = 0;
4514                                 //function for recovery interrupt in emergency/upms work
4515                                 if(__is_file_exist(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml")){
4516                                         //should recovery!, set normal with reboot
4517                                         is_recovery = true;
4518                                 }else{
4519                                         return res;
4520                                 }
4521                         }else{
4522                                 _DBG("noti method failing");
4523                                 return 1;       //failing code from sh
4524                         }
4525                 default:
4526                         res = 99;
4527         }
4528         _DBG("[in reboot-mode sys seq from shell]end:res[%d]\n",res);
4529 #endif
4530
4531         struct appdata ad;
4532
4533         struct appcore_ops ops = {
4534                 .create = __mode_syspopup_app_create,
4535                 .terminate = __mode_syspopup_app_terminate,
4536                 .pause = __mode_syspopup_app_pause,
4537                 .resume = __mode_syspopup_resume,
4538                 .reset = __mode_syspopup_reset,
4539         };
4540
4541         memset(&ad, 0x0, sizeof(struct appdata));
4542         ops.data = &ad;
4543
4544         return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
4545 }