Commit a7c3b020 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Ray Strode
parent 82fde2ab
......@@ -16,6 +16,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = $(WARN_CFLAGS)
gnome_session_SOURCES = \
$(BUILT_SOURCES) \
gsm-app.h \
gsm-app.c \
gsm-autostart-app.h \
......@@ -125,8 +126,14 @@ test_process_helper_SOURCES = test-process-helper.c gsm-process-helper.c gsm-pro
test_process_helper_CFLAGS = $(AM_CFLAGS) $(GIO_CFLAGS)
test_process_helper_LDADD = $(GIO_LIBS)
gsm-manager-glue.h: org.gnome.SessionManager.xml Makefile.am
$(AM_V_GEN)dbus-binding-tool --prefix=gsm_manager --mode=glib-server --output=gsm-manager-glue.h $(srcdir)/org.gnome.SessionManager.xml
org.gnome.SessionManager.h: org.gnome.SessionManager.xml Makefile.am
$(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager. \
--generate-c-code org.gnome.SessionManager \
--c-namespace Gsm \
--annotate "org.gnome.SessionManager" "org.gtk.GDBus.C.Name" ExportedManager \
$(srcdir)/org.gnome.SessionManager.xml
org.gnome.SessionManager.c: org.gnome.SessionManager.h
@: # generated as a side-effect
gsm-client-glue.h: org.gnome.SessionManager.Client.xml Makefile.am
$(AM_V_GEN)dbus-binding-tool --prefix=gsm_client --mode=glib-server --output=gsm-client-glue.h $(srcdir)/org.gnome.SessionManager.Client.xml
......@@ -141,7 +148,8 @@ gsm-presence-glue.h: org.gnome.SessionManager.Presence.xml Makefile.am
$(AM_V_GEN)dbus-binding-tool --prefix=gsm_presence --mode=glib-server --output=gsm-presence-glue.h $(srcdir)/org.gnome.SessionManager.Presence.xml
BUILT_SOURCES = \
gsm-manager-glue.h \
org.gnome.SessionManager.h \
org.gnome.SessionManager.c \
gsm-presence-glue.h \
gsm-inhibitor-glue.h \
gsm-client-glue.h \
......
......@@ -36,11 +36,9 @@
#include <glib/gstdio.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "gsm-manager.h"
#include "gsm-manager-glue.h"
#include "org.gnome.SessionManager.h"
#ifdef HAVE_SYSTEMD
#include <systemd/sd-journal.h>
......@@ -72,6 +70,7 @@
#define GSM_MANAGER_DBUS_PATH "/org/gnome/SessionManager"
#define GSM_MANAGER_DBUS_NAME "org.gnome.SessionManager"
#define GSM_MANAGER_DBUS_IFACE "org.gnome.SessionManager"
/* Probably about the longest amount of time someone could reasonably
* want to wait, at least for something happening more than once.
......@@ -156,9 +155,10 @@ struct GsmManagerPrivate
GSettings *lockdown_settings;
GsmSystem *system;
DBusGProxy *bus_proxy;
DBusGConnection *connection;
GDBusConnection *connection;
GsmExportedManager *skeleton;
gboolean dbus_disconnected : 1;
guint name_owner_id;
GsmShell *shell;
guint shell_end_session_dialog_canceled_id;
......@@ -171,21 +171,12 @@ struct GsmManagerPrivate
enum {
PROP_0,
PROP_CLIENT_STORE,
PROP_INHIBITED_ACTIONS,
PROP_SESSION_NAME,
PROP_SESSION_IS_ACTIVE,
PROP_FALLBACK,
PROP_FAILSAFE
};
enum {
PHASE_CHANGED,
CLIENT_ADDED,
CLIENT_REMOVED,
INHIBITOR_ADDED,
INHIBITOR_REMOVED,
SESSION_RUNNING,
SESSION_OVER,
LAST_SIGNAL
};
......@@ -211,42 +202,26 @@ static gpointer manager_object = NULL;
G_DEFINE_TYPE (GsmManager, gsm_manager, G_TYPE_OBJECT)
static const GDBusErrorEntry gsm_manager_error_entries[] = {
{ GSM_MANAGER_ERROR_GENERAL, GSM_MANAGER_DBUS_IFACE ".GeneralError" },
{ GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, GSM_MANAGER_DBUS_IFACE ".NotInInitialization" },
{ GSM_MANAGER_ERROR_NOT_IN_RUNNING, GSM_MANAGER_DBUS_IFACE ".NotInRunning" },
{ GSM_MANAGER_ERROR_ALREADY_REGISTERED, GSM_MANAGER_DBUS_IFACE ".AlreadyRegistered" },
{ GSM_MANAGER_ERROR_NOT_REGISTERED, GSM_MANAGER_DBUS_IFACE ".NotRegistered" },
{ GSM_MANAGER_ERROR_INVALID_OPTION, GSM_MANAGER_DBUS_IFACE ".InvalidOption" },
{ GSM_MANAGER_ERROR_LOCKED_DOWN, GSM_MANAGER_DBUS_IFACE ".LockedDown" }
};
GQuark
gsm_manager_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0) {
ret = g_quark_from_static_string ("gsm_manager_error");
}
return ret;
}
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
GType
gsm_manager_error_get_type (void)
{
static GType etype = 0;
static volatile gsize quark_volatile = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (GSM_MANAGER_ERROR_GENERAL, "GeneralError"),
ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, "NotInInitialization"),
ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_RUNNING, "NotInRunning"),
ENUM_ENTRY (GSM_MANAGER_ERROR_ALREADY_REGISTERED, "AlreadyRegistered"),
ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_REGISTERED, "NotRegistered"),
ENUM_ENTRY (GSM_MANAGER_ERROR_INVALID_OPTION, "InvalidOption"),
ENUM_ENTRY (GSM_MANAGER_ERROR_LOCKED_DOWN, "LockedDown"),
{ 0, 0, 0 }
};
g_assert (GSM_MANAGER_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
etype = g_enum_register_static ("GsmManagerError", values);
}
return etype;
g_dbus_error_register_error_domain ("gsm_manager_error",
&quark_volatile,
gsm_manager_error_entries,
G_N_ELEMENTS (gsm_manager_error_entries));
return quark_volatile;
}
static gboolean
......@@ -1369,7 +1344,7 @@ start_phase (GsmManager *manager)
complete_end_session_tasks (manager);
g_object_unref (manager->priv->end_session_cancellable);
manager->priv->end_session_cancellable = g_cancellable_new ();
g_signal_emit (manager, signals[SESSION_RUNNING], 0);
gsm_exported_manager_emit_session_running (manager->priv->skeleton);
update_idle (manager);
break;
case GSM_MANAGER_PHASE_QUERY_END_SESSION:
......@@ -1452,6 +1427,8 @@ _gsm_manager_set_active_session (GsmManager *manager,
g_free (manager->priv->session_name);
manager->priv->session_name = g_strdup (session_name);
manager->priv->is_fallback_session = is_fallback;
gsm_exported_manager_set_session_name (manager->priv->skeleton, session_name);
}
static gboolean
......@@ -1720,135 +1697,6 @@ remove_clients_for_connection (GsmManager *manager,
}
}
static gboolean
inhibitor_has_bus_name (gpointer key,
GsmInhibitor *inhibitor,
RemoveClientData *data)
{
gboolean matches;
const char *bus_name_b;
bus_name_b = gsm_inhibitor_peek_bus_name (inhibitor);
matches = FALSE;
if (! IS_STRING_EMPTY (data->service_name) && ! IS_STRING_EMPTY (bus_name_b)) {
matches = (strcmp (data->service_name, bus_name_b) == 0);
if (matches) {
g_debug ("GsmManager: removing inhibitor from %s for reason '%s' on connection %s",
gsm_inhibitor_peek_app_id (inhibitor),
gsm_inhibitor_peek_reason (inhibitor),
gsm_inhibitor_peek_bus_name (inhibitor));
}
}
return matches;
}
static void
remove_inhibitors_for_connection (GsmManager *manager,
const char *service_name)
{
RemoveClientData data;
guint count;
data.service_name = service_name;
data.manager = manager;
debug_inhibitors (manager);
count = gsm_store_foreach_remove (manager->priv->inhibitors,
(GsmStoreFunc)inhibitor_has_bus_name,
&data);
if (count > 0 &&
manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
end_session_or_show_shell_dialog (manager);
}
}
static void
bus_name_owner_changed (DBusGProxy *bus_proxy,
const char *service_name,
const char *old_service_name,
const char *new_service_name,
GsmManager *manager)
{
if (strlen (new_service_name) == 0
&& strlen (old_service_name) > 0) {
/* service removed */
remove_inhibitors_for_connection (manager, old_service_name);
remove_clients_for_connection (manager, old_service_name);
} else if (strlen (old_service_name) == 0
&& strlen (new_service_name) > 0) {
/* service added */
/* use this if we support automatically registering
* well known bus names */
}
}
static DBusHandlerResult
gsm_manager_bus_filter (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
GsmManager *manager;
manager = GSM_MANAGER (user_data);
if (dbus_message_is_signal (message,
DBUS_INTERFACE_LOCAL, "Disconnected") &&
strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) {
g_debug ("GsmManager: dbus disconnected; disconnecting dbus clients...");
manager->priv->dbus_disconnected = TRUE;
remove_clients_for_connection (manager, NULL);
/* let other filters get this disconnected signal, so that they
* can handle it too */
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static gboolean
register_manager (GsmManager *manager)
{
GError *error = NULL;
DBusConnection *connection;
manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (manager->priv->connection == NULL) {
if (error != NULL) {
g_critical ("error getting session bus: %s", error->message);
g_error_free (error);
}
exit (1);
}
connection = dbus_g_connection_get_connection (manager->priv->connection);
dbus_connection_add_filter (connection,
gsm_manager_bus_filter,
manager, NULL);
manager->priv->dbus_disconnected = FALSE;
manager->priv->bus_proxy = dbus_g_proxy_new_for_name (manager->priv->connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
dbus_g_proxy_add_signal (manager->priv->bus_proxy,
"NameOwnerChanged",
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (manager->priv->bus_proxy,
"NameOwnerChanged",
G_CALLBACK (bus_name_owner_changed),
manager,
NULL);
dbus_g_connection_register_g_object (manager->priv->connection, GSM_MANAGER_DBUS_PATH, G_OBJECT (manager));
return TRUE;
}
static void
gsm_manager_set_failsafe (GsmManager *manager,
gboolean enabled)
......@@ -2151,7 +1999,7 @@ on_store_client_added (GsmStore *store,
G_CALLBACK (on_client_end_session_response),
manager);
g_signal_emit (manager, signals [CLIENT_ADDED], 0, id);
gsm_exported_manager_emit_client_added (manager->priv->skeleton, id);
/* FIXME: disconnect signal handler */
}
......@@ -2162,7 +2010,7 @@ on_store_client_removed (GsmStore *store,
{
g_debug ("GsmManager: Client removed: %s", id);
g_signal_emit (manager, signals [CLIENT_REMOVED], 0, id);
gsm_exported_manager_emit_client_removed (manager->priv->skeleton, id);
}
static void
......@@ -2248,21 +2096,12 @@ gsm_manager_get_property (GObject *object,
case PROP_FAILSAFE:
g_value_set_boolean (value, self->priv->failsafe);
break;
case PROP_SESSION_NAME:
g_value_set_string (value, self->priv->session_name);
break;
case PROP_SESSION_IS_ACTIVE:
g_value_set_boolean (value, gsm_system_is_active (self->priv->system));
break;
case PROP_FALLBACK:
g_value_set_boolean (value, self->priv->is_fallback_session);
break;
case PROP_CLIENT_STORE:
g_value_set_object (value, self->priv->clients);
break;
case PROP_INHIBITED_ACTIONS:
g_value_set_uint (value, self->priv->inhibited_actions);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -2294,49 +2133,12 @@ static void
update_inhibited_actions (GsmManager *manager,
GsmInhibitorFlag new_inhibited_actions)
{
DBusGConnection *gconnection;
DBusConnection *connection;
DBusMessage *message;
DBusMessageIter iter;
DBusMessageIter subiter;
DBusMessageIter dict_iter;
DBusMessageIter v_iter;
const char *iface_name = GSM_MANAGER_DBUS_NAME;
const char *prop_name = "InhibitedActions";
if (manager->priv->inhibited_actions == new_inhibited_actions)
return;
manager->priv->inhibited_actions = new_inhibited_actions;
g_object_notify (G_OBJECT (manager), "inhibited-actions");
/* Now, the following bits emit the PropertiesChanged signal
* that GDBus expects. This code should just die in a port to
* GDBus.
*/
gconnection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
g_assert (gconnection);
connection = dbus_g_connection_get_connection (gconnection);
message = dbus_message_new_signal (GSM_MANAGER_DBUS_PATH, "org.freedesktop.DBus.Properties",
"PropertiesChanged");
g_assert (message != NULL);
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &iface_name);
/* changed */
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}", &subiter);
dbus_message_iter_open_container (&subiter, DBUS_TYPE_DICT_ENTRY, NULL, &dict_iter);
dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &prop_name);
dbus_message_iter_open_container (&dict_iter, DBUS_TYPE_VARIANT, "u", &v_iter);
dbus_message_iter_append_basic (&v_iter, DBUS_TYPE_UINT32, &new_inhibited_actions);
dbus_message_iter_close_container (&dict_iter, &v_iter);
dbus_message_iter_close_container (&subiter, &dict_iter);
dbus_message_iter_close_container (&iter, &subiter);
/* invalidated */
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s", &subiter);
dbus_message_iter_close_container (&iter, &subiter);
dbus_connection_send (connection, message, NULL);
dbus_message_unref (message);
gsm_exported_manager_set_inhibited_actions (manager->priv->skeleton,
manager->priv->inhibited_actions);
}
static void
......@@ -2356,7 +2158,7 @@ on_store_inhibitor_added (GsmStore *store,
new_inhibited_actions = manager->priv->inhibited_actions | gsm_inhibitor_peek_flags (i);
update_inhibited_actions (manager, new_inhibited_actions);
g_signal_emit (manager, signals [INHIBITOR_ADDED], 0, id);
gsm_exported_manager_emit_inhibitor_added (manager->priv->skeleton, id);
update_idle (manager);
}
......@@ -2390,7 +2192,7 @@ on_store_inhibitor_removed (GsmStore *store,
&new_inhibited_actions);
update_inhibited_actions (manager, new_inhibited_actions);
g_signal_emit (manager, signals [INHIBITOR_REMOVED], 0, id);
gsm_exported_manager_emit_inhibitor_removed (manager->priv->skeleton, id);
update_idle (manager);
}
......@@ -2440,6 +2242,19 @@ gsm_manager_dispose (GObject *object)
g_clear_object (&manager->priv->system);
g_clear_object (&manager->priv->shell);
if (manager->priv->name_owner_id != 0) {
g_dbus_connection_signal_unsubscribe (manager->priv->connection, manager->priv->name_owner_id);;
manager->priv->name_owner_id = 0;
}
if (manager->priv->skeleton != NULL) {
g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (manager->priv->skeleton),
manager->priv->connection);
g_clear_object (&manager->priv->skeleton);
}
g_clear_object (&manager->priv->connection);
G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object);
}
......@@ -2462,56 +2277,6 @@ gsm_manager_class_init (GsmManagerClass *klass)
G_TYPE_NONE,
1, G_TYPE_STRING);
signals [SESSION_RUNNING] =
g_signal_new ("session-running",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, session_running),
NULL, NULL, NULL,
G_TYPE_NONE,
0);
signals [SESSION_OVER] =
g_signal_new ("session-over",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, session_over),
NULL, NULL, NULL,
G_TYPE_NONE,
0);
signals [CLIENT_ADDED] =
g_signal_new ("client-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, client_added),
NULL, NULL, NULL,
G_TYPE_NONE,
1, DBUS_TYPE_G_OBJECT_PATH);
signals [CLIENT_REMOVED] =
g_signal_new ("client-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, client_removed),
NULL, NULL, NULL,
G_TYPE_NONE,
1, DBUS_TYPE_G_OBJECT_PATH);
signals [INHIBITOR_ADDED] =
g_signal_new ("inhibitor-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, inhibitor_added),
NULL, NULL, NULL,
G_TYPE_NONE,
1, DBUS_TYPE_G_OBJECT_PATH);
signals [INHIBITOR_REMOVED] =
g_signal_new ("inhibitor-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GsmManagerClass, inhibitor_removed),
NULL, NULL, NULL,
G_TYPE_NONE,
1, DBUS_TYPE_G_OBJECT_PATH);
g_object_class_install_property (object_class,
PROP_FAILSAFE,
g_param_spec_boolean ("failsafe",
......@@ -2520,50 +2285,6 @@ gsm_manager_class_init (GsmManagerClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/**
* GsmManager::inhibited-actions
*
* A bitmask of flags to indicate which actions are inhibited. See the Inhibit()
* function's description for a list of possible values.
*/
g_object_class_install_property (object_class,
PROP_INHIBITED_ACTIONS,
g_param_spec_uint ("inhibited-actions",
NULL,
NULL,
0,
G_MAXUINT,
0,
G_PARAM_READABLE));
/**
* GsmManager::session-name
*
* Then name of the currently active session, typically "gnome" or "gnome-fallback".
* This may be the name of the configured default session, or the name of a fallback
* session in case we fell back.
*/
g_object_class_install_property (object_class,
PROP_SESSION_NAME,
g_param_spec_string ("session-name",
NULL,
NULL,
NULL,
G_PARAM_READABLE));
/**
* GsmManager::session-is-active
*
* If true, the current session is in the foreground and
* available for user input.
*/
g_object_class_install_property (object_class,
PROP_SESSION_IS_ACTIVE,
g_param_spec_boolean ("session-is-active",
NULL,
NULL,
TRUE,
G_PARAM_READABLE));
/**
* GsmManager::fallback
*
......@@ -2587,9 +2308,6 @@ gsm_manager_class_init (GsmManagerClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GsmManagerPrivate));
dbus_g_object_type_install_info (GSM_TYPE_MANAGER, &dbus_glib_gsm_manager_object_info);
dbus_g_error_domain_register (GSM_MANAGER_ERROR, NULL, GSM_MANAGER_TYPE_ERROR);
}
static void
......@@ -2610,159 +2328,177 @@ on_gsm_system_active_changed (GsmSystem *system,
GParamSpec *pspec,
GsmManager *self)
{
DBusGConnection *gconnection;
DBusConnection *connection;
DBusMessage *message;
DBusMessageIter iter;
DBusMessageIter subiter;
DBusMessageIter dict_iter;
DBusMessageIter v_iter;
dbus_bool_t is_active;
const char *iface_name = GSM_MANAGER_DBUS_NAME;
const char *prop_name = "SessionIsActive";
gboolean is_active;
g_object_notify ((GObject*)self, "session-is-active");
is_active = gsm_system_is_active (self->priv->system);
g_debug ("emitting SessionIsActive");
/* Now, the following bits emit the PropertiesChanged signal
* that GDBus expects. This code should just die in a port to
* GDBus.
*/
gconnection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
g_assert (gconnection);
connection = dbus_g_connection_get_connection (gconnection);
is_active = gsm_system_is_active (self->priv->system);
message = dbus_message_new_signal (GSM_MANAGER_DBUS_PATH, "org.freedesktop.DBus.Properties",
"PropertiesChanged");
g_assert (message != NULL);
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &iface_name);
/* changed */
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}", &subiter);
dbus_message_iter_open_container (&subiter, DBUS_TYPE_DICT_ENTRY, NULL, &dict_iter);
dbus_message_iter_append_basic (&dict_iter, DBUS_TYPE_STRING, &prop_name);
dbus_message_iter_open_container (&dict_iter, DBUS_TYPE_VARIANT, "b", &v_iter);
dbus_message_iter_append_basic (&v_iter, DBUS_TYPE_BOOLEAN, &is_active);
dbus_message_iter_close_container (&dict_iter, &v_iter);
dbus_message_iter_close_container (&subiter, &dict_iter);
dbus_message_iter_close_container (&iter, &subiter);
/* invalidated */
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s", &subiter);
dbus_message_iter_close_container (&iter, &subiter);
dbus_connection_send (connection, message, NULL);
dbus_message_unref (message);
gsm_exported_manager_set_session_is_active (self->priv->skeleton, is_active);
}
static gboolean
idle_timeout_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
_log_out_is_locked_down (GsmManager *manager)
{
guint32 idle_timeout;
idle_timeout = g_variant_get_uint32 (variant);
g_value_set_uint (value, idle_timeout * 1000);
return TRUE;
return g_settings_get_boolean (manager->priv->lockdown_settings,
KEY_DISABLE_LOG_OUT);
}
static void
gsm_manager_init (GsmManager *manager)
complete_end_session_task (GsmManager *manager,
GAsyncResult *result,
GDBusMethodInvocation *invocation)
{
GError *error = NULL;
manager->priv = GSM_MANAGER_GET_PRIVATE (manager);
if (!g_task_propagate_boolean (G_TASK (result), &error))
g_dbus_method_invocation_take_error (invocation, error);
else
g_dbus_method_invocation_return_value (invocation, NULL);
}
manager->priv->settings = g_settings_new (GSM_MANAGER_SCHEMA);
manager->priv->session_settings = g_settings_new (SESSION_SCHEMA);
manager->priv->screensaver_settings = g_settings_new (SCREENSAVER_SCHEMA);
manager->priv->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
static void
request_reboot (GsmManager *manager)
{
g_debug ("GsmManager: requesting reboot");
manager->priv->inhibitors = gsm_store_new ();
g_signal_connect (manager->priv->inhibitors,
"added",
G_CALLBACK (on_store_inhibitor_added),
manager);
g_signal_connect (manager->priv->inhibitors,
"removed",
G_CALLBACK (on_store_inhibitor_removed),
manager);
/* FIXME: We need to support a more structured shutdown here,
* but that's blocking on an improved ConsoleKit api.
*
* See https://bugzilla.gnome.org/show_bug.cgi?id=585614
*/
manager->priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT;
end_phase (manager);
}
manager->priv->apps = gsm_store_new ();
static void
request_shutdown (GsmManager *manager)
{
g_debug ("GsmManager: requesting shutdown");
manager->priv->presence = gsm_presence_new ();
g_signal_connect (manager->priv->presence,
"status-changed",
G_CALLBACK (on_presence_status_changed),
manager);
/* See the comment in request_reboot() for some more details about
* what work needs to be done here. */
manager->priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT;
end_phase (manager);
}
g_settings_bind_with_mapping (manager->priv->session_settings,
KEY_IDLE_DELAY,
manager->priv->presence,
"idle-timeout",
G_SETTINGS_BIND_GET,
idle_timeout_get_mapping,
NULL,
NULL, NULL);
static void
request_logout (GsmManager *manager,
GsmManagerLogoutMode mode)
{
g_debug ("GsmManager: requesting logout");
manager->priv->system = gsm_get_system ();
g_signal_connect (manager->priv->system, "notify::active",
G_CALLBACK (on_gsm_system_active_changed), manager);
manager->priv->logout_mode = mode;
manager->priv->logout_type = GSM_MANAGER_LOGOUT_LOGOUT;
manager->priv->shell = gsm_get_shell ();
manager->priv->end_session_cancellable = g_cancellable_new ();
end_phase (manager);
}
GsmManager *
gsm_manager_get (void)
{
return manager_object;
static gboolean
gsm_manager_shutdown (GsmExportedManager *skeleton,
GDBusMethodInvocation *invocation,
GsmManager *manager)
{
GTask *task;
g_debug ("GsmManager: Shutdown called");
if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) {
g_dbus_method_invocation_return_error (invocation,
GSM_MANAGER_ERROR,
GSM_MANAGER_ERROR_NOT_IN_RUNNING,
"Shutdown interface is only available during the Running phase");
return TRUE;
}
if (_log_out_is_locked_down (manager)) {
g_dbus_method_invocation_return_error (invocation,
GSM_MANAGER_ERROR,
GSM_MANAGER_ERROR_LOCKED_DOWN,
"Logout has been locked down");
return TRUE;
}
task = g_task_new (manager, manager->priv->end_session_cancellable, (GAsyncReadyCallback) complete_end_session_task, invocation);
manager->priv->pending_end_session_tasks = g_slist_prepend (manager->priv->pending_end_session_tasks,