fix for applying wayland (removing X)
[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 <aul.h>
27 #include <pkgmgr-info.h>
28 /*#include <package-manager.h> */
29
30 #include <device.h>
31 #include <dd-display.h>
32 #include <dd-deviced.h>
33
34
35
36 #include <syspopup.h>
37 #include <mode-syspopup.h>
38 #include <mode-syspopup-alarmmgr.h>
39 #include <dd-haptic.h>
40 #include <dd-led.h>
41 #include <tapi_common.h>
42 #include <ITapiSim.h>
43 #include <ITapiModem.h>
44 #include <TapiUtility.h>
45 #include <TelPower.h>
46 #include <sound_manager.h>
47 #include <app_preference.h>
48 #include <bundle_internal.h>
49 #include <notification_text_domain.h>
50 #include <notification_internal.h>
51 #include <setting-debug.h>
52 #include <setting-common-data-error.h>
53
54 #include "setting-common-general-func.h"
55
56
57 void play_text(struct appdata *ad, const char *text);
58
59 static bool is_recovery = false;
60 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};
61 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};
62 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};
63 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};
64 /*brightness default as 20 changed 20131127 */
65 /*lcd freq default as 1 in setting spec */
66
67 /* default value for power saving
68 * Power saving mode default
69 Haptic feedback : Off
70 Apps opening effect : Off
71 Use GPS satellites : Off
72 ----------------------------------------
73 Brightness : 30%
74 Screen rotation: Off
75 Screen timeout : 15sec
76 Smart stay : off
77 Touch key light duration : Always off
78 Greyscale mode: Off
79 ----------------------------------------
80 CPU max frequency limit : On
81 Screen output : On
82 Eco wallpaper : Off
83 */
84
85
86 static Eina_List *mini_list;
87 static int __mode_reboot_noti_method();
88 static int __mode_syspopup_app_terminate(void *data);
89
90
91 /*dbus for CPU freq control*/
92 static int __append_param(DBusMessage *msg, const char *sig, char *param[])
93 {
94         DBusMessageIter iter;
95         DBusMessageIter cont_iter;
96         char *ch;
97         char *str_type;
98         int int_type;
99         int i;
100         if (sig == NULL || param == NULL)
101                 return 0;
102
103         dbus_message_iter_init_append(msg, &iter);
104         for (ch = (char *)sig, i = 0; *ch != '\0'; ++i, ++ch) {
105                 _DBG("sig : %c", *ch);
106                 switch (*ch) {
107                         case 'i':
108                                 int_type = atoi(param[i]);
109                                 _DBG("param[%2d] : %d", i, int_type);
110                                 dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &int_type);
111                                 break;
112                         case 's':
113                                 str_type = param[i];
114                                 _DBG("param[%2d] : %s", i, str_type);
115                                 dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &str_type);
116                                 break;
117                         default:
118                                 break;
119                 }
120         }
121         return 0;
122 }
123
124 static DBusMessage *__invoke_dbus_method(const char *dest, const char *path,
125                                          const char *interface, const char *method,
126                                          const char *sig, char *param[])
127 {
128         DBusError err;
129         DBusConnection *conn;
130         DBusMessage *reply;
131         DBusMessage *msg;
132         int r;
133
134         conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
135         if (conn == NULL) {
136                 _DBG("dbus_bus_get error");
137                 return NULL;
138         }
139         msg = dbus_message_new_method_call(dest, path, interface, method);
140         if (msg == NULL) {
141                 _DBG("dbus_message_new_method_call error");
142                 return NULL;
143         }
144         r = __append_param(msg, sig, param);
145         if (r < 0) {
146                 _DBG("append_param error");
147                 return NULL;
148         }
149         dbus_error_init(&err);
150         reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
151         dbus_message_unref(msg);
152         if (dbus_error_is_set(&err)) {
153                 _DBG("dbus_connection_send_with_reply_and_block error");
154                 _DBG("error [%s:%s]", err.name, err.message);
155                 dbus_error_free(&err);
156                 return NULL;
157         }
158         return reply;
159 }
160
161 int __set_LCD_freq_control(int value)
162 {
163         int ret = 0;
164         int state;
165         DBusMessage *msg;
166         DBusError err;
167         char *arr[4] = {0,};
168         char temp1[2] = {0,};
169         char temp[3] = {0,};
170
171         e_dbus_init();
172         dbus_error_init(&err);
173
174         snprintf(temp1, 2, "%1d", 0);   /*kernal parsing setting with value 0 */
175         temp1[1] = '\0';
176         _DBG("set as [%s]", temp1);
177
178         snprintf(temp, 3, "%1d", value);
179         temp[2] = '\0';
180         _DBG("set as [%s]", temp);
181         arr[0] = temp1;
182         arr[1] = temp;
183
184         msg = __invoke_dbus_method(BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, METHOD_NAME, "ii", arr);
185         if (msg) {
186                 if (!dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID)) {
187                         _DBG("no message : [%s:%s]", err.name, err.message);
188                         ret = -1;       /*RETURN FAIL */
189                 } else {
190                         _DBG("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_NAME, state);
191                 }
192                 dbus_message_unref(msg);
193         }
194         e_dbus_shutdown();
195
196         return ret;     /*succuess */
197 }
198
199 static Eina_Bool _LCD_freq_ctrl(void *data)
200 {
201         struct appdata *ad = data;
202         _DBG("_LCD_freq_ctrl");
203
204         /*lcd freq ctrl, it effect flickering while progressing on change home */
205         /*get master key psmode */
206         int m_key;
207         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
208
209         _DBG("ad->type: %s, vconfkey : %d", ad->type, m_key);
210         if (!strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY) || !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SETTING)) {
211                 if (ad->is_lcd_ctrl) {
212                         /*normal -> emergency */
213                         _DBG("set LCD FRQ ON, 40");
214                         __set_LCD_freq_control(LCD_FRQ_CONTROL_ON);
215                 }
216         } else if (!strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL) || !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL_SETTING)) {
217                 /*except powerful -> normal */
218                 if (!ad->is_lcd_ctrl) {
219                         /*emergency -> normal */
220                         _DBG("set LCD FRQ OFF, 60");
221                         __set_LCD_freq_control(LCD_FRQ_CONTROL_OFF);
222                 }
223         }
224         return FALSE;
225 }
226
227 static Eina_Bool _LCD_freq_ctrl_handler(void *data)
228 {
229         struct appdata *ad = data;
230         _DBG("_LCD_freq_ctrl_handler");
231
232         _LCD_freq_ctrl(ad);
233
234         ad->lcd_freq_timer = NULL;
235         return FALSE;
236 }
237
238 /*mini app term start*/
239 typedef struct {
240         char *appid;
241         int pid;
242 } pid_s;
243
244 void list_destroy_running_pid(Evas_Object *win)
245 {
246         ret_if(NULL == win);
247
248         Eina_List *list = evas_object_data_del(win, DATA_KEY_RUNNING_LIST);
249         if (NULL == list) return;
250
251         pid_s *p = NULL;
252         EINA_LIST_FREE(list, p) {
253                 if (NULL == p) continue;
254                 if (p->appid) free(p->appid);
255                 free(p);
256         }
257
258         eina_list_free(list);
259 }
260
261 static int _running_app_info_cb(const aul_app_info *ainfo, void *data)
262 {
263         retv_if(NULL == ainfo, 0);
264         retv_if(NULL == ainfo->pkg_name, 0);
265         retv_if(NULL == data, 0);
266
267         Evas_Object *win = data;
268         pid_s *p = calloc(1, sizeof(pid_s));
269         retv_if(NULL == p, 0);
270
271         char *appid = strdup(ainfo->pkg_name);
272         goto_if(NULL == appid, ERROR);
273
274         p->appid = appid;
275         p->pid = ainfo->pid;
276
277         Eina_List *rlist = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
278         rlist = eina_list_append(rlist, p);
279         evas_object_data_set(win, DATA_KEY_RUNNING_LIST, rlist);
280
281         return 1;
282
283 ERROR:
284         if (p) free(p);
285         return 0;
286 }
287
288 int list_create_running_pid(Evas_Object *win)
289 {
290         _DBG("list_create_running_pid");
291         list_destroy_running_pid(win);
292 #if 0 /* Proc */
293         if (AUL_R_OK != aul_app_get_running_app_info(_running_app_info_cb, win)) {
294 #else /* DB */
295         if (AUL_R_OK != aul_get_running_app_info_from_memory(_running_app_info_cb, win)) {
296 #endif
297                 _DBG("Cannot get the running apps' info");
298                 return -1;
299         }
300         return 0;
301 }
302
303 int list_get_running_pid(Evas_Object *win, const char *appid)
304 {
305         Eina_List *list = NULL;
306         const Eina_List *l = NULL;
307         const Eina_List *ln = NULL;
308         pid_s *p = NULL;
309
310         retv_if(NULL == win, -1);
311         retv_if(NULL == appid, -1);
312
313         list = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
314         if (!list) {
315                 retv_if(0 != list_create_running_pid(win), -1);
316                 list = evas_object_data_get(win, DATA_KEY_RUNNING_LIST);
317                 /* It's possible to be no running apps */
318                 if (NULL == list) return -1;
319         }
320
321         EINA_LIST_FOREACH_SAFE(list, l, ln, p) {
322                 if (NULL == p) continue;
323                 if (NULL == p->appid) continue;
324                 if (!strcmp(p->appid, appid)) return p->pid;
325         }
326
327         return -1;
328 }
329
330 #define APPID_PHONE "org.tizen.phone"
331 #define APPID_CONTACTS "org.tizen.contacts"     /*it is different appid in 'Phone' mini app P140623-06536 */
332 int _mini_apps_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
333 {
334         retv_if(NULL == handle, 0);
335
336         char *appid = NULL;
337         pkgmgrinfo_appinfo_get_appid(handle, &appid);
338         retv_if(NULL == appid, 0);
339
340         _DBG("appid[%s]", appid);
341         if (appid && !strcmp(appid, APPID_PHONE)) {
342                 mini_list = eina_list_append(mini_list, strdup(APPID_CONTACTS));
343         } else {
344                 mini_list = eina_list_append(mini_list, strdup(appid));
345         }
346         return 0;
347 }
348
349 #define MINIAPP_CATEGORY "http://samsung.com/category/floatingapp"
350 Eina_List *_miniapp_create(void)
351 {
352         /* Get info from AIL */
353         pkgmgrinfo_appinfo_filter_h filter = NULL;
354         int ret = 0;
355         int count = -1;
356
357         ret = pkgmgrinfo_appinfo_filter_create(&filter);
358         if (ret > 0) {
359                 _DBG("pkgmgrinfo_appinfo_filter_create() failed");
360         }
361         ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_CATEGORY, MINIAPP_CATEGORY);
362         ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, _mini_apps_cb, NULL);
363         ret = pkgmgrinfo_appinfo_filter_count(filter, &count);
364
365         if (count <= 0) {
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
407 /*help api */
408 static void __help_popup_language_change_cb(void *data, Evas_Object *obj, void *source)
409 {
410         /*char *string_id = (char *)data;
411         char *message = _(string_id);
412         helpui_set_popup_text(obj, message);*/
413 }
414
415 static void syspop_help_popup_circle_block_create(Evas_Object *win, Evas_Object *parent, Evas_Object **circle,
416                                                   Evas_Object **popup, char *string_id, int x, int y, Evas_Coord_Rectangle *rect)
417 {
418 }
419
420 int launching_effect_set(Evas_Object *win, int flag)
421 {
422         Ecore_X_Window xwin, root;
423         Ecore_X_Atom effect_enable_atom;
424         int is_enable = flag;
425         root = ecore_x_window_root_first_get();
426         effect_enable_atom = ecore_x_atom_get("_NET_CM_EFFECT_ENABLE");
427         if (!effect_enable_atom) {
428                 _DBG("Cannot create _NET_CM_EFFECT_ENABLE atom... \n\n");
429                 return -1;
430         }
431
432         /* is_enable  (0: effect disable, 1: effect enable) */
433         ecore_x_window_prop_card32_set(root, effect_enable_atom, &is_enable, 1);
434
435         return 0;
436 }
437
438 int launching_effect_get(Evas_Object *win, int *flag)
439 {
440         Ecore_X_Window xwin, root;
441         Ecore_X_Atom effect_enable_atom;
442         int is_enable = 0;
443         root = ecore_x_window_root_first_get();
444         effect_enable_atom = ecore_x_atom_get("_NET_CM_EFFECT_ENABLE");
445         if (!effect_enable_atom) {
446                 _DBG("Cannot create _NET_CM_EFFECT_ENABLE atom... \n\n");
447                 return -1;
448         }
449
450         /* is_enable  (0: effect disable, 1: effect enable) */
451         (void)ecore_x_window_prop_card32_get(root, effect_enable_atom, &is_enable, 1);
452         *flag = is_enable;
453
454         return 0;
455 }
456
457 static void mode_remove_noti(void *data, char *package)
458 {
459         struct appdata *ad = data;
460         notification_error_e ret = NOTIFICATION_ERROR_NONE;
461         ret = notification_delete_all_by_type(package, NOTIFICATION_TYPE_ONGOING);      /*pkg ex : "setting-blockingmode-efl" */
462         if (ret != NOTIFICATION_ERROR_NONE) {
463                 _DBG("Fail to notification_delete_all_by_type [%d]", ret);
464                 return;
465         }
466 }
467
468 static void mode_create_noti(void *data, const char *key_str, const char *package, const char *title)
469 {
470         struct appdata *ad = data;
471         notification_h noti = NULL;
472         notification_error_e ret = NOTIFICATION_ERROR_NONE;
473
474         /* remove noti */
475         mode_remove_noti(ad, package);
476
477         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
478                                 NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
479         if (!noti) {
480                 _DBG("Fail to notification_new [%d]", ret);
481                 return;
482         }
483
484         ret = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
485         if (ret != NOTIFICATION_ERROR_NONE) {
486                 _DBG("Fail to notification_set_layout [%d]", ret);
487                 goto FAIL;
488         }
489
490         if (!strcmp("setting-firewall-efl", package)) {
491                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_Firewall);
492                 if (ret != NOTIFICATION_ERROR_NONE) {
493                         _DBG("Fail to notification_set_image [%d]", ret);
494                         goto FAIL;
495                 }
496                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_Firewall);
497                 if (ret != NOTIFICATION_ERROR_NONE) {
498                         _DBG("Fail to notification_set_image [%d]", ret);
499                         goto FAIL;
500                 }
501         }
502
503         ret = notification_set_text(noti,
504                                     NOTIFICATION_TEXT_TYPE_TITLE,
505                                     title,
506                                     title, NOTIFICATION_VARIABLE_TYPE_NONE);
507         if (ret != NOTIFICATION_ERROR_NONE) {
508                 _DBG("Fail to notification_set_text [%d]", ret);
509                 goto FAIL;
510         }
511
512         ret = notification_set_text(noti,
513                                     NOTIFICATION_TEXT_TYPE_CONTENT,
514                                     key_str,
515                                     key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
516         if (ret != NOTIFICATION_ERROR_NONE) {
517                 _DBG("Fail to notification_set_text [%d]", ret);
518                 goto FAIL;
519         }
520
521         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
522         if (ret != NOTIFICATION_ERROR_NONE) {
523                 _DBG("Fail to notification_set_text [%d]", ret);
524                 goto FAIL;
525         }
526
527         ret = notification_set_pkgname(noti, package);  /*pkg ex : "setting-blockingmode-efl" */
528         if (ret != NOTIFICATION_ERROR_NONE) {
529                 _DBG("Fail to notification_set_pkgname [%d]", ret);
530                 goto FAIL;
531         }
532
533         ret = notification_set_application(noti, package);      /*pkg ex : "setting-blockingmode-efl" */
534         if (ret != NOTIFICATION_ERROR_NONE) {
535                 _DBG("Fail to notification_set_application [%d]", ret);
536                 goto FAIL;
537         }
538
539         ret = notification_insert(noti, &ad->noti_id);
540         if (ret != NOTIFICATION_ERROR_NONE) {
541                 _DBG("Fail to notification_insert [%d]", ret);
542                 goto FAIL;
543         }
544
545         ret = notification_free(noti);
546         if (ret != NOTIFICATION_ERROR_NONE) {
547                 _DBG("Fail to notification_free [%d]", ret);
548                 goto FAIL;
549         }
550
551         return;
552
553 FAIL:
554         ret = notification_free(noti);
555         if (ret != NOTIFICATION_ERROR_NONE) {
556                 _DBG("Fail to notification_free [%d]", ret);
557         }
558         return;
559 }
560
561 static void mode_create_noti_with_no_msg(void *data, const char *key_str, const char *package, const char *title)
562 {
563         struct appdata *ad = data;
564         notification_h noti = NULL;
565         notification_error_e ret = NOTIFICATION_ERROR_NONE;
566
567         /* remove noti */
568         mode_remove_noti(ad, package);
569
570         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
571                                 NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
572         if (!noti) {
573                 _DBG("Fail to notification_new [%d]", ret);
574                 return;
575         }
576
577         ret = notification_set_layout(noti, NOTIFICATION_LY_NOTI_THUMBNAIL);
578         if (ret != NOTIFICATION_ERROR_NONE) {
579                 _DBG("Fail to notification_set_layout [%d]", ret);
580                 goto FAIL;
581         }
582
583         if (!strcmp(PKG_BLOCKING_MODE, package)) {
584                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_BlockingMode);
585                 if (ret != NOTIFICATION_ERROR_NONE) {
586                         _DBG("Fail to notification_set_image [%d]", ret);
587                         goto FAIL;
588                 }
589                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_BlockingMode);
590                 if (ret != NOTIFICATION_ERROR_NONE) {
591                         _DBG("Fail to notification_set_image [%d]", ret);
592                         goto FAIL;
593                 }
594         }
595
596         ret = notification_set_text(noti,
597                                     NOTIFICATION_TEXT_TYPE_TITLE,
598                                     title,
599                                     title, NOTIFICATION_VARIABLE_TYPE_NONE);
600         if (ret != NOTIFICATION_ERROR_NONE) {
601                 _DBG("Fail to notification_set_text [%d]", ret);
602                 goto FAIL;
603         }
604
605         ret = notification_set_text(noti,
606                                     NOTIFICATION_TEXT_TYPE_CONTENT,
607                                     key_str,
608                                     key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
609         if (ret != NOTIFICATION_ERROR_NONE) {
610                 _DBG("Fail to notification_set_text [%d]", ret);
611                 goto FAIL;
612         }
613
614         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
615         if (ret != NOTIFICATION_ERROR_NONE) {
616                 _DBG("Fail to notification_set_text [%d]", ret);
617                 goto FAIL;
618         }
619
620         ret = notification_set_pkgname(noti, package);  /*pkg ex : "setting-blockingmode-efl" */
621         if (ret != NOTIFICATION_ERROR_NONE) {
622                 _DBG("Fail to notification_set_pkgname [%d]", ret);
623                 goto FAIL;
624         }
625
626         ret = notification_set_application(noti, package);      /*pkg ex : "setting-blockingmode-efl" */
627         if (ret != NOTIFICATION_ERROR_NONE) {
628                 _DBG("Fail to notification_set_application [%d]", ret);
629                 goto FAIL;
630         }
631
632         ret = notification_insert(noti, &ad->noti_id);
633         if (ret != NOTIFICATION_ERROR_NONE) {
634                 _DBG("Fail to notification_insert [%d]", ret);
635                 goto FAIL;
636         }
637
638         ret = notification_free(noti);
639         if (ret != NOTIFICATION_ERROR_NONE) {
640                 _DBG("Fail to notification_free [%d]", ret);
641                 goto FAIL;
642         }
643
644         return;
645
646 FAIL:
647         ret = notification_free(noti);
648         if (ret != NOTIFICATION_ERROR_NONE) {
649                 _DBG("Fail to notification_free [%d]", ret);
650         }
651         return;
652 }
653
654 void _mode_backup_settings(void *data)
655 {
656
657         struct appdata *ad = data;
658
659         int val, ret;
660         char *str1;
661         char *str2;
662
663         /*PSMODE #0 */
664         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val);
665         _DBG("VCONFKEY_SETAPPL_PSMODE [%d]", val);
666         ret = preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, val);
667         _DBG("PREFKEY_SAVINGPOWER_BACKUP_PSMODE [%d]", ret);
668
669         /*CPU */
670         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &val);
671         _DBG("VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU [%d]", val);
672         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF, val);
673         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF [%d]", ret);
674
675         /*Wallpaper change */
676         str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
677         ret = preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HOMESCREEN_PATH, str1);
678         free(str1);
679         str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
680         ret = preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LOCKSCREEN_PATH, str2);
681         free(str2);
682
683         /*time out */
684         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &val);
685         _DBG("VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL [%d]", val);
686         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT, val);
687         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT [%d]", ret);
688         /*Auto Brightness : ON/OFF */
689         vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &val);
690         _DBG("VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT [%d]", val);
691         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT, val);
692         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT [%d]", ret);
693         /*Brightness */
694         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &val);
695         _DBG("VCONFKEY_SETAPPL_LCD_BRIGHTNESS [%d]", val);
696         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT, val);
697         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT [%d]", ret);
698         /*Auto rotate screen */
699         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &val);
700         _DBG("VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL [%d]", val);
701         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE, val);
702         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE [%d]", ret);
703
704         /*Haptic feedback */
705         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &val);
706         _DBG("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL [%d]", val);
707         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK, val);       /*on/off */
708         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK [%d]", ret);
709         /*Launching effect */
710         launching_effect_get(ad->win, &val);
711         _DBG("launching_effect_get [%d]", val);
712         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT, val);
713         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT [%d]", ret);
714
715         /*pkg backup : cluster or easy */
716         char *pkg_home = NULL;
717         pkg_home = vconf_get_str(VCONF_PKG_PATH);
718         if (pkg_home) {
719                 _DBG("pkghome [%s]", pkg_home);
720                 ret = preference_set_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, pkg_home);
721                 _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME [%d]", ret);
722         }
723
724         /*vconf_get_int(VCONF_FAKE_KEY, &val); */
725         /*ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FAKE_EFFECT, val); */
726         /*setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FAKE_EFFECT ***"); */
727
728         /*GREYSCALE TONE */
729         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &val);
730         _DBG("VCONFKEY_SETAPPL_WINDOW_GRAYTONE [%d]", val);
731         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE, val);
732         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE [%d]", ret);
733
734         /*SCREEN OUTPUT */
735         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &val);
736         _DBG("VCONFKEY_SETAPPL_WINDOW_FPS [%d]", val);
737         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS, val);
738         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS [%d]", ret);
739
740         /*GPS */
741         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &val);
742         _DBG("VCONFKEY_LOCATION_ENABLED [%d]", val);
743         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS, val);
744         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS [%d]", ret);
745
746         /*touch key ligh duration */
747         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &val);
748         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION [%d]", val);
749         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT, val);
750         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT [%d]", ret);
751
752         /*end for power saving profile */
753
754         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LED_INDICATOR_NOTI, val);
755         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LED_INDICATOR_NOTI [%d]", ret);
756
757         /*Net-restriction mode - syspopup #20 */
758         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &val);
759         _DBG("VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE [%d]", val);
760         ret = preference_set_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE, val);
761         _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE [%d]", ret);
762
763         /*default power saving need 1 time */
764         ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &val);
765         _DBG("PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR : ret [%d], val [%d]", ret, val);
766         if (ret != PREFERENCE_ERROR_NONE) {
767                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 1);
768         }
769 }
770
771 void _mode_power_backup_settings(void *data)
772 {
773
774         struct appdata *ad = data;
775
776         int val, ret;
777         char *str1;
778         char *str2;
779
780         /*PSMODE #0 */
781         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &val);
782         _DBG("VCONFKEY_SETAPPL_PSMODE [%d]", val);
783         ret = preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, val);
784         _DBG("PREFKEY_SAVINGPOWER_BACKUP_PSMODE [%d]", ret);
785
786         /*CPU */
787         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &val);
788         _DBG("VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU [%d]", val);
789         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF, val);
790         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF [%d]", ret);
791
792         /*Wallpaper change */
793         str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
794         ret = preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH, str1);
795         /*setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH ***"); */
796         free(str1);
797         str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
798         ret = preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH, str2);
799         /*setting_retm_if(ret != PREFERENCE_ERROR_NONE, "*** [ERR] PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH ***"); */
800         free(str2);
801
802         /*time out */
803         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &val);
804         _DBG("VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL [%d]", val);
805         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT, val);
806         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT [%d]", ret);
807         /*Auto Brightness : ON/OFF */
808         vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &val);
809         _DBG("VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT [%d]", val);
810         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT, val);
811         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT [%d]", ret);
812         /*Brightness */
813         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &val);
814         _DBG("VCONFKEY_SETAPPL_LCD_BRIGHTNESS [%d]", val);
815         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT, val);
816         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT [%d]", ret);
817         /*Auto rotate screen */
818         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &val);
819         _DBG("VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL [%d]", val);
820         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE, val);
821         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE [%d]", ret);
822
823         /*Haptic feedback */
824         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &val);
825         _DBG("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL [%d]", val);
826         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK, val);        /*on/off */
827         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK [%d]", ret);
828
829         /*Launching effect */
830         launching_effect_get(ad->win, &val);
831         _DBG("launching_effect_get [%d]", val);
832         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT, val);
833         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT [%d]", ret);
834
835         /*pkg backup : cluster or easy */
836         char *pkg_home = NULL;
837         pkg_home = vconf_get_str(VCONF_PKG_PATH);
838         if (pkg_home) {
839                 _DBG("pkghome [%s]", pkg_home);
840                 ret = preference_set_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_PKG_HOME, pkg_home);
841                 _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_PKG_HOME [%d]", ret);
842         }
843
844         /*GREYSCALE TONE */
845         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &val);
846         _DBG("VCONFKEY_SETAPPL_WINDOW_GRAYTONE [%d]", val);
847         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE, val);
848         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE [%d]", ret);
849
850         /*SCREEN OUTPUT */
851         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &val);
852         _DBG("VCONFKEY_SETAPPL_WINDOW_FPS [%d]", val);
853         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS, val);
854         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS [%d]", ret);
855
856         /*GPS */
857         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &val);
858         _DBG("VCONFKEY_LOCATION_ENABLED [%d]", val);
859         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS, val);
860         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS [%d]", ret);
861
862         /*touch key ligh duration */
863         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &val);
864         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION [%d]", val);
865         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT, val);
866         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT [%d]", ret);
867
868         /*end for power saving profile */
869
870         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LED_INDICATOR_NOTI, val);
871         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_LED_INDICATOR_NOTI [%d]", ret);
872
873         /*Net-restriction mode - syspopup #20 */
874         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &val);
875         _DBG("VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE [%d]", val);
876         ret = preference_set_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE, val);
877         _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE [%d]", ret);
878 }
879
880
881 void _mode_apply_settings(void *data, int *set)
882 {
883
884         struct appdata *ad = data;
885         int val, crt_val, ret;
886
887
888         /*/////////////////////////////// */
889         /* power saving mode content order */
890         /*/////////////////////////////// */
891
892         /*Haptic feedback #1 */
893         vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &crt_val);
894         val = set[0];
895         if (val == -1) {
896                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HAPTIC_FEEDBACK, &val);
897         } else if (val == -2) {
898                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HAPTIC_FEEDBACK, &val);
899         }
900         if (val != crt_val) {
901                 vconf_set_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, val);
902                 _DBG("set haptic  feedback : %d", val);
903         }
904
905         /*Launching effect #2 */
906         launching_effect_get(ad->win, &crt_val);
907         val = set[1];
908         if (val == -1) {
909                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LAUNCH_EFFECT, &val);
910         }
911         if (val == -2) {
912                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_LAUNCH_EFFECT, &val);
913         }
914         if (val != crt_val) {
915                 launching_effect_set(ad->win, val);
916                 _DBG("set launching effect %d", val);
917         }
918
919         /*GPS #3 */
920         vconf_get_int(VCONFKEY_LOCATION_ENABLED, &crt_val);
921         _DBG("get GPS %d", crt_val);
922         val = set[2];
923         if (val == -1) {
924                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GPS, &val);
925                 _DBG("get GPS %d", val);
926         }
927         if (val == -2) {
928                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GPS, &val);
929                 _DBG("get GPS %d", val);
930         }
931         if (val != crt_val) {
932                 vconf_set_int(VCONFKEY_LOCATION_ENABLED, val);
933                 _DBG("set GPS %d", val);
934         }
935
936         /*Brightness #4 */
937         /*add check auto brightness routine */
938         vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &crt_val);
939         val = set[3];
940         if (val == -1) {
941                 int auto_br = 0;
942                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_BRIGHT, &auto_br);
943                 /* * 0 : Off */
944                 /* * 1 : On */
945                 /* * 2 : Pause */
946                 _DBG("check1 auto_br [%d]", auto_br);
947                 if (auto_br == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
948                         /*prev : auto on, fix to auto status last */
949                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
950
951                 } else if (auto_br == SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
952                         /*auto to off and set bright */
953                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
954                         ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_BRIGHT, &val);
955                 }
956         } else if (val == -2) {
957                 int auto_br = 0;
958                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_BRIGHT, &auto_br);
959                 /* * 0 : Off */
960                 /* * 1 : On */
961                 /* * 2 : Pause */
962                 _DBG("check1 auto_br [%d]", auto_br);
963                 if (auto_br == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
964                         /*prev : auto on, fix to auto status last */
965                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON);
966
967                 } else if (auto_br == SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
968                         /*auto to off and set bright */
969                         ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
970                         ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_BRIGHT, &val);
971                 }
972         } else {
973                 /*normal to power saving or emergency(val != -1), get auto brightness off */
974                 ret = vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
975         }
976
977         if (val != -1 && val != -2) {
978                 ret = display_set_brightness_with_setting(val);
979                 _DBG("set Brightness %d, ret = %d", val, ret);
980                 ret = vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, val);
981         }
982
983         /*Auto rotate screen #5 */
984         vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &crt_val);
985         val = set[4];
986         if (val == -1) {
987                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_AUTO_ROTATE, &val);
988         }
989         if (val == -2) {
990                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_AUTO_ROTATE, &val);
991         }
992         if (val != crt_val) {
993                 vconf_set_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, val);
994                 _DBG("set Auto rotate screen  %d", val);
995         }
996
997         /*time out #6 */
998         vconf_get_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &crt_val);
999         val = set[5];
1000         if (val == -1) {
1001                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TIMEOUT, &val);
1002         }
1003         if (val == -2) {
1004                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TIMEOUT, &val);
1005         }
1006         if (val != crt_val) {
1007                 vconf_set_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, val);
1008                 _DBG("set time out %d", val);
1009         }
1010
1011         /*Touch key light duration #8 */
1012         vconf_get_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, &crt_val);
1013         _DBG("VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION %d", crt_val);
1014         val = set[7];
1015         if (val == -3) {
1016                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT, &val);
1017                 _DBG("PREFKEY_SAVINGPOWER_NORMAL_BACKUP_TOUCH_KEY_LIGHT %d", val);
1018         }
1019         if (val == -4) {
1020                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT, &val);
1021                 _DBG("PREFKEY_SAVINGPOWER_POWER_BACKUP_TOUCH_KEY_LIGHT %d", val);
1022         }
1023         if (val != crt_val) {
1024                 vconf_set_int(VCONFKEY_SETAPPL_TOUCHKEY_LIGHT_DURATION, val);
1025                 _DBG("set Touch key light duration %d", val);
1026         }
1027
1028         /*gray scale tone #9 */
1029         /*gray scale tone for power saving mode! */
1030         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, &crt_val);
1031         val = set[8];
1032         if (val == -1) {
1033                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_GRAYTONE, &val);
1034         }
1035         if (val == -2) {
1036                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_GRAYTONE, &val);
1037         }
1038         if (val != crt_val) {
1039                 vconf_set_bool(VCONFKEY_SETAPPL_WINDOW_GRAYTONE, val);
1040                 _DBG("set gray scale tone %d", val);
1041         }
1042
1043         /*CPU max freq #10 */
1044         /*cpu limit on for power saving mode! */
1045         vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, &crt_val);
1046         val = set[9];
1047         if (val == -1) {
1048                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_CPU_PERF, &val);
1049         }
1050         if (val == -2) {
1051                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_CPU_PERF, &val);
1052         }
1053
1054         if (val != crt_val) {
1055                 vconf_set_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_CPU, val);
1056                 _DBG("set CPU frequency limit %d", val);
1057         }
1058
1059         /*Screen Output (D.FPS) #11 */
1060         /*screen output for power saving mode! */
1061         vconf_get_bool(VCONFKEY_SETAPPL_WINDOW_FPS, &crt_val);
1062         val = set[10];
1063         if (val == -1) {
1064                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_FPS, &val);
1065         }
1066         if (val == -2) {
1067                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_FPS, &val);
1068         }
1069         if (val != crt_val) {
1070                 vconf_set_bool(VCONFKEY_SETAPPL_WINDOW_FPS, val);
1071                 _DBG("set FPS %d", val);
1072         }
1073
1074         /*Eco. wallpaper (Wallpaper change) #12 */
1075         char *str1;
1076         char *str2;
1077         char *crt_str1;
1078         char *crt_str2;
1079         val = set[11];
1080         crt_str1 = vconf_get_str(VCONF_HOMESCREEN_PATH);
1081         crt_str2 = vconf_get_str(VCONF_LOCKSCREEN_PATH);
1082         if (val == -1) {
1083                 ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HOMESCREEN_PATH, &str1);
1084                 ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_LOCKSCREEN_PATH, &str2);
1085         } else if (val == -2) {
1086                 ret = preference_get_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_HOMESCREEN_PATH, &str1);
1087                 ret = preference_get_string(PREFKEY_SAVINGPOWER_POWER_BACKUP_LOCKSCREEN_PATH, &str2);
1088         } else { /* value ==1 and other cases -> set to default value */
1089                 str1 = strdup(HOMESCREEN_FILE);
1090                 str2 = strdup(LOCKSCREEN_FILE);
1091         }
1092
1093         if (str1) {
1094                 if (strcmp(str1, crt_str1) != 0) {
1095                         vconf_set_str(VCONF_HOMESCREEN_PATH, str1);
1096                         _DBG("set eco home screen wallpaper");
1097                 }
1098         }
1099         if (str2) {
1100                 if (strcmp(str2, crt_str2) != 0) {
1101                         vconf_set_str(VCONF_LOCKSCREEN_PATH, str2);
1102                         _DBG("set eco lock screen wallpaper");
1103                 }
1104         }
1105         free(str1);
1106         free(str2);
1107         free(crt_str1);
1108         free(crt_str2);
1109
1110         /*END of the Power saving profile set */
1111
1112         /*pkghome -for HOMESCREEN #13 */
1113         char *str = NULL;
1114         char *crt_str = NULL;
1115         val = set[12];
1116         crt_str = vconf_get_str(VCONF_PKG_PATH);
1117         if (val == -1) {
1118                 int chk_easy = 0;
1119                 vconf_get_bool(VCONFKEY_SETAPPL_HOMESCREEN_EASYMODE_BOOL, &chk_easy);
1120                 if (chk_easy) {
1121                         /*easy-mode :on -> off mode did not go back to current, just keep easy home state */
1122                         str = strdup(PKG_EASYHOME);     /*get curren pkg home path -> easy-mode */
1123                 } else {
1124                         /*off on easy-mode */
1125                         /*ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, &str); */
1126                         str = strdup(PKG_CLUSTERHOME);
1127                 }
1128         } else if (val == -2) {
1129                 int chk_easy = 0;
1130                 vconf_get_bool(VCONFKEY_SETAPPL_HOMESCREEN_EASYMODE_BOOL, &chk_easy);
1131                 if (chk_easy) {
1132                         /*easy-mode :on -> off mode did not go back to current, just keep easy home state */
1133                         str = strdup(PKG_EASYHOME);     /*get curren pkg home path -> easy-mode */
1134                 } else {
1135                         /*off on easy-mode */
1136                         /*ret = preference_get_string(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_PKG_HOME, &str); */
1137                         str = strdup(PKG_CLUSTERHOME);
1138                 }
1139         } else if (val == 1) {
1140                 str = strdup(PKG_EMERGENCY);
1141         }
1142
1143         if (crt_str) {
1144                 if (str != NULL && strcmp(str, crt_str) != 0) {
1145                         vconf_set_str(VCONF_PKG_PATH, str);
1146                 }
1147         }
1148         free(str);
1149         free(crt_str);
1150
1151         /*ENDOF POWER SAVING PROFILES */
1152
1153         /*OTHERS */
1154         val = set[17];
1155         if (val == -1) {
1156                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_HANDS_FREE_MODE, &val);
1157         }
1158         if (val == -2) {
1159                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_HANDS_FREE_MODE, &val);
1160         }
1161
1162         /*Net-restriction mode - syspopup #20 */
1163         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &crt_val);
1164         val = set[19];
1165         if (val == -1) {
1166                 ret = preference_get_int(PREFKEY_SAVINGPOWER_NORMAL_BACKUP_NET_RESRICT_MODE, &val);
1167         }
1168         if (val == -2) {
1169                 ret = preference_get_int(PREFKEY_SAVINGPOWER_POWER_BACKUP_NET_RESRICT_MODE, &val);
1170         }
1171
1172         if (val != crt_val) {
1173                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, val);
1174                 /*todo mode-syspopup */
1175                 _DBG("set Net-restriction mode %d", val);
1176         }
1177
1178         /*mini app terminate - syspopup #21 */
1179         val = set[20];
1180         if (val == 1) {
1181                 _DBG("emergency terminate mini");
1182                 _terminate_miniapp(ad);
1183         }
1184 }
1185
1186 /*///////////////// */
1187 /*/ blocking mode /// */
1188 /*///////////////// */
1189
1190 /* rotation policy with lock screen */
1191 static void lcd_state_changed(keynode_t *key, void *data)
1192 {
1193         int state;
1194         struct appdata *ad = data;
1195
1196         if (!key || !ad)
1197                 return;
1198
1199         state = vconf_keynode_get_int(key);
1200         if (state != VCONFKEY_PM_STATE_LCDOFF)
1201                 return;
1202
1203         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
1204                 _DBG("vconf key ignore failed");
1205
1206         elm_exit();
1207 }
1208
1209 /*popup handling */
1210 static void __def_response_cb(void *data, Evas_Object *obj,
1211                               void *event_info)
1212 {
1213         _DBG(" REMOVE THE POPUP OBJECT BY THIS FUNCTION ");
1214         if (obj) {
1215                 evas_object_del(obj);
1216                 obj = NULL;
1217         }
1218 }
1219
1220 void __popup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
1221 {
1222         _DBG("__popup_del_cb");
1223 #if 0
1224         Ecore_X_Display *disp = ecore_x_display_get();
1225         Ecore_X_Window xwin = elm_win_xwindow_get(obj);
1226         int ret = utilx_ungrab_key(disp, xwin, KEY_HOME);
1227         if (ret) {
1228                 _DBG("KEY_HOME ungrab error ret[%d]", ret);
1229         }
1230
1231         ret = utilx_ungrab_key(disp, xwin, KEY_BACK);
1232         if (ret) {
1233                 _DBG("KEY_BACK ungrab error ret[%d]", ret);
1234         }
1235
1236         ret = utilx_ungrab_key(disp, xwin, KEY_POWER);
1237         if (ret) {
1238                 _DBG("KEY_POWER ungrab error ret[%d]", ret);
1239         }
1240
1241         ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEUP);
1242         if (ret) {
1243                 _DBG("KEY_VOLUMEUP ungrab error ret[%d]", ret);
1244         }
1245
1246         ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEDOWN);
1247         if (ret) {
1248                 _DBG("KEY_VOLUMEDOWN ungrab error ret[%d]", ret);
1249         }
1250 #endif
1251 }
1252
1253 static void __popup_event_set(Evas_Object *popup, void *data,
1254                               _cb_func response_cb,
1255                               int timeout,/*to control the timeout time */
1256                               bool blocked_flag,/*to control whether to block the screen */
1257                               bool keygrab_flag/*to control whether to block the 'Home key' */
1258                              )
1259 {
1260         _DBG("__popup_event_set");
1261         if (timeout > 0) {
1262                 if (response_cb) {
1263                         evas_object_smart_callback_add(popup, "timeout", response_cb, data);
1264                 } else {
1265                         evas_object_smart_callback_add(popup, "timeout", __def_response_cb, data);
1266                 }
1267         }
1268
1269         if (!blocked_flag) {/*not blocked_flag == TRUE !!! */
1270                 if (response_cb) {
1271                         evas_object_smart_callback_add(popup, "block,clicked", response_cb, data);
1272                 } else {
1273                         evas_object_smart_callback_add(popup, "block,clicked", __def_response_cb, data);
1274                 }
1275         }
1276
1277         if (keygrab_flag) {
1278 #if 0
1279                 Ecore_X_Display *disp = ecore_x_display_get();
1280                 Ecore_X_Window xwin = elm_win_xwindow_get(popup);
1281                 int ret = utilx_grab_key(disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
1282                 if (ret) {
1283                         _DBG("KEY_HOME grab error ret[%d]", ret);
1284                 }
1285
1286                 ret = utilx_grab_key(disp, xwin, KEY_BACK, TOP_POSITION_GRAB);
1287                 if (ret) {
1288                         _DBG("KEY_BACK grab error ret[%d]", ret);
1289                 }
1290
1291                 ret = utilx_grab_key(disp, xwin, KEY_POWER, TOP_POSITION_GRAB);
1292                 if (ret) {
1293                         _DBG("KEY_POWER grab error ret[%d]", ret);
1294                 }
1295
1296                 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEUP, TOP_POSITION_GRAB);
1297                 if (ret) {
1298                         _DBG("KEY_VOLUMEUP grab error ret[%d]", ret);
1299                 }
1300
1301                 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEDOWN, TOP_POSITION_GRAB);
1302                 if (ret) {
1303                         _DBG("KEY_VOLUMEDOWN grab error ret[%d]", ret);
1304                 }
1305 #endif
1306                 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, __popup_del_cb, NULL);
1307         }
1308 }
1309
1310 static Evas_Object *__add_progressbar(void *data, Evas_Object *parent,
1311                                       char *progressbar_style,
1312                                       char *progressbar_title,
1313                                       char *progressbar_lable)
1314 {
1315         _DBG("__add_progressbar");
1316 #if 0
1317         Evas_Object *popup;
1318         Evas_Object *progressbar;
1319         struct appdata *ad;
1320         Evas_Object *layout;
1321
1322         ad = (struct appdata *) data;
1323         popup = ea_center_popup_add(parent);
1324
1325         layout = elm_layout_add(popup);
1326         elm_layout_file_set(layout, POPUP_EDJ, "popup_processingview_1button"); /*u can use add button or not */
1327         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1328
1329         /* [UI] progress icon */
1330         progressbar = elm_progressbar_add(popup);
1331         elm_progressbar_pulse(progressbar, EINA_TRUE);
1332         elm_object_style_set(progressbar, progressbar_style);
1333         elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
1334         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1335         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1336         evas_object_show(progressbar);
1337
1338         elm_object_part_content_set(layout, "elm.swallow.content", progressbar);
1339         /* [UI] text */
1340         elm_object_part_text_set(layout, "elm.text", progressbar_lable);
1341
1342         elm_object_content_set(popup, layout);
1343         return popup;
1344 #endif
1345         Evas_Object *popup;
1346         Evas_Object *progressbar;
1347         Evas_Object *layout;
1348         Evas_Object *label;
1349         int change_ang = 0;
1350
1351         popup = elm_popup_add(parent);
1352         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1353
1354         Evas_Object *box = elm_box_add(popup);
1355         elm_box_horizontal_set(box, EINA_TRUE);
1356         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1357         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1358         elm_box_align_set(box, 0.5, 0.5);
1359         elm_box_padding_set(box, 16, 0);
1360
1361         progressbar = elm_progressbar_add(popup);
1362         elm_progressbar_pulse(progressbar, EINA_TRUE);
1363         elm_object_style_set(progressbar, "process_large");
1364         evas_object_show(progressbar);
1365         elm_box_pack_end(box, progressbar);
1366
1367         label = elm_label_add(popup);
1368         elm_object_text_set(label, progressbar_lable);
1369         evas_object_show(label);
1370         elm_box_pack_end(box, label);
1371
1372         Evas_Object *table = elm_table_add(popup);
1373         evas_object_show(table);
1374         elm_table_homogeneous_set(table, EINA_FALSE);
1375
1376         Evas_Object *rect_up;
1377         rect_up = evas_object_rectangle_add(evas_object_evas_get(popup));
1378         evas_object_size_hint_min_set(rect_up, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(32));
1379
1380         Evas_Object *rect_down;
1381         rect_down = evas_object_rectangle_add(evas_object_evas_get(popup));
1382         evas_object_size_hint_min_set(rect_down, ELM_SCALE_SIZE(100), ELM_SCALE_SIZE(37));
1383
1384         /* box */
1385         elm_table_pack(table, rect_up, 0, 0, 1, 1);/* rect as a padding */
1386         elm_table_pack(table, box, 0, 1, 1, 1);
1387         elm_table_pack(table, rect_down, 0, 2, 1, 1);/* rect as a padding */
1388         evas_object_show(box);
1389         elm_object_content_set(popup, table);
1390
1391         evas_object_show(popup);
1392         return popup;
1393 }
1394
1395 static Evas_Object *__add_double_line_progressbar(void *data, Evas_Object *parent,
1396                                                   char *progressbar_style,
1397                                                   char *progressbar_title,
1398                                                   char *progressbar_lable)
1399 {
1400         _DBG("__add_double_line_progressbar");
1401         Evas_Object *popup;
1402         Evas_Object *label;
1403         Evas_Object *layout;
1404         Evas_Object *progressbar = NULL;
1405         popup = ea_center_popup_add(parent);
1406         /* [UI] add lable */
1407         if (progressbar_lable) {
1408                 label = elm_label_add(popup);
1409                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
1410                 elm_object_text_set(label, _(progressbar_lable));
1411                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
1412                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
1413                 evas_object_show(label);
1414         }
1415         layout = elm_layout_add(popup);
1416         elm_layout_file_set(layout, POPUP_EDJ, "popup_processingview");
1417         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1418
1419         /* [UI] progress icon */
1420         if (progressbar_style) {
1421                 progressbar = elm_progressbar_add(popup);
1422                 elm_progressbar_pulse(progressbar, EINA_TRUE);
1423                 elm_object_style_set(progressbar, progressbar_style);
1424                 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
1425                 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
1426                 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1427                 evas_object_show(progressbar);
1428         }
1429
1430         elm_object_part_content_set(layout, "elm.swallow.content", progressbar);
1431         elm_object_part_content_set(layout, "elm.swallow.text", label);
1432
1433         elm_object_content_set(popup, layout);
1434         return popup;
1435 }
1436
1437
1438 Evas_Object *__popup_with_progressbar(void *data, Evas_Object *popup,
1439                                       Evas_Object *parent,
1440                                       char *progressbar_style,
1441                                       char *title,
1442                                       char *text,
1443                                       _cb_func response_cb,
1444                                       int timeout,
1445                                       bool blocked_flag,
1446                                       bool keygrab_flag,
1447                                       bool dobule_line_flag)
1448 {
1449         if (dobule_line_flag) {
1450                 popup = __add_double_line_progressbar(data, parent, progressbar_style,
1451                                                       title, text);
1452         } else {
1453                 popup = __add_progressbar(data, parent, progressbar_style,
1454                                           title, text);
1455                 elm_object_style_set(popup, "no_effect");
1456         }
1457
1458         if (timeout > 0) {
1459                 elm_popup_timeout_set(popup, timeout);
1460         }
1461         __popup_event_set(popup, data, response_cb, timeout, blocked_flag, keygrab_flag);
1462         evas_object_show(popup);
1463         return popup;
1464 }
1465
1466 Evas_Object *_create_bg(Evas_Object *parent, Evas_Object *win, const char *bg_style)
1467 {
1468         char *path = NULL;
1469         if (parent == NULL) {
1470                 return "NULL";
1471         }
1472         Evas_Object *bg = elm_bg_add(parent);
1473
1474         if (bg == NULL) {
1475                 return "NULL";
1476         }
1477         elm_object_style_set(bg, bg_style);
1478         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
1479                                          EVAS_HINT_EXPAND);
1480         elm_win_resize_object_add(parent, bg);  /*regarding window resize */
1481         /*elm_bg_file_set(bg, DEFAULT_BG_PATH, NULL); */
1482         evas_object_show(bg);
1483         return bg;
1484 }
1485
1486 char *mode_syspopup_gettext(const char *s)
1487 {
1488         /* fisrt find in app pg */
1489         if (s == NULL) {
1490                 return "NULL";
1491         }
1492
1493         char *p = dgettext(PACKAGE, s);
1494
1495         if (p && !strcmp(s, p)) {        /* not found */
1496                 /* find in system pkg */
1497                 p = dgettext("sys_string", s);
1498         }
1499
1500         if (p && !strcmp(s, p)) {        /* not found */
1501                 /* find in system pkg */
1502                 p = dgettext("setting", s);
1503         }
1504         return p;
1505 }
1506
1507 int myterm(bundle *b, void *data)
1508 {
1509         return 0;
1510 }
1511
1512 int mytimeout(bundle *b, void *data)
1513 {
1514         return 0;
1515 }
1516
1517 syspopup_handler handler = {
1518         .def_term_fn = myterm,
1519         .def_timeout_fn = mytimeout
1520 };
1521
1522 /* Release evas object */
1523 void release_evas_object(Evas_Object **obj)
1524 {
1525         if (!obj || !(*obj))
1526                 return;
1527         evas_object_del(*obj);
1528         *obj = NULL;
1529 }
1530
1531
1532 static void ea_popup_back_cb_overide(void *data, Evas_Object *obj, void *event_info)
1533 {
1534         ea_popup_back_cb(data, obj, event_info);
1535
1536         if (NULL == data) return;
1537         struct appdata *ad = data;
1538         __mode_syspopup_app_terminate(ad);
1539 }
1540
1541 static void timeout_response_cb(void *data, Evas_Object *obj, void *event_info)
1542 {
1543         ea_popup_back_cb(data, obj, event_info);
1544
1545         if (NULL == data) return;
1546         struct appdata *ad = data;
1547
1548         if (ad->popup) {
1549                 evas_object_del(ad->popup);
1550                 ad->popup = NULL;
1551         }
1552         __mode_syspopup_app_terminate(ad);
1553 }
1554
1555 static void __progress_popup_cb(void *data, Evas_Object *obj, void *event_info)
1556 {
1557         if (NULL == data) return;
1558         struct appdata *ad = data;
1559         _DBG("progress popup cb");
1560
1561         /* have operating delay in emergency to cluster, exit point was after progress */
1562         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
1563                 _DBG("vconf key ignore failed");
1564
1565         is_recovery = false;
1566
1567         /*refresh indicator */
1568         __mode_reboot_noti_method();
1569
1570         elm_exit();
1571 }
1572
1573 Eina_Bool
1574 play_timeout_update_cb(void *data)
1575 {
1576         if (NULL == data) return EINA_FALSE;
1577         struct appdata *ad = data;
1578         play_text(ad, _("IDS_ST_BODY_A_PERSON_YOU_HAVE_GRANTED_AUTHORITY_TO_IS_TRYING_TO_REMOTELY_ENABLE_EMERGENCY_MODE_ON_THIS_DEVICE_MSG"));
1579         ad->play_timer = NULL;
1580         return EINA_FALSE;
1581 }
1582
1583
1584 static void __mode_syspopup_emergency_cb(void *data, Evas_Object *obj, void *event_info)
1585 {
1586         struct appdata *ad = data;
1587
1588         if (!ad)
1589                 return;
1590
1591         /*delete old help */
1592         if (ad->help_type != HELP_NONE) {
1593                 if (ad->help_circle) {
1594                         evas_object_del(ad->help_circle);
1595                         ad->help_circle = NULL;
1596                 }
1597                 if (ad->help_popup) {
1598                         evas_object_del(ad->help_popup);
1599                         ad->help_popup = NULL;
1600                 }
1601         }
1602
1603         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1604         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1605         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))) {
1606                 /*make complete flag */
1607                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
1608                 if (ret) _ERR("check export xml");
1609
1610                 int m_key;
1611                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
1612                 if (m_key == SETTING_PSMODE_NORMAL) {
1613                         /*backup */
1614                         _mode_backup_settings(ad);
1615                 } else if (m_key == SETTING_PSMODE_POWERFUL) {
1616                         /*backup */
1617                         _mode_power_backup_settings(ad);
1618                 }
1619                 release_evas_object(&(ad->popup));
1620                 ad->bg = _create_bg(ad->win, NULL, "group_list");
1621                 /*progress bar */
1622                 ad->enable_popup = __popup_with_progressbar(ad, ad->enable_popup, ad->win, PROGRESSBAR_STYLE,
1623                                                             NULL, _("IDS_ST_POP_ENABLING_EMERGENCY_MODE_ING"), __progress_popup_cb, 3/*0*/, TRUE, TRUE, TRUE);  /* 2 seconds to wait in maximum */
1624
1625                 /*assistive light off, P140422-06240 */
1626                 ret = led_set_brightness_with_noti(0, TRUE);
1627                 if (0 != ret) {
1628                         _DBG(">>>led SET TO ZERO err [%d]", ret);
1629                 } else {
1630                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
1631                         if (ret != 0) {
1632                                 _DBG("*** [ERR] Failed to disable popup off reminder %d***", ret);
1633                         }
1634                 }
1635
1636                 /*set emergency*/
1637                 _mode_apply_settings(ad, emergency_settings);
1638                 /*set gray tone */
1639                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
1640                         _DBG("set on SETTING_PSMODE_EMERGENCY");
1641                 }
1642                 free(btn_str);
1643         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1644                 _DBG("CANCEL");
1645                 free(btn_str);
1646                 elm_exit();
1647         } else {
1648                 free(btn_str);
1649         }
1650         /*evas_object_del(ad->win); */
1651 }
1652
1653 static void __mode_syspopup_powerful_cb(void *data, Evas_Object *obj, void *event_info)
1654 {
1655         struct appdata *ad = data;
1656
1657         if (!ad)
1658                 return;
1659
1660         /*delete old help */
1661         if (ad->help_type != HELP_NONE) {
1662                 if (ad->help_circle) {
1663                         evas_object_del(ad->help_circle);
1664                         ad->help_circle = NULL;
1665                 }
1666                 if (ad->help_popup) {
1667                         evas_object_del(ad->help_popup);
1668                         ad->help_popup = NULL;
1669                 }
1670         }
1671
1672         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1673         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1674         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1675                 int m_key, first;
1676                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
1677                 if (m_key == SETTING_PSMODE_NORMAL) {
1678                         /*backup */
1679                         _mode_backup_settings(ad);
1680                 }
1681                 _DBG("OK OK");
1682                 /*set normal sub*/
1683                 int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
1684
1685                 if (first) {
1686                         _mode_apply_settings(ad, powerful_settings_def);
1687                         preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
1688                 } else {
1689                         _mode_apply_settings(ad, powerful_settings);
1690                         _DBG("right to set powerful");
1691                 }
1692                 /* set to default */
1693                 int opposite;
1694                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
1695                 if (ret) _DBG("vconf_get_bool failed");
1696                 /*emergency mode -> normal */
1697                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
1698                         _DBG("set on SETTING_PSMODE_POWERFUL");
1699                 }
1700         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1701                 _DBG("CANCEL");
1702         }
1703         /*evas_object_del(ad->win); */
1704         free(btn_str);
1705         elm_exit();
1706 }
1707
1708 static void __mode_syspopup_netrestrictionmode_change_on_cb(void *data, Evas_Object *obj, void *event_info)
1709 {
1710         struct appdata *ad = data;
1711
1712         if (!ad)
1713                 return;
1714
1715         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1716         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1717
1718         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1719                 _DBG("OK button");
1720
1721                 if (vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, 1) == 0) {
1722                         _DBG("network_restrict_mode vconf set 1");
1723                 } else {
1724                         _DBG("network_restrict_mode vconf set failed");
1725                 }
1726         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1727                 _DBG("Cancel button");
1728         }
1729
1730         free(btn_str);
1731
1732         elm_exit();
1733 }
1734
1735 static void __mode_syspopup_netrestrictionmode_change_off_cb(void *data, Evas_Object *obj, void *event_info)
1736 {
1737         struct appdata *ad = data;
1738
1739         if (!ad)
1740                 return;
1741
1742         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1743         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1744
1745         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1746                 _DBG("OK button");
1747
1748                 if (vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, 0) == 0) {
1749                         _DBG("network_restrict_mode vconf set 0");
1750                 } else {
1751                         _DBG("network_restrict_mode vconf set failed");
1752                 }
1753         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1754                 _DBG("Cancel button");
1755         }
1756
1757         free(btn_str);
1758
1759         elm_exit();
1760 }
1761
1762 static void __mode_syspopup_normal_cb(void *data, Evas_Object *obj, void *event_info)
1763 {
1764         _DBG("__mode_syspopup_normal_cb");
1765         struct appdata *ad = data;
1766
1767         if (!ad)
1768                 return;
1769
1770         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1771         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1772         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_DISABLE"))) {
1773                 /*using normal cb as 1) emergency -> normal or 2) emergency -> powerful , after[K] concept back_mode needed */
1774                 int back_mode;
1775                 preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_PSMODE, &back_mode);
1776
1777                 int m_key;
1778                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
1779                 if (m_key == SETTING_PSMODE_POWERFUL) {
1780                         /*backup */
1781                         _mode_power_backup_settings(ad);
1782                 }
1783                 /*evas_object_hide(ad->popup); */
1784                 release_evas_object(&(ad->popup));
1785                 ad->bg = _create_bg(ad->win, NULL, "group_list");
1786                 /*progress bar */
1787                 ad->disable_popup = __popup_with_progressbar(ad, ad->disable_popup, ad->win, PROGRESSBAR_STYLE,
1788                                                              NULL, _(KeyStr_Loading), __progress_popup_cb, 3/*0*/, TRUE, TRUE, FALSE);  /* 2 seconds to wait in maximum */
1789
1790
1791                 /*set normal sub*/
1792                 if (back_mode == SETTING_PSMODE_NORMAL) {
1793                         /*make complete flag */
1794                         int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
1795                         if (ret) _ERR("check export xml");
1796                         /*torch light off with diable emergency/ups mode, P140507-03841 */
1797                         int t_ret = led_set_brightness_with_noti(0, TRUE);
1798                         if (0 != t_ret) {
1799                                 _DBG(">>>led SET TO ZERO err [%d]", t_ret);
1800                         } else {
1801                                 vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
1802                                 if (t_ret != 0) {
1803                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***", t_ret);
1804                                 }
1805                         }
1806                         int b_network_lcd_off;
1807                         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
1808                         if (b_network_lcd_off) {
1809                                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
1810                         }
1811                         _mode_apply_settings(ad, normal_settings);
1812                 }
1813
1814                 /*set power sub*/
1815                 if (back_mode == SETTING_PSMODE_POWERFUL) {
1816                         int first;
1817                         /*set normal sub*/
1818                         int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
1819                         if (first) {
1820                                 _mode_apply_settings(ad, powerful_settings_def);
1821                                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
1822                         } else {
1823                                 _mode_apply_settings(ad, powerful_settings);
1824                                 _DBG("right to set powerful");
1825                         }
1826                 }
1827
1828                 /* set to default */
1829                 int opposite;
1830                 int ret = 0;
1831                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
1832                 if (ret) _DBG("vconf_get_bool failed");
1833                 if (back_mode == SETTING_PSMODE_NORMAL) {
1834                         /*emergency mode -> normal */
1835                         if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
1836                                 _DBG("set on SETTING_PSMODE_NORMAL");
1837                         }
1838                 } else if (back_mode == SETTING_PSMODE_POWERFUL) {
1839                         /*emergency mode -> power saving */
1840                         if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
1841                                 _DBG("set on SETTING_PSMODE_POWERFUL");
1842                         }
1843                 }
1844                 free(btn_str);
1845
1846                 /* */
1847 #if LCD_FREQ_CTRL
1848                 if (ad->lcd_freq_timer) {
1849                         ecore_timer_del(ad->lcd_freq_timer);
1850                         ad->lcd_freq_timer = NULL;
1851                 }
1852                 ad->is_lcd_ctrl = EINA_FALSE;
1853                 ad->lcd_freq_timer = ecore_timer_add(2.7, (Ecore_Task_Cb)_LCD_freq_ctrl_handler, ad);
1854 #endif
1855
1856                 _DBG("OK end");
1857         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1858                 _DBG("CANCEL");
1859                 free(btn_str);
1860                 elm_exit();
1861         } else {
1862                 free(btn_str);
1863         }
1864         /*evas_object_del(ad->win); */
1865 }
1866
1867 static void __mode_blockingmode_popup_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *data)
1868 {
1869         struct appdata *ad = data;
1870         _DBG("__mode_blockingmode_popup_cb");
1871         if (ad->popup) {
1872                 evas_object_del(ad->popup);
1873                 ad->popup = NULL;
1874         }
1875 }
1876
1877 static void __mode_syspopup_blockingmode_cb(void *data, Evas_Object *obj, void *event_info)
1878 {
1879         struct appdata *ad = data;
1880
1881         if (!ad)
1882                 return;
1883
1884         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1885         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1886         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1887                 _DBG("OK OK");
1888
1889                 app_control_h app_control = NULL;
1890                 app_control_create(&app_control);
1891                 if (app_control == NULL) {
1892                         _DBG("the app_control is NULL");
1893                         free(btn_str);
1894                         return;
1895                 }
1896                 int ret;
1897                 ret = app_control_set_app_id(app_control, "setting-blockingmode-efl");
1898                 if (ret != APP_CONTROL_ERROR_NONE) {
1899                         _DBG("app_control_set_app_id fail : %d", ret);
1900                 }
1901                 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
1902                 ret = app_control_send_launch_request(app_control, NULL, NULL);
1903                 if (ret != APP_CONTROL_ERROR_NONE) {
1904                         _DBG("app_control_send_launch_request fail : %d", ret);
1905                 }
1906                 app_control_destroy(app_control);
1907         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1908                 _DBG("CANCEL");
1909         }
1910         if (ad->popup) {
1911                 evas_object_del(ad->popup);
1912                 ad->popup = NULL;
1913         }
1914         /*evas_object_del(ad->win); */
1915         free(btn_str);
1916         elm_exit();
1917 }
1918
1919 static void __mode_syspopup_drivingmode_cb(void *data, Evas_Object *obj, void *event_info)
1920 {
1921         struct appdata *ad = data;
1922
1923         if (!ad)
1924                 return;
1925
1926         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1927         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1928         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1929                 _DBG("OK OK");
1930
1931                 app_control_h app_control = NULL;
1932                 app_control_create(&app_control);
1933                 if (app_control == NULL) {
1934                         _DBG("the app_control is NULL");
1935                         free(btn_str);
1936                         return;
1937                 }
1938                 int ret;
1939                 ret = app_control_set_app_id(app_control, "setting-drivingmode-efl");
1940                 if (ret != APP_CONTROL_ERROR_NONE) {
1941                         _DBG("app_control_set_app_id fail : %d", ret);
1942                 }
1943                 app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
1944                 ret = app_control_send_launch_request(app_control, NULL, NULL);
1945                 if (ret != APP_CONTROL_ERROR_NONE) {
1946                         _DBG("app_control_send_launch_request fail : %d", ret);
1947                 }
1948                 app_control_destroy(app_control);
1949         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
1950                 _DBG("CANCEL");
1951         }
1952         if (ad->popup) {
1953                 evas_object_del(ad->popup);
1954                 ad->popup = NULL;
1955         }
1956         /*evas_object_del(ad->win); */
1957         free(btn_str);
1958         elm_exit();
1959 }
1960
1961
1962 static void __mode_syspopup_mobiledata_cb(void *data, Evas_Object *obj, void *event_info)
1963 {
1964         struct appdata *ad = data;
1965
1966         if (!ad)
1967                 return;
1968
1969         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
1970         setting_retm_if(NULL == btn_str, "btn_str is NULL");
1971         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK"))) {
1972                 _DBG("OK OK");
1973
1974                 int ret;
1975                 if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_ON)) {
1976                         /*enable mobile data */
1977                         ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 1);
1978                         if (ret != 0) {
1979                                 _DBG("*** [ERR] Failed to enable mobile data with error code %d***", ret);
1980                         }
1981                         if (ad->popup_chk && elm_check_state_get(ad->popup_chk)) {
1982                                 ret = vconf_set_bool(VCONFKEY_SETAPPL_MOBILE_DATA_ON_REMINDER, 0);
1983                                 if (ret != 0) {
1984                                         _DBG("*** [ERR] Failed to disable popup on reminder %d***", ret);
1985                                 }
1986                         }
1987
1988                 } else {
1989                         /*disable mobile data*/
1990                         ret = vconf_set_bool(VCONFKEY_3G_ENABLE, 0);
1991                         if (ret != 0) {
1992                                 _DBG("*** [ERR] Failed to enable mobile data with error code %d***", ret);
1993                         }
1994                         if (ad->popup_chk && elm_check_state_get(ad->popup_chk)) {
1995                                 ret = vconf_set_bool(VCONFKEY_SETAPPL_MOBILE_DATA_OFF_REMINDER, 0);
1996                                 if (ret != 0) {
1997                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***", ret);
1998                                 }
1999                         }
2000                 }
2001
2002         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
2003                 _DBG("CANCEL");
2004
2005         }
2006         free(btn_str);
2007         elm_exit();
2008 }
2009
2010 static void __mode_syspopup_flightmode_tapi_event_cb(TapiHandle *handle, int result, void *data, void *user_data)
2011 {
2012         _DBG("flight mode result:%d", result);
2013         elm_exit();
2014 }
2015
2016 static void __mode_syspopup_flightmode_cb(void *data, Evas_Object *obj, void *event_info)
2017 {
2018         struct appdata *ad = data;
2019
2020         if (!ad)
2021                 return;
2022
2023         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2024         setting_retm_if(NULL == btn_str, "btn_str is NULL");
2025         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))) {
2026                 _DBG("OK OK");
2027
2028                 int ret;
2029                 TapiHandle *tapi_handle = tel_init(NULL);
2030                 if (!tapi_handle) {
2031                         _DBG("*** [ERR] tel_init failed ***");
2032                         free(btn_str);
2033                         elm_exit();
2034                         return;
2035                 }
2036
2037                 int firewall_state;
2038                 vconf_get_bool(VCONFKEY_SETAPPL_FIREWALL_KEY, &firewall_state);
2039                 if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_ON)) {
2040                         /*enable flight mode on*/
2041                         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_ENTER, __mode_syspopup_flightmode_tapi_event_cb, ad);
2042                         if (ret != TAPI_API_SUCCESS) {
2043                                 _DBG("*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_ENTER) ***");
2044                         }
2045
2046
2047                         if (firewall_state) {
2048                                 mode_remove_noti(ad, "setting-firewall-efl");
2049                         }
2050                 } else {
2051                         /*disable flight mode*/
2052                         ret = tel_set_flight_mode(tapi_handle, TAPI_POWER_FLIGHT_MODE_LEAVE, __mode_syspopup_flightmode_tapi_event_cb, ad);
2053                         if (ret != TAPI_API_SUCCESS) {
2054                                 _DBG("*** [ERR] tel_set_flight_mode(TAPI_POWER_FLIGHT_MODE_LEAVE) ***");
2055                         }
2056                         if (firewall_state) {
2057                                 mode_create_noti(ad, "IDS_ST_BODY_CONFIGURE_FIREWALL_SETTINGS", "setting-firewall-efl", "IDS_ST_BODY_FIREWALL_ENABLED_ABB");
2058                         }
2059                 }
2060
2061                 if ((ret = tel_deinit(tapi_handle)) != TAPI_API_SUCCESS) {
2062                         _DBG("failed to deinitialized tapi handler:%d", ret);
2063                 }
2064
2065         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
2066                 _DBG("CANCEL");
2067
2068         }
2069         /*evas_object_del(ad->win); */
2070         free(btn_str);
2071         elm_exit();
2072 }
2073
2074
2075 static void _text_rotation_changed(void *data, Evas_Object *obj, void *event_info)
2076 {
2077         int rot = -1;
2078         Evas_Object *win = obj;
2079         Evas_Object *layout = data;
2080
2081         rot = elm_win_rotation_get(win);
2082         if (rot == 90 || rot == 270)
2083                 elm_layout_file_set(layout, POPUP_EDJ, "label_layout_landscape");
2084         else
2085                 elm_layout_file_set(layout, POPUP_EDJ, "label_layout");
2086 }
2087
2088 static Eina_Bool _help_handler(void *data)
2089 {
2090         struct appdata *ad = data;
2091         Evas_Coord_Rectangle rect = {0,};
2092         evas_object_geometry_get(ad->help_eo, &rect.x, &rect.y, &rect.w, &rect.h);
2093         if (ad->help_type != HELP_NONE) {
2094                 syspop_help_popup_circle_block_create(ad->win, ad->popup,
2095                                                       &ad->help_circle, &ad->help_popup,
2096                                                       _(MODE_SYSTEM_POPUP_MSG),
2097                                                       rect.x + rect.w / 2, rect.y + rect.h / 2, &rect);
2098         }
2099         ad->help_timer = NULL;
2100         return FALSE;
2101 }
2102
2103 static void _help_rotation_changed(void *data, Evas_Object *obj, void *event_info)
2104 {
2105         struct appdata *ad = (struct appdata *)data;
2106         /*delete old help */
2107         if (ad->help_circle) {
2108                 evas_object_del(ad->help_circle);
2109                 ad->help_circle = NULL;
2110         }
2111         if (ad->help_popup) {
2112                 evas_object_del(ad->help_popup);
2113                 ad->help_popup = NULL;
2114         }
2115         /*update help */
2116         if (ad->help_type != HELP_NONE) {
2117                 if (ad->help_timer) {
2118                         ecore_timer_del(ad->help_timer);
2119                         ad->help_timer = NULL;
2120                 }
2121                 ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
2122         }
2123 }
2124
2125 static void _ultra_popup_cb(void *data, Evas_Object *obj, void *event_info)
2126 {
2127         struct appdata *ad = data;
2128
2129         if (!ad)
2130                 return;
2131
2132         /*delete old help */
2133         if (ad->help_type != HELP_NONE) {
2134                 if (ad->help_circle) {
2135                         evas_object_del(ad->help_circle);
2136                         ad->help_circle = NULL;
2137                 }
2138                 if (ad->help_popup) {
2139                         evas_object_del(ad->help_popup);
2140                         ad->help_popup = NULL;
2141                 }
2142         }
2143
2144         char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj));
2145         setting_retm_if(NULL == btn_str, "btn_str is NULL");
2146         if (!strcmp(btn_str, _("IDS_ST_BUTTON_OK")) || !strcmp(btn_str, _("IDS_ST_BUTTON_ENABLE"))) {
2147                 /*make complete flag */
2148                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2149                 if (ret) _ERR("check export xml");
2150                 int m_key;
2151                 vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2152                 if (m_key == SETTING_PSMODE_NORMAL) {
2153                         /*backup */
2154                         _mode_backup_settings(ad);
2155                 } else if (m_key == SETTING_PSMODE_POWERFUL) {
2156                         /*backup */
2157                         _mode_power_backup_settings(ad);
2158                 }
2159                 _DBG("OK OK");
2160                 release_evas_object(&(ad->popup));
2161                 ad->bg = _create_bg(ad->win, NULL, "group_list");
2162                 /*progress bar */
2163                 ad->enable_popup = __popup_with_progressbar(ad, ad->enable_popup, ad->win, PROGRESSBAR_STYLE,
2164                                                             NULL, _("IDS_ST_TPOP_ENABLING_ULTRA_POWER_SAVING_MODE_ING"), __progress_popup_cb, 3/*0*/, TRUE, TRUE, TRUE);        /* 2 seconds to wait in maximum */
2165
2166                 /*assistive light off, P140422-06240 */
2167                 ret = led_set_brightness_with_noti(0, TRUE);
2168                 if (0 != ret) {
2169                         _DBG(">>>led SET TO ZERO err [%d]", ret);
2170                 } else {
2171                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2172                         if (ret != 0) {
2173                                 _DBG("*** [ERR] Failed to disable popup off reminder %d***", ret);
2174                         }
2175                 }
2176
2177                 /*set ultra == emergency*/
2178                 _mode_apply_settings(ad, emergency_settings);
2179                 /*set gray tone */
2180                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
2181                         _DBG("set upsm, in indicator");
2182                 }
2183                 free(btn_str);
2184         } else if (!strcmp(btn_str, _("IDS_ST_BUTTON_CANCEL_ABB"))) {
2185                 _DBG("CANCEL");
2186                 free(btn_str);
2187                 elm_exit();
2188         } else {
2189                 free(btn_str);
2190         }
2191 }
2192
2193 void _set_battery(Evas_Object *battery, int percent)
2194 {
2195         int stage = ((double) percent) / 100 * 35;
2196         stage = stage == 0 ? 1 : stage;
2197
2198         char stage_txt[16] = { '\0' };
2199         snprintf(stage_txt, sizeof(stage_txt), "%02d", stage);
2200
2201         char percent_txt[16] = { '\0' };
2202         snprintf(percent_txt, sizeof(percent_txt), "%d%%", percent);
2203
2204         /*batt level image set */
2205         elm_object_signal_emit(battery, stage_txt, "batt_image");
2206
2207         /*batt percent text */
2208         elm_object_part_text_set(battery, "text2", percent_txt);
2209 }
2210
2211 void _set_stand_by_time(Evas_Object *stand_by_time, int percent)
2212 {
2213         int stage = ((double) percent) / 100 * 36;      /*battery percent value */
2214         double sbt_val = ((double) percent) * 2.80f;    /*estimated time value */
2215
2216         stage = stage == 0 ? 1 : stage;
2217
2218         char stage_txt[16] = { '\0' };
2219         snprintf(stage_txt, sizeof(stage_txt), "%02d", stage);
2220
2221         char percent_txt[16] = { '\0' };
2222         if (sbt_val > 24) {
2223                 double decimal = sbt_val / 24.0f - (int)sbt_val / 24.0f;
2224                 if (decimal == 0.0) {
2225                         snprintf(percent_txt, sizeof(percent_txt), "%d%s", (int)(sbt_val / 24.0f), _("IDS_ST_MBODY_DAYS_M_WEEKDAY"));
2226                 } else {
2227                         snprintf(percent_txt, sizeof(percent_txt), "%.1f%s", sbt_val / 24.0f, _("IDS_ST_MBODY_DAYS_M_WEEKDAY"));
2228                 }
2229         } else if (sbt_val > 1) {
2230                 snprintf(percent_txt, sizeof(percent_txt), "%dh%dm", (int)sbt_val, (int)(sbt_val / 0.6f));
2231         } else {
2232                 snprintf(percent_txt, sizeof(percent_txt), "%dm", (int)(sbt_val / 0.6f));
2233         }
2234
2235         elm_object_signal_emit(stand_by_time, stage_txt, "standby_lev_img");
2236         elm_object_part_text_set(stand_by_time, "text_r3", percent_txt);
2237 }
2238
2239 Evas_Object *_ultra_popup_with_btn(void *data,
2240                                    Evas_Object *parent,
2241                                    char *title,
2242                                    char *text,
2243                                    _cb_func response_cb,
2244                                    int timeout, int btn_num)
2245 {
2246         _DBG("_ultra_popup_with_btn");
2247         struct appdata *ad = data;
2248         if (!ad)
2249                 return NULL;
2250
2251         Evas_Object *popup = ad->popup;
2252
2253         if (text) {
2254                 Evas_Object *layout = elm_layout_add(popup);
2255                 int rotation = elm_win_rotation_get(parent);
2256                 if (rotation == 90 || rotation == 270)
2257                         elm_layout_file_set(layout, UPMS_EDJ, "label_layout_landscape");
2258                 else
2259                         elm_layout_file_set(layout, UPMS_EDJ, "label_layout");
2260                 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2261
2262                 Evas_Object *inner_layout = elm_layout_add(popup);
2263                 elm_layout_file_set(inner_layout, UPMS_EDJ, "inner_layout");
2264                 evas_object_size_hint_weight_set(inner_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2265
2266                 Evas_Object *scroller = elm_scroller_add(layout);
2267                 elm_object_style_set(scroller, "list_effect");
2268                 elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
2269                 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
2270                 evas_object_show(scroller);
2271                 elm_object_content_set(scroller, inner_layout);
2272
2273 #if 0
2274                 /*1) battery image, text */
2275                 /*text */
2276                 elm_object_part_text_set(inner_layout, "text1" , _("IDS_ST_BODY_BATTERY_PERCENTAGE_ABB"));
2277                 /*image */
2278                 Evas_Object *img = NULL;
2279                 img = elm_image_add(inner_layout);
2280                 elm_image_file_set(img, "/usr/apps/org.tizen.setting/res/icons/savingpower/popup/battery/A01-11_popup_battery_bg.png", NULL);
2281                 elm_object_part_content_set(inner_layout, "def_image", img);
2282                 /*batt level image, text */
2283                 int percent;
2284                 if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &percent))
2285                         _DBG("Cannot get the vconf value for VCONFKEY_SYSMAN_BATTERY_CAPACITY");
2286                 _set_battery(inner_layout, percent);
2287 #endif
2288                 /*2) standby time image, text */
2289                 /*text r1, r2 -> text r1 */
2290                 elm_object_part_text_set(inner_layout, "text_r1" , _("IDS_ST_BODY_ESTIMATED_MAX_STANDBY_TIME_ABB"));
2291                 /*elm_object_part_text_set(inner_layout, "text_r2" ,"standby time"); */
2292                 /*image */
2293                 Evas_Object *standby_img = NULL;
2294                 standby_img = elm_image_add(inner_layout);
2295                 elm_image_file_set(standby_img, "/usr/apps/org.tizen.setting/res/icons/savingpower/popup/standby_time/A01-11_popup_time_bg.png", NULL);
2296                 elm_object_part_content_set(inner_layout, "standby_image", standby_img);
2297                 /*standby time image, text */
2298                 /*_set_stand_by_time(inner_layout, percent);*/
2299
2300                 /* label for long typing popup */
2301                 Evas_Object *label = elm_label_add(popup);
2302                 elm_object_style_set(label, "popup/default");
2303                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
2304
2305                 char ultra_desc[1024] = {0, };
2306                 snprintf(ultra_desc, sizeof(ultra_desc), "%s", text);
2307                 elm_object_text_set(label, ultra_desc);
2308                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
2309                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
2310                 evas_object_show(label);
2311
2312                 elm_object_part_content_set(inner_layout, "guide_text", label);
2313
2314                 elm_object_part_content_set(layout, "elm.swallow.content", scroller);
2315
2316                 elm_object_content_set(popup, layout);
2317                 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _text_rotation_changed, layout);
2318         }
2319         if (title) {
2320                 elm_object_part_text_set(popup, "title,text", _(title));
2321         }
2322         if (timeout > 0) {
2323                 elm_popup_timeout_set(popup, timeout);
2324         }
2325         if (btn_num > 0) { /*the case popup has button or buttons */
2326                 Evas_Object *btn1 = elm_button_add(popup);
2327                 elm_object_style_set(btn1, "popup");
2328                 elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2329                 elm_object_part_content_set(popup, "button1", btn1);    /*right */
2330                 evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
2331                 Evas_Object *btn2 = elm_button_add(popup);
2332                 elm_object_style_set(btn2, "popup");
2333                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
2334                 elm_object_part_content_set(popup, "button2", btn2);    /*left */
2335                 evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);
2336                 evas_object_show(popup);
2337         }
2338         evas_object_show(popup);
2339         return popup;
2340 }
2341
2342
2343 static Evas_Object *mode_syspopup_create_popup_with_label_check(void *data,
2344                                                                 Evas_Object *parent,
2345                                                                 char *title,
2346                                                                 char *content,
2347                                                                 char *check_str,
2348                                                                 Evas_Object **check,
2349                                                                 Evas_Smart_Cb response_cb,
2350                                                                 int timeout,
2351                                                                 const char *btn_left, const char *btn_right)
2352 {
2353         _DBG("ENTER mode_syspopup_create_popup_with_label_check");
2354         struct appdata *ad = data;
2355         if (!ad) return NULL;
2356         Evas_Object *popup = elm_popup_add(parent);
2357 #if 0
2358         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
2359         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2360         if (title) {
2361                 elm_object_part_text_set(popup, "title,text", _(title));
2362         }
2363         if (btn_left) {
2364                 Evas_Object *btn1 = elm_button_add(popup);
2365                 elm_object_style_set(btn1, "popup");
2366                 elm_object_text_set(btn1, _(btn_left));
2367                 elm_object_part_content_set(popup, "button1", btn1);
2368                 if (response_cb) {
2369                         evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
2370                 }
2371         }
2372         if (btn_right) {
2373                 Evas_Object *btn2 = elm_button_add(popup);
2374                 elm_object_style_set(btn2, "popup");
2375                 elm_object_text_set(btn2, _(btn_right));
2376                 elm_object_part_content_set(popup, "button2", btn2);
2377                 if (response_cb) {
2378                         evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);
2379                 }
2380         }
2381         evas_object_show(popup);
2382         return popup;
2383 #endif
2384         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
2385         /*setting_add_hardkey_features(popup, data); */
2386         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2387
2388         if (title) {
2389                 elm_object_part_text_set(popup, "title,text", _(title));
2390         }
2391
2392         if (timeout > 0) {
2393                 elm_popup_timeout_set(popup, timeout);
2394         }
2395
2396         Evas_Object *label = NULL;
2397         label = elm_label_add(popup);
2398         elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
2399 #if 1
2400         char arr[2048] = {'\0',};
2401         snprintf(arr, 2048, "<color=#000000>%s</color>", _(content));
2402         elm_object_text_set(label, arr);
2403 #else
2404         evas_object_color_set(label, 0, 0, 0, 255);
2405         evas_object_show(label);
2406 #endif
2407         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
2408         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
2409
2410         Evas_Object *layout = elm_layout_add(popup);
2411         elm_layout_file_set(layout, MODE_POPUP_EDJ, "popup_checkview_setting");
2412         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2413
2414         if (check) {
2415                 *check = elm_check_add(popup);
2416 #if 1
2417                 elm_object_style_set(*check, "multiline");
2418                 if (check_str) {
2419                         elm_object_text_set(*check, _(check_str));
2420                 }
2421 #else
2422                 elm_object_style_set(*check, "multiline");
2423                 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  ");
2424 #endif
2425                 evas_object_size_hint_align_set(*check, EVAS_HINT_FILL, EVAS_HINT_FILL);
2426                 evas_object_size_hint_weight_set(*check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2427                 evas_object_show(*check);
2428
2429                 Evas_Object *box = elm_box_add(popup);
2430                 elm_box_horizontal_set(box, EINA_TRUE);
2431                 elm_box_pack_end(box, *check);
2432
2433                 /* add text */
2434                 Evas_Object *lbl = elm_label_add(popup);
2435                 elm_object_text_set(lbl, _(check_str));
2436                 evas_object_show(lbl);
2437                 elm_box_pack_end(box, lbl);
2438
2439                 elm_box_padding_set(box, 30, 0);
2440                 evas_object_show(box);
2441
2442                 elm_object_part_content_set(layout, "elm.swallow.end", box);
2443         }
2444
2445         elm_object_part_content_set(layout, "elm.swallow.content", label);
2446
2447
2448         elm_object_content_set(popup, layout);
2449         evas_object_data_set(popup, "check_str", check_str);
2450         Evas_Object *btn1;
2451         Evas_Object *btn2;
2452
2453         if (btn_left) {
2454                 btn1 = elm_button_add(popup);
2455                 elm_object_style_set(btn1, "popup");
2456                 elm_object_text_set(btn1, _(btn_left));
2457                 elm_object_part_content_set(popup, "button1", btn1);
2458                 if (response_cb) {
2459                         evas_object_smart_callback_add(btn1, "clicked", response_cb, ad);
2460                 }
2461         }
2462         if (btn_right) {
2463                 btn2 = elm_button_add(popup);
2464                 elm_object_style_set(btn2, "popup");
2465                 elm_object_text_set(btn2, _(btn_right));
2466                 elm_object_part_content_set(popup, "button2", btn2);
2467                 if (response_cb) {
2468                         evas_object_smart_callback_add(btn2, "clicked", response_cb, ad);
2469                 }
2470         }
2471         evas_object_show(popup);
2472         return popup;
2473 }
2474
2475 void fini_tts(struct appdata *ad)
2476 {
2477         _INFO("fini tts");
2478         if (ad->tts) {
2479                 int result = 0;
2480                 tts_state_e current_state;
2481                 tts_get_state(ad->tts, &current_state);
2482
2483                 if (TTS_STATE_READY == current_state) {
2484                         result = tts_unprepare(ad->tts);
2485                         if (TTS_ERROR_NONE != result) {
2486                                 _ERR("Fail to prepare function : ret(%d)\n", result);
2487                         }
2488                 }
2489
2490                 result = tts_destroy(ad->tts);
2491                 if (TTS_ERROR_NONE != result) {
2492                         _ERR("Fail to destroy handle : result(%d)", result);
2493                 }
2494                 ad->tts = NULL;
2495         }
2496 }
2497
2498 void __tts_completed_cb(tts_h tts, int utt_id, void *user_data)
2499 {
2500         fini_tts(user_data);
2501 }
2502
2503 void init_tts(struct appdata *ad)
2504 {
2505         _INFO("init tts");
2506         int result = tts_create(&(ad->tts));
2507         if (TTS_ERROR_NONE != result) {
2508                 _ERR("Fail to get handle : result(%d)", result);
2509                 ad->tts = NULL;
2510         } else {
2511                 result = tts_set_utterance_completed_cb(ad->tts, __tts_completed_cb, ad);
2512                 if (TTS_ERROR_NONE != result) {
2513                         _ERR("Fail to set callback : ret(%d)\n", result);
2514                 }
2515                 result = tts_set_mode(ad->tts, TTS_MODE_DEFAULT);
2516                 if (TTS_ERROR_NONE != result) {
2517                         _ERR("Fail to set tts mode : ret(%d)\n", result);
2518                 }
2519                 result = tts_prepare(ad->tts);/*async API,need to wait until TTS_STATE_READY */
2520                 if (TTS_ERROR_NONE != result) {
2521                         _ERR("Fail to prepare function : ret(%d)\n", result);
2522                 }
2523         }
2524 }
2525
2526 void play_text(struct appdata *ad, const char *text)
2527 {
2528         /*paly prompts */
2529         _INFO("play text");
2530         if (!ad || !ad->tts) {
2531                 _ERR("ad or tts == NULL");
2532                 return;
2533         }
2534         int ret = 0;
2535         setting_retm_if(NULL == ad->tts, "ad->tts is NULL");
2536         ret = tts_stop(ad->tts);
2537         if (TTS_ERROR_NONE != ret) {
2538                 _ERR("failed to call tts_stop: %d", ret);
2539         }
2540         int utt_id;
2541         setting_retm_if(NULL == text, "text is NULL");
2542         ret = tts_add_text(ad->tts, text, NULL,
2543                            TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &utt_id);
2544         if (TTS_ERROR_NONE != ret) {
2545                 _ERR("failed to call tts_add_text: %d", ret);
2546         }
2547
2548         ret = tts_play(ad->tts);
2549         if (TTS_ERROR_NONE != ret) {
2550                 _ERR("failed to call tts_play: %d", ret);
2551         }
2552 }
2553
2554
2555 static void __mode_syspopup_add(struct appdata *ad)
2556 {
2557         if (!ad)
2558                 return;
2559
2560         Evas_Object *popup = NULL;
2561         Evas_Object *btn1;
2562         Evas_Object *btn2 = NULL;
2563
2564         /*evas_object_show(ad->win); */
2565         if (ad->win) {
2566                 popup = elm_popup_add(ad->win);
2567                 ad->popup = popup;
2568
2569                 if (popup == NULL) {
2570                         _ERR("elm_popup_add failed..!!");
2571                         return;
2572                 }
2573         }
2574         int m_key;
2575         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2576         if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY)) {
2577                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_EMERGENCY);
2578                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Enable_emergency_Mode));
2579                 Evas_Object *layout = elm_layout_add(popup);
2580                 int rotation = elm_win_rotation_get(ad->win);
2581                 if (rotation == 90 || rotation == 270)
2582                         elm_layout_file_set(layout, POPUP_EDJ, "label_layout_landscape");
2583                 else
2584                         elm_layout_file_set(layout, POPUP_EDJ, "label_layout");
2585                 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2586                 /* label for long typing popup */
2587                 Evas_Object *label = elm_label_add(popup);
2588                 elm_object_style_set(label, "popup/default");
2589                 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
2590                 elm_object_text_set(label, _(KeyStr_Survivor_Mode_POP_DESC));
2591                 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
2592                 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
2593                 evas_object_show(label);
2594
2595                 Evas_Object *scroller = elm_scroller_add(layout);
2596                 elm_object_style_set(scroller, "list_effect");
2597                 elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_TRUE);
2598                 elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
2599                 evas_object_show(scroller);
2600                 elm_object_content_set(scroller, label);
2601
2602                 elm_object_part_content_set(layout, "elm.swallow.content", scroller);
2603
2604                 elm_object_content_set(popup, layout);
2605                 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _text_rotation_changed, layout);
2606
2607                 btn1 = elm_button_add(popup);
2608                 elm_object_style_set(btn1, "popup");
2609                 elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2610                 elm_object_part_content_set(popup, "button1", btn1);    /*right */
2611                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_emergency_cb, ad);
2612                 btn2 = elm_button_add(popup);
2613                 elm_object_style_set(btn2, "popup");
2614                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
2615                 elm_object_part_content_set(popup, "button2", btn2);    /*left */
2616                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_emergency_cb, ad);
2617                 evas_object_show(popup);
2618
2619                 /*help */
2620                 if (ad->help_type != HELP_NONE) {
2621                         if (ad->help_timer) {
2622                                 ecore_timer_del(ad->help_timer);
2623                                 ad->help_timer = NULL;
2624                         }
2625                         ad->help_eo = btn2;
2626                         ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
2627                 }
2628         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_ULTRA)) {
2629                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_ULTRA_POWER_SAVING);
2630                 char ultra_desc[1024] = {0, };
2631                 snprintf(ultra_desc, sizeof(ultra_desc), "- %s<br>- %s<br>- %s<br>- %s",
2632                          _(KeyStr_Survivor_Mode_POP_DESC1),
2633                          _(KeyStr_Survivor_Mode_POP_DESC2),
2634                          _(KeyStr_Survivor_Mode_POP_DESC3),
2635                          _(KeyStr_Survivor_Mode_POP_DESC4));
2636                 _ultra_popup_with_btn(ad, ad->win, "IDS_ST_HEADER_ULTRA_POWER_SAVING_MODE",
2637                                       ultra_desc,
2638                                       _ultra_popup_cb, 0,
2639                                       2);
2640         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SETTING)) {
2641                 /*upsm in setting */
2642                 /*make complete flag */
2643                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2644                 if (ret) _ERR("check export xml");
2645                 /*ultra power saving mode !! */
2646                 if (popup) {
2647                         evas_object_del(popup);
2648                         popup = NULL;
2649                 }
2650
2651                 if (m_key == SETTING_PSMODE_NORMAL) {
2652                         /*backup */
2653                         _mode_backup_settings(ad);
2654                 } else if (m_key == SETTING_PSMODE_POWERFUL) {
2655                         /*backup */
2656                         _mode_power_backup_settings(ad);
2657                 }
2658 #if LCD_FREQ_CTRL
2659                 ad->is_lcd_ctrl = EINA_TRUE;
2660                 _LCD_freq_ctrl(ad);
2661 #endif
2662                 /*assistive light off, P140422-06240 */
2663                 ret = led_set_brightness_with_noti(0, TRUE);
2664                 if (0 != ret) {
2665                         _DBG(">>>led SET TO ZERO err [%d]", ret);
2666                 } else {
2667                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2668                         if (ret != 0) {
2669                                 _DBG("*** [ERR] Failed to disable popup off reminder %d***", ret);
2670                         }
2671                 }
2672                 _mode_apply_settings(ad, emergency_settings);
2673 #if 1 /*---------following two invoking will cause KERNAL PANNIC */
2674                 {
2675                         _DBG("set ultra power saving mode in setting");
2676                 }
2677 #endif
2678         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_EMERGENCY_SAFETY)) {
2679                 vconf_set_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, EMERGENCY_UI_MODE_EMERGENCY);
2680
2681                 /*make complete flag */
2682                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2683                 if (ret) _ERR("check export xml");
2684                 if (popup) {
2685                         evas_object_del(popup);
2686                         popup = NULL;
2687                 }
2688
2689                 if (m_key == SETTING_PSMODE_NORMAL) {
2690                         /*backup */
2691                         _mode_backup_settings(ad);
2692                 } else if (m_key == SETTING_PSMODE_POWERFUL) {
2693                         /*backup */
2694                         _mode_power_backup_settings(ad);
2695                 }
2696
2697                 /*assistive light off, P140422-06240 */
2698                 ret = led_set_brightness_with_noti(0, TRUE);
2699                 if (0 != ret) {
2700                         _DBG(">>>led SET TO ZERO err [%d]", ret);
2701                 } else {
2702                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2703                         if (ret != 0) {
2704                                 _DBG("*** [ERR] Failed to disable popup off reminder %d***", ret);
2705                         }
2706                 }
2707
2708                 _mode_apply_settings(ad, emergency_settings);
2709                 /*set gray tone */
2710                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_EMERGENCY) == 0) {
2711                         _DBG("set on SETTING_PSMODE_EMERGENCY");
2712                 }
2713                 elm_exit();
2714         }
2715         if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL)) {
2716                 elm_object_style_set(popup, "transparent");
2717                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2718
2719                 int ultra_emergency;
2720                 vconf_get_int(VCONFKEY_SETAPPL_EMERGENCY_UI_MODE, &ultra_emergency);
2721
2722                 if (ultra_emergency == 1) {
2723                         elm_object_text_set(popup, _(KeyStr_Emergency_off_Mode_POP_DESC));
2724                         elm_object_part_text_set(popup, "title,text", _("IDS_ST_HEADER_DISABLE_EMERGENCY_MODE_ABB"));
2725                 } else if (ultra_emergency == 2) {
2726                         elm_object_text_set(popup, _(KeyStr_Ultra_off_Mode_POP_DESC));
2727                         elm_object_part_text_set(popup, "title,text", _("IDS_ST_HEADER_ULTRA_POWER_SAVING_MODE"));
2728                 }
2729
2730                 if (is_recovery) {
2731                         release_evas_object(&(ad->popup));
2732                         ad->bg = _create_bg(ad->win, NULL, "group_list");
2733
2734                         /*progress bar */
2735                         ad->disable_popup = __popup_with_progressbar(ad, ad->disable_popup, ad->win, PROGRESSBAR_STYLE,
2736                                                                      NULL, _(KeyStr_Loading), __progress_popup_cb, 3/*0*/, TRUE, TRUE, FALSE);  /* 2 seconds to wait in maximum */
2737
2738                         /*set normal sub*/
2739                         /*make complete flag */
2740                         int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2741                         if (ret) _ERR("check export xml");
2742                         /*torch light off with diable emergency/ups mode, P140507-03841 */
2743                         int t_ret = led_set_brightness_with_noti(0, TRUE);
2744                         if (0 != t_ret) {
2745                                 _DBG(">>>led SET TO ZERO err [%d]", t_ret);
2746                         } else {
2747                                 vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2748                                 if (t_ret != 0) {
2749                                         _DBG("*** [ERR] Failed to disable popup off reminder %d***", t_ret);
2750                                 }
2751                         }
2752
2753                         int b_network_lcd_off;
2754                         vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
2755                         if (b_network_lcd_off) {
2756                                 vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
2757                         }
2758                         _mode_apply_settings(ad, normal_settings);
2759
2760                         /* set to default */
2761                         int opposite;
2762                         ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2763                         if (ret) _DBG("vconf_get_bool failed");
2764                         if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
2765                                 _DBG("set on SETTING_PSMODE_NORMAL");
2766                         }
2767                 } else {
2768                         btn1 = elm_button_add(popup);
2769                         elm_object_style_set(btn1, "popup");
2770                         elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2771                         elm_object_part_content_set(popup, "button1", btn1);    /*right */
2772                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_normal_cb, ad);
2773                         btn2 = elm_button_add(popup);
2774                         elm_object_style_set(btn2, "popup");
2775                         elm_object_text_set(btn2, _("IDS_ST_BUTTON_DISABLE"));
2776                         elm_object_part_content_set(popup, "button2", btn2);    /*left */
2777                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_normal_cb, ad);
2778                         evas_object_show(popup);
2779
2780                         if (vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_changed, ad) != 0)
2781                                 _DBG("vconf key notify failed");
2782                 }
2783         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_REMOVE_FLAG)) {
2784                 int ret = remove_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2785                 if (ret) _ERR("check remove xml");
2786                 if (popup) {
2787                         evas_object_del(popup);
2788                         popup = NULL;
2789                 }
2790                 elm_exit();
2791         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL)) {
2792                 int flight;
2793                 int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight);
2794                 if (ret) _DBG("vconf_get_bool failed");
2795
2796                 if (flight == EINA_TRUE) {
2797                         /*cannot set with flight mode on */
2798                         elm_object_style_set(popup, "transparent");
2799                         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2800                         elm_object_text_set(popup, _("IDS_IM_POP_THIS_FEATURE_IS_NOT_AVAILABLE_WHILE_FLIGHT_MODE_IS_ON"));
2801
2802                         elm_popup_timeout_set(popup, 2.0);
2803                         evas_object_smart_callback_add(popup, "block,clicked", timeout_response_cb, ad);
2804                         evas_object_smart_callback_add(popup, "timeout", timeout_response_cb, ad);
2805
2806                         evas_object_show(popup);
2807                 } else {
2808                         if (popup) {
2809                                 evas_object_del(popup);
2810                                 popup = NULL;
2811                         }
2812                         int m_key, first;
2813                         vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &m_key);
2814                         if (m_key == SETTING_PSMODE_NORMAL) {
2815                                 /*backup */
2816                                 _mode_backup_settings(ad);
2817                         }
2818
2819                         /*set normal sub*/
2820                         int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
2821
2822                         if (first) {
2823                                 _mode_apply_settings(ad, powerful_settings_def);
2824                                 preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
2825                         } else {
2826                                 _mode_apply_settings(ad, powerful_settings);
2827                                 _DBG("right to set powerful");
2828                         }
2829                         /* set to default */
2830                         int opposite;
2831                         ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2832                         if (ret) _DBG("vconf_get_bool failed");
2833                         /*emergency mode -> normal */
2834                         if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
2835                                 _DBG("set on SETTING_PSMODE_POWERFUL");
2836                         }
2837
2838                         evas_object_smart_callback_add(elm_object_top_widget_get(popup), "rotation,changed", _help_rotation_changed, ad);
2839
2840                         /*help */
2841                         if (ad->help_type != HELP_NONE) {
2842                                 if (ad->help_timer) {
2843                                         ecore_timer_del(ad->help_timer);
2844                                         ad->help_timer = NULL;
2845                                 }
2846                                 ad->help_eo = btn2;
2847                                 ad->help_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_help_handler, ad);
2848                         }
2849
2850                         if (vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_changed, ad) != 0)
2851                                 _DBG("vconf key notify failed");
2852                         elm_exit();
2853                 }
2854         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL_SETTING)) {
2855                 if (popup) {
2856                         evas_object_del(popup);
2857                         popup = NULL;
2858                 }
2859
2860                 if (m_key == SETTING_PSMODE_NORMAL) {
2861                         /*backup */
2862                         _mode_backup_settings(ad);
2863                 }
2864
2865                 int first;
2866                 /*set normal sub*/
2867                 int ret = preference_get_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, &first);
2868                 if (first) {
2869                         _mode_apply_settings(ad, powerful_settings_def);
2870                         preference_set_int(PREFKEY_SAVINGPOWER_BACKUP_FIRST_PWR, 0);
2871                 } else {
2872                         _mode_apply_settings(ad, powerful_settings);
2873                         _DBG("right to set powerful");
2874                 }
2875
2876                 /* set to default */
2877                 int opposite;
2878                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2879                 if (ret) _DBG("vconf_get_bool failed");
2880                 /*emergency mode -> normal */
2881                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_POWERFUL) == 0) {
2882                         _DBG("set on SETTING_PSMODE_POWERFUL");
2883                 }
2884                 elm_exit();
2885         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NORMAL_SETTING)) {
2886                 /*make complete flag */
2887                 int ret = export_xml(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml");
2888                 if (ret) _ERR("check export xml");
2889
2890                 if (m_key == SETTING_PSMODE_POWERFUL) {
2891                         /*backup */
2892                         _mode_power_backup_settings(ad);
2893                 }
2894                 /*torch light off with diable emergency/ups mode, P140507-03841 */
2895                 int t_ret = led_set_brightness_with_noti(0, TRUE);
2896                 if (0 != t_ret) {
2897                         _DBG(">>>led SET TO ZERO err [%d]", t_ret);
2898                 } else {
2899                         vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TORCH_LIGHT, EINA_FALSE);
2900                         if (t_ret != 0) {
2901                                 _DBG("*** [ERR] Failed to disable popup off reminder %d***", t_ret);
2902                         }
2903                 }
2904
2905                 int b_network_lcd_off;
2906                 vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, &b_network_lcd_off);
2907                 if (b_network_lcd_off) {
2908                         vconf_set_bool(VCONFKEY_SETAPPL_NETWORK_PERMIT_WITH_LCD_OFF_LIMIT, EINA_FALSE);
2909                 }
2910
2911                 /*set normal sub*/
2912                 _mode_apply_settings(ad, normal_settings);
2913                 /* set to default */
2914                 int opposite;
2915                 ret = 0;
2916                 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &opposite);
2917                 if (ret) _DBG("vconf_get_bool failed");
2918                 /*emergency mode -> normal */
2919                 if (vconf_set_int(VCONFKEY_SETAPPL_PSMODE, SETTING_PSMODE_NORMAL) == 0) {
2920                         _DBG("set on SETTING_PSMODE_NORMAL");
2921                 }
2922                 elm_exit();
2923         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_BACKUP_SETTING)) {
2924                 if (popup) {
2925                         evas_object_del(popup);
2926                         popup = NULL;
2927                 }
2928                 /*backup*/
2929                 _mode_backup_settings(ad);
2930                 elm_exit();
2931         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_ON)) {
2932
2933                 setting_set_i18n(MODE_SYSPOPUP_PACKAGE, MODE_SYSPOPUP_LOCALEDIR);
2934                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2935
2936                 _DBG("--------------------------------------------------------------");
2937                 elm_object_text_set(popup, _(KeyStr_Fligtmode_Popup_On_Text));
2938                 _DBG("--------------------------------------------------------------");
2939
2940                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Fligtmode_Popup_Title));
2941                 btn1 = elm_button_add(popup);
2942                 elm_object_style_set(btn1, "popup");
2943                 elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2944                 elm_object_part_content_set(popup, "button1", btn1);    /*right */
2945                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_flightmode_cb, ad);
2946                 btn2 = elm_button_add(popup);
2947                 elm_object_style_set(btn2, "popup");
2948                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_ENABLE"));
2949                 elm_object_part_content_set(popup, "button2", btn2);    /*left */
2950                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_flightmode_cb, ad);
2951                 evas_object_show(popup);
2952
2953         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_FLIGHTMODE_OFF)) {
2954
2955                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2956
2957                 elm_object_text_set(popup, _(KeyStr_Fligtmode_Popup_Off_Text));
2958
2959                 elm_object_part_text_set(popup, "title,text", _(KeyStr_Fligtmode_Popup_Title));
2960                 btn1 = elm_button_add(popup);
2961                 elm_object_style_set(btn1, "popup");
2962                 elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2963                 elm_object_part_content_set(popup, "button1", btn1);    /*right */
2964                 evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_flightmode_cb, ad);
2965                 btn2 = elm_button_add(popup);
2966                 elm_object_style_set(btn2, "popup");
2967                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_OK"));
2968                 elm_object_part_content_set(popup, "button2", btn2);    /*left */
2969                 evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_flightmode_cb, ad);
2970                 evas_object_show(popup);
2971
2972         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_NETRESTRICTIONMODE_CHANGE)) {
2973
2974                 /* Network restriction mode change */
2975                 int vconf_value;
2976                 int ret = vconf_get_bool(VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE, &vconf_value);
2977                 if (ret != 0) {
2978                         _DBG("network_restrict_mode vconf get failed");
2979                 } else {
2980                         _DBG("network_restrict_mode vconf get %d", vconf_value);
2981                 }
2982
2983                 elm_object_style_set(popup, "transparent");
2984                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2985
2986                 if (vconf_value) {
2987                         /* on -> off */
2988                         elm_object_text_set(popup, _("IDS_QP_POP_NETWORK_RESTRICTION_MODE_WILL_BE_DISABLED_JPN"));
2989                 } else {
2990                         /* off -> on */
2991                         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"));
2992                 }
2993                 elm_object_part_text_set(popup, "title,text", _("IDS_ST_HEADER_NETWORK_RESTRICTION_MODE_ABB_JPN"));
2994                 btn1 = elm_button_add(popup);
2995                 elm_object_style_set(btn1, "popup");
2996                 elm_object_text_set(btn1, _("IDS_ST_BUTTON_CANCEL_ABB"));
2997                 elm_object_part_content_set(popup, "button1", btn1);    /*right */
2998
2999                 btn2 = elm_button_add(popup);
3000                 elm_object_style_set(btn2, "popup");
3001                 elm_object_text_set(btn2, _("IDS_ST_BUTTON_OK"));
3002                 elm_object_part_content_set(popup, "button2", btn2);    /*left */
3003
3004                 if (vconf_value) {
3005                         /* on -> off */
3006                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_netrestrictionmode_change_off_cb, popup);
3007                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_netrestrictionmode_change_off_cb, popup);
3008                 } else {
3009                         /* off -> on */
3010                         evas_object_smart_callback_add(btn1, "clicked", __mode_syspopup_netrestrictionmode_change_on_cb, popup);
3011                         evas_object_smart_callback_add(btn2, "clicked", __mode_syspopup_netrestrictionmode_change_on_cb, popup);
3012                 }
3013
3014                 evas_object_show(popup);
3015         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_ON)) {
3016                 if (ad->popup) {
3017                         evas_object_del(ad->popup);
3018                         ad->popup = NULL;
3019                 }
3020                 ad->popup = mode_syspopup_create_popup_with_label_check(ad, ad->win, NULL,
3021                                                                         _(Data_packet_Popup_desc),
3022                                                                         KeyStr_DO_NOT_ASK_AGAIN,
3023                                                                         &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
3024                                                                         "IDS_ST_BUTTON_CANCEL_ABB", "IDS_ST_BUTTON_OK");
3025
3026
3027         } else if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_MOBILEDATA_OFF)) {
3028                 if (ad->popup) {
3029                         evas_object_del(ad->popup);
3030                         ad->popup = NULL;
3031                 }
3032                 ad->popup = mode_syspopup_create_popup_with_label_check(ad, ad->win, NULL,
3033                                                                         KeyStr_MOBILEDATA_Popup_Off_Text,
3034                                                                         KeyStr_DO_NOT_ASK_AGAIN,
3035                                                                         &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
3036                                                                         "IDS_ST_BUTTON_CANCEL_ABB", "IDS_ST_BUTTON_OK");
3037         }
3038 }
3039
3040 static int __mode_syspopup_reset(bundle *b, void *data)
3041 {
3042         struct appdata *ad = data;
3043         const char *val;
3044         int ret = 0;
3045
3046         if (is_recovery) {
3047                 _DBG("recovery");
3048                 /*recovery normal */
3049                 ad->type = strdup(MODE_SYSTEM_POPUP_NORMAL);
3050                 evas_object_show(ad->win);
3051                 __mode_syspopup_add(ad);
3052
3053                 return 0;
3054         }
3055
3056         ad->b = bundle_dup(b);
3057
3058         /* When syspopup is already loaded, remove the popup and load new popup */
3059         if (syspopup_has_popup(b)) {
3060                 syspopup_reset(b);
3061         } else {
3062                 ret = syspopup_create(b, &handler, ad->win, ad);
3063                 _DBG("ret = %d", ret);
3064
3065                 char *help = NULL;
3066                 help = bundle_get_val(b, "help_type");
3067                 if (help != NULL)
3068                         ad->help_type = HELP_PS_MODE;
3069
3070                 if (ret == 0) {
3071                         val = bundle_get_val(b, "_MODE_SYSTEM_POPUP_TYPE_");
3072                         if (val) {
3073                                 ad->type = strdup(val);
3074                                 _INFO("type :%s", ad->type);
3075
3076                                 if (ad->type && !strcmp(ad->type, MODE_SYSTEM_POPUP_POWERFUL)) {
3077                                         int flight;
3078                                         int ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight);
3079                                         if (ret) _DBG("vconf_get_bool failed");
3080
3081                                         if (flight) {
3082                                                 evas_object_show(ad->win);
3083                                         }
3084                                 } else {
3085                                         evas_object_show(ad->win);
3086                                 }
3087                         }
3088                 } else {
3089                         _ERR("Unknown popup type");
3090                         elm_exit();
3091                 }
3092                 __mode_syspopup_add(ad);
3093
3094                 return 0;
3095         }
3096
3097         return 0;
3098 }
3099
3100 static int mode_reboot_create_noti_only(const char *key_str, const char *package, const char *title)
3101 {
3102         notification_h noti = NULL;
3103         notification_error_e ret = NOTIFICATION_ERROR_NONE;
3104
3105         /* not need to remove noti */
3106         noti = notification_new(NOTIFICATION_TYPE_ONGOING,
3107                                 NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
3108         if (!noti) {
3109                 _DBG("Fail to notification_new [%d]", ret);
3110                 return SETTING_RETURN_FAIL;
3111         }
3112
3113         ret = notification_set_layout(noti, NOTIFICATION_LY_ONGOING_EVENT);
3114         if (ret != NOTIFICATION_ERROR_NONE) {
3115                 _DBG("Fail to notification_set_layout [%d]", ret);
3116                 goto FAIL;
3117         }
3118
3119         if (!strcmp(PKG_BLOCKING_MODE, package)) {
3120                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_BlockingMode);
3121                 if (ret != NOTIFICATION_ERROR_NONE) {
3122                         _DBG("Fail to notification_set_image [%d]", ret);
3123                         goto FAIL;
3124                 }
3125                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_BlockingMode);
3126                 if (ret != NOTIFICATION_ERROR_NONE) {
3127                         _DBG("Fail to notification_set_image [%d]", ret);
3128                         goto FAIL;
3129                 }
3130         } else if (!strcmp(PKG_FIREWALL, package)) {
3131                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, IMG_Firewall);
3132                 if (ret != NOTIFICATION_ERROR_NONE) {
3133                         _DBG("Fail to notification_set_image [%d]", ret);
3134                         goto FAIL;
3135                 }
3136                 ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, INDI_IMG_Firewall);
3137                 if (ret != NOTIFICATION_ERROR_NONE) {
3138                         _DBG("Fail to notification_set_image [%d]", ret);
3139                         goto FAIL;
3140                 }
3141         }
3142
3143         ret = notification_set_text(noti,
3144                                     NOTIFICATION_TEXT_TYPE_TITLE,
3145                                     title,
3146                                     title, NOTIFICATION_VARIABLE_TYPE_NONE);
3147         if (ret != NOTIFICATION_ERROR_NONE) {
3148                 _DBG("Fail to notification_set_text [%d]", ret);
3149                 goto FAIL;
3150         }
3151
3152         ret = notification_set_text(noti,
3153                                     NOTIFICATION_TEXT_TYPE_CONTENT,
3154                                     key_str,
3155                                     key_str, NOTIFICATION_VARIABLE_TYPE_NONE);
3156         if (ret != NOTIFICATION_ERROR_NONE) {
3157                 _DBG("Fail to notification_set_text [%d]", ret);
3158                 goto FAIL;
3159         }
3160
3161         ret = notification_set_text_domain(noti, SETTING_PACKAGE, SETTING_LOCALEDIR);
3162         if (ret != NOTIFICATION_ERROR_NONE) {
3163                 _DBG("Fail to notification_set_text [%d]", ret);
3164                 goto FAIL;
3165         }
3166
3167         ret = notification_set_pkgname(noti, package);  /*pkg ex : "setting-blockingmode-efl" */
3168         if (ret != NOTIFICATION_ERROR_NONE) {
3169                 _DBG("Fail to notification_set_pkgname [%d]", ret);
3170                 goto FAIL;
3171         }
3172
3173         ret = notification_set_application(noti, package);      /*pkg ex : "setting-blockingmode-efl" */
3174         if (ret != NOTIFICATION_ERROR_NONE) {
3175                 _DBG("Fail to notification_set_application [%d]", ret);
3176                 goto FAIL;
3177         }
3178
3179         int noti_id = 0;
3180         ret = notification_insert(noti, &noti_id);
3181         if (ret != NOTIFICATION_ERROR_NONE) {
3182                 _DBG("Fail to notification_insert [%d]", ret);
3183                 goto FAIL;
3184         }
3185
3186         ret = notification_free(noti);
3187         if (ret != NOTIFICATION_ERROR_NONE) {
3188                 _DBG("Fail to notification_free [%d]", ret);
3189                 goto FAIL;
3190         }
3191
3192         return 0 ;
3193
3194 FAIL:
3195         ret = notification_free(noti);
3196         if (ret != NOTIFICATION_ERROR_NONE) {
3197                 _DBG("Fail to notification_free [%d]", ret);
3198         }
3199         return 1;
3200 }
3201
3202 /*
3203  * Check whether file existed or not
3204  *
3205  * @param       pszFilePathName [in] : File path (/Folder)
3206  * @return      TRUE on success, FALSE on failure
3207  */
3208 static int __is_file_exist(char *pszFilePathName)
3209 {
3210         FILE    *pFile = NULL;
3211
3212         pFile = fopen(pszFilePathName, "r");
3213         if (pFile == NULL) {
3214                 _DBG("fopen('%s')=NULL, File not existed.", pszFilePathName);
3215                 return 0;
3216         }
3217
3218         _DBG("fopen('%s')!=NULL, File existed.", pszFilePathName);
3219
3220         fclose(pFile);
3221         pFile = NULL;
3222
3223         return 1;
3224 }
3225
3226 static int __mode_reboot_noti_method()
3227 {
3228         /*get vconf to notif register */
3229         /*blockingmode, drivingmode, flightmode */
3230         int driving, firewall, ret;
3231         ret = 0;
3232         ret |= vconf_get_bool(VCONFKEY_SETAPPL_FIREWALL_KEY, &firewall);
3233         /*ret |= vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight); */
3234         _DBG("__mode_reboot_noti_method");
3235         printf("noti method start\n");
3236         if (ret) {
3237                 printf("mode get vconf failed\n");
3238                 return ret;
3239         }
3240         /*set noti for on status */
3241         if (driving)
3242                 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");
3243         if (firewall)
3244                 ret |= mode_reboot_create_noti_only("IDS_ST_BODY_CONFIGURE_FIREWALL_SETTINGS", PKG_FIREWALL, "IDS_ST_BODY_FIREWALL_ENABLED_ABB");
3245         /*if(flight) mode_reboot_create_noti_only ... not need to */
3246
3247         return ret;     /*zero for success */
3248 }
3249 static void __win_del(void *data, Evas_Object *obj, void *event)
3250 {
3251         elm_exit();
3252 }
3253
3254 static Evas_Object *__create_win(const char *name)
3255 {
3256         _DBG("ENTER __create_win");
3257         Evas_Object *eo;
3258         int w;
3259         int h;
3260         Ecore_X_Window xwin;
3261         unsigned int val = 1;
3262
3263         eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
3264         if (eo) {
3265                 elm_win_title_set(eo, name);
3266                 elm_win_borderless_set(eo, EINA_TRUE);
3267                 elm_win_alpha_set(eo, EINA_TRUE);
3268                 elm_win_raise(eo);
3269                 evas_object_smart_callback_add(eo, "delete,request", __win_del, NULL);
3270                 #if 0
3271                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
3272                 evas_object_resize(eo, w, h);
3273                 xwin = elm_win_xwindow_get(eo);
3274                 ecore_x_window_prop_card32_set(xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
3275                 #endif
3276         }
3277
3278         return eo;
3279 }
3280
3281 static int __mode_syspopup_app_create(void *data)
3282 {
3283         _DBG("ENTER __mode_syspopup_app_create");
3284         struct appdata *ad = data;
3285         int r;
3286
3287         /* create window */
3288         ad->win = __create_win(PACKAGE);
3289         if (ad->win == NULL) {
3290                 _ERR("Create win error");
3291                 return -1;
3292         }
3293
3294         ad->ly_main = elm_layout_add(ad->win);
3295         evas_object_size_hint_weight_set(ad->ly_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3296         elm_layout_theme_set(ad->ly_main, "layout", "application", "default");
3297
3298         evas_object_show(ad->ly_main);
3299         elm_win_resize_object_add(ad->win, ad->ly_main);
3300         evas_object_show(ad->win);
3301
3302         /* init internationalization */
3303         setting_set_i18n(MODE_SYSPOPUP_PACKAGE, MODE_SYSPOPUP_LOCALEDIR);
3304         /*#define TEST */
3305 #ifdef TEST
3306         mode_syspopup_create_popup_with_label_check(ad, ad->ly_main, NULL,
3307                                                     KeyStr_MOBILEDATA_Popup_Off_Text,
3308                                                     KeyStr_DO_NOT_ASK_AGAIN,
3309                                                     &(ad->popup_chk), __mode_syspopup_mobiledata_cb, 0,
3310                                                     "IDS_ST_BUTTON_CANCEL_ABB", "IDS_ST_BUTTON_OK");
3311
3312 #endif
3313         return 0;
3314 }
3315
3316 static int __mode_syspopup_app_terminate(void *data)
3317 {
3318         _DBG("__mode_syspopup_app_terminate");
3319         struct appdata *ad = data;
3320
3321         if (ad->tts) {
3322                 fini_tts(ad);
3323         }
3324
3325         if (vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_changed) != 0)
3326                 _DBG("vconf key ignore failed");
3327
3328         _mini_destroy();
3329
3330         if (ad->win) {
3331                 evas_object_del(ad->win);
3332                 ad->win = NULL;
3333         }
3334
3335         if (ad->lcd_freq_timer) {
3336                 ecore_timer_del(ad->lcd_freq_timer);
3337                 ad->lcd_freq_timer = NULL;
3338         }
3339
3340         if (ad->play_timer) {
3341                 ecore_timer_del(ad->play_timer);
3342                 ad->play_timer = NULL;
3343         }
3344
3345         if (ad->disable_popup) {
3346                 evas_object_del(ad->disable_popup);
3347                 ad->disable_popup = NULL;
3348         }
3349
3350         if (ad->enable_popup) {
3351                 evas_object_del(ad->enable_popup);
3352                 ad->enable_popup = NULL;
3353         }
3354
3355         elm_exit();
3356         return 0;
3357 }
3358
3359 static int __mode_syspopup_app_pause(void *data)
3360 {
3361         /*struct appdata *ad = data; */
3362
3363         return 0;
3364 }
3365
3366 static int __mode_syspopup_resume(void *data)
3367 {
3368         /*struct appdata *ad = data; */
3369
3370         return 0;
3371 }
3372
3373 int main(int argc, char *argv[])
3374 {
3375         _DBG("ENTER main");
3376 #if REBOOT_METHOD_FROM_SHELL
3377         int i = 0;
3378         /*for(; i < argc;i++) _DBG("argv[%d]:%s", i, argv[i]); */
3379         int command = 99;
3380         int res = 77;
3381         if (argc >= 2) command = atoi(argv[1]);
3382         /*_DBG("[0]%s [1]%s [2]%s command=%d , argc = %d",argv[0], argv[1],argv[2],command, argc); */
3383         switch (command) {
3384                 case 1:/* from sh */
3385                         sleep(1);       /*notification_is_service_ready */
3386                         /*function for vconf get and notification register */
3387                         if (!__mode_reboot_noti_method()) {
3388                                 /*success */
3389                                 res = 0;
3390                                 /*function for recovery interrupt in emergency/upms work */
3391                                 if (__is_file_exist(DEFAULT_COMPLETE_CONFIG_FLAG_DIR"mode_perf.xml")) {
3392                                         /*should recovery!, set normal with reboot */
3393                                         is_recovery = true;
3394                                 } else {
3395                                         return res;
3396                                 }
3397                         } else {
3398                                 _DBG("noti method failing");
3399                                 return 1;       /*failing code from sh */
3400                         }
3401                 default:
3402                         res = 99;
3403         }
3404         _DBG("[in reboot-mode sys seq from shell]end:res[%d]\n", res);
3405 #endif
3406
3407         struct appdata ad;
3408
3409         struct appcore_ops ops = {
3410                 .create = __mode_syspopup_app_create,
3411                 .terminate = __mode_syspopup_app_terminate,
3412                 .pause = __mode_syspopup_app_pause,
3413                 .resume = __mode_syspopup_resume,
3414                 .reset = __mode_syspopup_reset,
3415         };
3416
3417         memset(&ad, 0x0, sizeof(struct appdata));
3418         ops.data = &ad;
3419
3420         return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
3421 }