3 #define ACTION_TIMEOUT 30.0
5 /* local subsystem functions */
6 static Eina_Bool _e_sys_cb_timer(void *data);
7 static Eina_Bool _e_sys_cb_exit(void *data, int type, void *event);
8 static void _e_sys_cb_logout_logout(void *data, E_Dialog *dia);
9 static void _e_sys_cb_logout_wait(void *data, E_Dialog *dia);
10 static void _e_sys_cb_logout_abort(void *data, E_Dialog *dia);
11 static Eina_Bool _e_sys_cb_logout_timer(void *data);
12 static void _e_sys_logout_after(void);
13 static void _e_sys_logout_begin(E_Sys_Action a_after, Eina_Bool raw);
14 static void _e_sys_current_action(void);
15 static void _e_sys_action_failed(void);
16 static int _e_sys_action_do(E_Sys_Action a, char *param, Eina_Bool raw);
17 static void _e_sys_dialog_cb_delete(E_Obj_Dialog *od);
19 static Ecore_Event_Handler *_e_sys_exe_exit_handler = NULL;
20 static Ecore_Exe *_e_sys_halt_check_exe = NULL;
21 static Ecore_Exe *_e_sys_reboot_check_exe = NULL;
22 static Ecore_Exe *_e_sys_suspend_check_exe = NULL;
23 static Ecore_Exe *_e_sys_hibernate_check_exe = NULL;
24 static int _e_sys_can_halt = 0;
25 static int _e_sys_can_reboot = 0;
26 static int _e_sys_can_suspend = 0;
27 static int _e_sys_can_hibernate = 0;
29 static E_Sys_Action _e_sys_action_current = E_SYS_NONE;
30 static E_Sys_Action _e_sys_action_after = E_SYS_NONE;
31 static Eina_Bool _e_sys_action_after_raw = EINA_FALSE;
32 static Ecore_Exe *_e_sys_exe = NULL;
33 static double _e_sys_begin_time = 0.0;
34 static double _e_sys_logout_begin_time = 0.0;
35 static Ecore_Timer *_e_sys_logout_timer = NULL;
36 static E_Obj_Dialog *_e_sys_dialog = NULL;
37 static E_Dialog *_e_sys_logout_confirm_dialog = NULL;
38 static Ecore_Timer *_e_sys_susp_hib_check_timer = NULL;
39 static double _e_sys_susp_hib_check_last_tick = 0.0;
41 static void _e_sys_systemd_handle_inhibit(void);
42 static void _e_sys_systemd_poweroff(void);
43 static void _e_sys_systemd_reboot(void);
44 static void _e_sys_systemd_suspend(void);
45 static void _e_sys_systemd_hibernate(void);
46 static void _e_sys_systemd_exists_cb(void *data, const Eldbus_Message *m, Eldbus_Pending *p);
48 static Eina_Bool systemd_works = EINA_FALSE;
49 static int _e_sys_systemd_inhibit_fd = -1;
51 static const int E_LOGOUT_AUTO_TIME = 60;
52 static const int E_LOGOUT_WAIT_TIME = 15;
54 static Ecore_Timer *action_timeout = NULL;
56 static Eldbus_Proxy *login1_manger_proxy = NULL;
58 EAPI int E_EVENT_SYS_SUSPEND = -1;
59 EAPI int E_EVENT_SYS_HIBERNATE = -1;
60 EAPI int E_EVENT_SYS_RESUME = -1;
63 _e_sys_comp_done_cb(void *data, Evas_Object *obj, const char *sig, const char *src)
65 edje_object_signal_callback_del(obj, sig, src, _e_sys_comp_done_cb);
66 e_sys_action_raw_do((E_Sys_Action)(long)data, NULL);
67 E_FREE_FUNC(action_timeout, ecore_timer_del);
71 _e_sys_comp_action_timeout(void *data)
75 E_Sys_Action a = (long)(intptr_t)data;
76 const char *sig = NULL;
81 sig = "e,state,sys,logout,done";
84 sig = "e,state,sys,halt,done";
87 sig = "e,state,sys,reboot,done";
90 sig = "e,state,sys,suspend,done";
93 sig = "e,state,sys,hibernate,done";
98 E_FREE_FUNC(action_timeout, ecore_timer_del);
101 EINA_LIST_FOREACH(e_comp->zones, l, zone)
102 edje_object_signal_callback_del(zone->over, sig, "e", _e_sys_comp_done_cb);
104 e_sys_action_raw_do(a, NULL);
109 _e_sys_comp_emit_cb_wait(E_Sys_Action a, const char *sig, const char *rep, Eina_Bool nocomp_push)
113 Eina_Bool first = EINA_TRUE;
115 if (nocomp_push) e_comp_override_add(e_comp);
116 else e_comp_override_timed_pop(e_comp);
117 EINA_LIST_FOREACH(e_comp->zones, l, zone)
119 e_zone_fade_handle(zone, nocomp_push, 0.5);
120 edje_object_signal_emit(zone->base, sig, "e");
121 edje_object_signal_emit(zone->over, sig, "e");
122 if ((rep) && (first))
123 edje_object_signal_callback_add(zone->over, rep, "e", _e_sys_comp_done_cb, (void *)(long)a);
128 if (action_timeout) ecore_timer_del(action_timeout);
129 action_timeout = ecore_timer_add(ACTION_TIMEOUT, (Ecore_Task_Cb)_e_sys_comp_action_timeout, (intptr_t*)(long)a);
134 _e_sys_comp_suspend(void)
136 _e_sys_comp_emit_cb_wait(E_SYS_SUSPEND, "e,state,sys,suspend", "e,state,sys,suspend,done", EINA_TRUE);
140 _e_sys_comp_hibernate(void)
142 _e_sys_comp_emit_cb_wait(E_SYS_HIBERNATE, "e,state,sys,hibernate", "e,state,sys,hibernate,done", EINA_TRUE);
146 _e_sys_comp_reboot(void)
148 _e_sys_comp_emit_cb_wait(E_SYS_REBOOT, "e,state,sys,reboot", "e,state,sys,reboot,done", EINA_TRUE);
152 _e_sys_comp_shutdown(void)
154 _e_sys_comp_emit_cb_wait(E_SYS_HALT, "e,state,sys,halt", "e,state,sys,halt,done", EINA_TRUE);
158 _e_sys_comp_logout(void)
160 _e_sys_comp_emit_cb_wait(E_SYS_LOGOUT, "e,state,sys,logout", "e,state,sys,logout,done", EINA_TRUE);
164 _e_sys_comp_resume(void)
166 evas_damage_rectangle_add(e_comp->evas, 0, 0, e_comp->man->w, e_comp->man->h);
167 _e_sys_comp_emit_cb_wait(E_SYS_SUSPEND, "e,state,sys,resume", NULL, EINA_FALSE);
168 e_screensaver_deactivate();
171 /* externally accessible functions */
175 Eldbus_Connection *conn;
179 conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
180 obj = eldbus_object_get(conn, "org.freedesktop.login1",
181 "/org/freedesktop/login1");
182 login1_manger_proxy = eldbus_proxy_get(obj,
183 "org.freedesktop.login1.Manager");
184 eldbus_name_owner_get(conn, "org.freedesktop.login1",
185 _e_sys_systemd_exists_cb, NULL);
186 _e_sys_systemd_handle_inhibit();
188 E_EVENT_SYS_SUSPEND = ecore_event_type_new();
189 E_EVENT_SYS_HIBERNATE = ecore_event_type_new();
190 E_EVENT_SYS_RESUME = ecore_event_type_new();
191 /* this is not optimal - but it does work cleanly */
192 _e_sys_exe_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
193 _e_sys_cb_exit, NULL);
200 if (_e_sys_exe_exit_handler)
201 ecore_event_handler_del(_e_sys_exe_exit_handler);
202 _e_sys_exe_exit_handler = NULL;
203 _e_sys_halt_check_exe = NULL;
204 _e_sys_reboot_check_exe = NULL;
205 _e_sys_suspend_check_exe = NULL;
206 _e_sys_hibernate_check_exe = NULL;
207 if (login1_manger_proxy)
209 Eldbus_Connection *conn;
212 obj = eldbus_proxy_object_get(login1_manger_proxy);
213 conn = eldbus_object_connection_get(obj);
214 eldbus_proxy_unref(login1_manger_proxy);
215 eldbus_object_unref(obj);
216 eldbus_connection_unref(conn);
217 login1_manger_proxy = NULL;
219 if (_e_sys_systemd_inhibit_fd >= 0)
221 close(_e_sys_systemd_inhibit_fd);
222 _e_sys_systemd_inhibit_fd = -1;
229 e_sys_action_possible_get(E_Sys_Action a)
243 return _e_sys_can_halt;
246 return _e_sys_can_reboot;
249 return _e_sys_can_suspend;
251 case E_SYS_HIBERNATE:
252 return _e_sys_can_hibernate;
261 e_sys_action_do(E_Sys_Action a, char *param)
265 if (_e_sys_action_current != E_SYS_NONE)
267 _e_sys_current_action();
277 case E_SYS_HIBERNATE:
279 ret = _e_sys_action_do(a, param, EINA_FALSE);
284 if (!e_util_immortal_check())
285 ret = _e_sys_action_do(a, param, EINA_FALSE);
292 if (ret) _e_sys_action_current = a;
293 else _e_sys_action_current = E_SYS_NONE;
299 e_sys_action_raw_do(E_Sys_Action a, char *param)
303 if (_e_sys_action_current != E_SYS_NONE)
305 _e_sys_current_action();
308 ret = _e_sys_action_do(a, param, EINA_TRUE);
310 if (ret) _e_sys_action_current = a;
311 else _e_sys_action_current = E_SYS_NONE;
316 static Eina_List *extra_actions = NULL;
318 EAPI E_Sys_Con_Action *
319 e_sys_con_extra_action_register(const char *label,
320 const char *icon_group,
321 const char *button_name,
322 void (*func)(void *data),
325 E_Sys_Con_Action *sca;
327 sca = E_NEW(E_Sys_Con_Action, 1);
329 sca->label = eina_stringshare_add(label);
331 sca->icon_group = eina_stringshare_add(icon_group);
333 sca->button_name = eina_stringshare_add(button_name);
336 extra_actions = eina_list_append(extra_actions, sca);
341 e_sys_con_extra_action_unregister(E_Sys_Con_Action *sca)
343 extra_actions = eina_list_remove(extra_actions, sca);
344 if (sca->label) eina_stringshare_del(sca->label);
345 if (sca->icon_group) eina_stringshare_del(sca->icon_group);
346 if (sca->button_name) eina_stringshare_del(sca->button_name);
350 EAPI const Eina_List *
351 e_sys_con_extra_action_list_get(void)
353 return extra_actions;
357 _e_sys_systemd_inhibit_cb(void *data __UNUSED__, const Eldbus_Message *m, Eldbus_Pending *p __UNUSED__)
360 if (eldbus_message_error_get(m, NULL, NULL)) return;
361 if (!eldbus_message_arguments_get(m, "h", &fd))
362 _e_sys_systemd_inhibit_fd = fd;
366 _e_sys_systemd_handle_inhibit(void)
370 if (!login1_manger_proxy) return;
371 if (!(m = eldbus_proxy_method_call_new(login1_manger_proxy, "Inhibit")))
373 eldbus_message_arguments_append
376 "handle-suspend-key:"
377 "handle-hibernate-key:"
378 "handle-lid-switch", // what
379 "Enlightenment", // who (string)
380 "Normal Execution", // why (string)
382 eldbus_proxy_send(login1_manger_proxy, m, _e_sys_systemd_inhibit_cb, NULL, -1);
386 _e_sys_systemd_check_cb(void *data, const Eldbus_Message *m, Eldbus_Pending *p __UNUSED__)
390 if (!eldbus_message_arguments_get(m, "s", &s)) return;
392 if (!strcmp(s, "yes")) *dest = 1;
397 _e_sys_systemd_check(void)
399 if (!login1_manger_proxy) return;
400 if (!eldbus_proxy_call(login1_manger_proxy, "CanPowerOff",
401 _e_sys_systemd_check_cb, &_e_sys_can_halt, -1, ""))
403 if (!eldbus_proxy_call(login1_manger_proxy, "CanReboot",
404 _e_sys_systemd_check_cb, &_e_sys_can_reboot, -1, ""))
406 if (!eldbus_proxy_call(login1_manger_proxy, "CanSuspend",
407 _e_sys_systemd_check_cb, &_e_sys_can_suspend, -1, ""))
409 if (!eldbus_proxy_call(login1_manger_proxy, "CanHibernate",
410 _e_sys_systemd_check_cb, &_e_sys_can_hibernate, -1, ""))
415 _e_sys_systemd_exists_cb(void *data __UNUSED__, const Eldbus_Message *m, Eldbus_Pending *p __UNUSED__)
417 const char *id = NULL;
419 if (eldbus_message_error_get(m, NULL, NULL)) goto fail;
420 if (!eldbus_message_arguments_get(m, "s", &id)) goto fail;
421 if ((!id) || (id[0] != ':')) goto fail;
422 systemd_works = EINA_TRUE;
423 _e_sys_systemd_check();
426 systemd_works = EINA_FALSE;
427 /* delay this for 1.0 seconds while the rest of e starts up */
428 ecore_timer_add(1.0, _e_sys_cb_timer, NULL);
432 _e_sys_systemd_poweroff(void)
434 eldbus_proxy_call(login1_manger_proxy, "PowerOff", NULL, NULL, -1, "b", 0);
438 _e_sys_systemd_reboot(void)
440 eldbus_proxy_call(login1_manger_proxy, "Reboot", NULL, NULL, -1, "b", 0);
444 _e_sys_systemd_suspend(void)
446 eldbus_proxy_call(login1_manger_proxy, "Suspend", NULL, NULL, -1, "b", 0);
450 _e_sys_systemd_hibernate(void)
452 eldbus_proxy_call(login1_manger_proxy, "Hibernate", NULL, NULL, -1, "b", 0);
456 _e_sys_resume_job(void *d EINA_UNUSED)
458 ecore_event_add(E_EVENT_SYS_RESUME, NULL, NULL, NULL);
459 _e_sys_comp_resume();
463 _e_sys_susp_hib_check_timer_cb(void *data __UNUSED__)
465 double t = ecore_time_unix_get();
467 if ((t - _e_sys_susp_hib_check_last_tick) > 0.2)
469 _e_sys_susp_hib_check_timer = NULL;
472 e_object_del(E_OBJECT(_e_sys_dialog));
473 _e_sys_dialog = NULL;
475 ecore_job_add(_e_sys_resume_job, NULL);
478 _e_sys_susp_hib_check_last_tick = t;
483 _e_sys_susp_hib_check(void)
485 if (_e_sys_susp_hib_check_timer)
486 ecore_timer_del(_e_sys_susp_hib_check_timer);
487 _e_sys_susp_hib_check_last_tick = ecore_time_unix_get();
488 _e_sys_susp_hib_check_timer =
489 ecore_timer_add(0.1, _e_sys_susp_hib_check_timer_cb, NULL);
492 /* local subsystem functions */
494 _e_sys_cb_timer(void *data __UNUSED__)
496 /* exec out sys helper and ask it to test if we are allowed to do these
501 e_init_status_set(_("Checking System Permissions"));
502 snprintf(buf, sizeof(buf),
503 "%s/enlightenment/utils/enlightenment_sys -t halt",
505 _e_sys_halt_check_exe = ecore_exe_run(buf, NULL);
506 snprintf(buf, sizeof(buf),
507 "%s/enlightenment/utils/enlightenment_sys -t reboot",
509 _e_sys_reboot_check_exe = ecore_exe_run(buf, NULL);
510 snprintf(buf, sizeof(buf),
511 "%s/enlightenment/utils/enlightenment_sys -t suspend",
513 _e_sys_suspend_check_exe = ecore_exe_run(buf, NULL);
514 snprintf(buf, sizeof(buf),
515 "%s/enlightenment/utils/enlightenment_sys -t hibernate",
517 _e_sys_hibernate_check_exe = ecore_exe_run(buf, NULL);
518 return ECORE_CALLBACK_CANCEL;
522 _e_sys_cb_exit(void *data __UNUSED__, int type __UNUSED__, void *event)
524 Ecore_Exe_Event_Del *ev;
527 if ((_e_sys_exe) && (ev->exe == _e_sys_exe))
529 if (ev->exit_code != 0) _e_sys_action_failed();
530 if (((_e_sys_action_current != E_SYS_HALT) &&
531 (_e_sys_action_current != E_SYS_HALT_NOW) &&
532 (_e_sys_action_current != E_SYS_REBOOT)) ||
533 (ev->exit_code != 0))
537 e_object_del(E_OBJECT(_e_sys_dialog));
538 _e_sys_dialog = NULL;
541 _e_sys_action_current = E_SYS_NONE;
543 return ECORE_CALLBACK_RENEW;
545 if ((_e_sys_halt_check_exe) && (ev->exe == _e_sys_halt_check_exe))
547 e_init_status_set(_("System Check Done"));
548 /* exit_code: 0 == OK, 5 == suid root removed, 7 == group id error
549 * 10 == permission denied, 20 == action undefined */
550 if (ev->exit_code == 0)
553 _e_sys_halt_check_exe = NULL;
556 else if ((_e_sys_reboot_check_exe) && (ev->exe == _e_sys_reboot_check_exe))
558 e_init_status_set(_("System Check Done"));
559 if (ev->exit_code == 0)
561 _e_sys_can_reboot = 1;
562 _e_sys_reboot_check_exe = NULL;
565 else if ((_e_sys_suspend_check_exe) && (ev->exe == _e_sys_suspend_check_exe))
567 e_init_status_set(_("System Check Done"));
568 if (ev->exit_code == 0)
570 _e_sys_can_suspend = 1;
571 _e_sys_suspend_check_exe = NULL;
574 else if ((_e_sys_hibernate_check_exe) && (ev->exe == _e_sys_hibernate_check_exe))
576 e_init_status_set(_("System Check Done"));
577 if (ev->exit_code == 0)
579 _e_sys_can_hibernate = 1;
580 _e_sys_hibernate_check_exe = NULL;
583 return ECORE_CALLBACK_RENEW;
587 _e_sys_cb_logout_logout(void *data __UNUSED__, E_Dialog *dia)
589 if (_e_sys_logout_timer)
591 ecore_timer_del(_e_sys_logout_timer);
592 _e_sys_logout_timer = NULL;
594 _e_sys_logout_begin_time = 0.0;
595 _e_sys_logout_after();
596 e_object_del(E_OBJECT(dia));
597 _e_sys_logout_confirm_dialog = NULL;
601 _e_sys_cb_logout_wait(void *data __UNUSED__, E_Dialog *dia)
603 if (_e_sys_logout_timer) ecore_timer_del(_e_sys_logout_timer);
604 _e_sys_logout_timer = ecore_timer_add(0.5, _e_sys_cb_logout_timer, NULL);
605 _e_sys_logout_begin_time = ecore_time_get();
606 e_object_del(E_OBJECT(dia));
607 _e_sys_logout_confirm_dialog = NULL;
611 _e_sys_cb_logout_abort(void *data __UNUSED__, E_Dialog *dia)
613 if (_e_sys_logout_timer)
615 ecore_timer_del(_e_sys_logout_timer);
616 _e_sys_logout_timer = NULL;
618 _e_sys_logout_begin_time = 0.0;
619 e_object_del(E_OBJECT(dia));
620 _e_sys_logout_confirm_dialog = NULL;
621 _e_sys_action_current = E_SYS_NONE;
622 _e_sys_action_after = E_SYS_NONE;
623 _e_sys_action_after_raw = EINA_FALSE;
626 e_object_del(E_OBJECT(_e_sys_dialog));
627 _e_sys_dialog = NULL;
632 _e_sys_logout_confirm_dialog_update(int remaining)
636 if (!_e_sys_logout_confirm_dialog)
638 fputs("ERROR: updating logout confirm dialog, but none exists!\n",
643 snprintf(txt, sizeof(txt),
644 _("Logout is taking too long.<br>"
645 "Some applications refuse to close.<br>"
646 "Do you want to finish the logout<br>"
647 "anyway without closing these<br>"
648 "applications first?<br><br>"
649 "Auto logout in %d seconds."), remaining);
651 e_dialog_text_set(_e_sys_logout_confirm_dialog, txt);
655 _e_sys_cb_logout_timer(void *data __UNUSED__)
660 E_CLIENT_FOREACH(e_comp, ec)
662 if (e_client_util_ignored_get(ec)) continue;
663 if (!ec->internal) pending++;
665 if (pending == 0) goto after;
666 else if (_e_sys_logout_confirm_dialog)
668 int remaining = E_LOGOUT_AUTO_TIME -
669 round(ecore_loop_time_get() - _e_sys_logout_begin_time);
670 /* it has taken 60 (E_LOGOUT_AUTO_TIME) seconds of waiting the
671 * confirm dialog and we still have apps that will not go
672 * away. Do the action as user may be far away or forgot it.
674 * NOTE: this is the behavior for many operating systems and I
675 * guess the reason is people that hit "shutdown" and
676 * put their laptops in their backpacks in the hope
677 * everything will be turned off properly.
681 _e_sys_logout_confirm_dialog_update(remaining);
682 return ECORE_CALLBACK_RENEW;
686 _e_sys_cb_logout_logout(NULL, _e_sys_logout_confirm_dialog);
687 return ECORE_CALLBACK_CANCEL;
692 /* it has taken 15 seconds of waiting and we still have apps that
695 double now = ecore_loop_time_get();
696 if ((now - _e_sys_logout_begin_time) > E_LOGOUT_WAIT_TIME)
700 dia = e_dialog_new(NULL, "E", "_sys_error_logout_slow");
703 _e_sys_logout_confirm_dialog = dia;
704 e_dialog_title_set(dia, _("Logout problems"));
705 e_dialog_icon_set(dia, "system-log-out", 64);
706 e_dialog_button_add(dia, _("Logout now"), NULL,
707 _e_sys_cb_logout_logout, NULL);
708 e_dialog_button_add(dia, _("Wait longer"), NULL,
709 _e_sys_cb_logout_wait, NULL);
710 e_dialog_button_add(dia, _("Cancel Logout"), NULL,
711 _e_sys_cb_logout_abort, NULL);
712 e_dialog_button_focus_num(dia, 1);
713 _e_sys_logout_confirm_dialog_update(E_LOGOUT_AUTO_TIME);
714 elm_win_center(dia->win, 1, 1);
716 _e_sys_logout_begin_time = now;
718 _e_sys_comp_resume();
719 return ECORE_CALLBACK_RENEW;
722 return ECORE_CALLBACK_RENEW;
724 switch (_e_sys_action_after)
727 _e_sys_comp_logout();
731 _e_sys_comp_shutdown();
734 _e_sys_comp_reboot();
738 _e_sys_logout_timer = NULL;
739 return ECORE_CALLBACK_CANCEL;
743 _e_sys_logout_after(void)
747 e_object_del(E_OBJECT(_e_sys_dialog));
748 _e_sys_dialog = NULL;
750 _e_sys_action_current = _e_sys_action_after;
751 _e_sys_action_do(_e_sys_action_after, NULL, _e_sys_action_after_raw);
752 _e_sys_action_after = E_SYS_NONE;
753 _e_sys_action_after_raw = EINA_FALSE;
757 _e_sys_logout_begin(E_Sys_Action a_after, Eina_Bool raw)
763 /* start logout - at end do the a_after action */
766 od = e_obj_dialog_new(e_util_comp_current_get(),
767 _("Logout in progress"), "E", "_sys_logout");
768 e_obj_dialog_obj_theme_set(od, "base/theme/sys", "e/sys/logout");
769 e_obj_dialog_obj_part_text_set(od, "e.textblock.message",
770 _("Logout in progress.<br>"
771 "<hilight>Please wait.</hilight>"));
772 e_obj_dialog_show(od);
773 e_obj_dialog_icon_set(od, "system-log-out");
774 if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
777 _e_sys_action_after = a_after;
778 _e_sys_action_after_raw = raw;
779 EINA_LIST_FOREACH(e_comp->clients, l, ec)
781 e_client_act_close_begin(ec);
783 /* and poll to see if all pending windows are gone yet every 0.5 sec */
784 _e_sys_logout_begin_time = ecore_time_get();
785 if (_e_sys_logout_timer) ecore_timer_del(_e_sys_logout_timer);
786 _e_sys_logout_timer = ecore_timer_add(0.5, _e_sys_cb_logout_timer, NULL);
790 _e_sys_current_action(void)
792 /* display dialog that currently an action is in progress */
795 dia = e_dialog_new(NULL,
796 "E", "_sys_error_action_busy");
799 e_dialog_title_set(dia, _("Enlightenment is busy with another request"));
800 e_dialog_icon_set(dia, "enlightenment/sys", 64);
801 switch (_e_sys_action_current)
804 e_dialog_text_set(dia, _("Logging out.<br>"
805 "You cannot perform other system actions<br>"
806 "once a logout has begun."));
811 e_dialog_text_set(dia, _("Powering off.<br>"
812 "You cannot do any other system actions<br>"
813 "once a shutdown has been started."));
817 e_dialog_text_set(dia, _("Resetting.<br>"
818 "You cannot do any other system actions<br>"
819 "once a reboot has begun."));
823 e_dialog_text_set(dia, _("Suspending.<br>"
824 "Until suspend is complete you cannot perform<br>"
825 "any other system actions."));
828 case E_SYS_HIBERNATE:
829 e_dialog_text_set(dia, _("Hibernating.<br>"
830 "You cannot perform any other system actions<br>"
831 "until this is complete."));
835 e_dialog_text_set(dia, _("EEK! This should not happen"));
838 e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
839 e_dialog_button_focus_num(dia, 0);
840 elm_win_center(dia->win, 1, 1);
845 _e_sys_action_failed(void)
847 /* display dialog that the current action failed */
850 dia = e_dialog_new(NULL,
851 "E", "_sys_error_action_failed");
854 e_dialog_title_set(dia, _("Enlightenment is busy with another request"));
855 e_dialog_icon_set(dia, "enlightenment/sys", 64);
856 switch (_e_sys_action_current)
860 e_dialog_text_set(dia, _("Power off failed."));
864 e_dialog_text_set(dia, _("Reset failed."));
868 e_dialog_text_set(dia, _("Suspend failed."));
871 case E_SYS_HIBERNATE:
872 e_dialog_text_set(dia, _("Hibernate failed."));
876 e_dialog_text_set(dia, _("EEK! This should not happen"));
879 e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
880 e_dialog_button_focus_num(dia, 0);
881 elm_win_center(dia->win, 1, 1);
886 _e_sys_action_do(E_Sys_Action a, char *param __UNUSED__, Eina_Bool raw)
895 // XXX TODO: check for e_fm_op_registry entries and confirm
896 if (!e_util_immortal_check())
897 ecore_main_loop_quit();
903 // XXX TODO: check for e_fm_op_registry entries and confirm
904 // FIXME: we dont share out immortal info to restarted e. :(
905 // if (!e_util_immortal_check())
908 ecore_main_loop_quit();
919 // XXX TODO: check for e_fm_op_registry entries and confirm
922 _e_sys_logout_after();
926 _e_sys_logout_begin(E_SYS_EXIT, raw);
932 /* shutdown -h now */
933 if (e_util_immortal_check()) return 0;
934 snprintf(buf, sizeof(buf),
935 "%s/enlightenment/utils/enlightenment_sys halt",
939 if ((ecore_time_get() - _e_sys_begin_time) > 2.0)
940 _e_sys_current_action();
947 _e_sys_begin_time = ecore_time_get();
949 _e_sys_systemd_poweroff();
952 _e_sys_exe = ecore_exe_run(buf, NULL);
959 _e_sys_begin_time = ecore_time_get();
961 od = e_obj_dialog_new(NULL,
962 _("Power off"), "E", "_sys_halt");
963 e_obj_dialog_obj_theme_set(od, "base/theme/sys", "e/sys/halt");
964 e_obj_dialog_obj_part_text_set(od, "e.textblock.message",
966 "<hilight>Please wait.</hilight>"));
967 e_obj_dialog_show(od);
968 e_obj_dialog_icon_set(od, "system-shutdown");
969 if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
970 e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
972 _e_sys_logout_begin(a, EINA_TRUE);
974 /* FIXME: display halt status */
979 /* shutdown -r now */
980 if (e_util_immortal_check()) return 0;
981 snprintf(buf, sizeof(buf),
982 "%s/enlightenment/utils/enlightenment_sys reboot",
986 if ((ecore_time_get() - _e_sys_begin_time) > 2.0)
987 _e_sys_current_action();
994 _e_sys_begin_time = ecore_time_get();
996 _e_sys_systemd_reboot();
999 _e_sys_exe = ecore_exe_run(buf, NULL);
1006 _e_sys_begin_time = ecore_time_get();
1007 od = e_obj_dialog_new(NULL,
1008 _("Resetting"), "E", "_sys_reboot");
1009 e_obj_dialog_obj_theme_set(od, "base/theme/sys", "e/sys/reboot");
1010 e_obj_dialog_obj_part_text_set(od, "e.textblock.message",
1012 "<hilight>Please wait.</hilight>"));
1013 e_obj_dialog_show(od);
1014 e_obj_dialog_icon_set(od, "system-restart");
1015 if (_e_sys_dialog) e_object_del(E_OBJECT(_e_sys_dialog));
1016 e_obj_dialog_cb_delete_set(od, _e_sys_dialog_cb_delete);
1018 _e_sys_logout_begin(a, EINA_TRUE);
1020 /* FIXME: display reboot status */
1025 /* /etc/acpi/sleep.sh force */
1026 snprintf(buf, sizeof(buf),
1027 "%s/enlightenment/utils/enlightenment_sys suspend",
1028 e_prefix_lib_get());
1031 if ((ecore_time_get() - _e_sys_begin_time) > 2.0)
1032 _e_sys_current_action();
1039 _e_sys_susp_hib_check();
1040 if (e_config->desklock_on_suspend)
1041 e_desklock_show(EINA_TRUE);
1042 _e_sys_begin_time = ecore_time_get();
1044 _e_sys_systemd_suspend();
1047 _e_sys_exe = ecore_exe_run(buf, NULL);
1053 ecore_event_add(E_EVENT_SYS_SUSPEND, NULL, NULL, NULL);
1054 _e_sys_comp_suspend();
1057 /* FIXME: display suspend status */
1061 case E_SYS_HIBERNATE:
1062 /* /etc/acpi/hibernate.sh force */
1063 snprintf(buf, sizeof(buf),
1064 "%s/enlightenment/utils/enlightenment_sys hibernate",
1065 e_prefix_lib_get());
1068 if ((ecore_time_get() - _e_sys_begin_time) > 2.0)
1069 _e_sys_current_action();
1076 _e_sys_susp_hib_check();
1077 if (e_config->desklock_on_suspend)
1078 e_desklock_show(EINA_TRUE);
1079 _e_sys_begin_time = ecore_time_get();
1081 _e_sys_systemd_hibernate();
1084 _e_sys_exe = ecore_exe_run(buf, NULL);
1090 ecore_event_add(E_EVENT_SYS_HIBERNATE, NULL, NULL, NULL);
1091 _e_sys_comp_hibernate();
1094 /* FIXME: display hibernate status */
1105 _e_sys_dialog_cb_delete(E_Obj_Dialog *od __UNUSED__)
1107 /* If we don't NULL out the _e_sys_dialog, then the
1108 * ECORE_EXE_EVENT_DEL callback will trigger and segv if the window
1109 * is deleted in some other way. */
1110 _e_sys_dialog = NULL;