4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <appcore-efl.h>
24 //#include <dd-deviced.h>
25 //#include <dd-display.h>
32 #include <Ecore_Input.h>
35 /* Time profiling support */
38 #endif /* ACCT_PROF */
43 int create_and_show_basic_popup_min(struct appdata *ad);
44 void poweroff_response_yes_cb(void *data, Evas_Object * obj, void *event_info);
45 void poweroff_response_no_cb(void *data, Evas_Object * obj, void *event_info);
47 int myterm(bundle *b, void *data)
52 int mytimeout(bundle *b, void *data)
57 syspopup_handler handler = {
58 .def_term_fn = myterm,
59 .def_timeout_fn = mytimeout
62 /* App Life cycle funtions */
63 static void win_del(void *data, Evas_Object * obj, void *event)
68 /* Create main window */
69 static Evas_Object *create_win(const char *name)
76 eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
78 elm_win_title_set(eo, name);
79 elm_win_borderless_set(eo, EINA_TRUE);
80 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
81 elm_win_alpha_set(eo, EINA_TRUE);
82 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
84 evas_object_resize(eo, w, h);
86 xwin = elm_win_xwindow_get(eo);
87 ecore_x_window_prop_card32_set(xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
92 /* Cleanup objects to avoid mem-leak */
93 void poweroff_cleanup(struct appdata *ad)
98 if (ad->popup_poweroff)
99 evas_object_del(ad->popup_poweroff);
101 evas_object_del(ad->layout_main);
104 void poweroff_response_yes_cb(void *data, Evas_Object * obj, void *event_info)
106 static int bPowerOff = 0;
110 _I("System-popup : Switching off phone !! Bye Bye");
111 /* This will cleanup the memory */
112 poweroff_cleanup(data);
114 if (sysman_call_predef_action(PREDEF_POWEROFF, 0) == -1) {
115 _E("System-popup : failed to request poweroff to system_server");
120 void poweroff_response_no_cb(void *data, Evas_Object * obj, void *event_info)
122 _I("System-popup: Option is Wrong");
123 poweroff_cleanup(data);
127 int create_and_show_basic_popup(struct appdata *ad)
132 ad->popup_poweroff = elm_popup_add(ad->win_main);
133 if (ad->popup_poweroff == NULL) {
134 _E("System-popup : Add popup failed ");
138 evas_object_size_hint_weight_set(ad->popup_poweroff, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
139 elm_object_style_set(ad->popup_poweroff, "transparent");
140 elm_object_text_set(ad->popup_poweroff, _("IDS_ST_BODY_POWER_OFF"));
141 elm_object_part_text_set(ad->popup_poweroff, "title,text", _("IDS_COM_BODY_SYSTEM_INFO_ABB"));
143 btn1 = elm_button_add(ad->popup_poweroff);
144 elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
145 elm_object_part_content_set(ad->popup_poweroff, "button1", btn1);
146 elm_object_style_set (btn1,"popup_button/default");
147 evas_object_smart_callback_add(btn1, "clicked", poweroff_response_no_cb, ad);
148 btn2 = elm_button_add(ad->popup_poweroff);
149 elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
150 elm_object_part_content_set(ad->popup_poweroff, "button2", btn2);
151 elm_object_style_set (btn2,"popup_button/default");
152 evas_object_smart_callback_add(btn2, "clicked", poweroff_response_yes_cb, ad);
155 xwin = elm_win_xwindow_get(ad->popup_poweroff);
156 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
157 utilx_grab_key(ecore_x_display_get(), xwin, KEY_SELECT, SHARED_GRAB);
158 evas_object_show(ad->popup_poweroff);
163 int poweroff_start(void *data)
165 struct appdata *ad = data;
168 /* Create and show popup */
169 ret_val = create_and_show_basic_popup(ad);
173 /* Change LCD brightness */
174 // ret_val = display_change_state(LCD_NORMAL);
182 int app_create(void *data)
186 struct appdata *ad = data;
188 /* Create window (Reqd for sys-popup) */
189 win = create_win(PACKAGE);
195 elm_theme_overlay_add(NULL,EDJ_NAME);
200 /* Terminate noti handler */
201 static int app_terminate(void *data)
203 struct appdata *ad = data;
206 evas_object_del(ad->layout_main);
209 evas_object_del(ad->win_main);
214 /* Pause/background */
215 static int app_pause(void *data)
221 static int app_resume(void *data)
228 static int app_reset(bundle *b, void *data)
230 struct appdata *ad = data;
232 if (syspopup_has_popup(b)) {
235 syspopup_create(b, &handler, ad->win_main, ad);
236 evas_object_show(ad->win_main);
239 poweroff_start((void *)ad);
245 int main(int argc, char *argv[])
249 /* App life cycle management */
250 struct appcore_ops ops = {
251 .create = app_create,
252 .terminate = app_terminate,
254 .resume = app_resume,
258 memset(&ad, 0x0, sizeof(struct appdata));
262 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);