mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Process shutdown signal
This commit is contained in:
parent
7032f57bb8
commit
129c7987c4
@ -35,6 +35,9 @@
|
|||||||
#define EMOUNTD_INTERFACE "org.equinoxproject.Emountd"
|
#define EMOUNTD_INTERFACE "org.equinoxproject.Emountd"
|
||||||
#define EMOUNTD_OBJECT_PATH "/org/equinoxproject/Emountd"
|
#define EMOUNTD_OBJECT_PATH "/org/equinoxproject/Emountd"
|
||||||
|
|
||||||
|
#define EDE_SHUTDOWN_INTERFACE "org.equinoxproject.Shutdown"
|
||||||
|
#define EDE_SHUTDOWN_MEMBER "Shutdown"
|
||||||
|
|
||||||
struct DeviceInfo {
|
struct DeviceInfo {
|
||||||
unsigned int udi_hash;
|
unsigned int udi_hash;
|
||||||
const char* label;
|
const char* label;
|
||||||
@ -328,6 +331,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
DBusError err;
|
DBusError err;
|
||||||
DBusConnection* conn = NULL, *session_conn = NULL;
|
DBusConnection* conn = NULL, *session_conn = NULL;
|
||||||
|
DBusMessage* down_msg = NULL;
|
||||||
|
|
||||||
LibHalContext* ctx = NULL;
|
LibHalContext* ctx = NULL;
|
||||||
LibHalDrive* hd;
|
LibHalDrive* hd;
|
||||||
@ -421,9 +425,30 @@ int main(int argc, char** argv) {
|
|||||||
libhal_free_string_array(drive_udis);
|
libhal_free_string_array(drive_udis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loop to receive/send messages */
|
/* add matcher for quit dbus signal */
|
||||||
while(dbus_connection_read_write_dispatch(conn, 1000) && !quit_signaled)
|
dbus_bus_add_match(bus_connection, "type='signal',interface='"EDE_SHUTDOWN_INTERFACE"'", 0);
|
||||||
;
|
|
||||||
|
/*
|
||||||
|
* Now handle both system and session bus messages: system messages
|
||||||
|
* are to receive HAL notifications and bus messages are to dispatch them to EDE clients
|
||||||
|
* and to receive Shutdown signal
|
||||||
|
*/
|
||||||
|
while(1) {
|
||||||
|
if(quit_signaled)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* fetch and dispatch system bus messages */
|
||||||
|
dbus_connection_read_write_dispatch(conn, 10);
|
||||||
|
|
||||||
|
/* but only fetch session bus messages; they are processed here */
|
||||||
|
dbus_connection_read_write(bus_connection, 10);
|
||||||
|
|
||||||
|
down_msg = dbus_connection_pop_message(bus_connection);
|
||||||
|
if(down_msg && dbus_message_is_signal(down_msg, EDE_SHUTDOWN_INTERFACE, EDE_SHUTDOWN_MEMBER))
|
||||||
|
break;
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if(!ctx)
|
if(!ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user