Added shutdown dbus signal that will be broadcasted when EDE starts to shut down

so apps (but not X11 related) could quit nicely. Primarly intended for services, like emountd
This commit is contained in:
Sanel Zukan
2009-02-26 12:04:29 +00:00
parent 555433bfeb
commit 7032f57bb8
2 changed files with 22 additions and 3 deletions

View File

@@ -21,6 +21,8 @@
#include <edelib/MessageBox.h> #include <edelib/MessageBox.h>
#include <edelib/Nls.h> #include <edelib/Nls.h>
#include <edelib/Run.h> #include <edelib/Run.h>
#include <edelib/EdbusMessage.h>
#include <edelib/EdbusConnection.h>
#include "EvokeService.h" #include "EvokeService.h"
#include "Splash.h" #include "Splash.h"
@@ -30,6 +32,9 @@
EDELIB_NS_USING(Config) EDELIB_NS_USING(Config)
EDELIB_NS_USING(Resource) EDELIB_NS_USING(Resource)
EDELIB_NS_USING(EdbusMessage)
EDELIB_NS_USING(EdbusConnection)
EDELIB_NS_USING(EDBUS_SESSION)
EDELIB_NS_USING(RES_SYS_ONLY) EDELIB_NS_USING(RES_SYS_ONLY)
EDELIB_NS_USING(file_exists) EDELIB_NS_USING(file_exists)
EDELIB_NS_USING(file_remove) EDELIB_NS_USING(file_remove)
@@ -61,6 +66,16 @@ static int get_int_property_value(Atom at) {
return ret; return ret;
} }
static void send_dbus_ede_quit(void) {
EdbusConnection c;
E_RETURN_IF_FAIL(c.connect(EDBUS_SESSION));
EdbusMessage msg;
msg.create_signal("/org/equinoxproject/Shutdown", "org.equinoxproject.Shutdown", "Shutdown");
c.send(msg);
}
EvokeService::EvokeService() : lock_name(NULL), xsm(NULL), is_running(false) { EvokeService::EvokeService() : lock_name(NULL), xsm(NULL), is_running(false) {
/* TODO: or add setup_atoms() function */ /* TODO: or add setup_atoms() function */
XA_EDE_EVOKE_SHUTDOWN_ALL = XInternAtom(fl_display, "_EDE_EVOKE_SHUTDOWN_ALL", False); XA_EDE_EVOKE_SHUTDOWN_ALL = XInternAtom(fl_display, "_EDE_EVOKE_SHUTDOWN_ALL", False);
@@ -223,6 +238,7 @@ int EvokeService::handle(const XEvent* xev) {
int ret = logout_dialog_show(dw, dh, LOGOUT_OPT_SHUTDOWN | LOGOUT_OPT_RESTART); int ret = logout_dialog_show(dw, dh, LOGOUT_OPT_SHUTDOWN | LOGOUT_OPT_RESTART);
if(ret != -1) { if(ret != -1) {
send_dbus_ede_quit();
x_shutdown(); x_shutdown();
stop(); stop();
} }

View File

@@ -10,9 +10,6 @@
SubDir TOP evoke ; SubDir TOP evoke ;
# use SIGHUP for now as default
ObjectC++Flags evoke.cpp : -DUSE_SIGHUP ;
SOURCE = evoke.cpp SOURCE = evoke.cpp
EvokeService.cpp EvokeService.cpp
Splash.cpp Splash.cpp
@@ -26,6 +23,12 @@ CONFIG = ede-settings.conf
#ObjectC++Flags $(SOURCE) : -DUSE_LOCAL_CONFIG ; #ObjectC++Flags $(SOURCE) : -DUSE_LOCAL_CONFIG ;
# use SIGHUP for now as default
ObjectC++Flags evoke.cpp : -DUSE_SIGHUP ;
ObjectC++Flags EvokeService.cpp : $(EDELIB_DBUS_INCLUDE) ;
LinkAgainstAsFirst evoke : $(EDELIB_DBUS_LIB) ;
EdeProgram evoke : $(SOURCE) ; EdeProgram evoke : $(SOURCE) ;
ProgramBare ede-shutdown : ede-shutdown.cpp ; ProgramBare ede-shutdown : ede-shutdown.cpp ;
LinkAgainst ede-shutdown : -lX11 ; LinkAgainst ede-shutdown : -lX11 ;