From 7636e191ecf68f41ef28ae5e8811467e993aa108 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Feb 2010 16:55:45 -0600 Subject: Changed names to patch current upower --- src/session-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 9fb9ee7..289bff8 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -226,7 +226,7 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) G_TYPE_STRING, UP_INTERFACE, G_TYPE_STRING, - "can-suspend", + "CanSuspend", G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); @@ -242,7 +242,7 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) G_TYPE_STRING, UP_INTERFACE, G_TYPE_STRING, - "can-hibernate", + "CanHibernate", G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); -- cgit v1.2.3 From 02ab93a720729796e63b66a521edd647c26182cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Feb 2010 11:26:24 -0600 Subject: Adding a fallback for now gnome-session detected. --- src/gtk-dialog/gtk-logout-helper.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index d8aea6b..29f0add 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -29,6 +29,33 @@ with this program. If not, see . #include "ck-pk-helper.h" #include "gconf-helper.h" +static void +consolekit_fallback (LogoutDialogAction action) +{ + DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + g_return_if_fail(sbus != NULL); /* worst case */ + DBusGProxy * proxy = dbus_g_proxy_new_for_name(sbus, "org.freedesktop.ConsoleKit", + "/org/freedesktop/ConsoleKit/Manager", + "org.freedesktop.ConsoleKit.Manager"); + + if (proxy == NULL) { + g_warning("Unable to get consolekit proxy"); + return; + } + + switch (action) { + case LOGOUT_DIALOG_LOGOUT: { + g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); + break; + } + default: + g_warning("Unknown action"); + break; + } + + g_object_unref(proxy); +} + static void session_action (LogoutDialogAction action) { @@ -50,6 +77,8 @@ session_action (LogoutDialogAction action) if (sm_proxy == NULL) { g_warning("Unable to get DBus proxy to SessionManager interface: %s", error->message); g_error_free(error); + + consolekit_fallback(action); return; } -- cgit v1.2.3 From 8985b002f45ca55cabf32225c7a483ea36905c86 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Feb 2010 11:39:50 -0600 Subject: Adding in shutdown and restart --- src/gtk-dialog/gtk-logout-helper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 29f0add..4c6614c 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -44,16 +44,27 @@ consolekit_fallback (LogoutDialogAction action) } switch (action) { - case LOGOUT_DIALOG_LOGOUT: { + case LOGOUT_DIALOG_LOGOUT: g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); break; - } + case LOGOUT_DIALOG_SHUTDOWN: + dbus_g_proxy_call_no_reply(proxy, + "Stop", + G_TYPE_INVALID); + break; + case LOGOUT_DIALOG_RESTART: + dbus_g_proxy_call_no_reply(proxy, + "Restart", + G_TYPE_INVALID); + break; default: g_warning("Unknown action"); break; } g_object_unref(proxy); + + return; } static void -- cgit v1.2.3 From 148dffa32c100904f9e58afce26f9b75f45bb2ae Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 25 Feb 2010 10:26:23 -0600 Subject: Don't set the gdk decorations. --- src/gtk-dialog/logout-dialog.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gtk-dialog/logout-dialog.c b/src/gtk-dialog/logout-dialog.c index 65df9fe..98806ca 100644 --- a/src/gtk-dialog/logout-dialog.c +++ b/src/gtk-dialog/logout-dialog.c @@ -278,7 +278,6 @@ logout_dialog_init (LogoutDialog *logout_dialog) gtk_widget_realize(GTK_WIDGET(logout_dialog)); /* remove superfluous window buttons */ gdk_window_set_functions (GTK_WIDGET(logout_dialog)->window, 0); - gdk_window_set_decorations (GTK_WIDGET(logout_dialog)->window, GDK_DECOR_BORDER | GDK_DECOR_TITLE); /* center window */ gtk_window_set_position (GTK_WINDOW(logout_dialog), GTK_WIN_POS_CENTER); -- cgit v1.2.3 From ab02e295a6e21e1acb577516f0796d0ff4cc7092 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 25 Feb 2010 11:54:38 -0600 Subject: 0.2.4 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 221da2c..b3bfd8b 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.2.3) +AM_INIT_AUTOMAKE(indicator-session, 0.2.4) AM_MAINTAINER_MODE -- cgit v1.2.3 From 8689698b0545046a871730b24ad0eef6414dd990 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 25 Feb 2010 16:38:38 -0600 Subject: Switching to getting a reply --- src/gtk-dialog/gtk-logout-helper.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 4c6614c..7973bfc 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -29,6 +29,15 @@ with this program. If not, see . #include "ck-pk-helper.h" #include "gconf-helper.h" +static void +console_kit_action_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + g_return_if_fail(DBUS_IS_G_PROXY(proxy)); + g_return_if_fail(call != NULL); + + +} + static void consolekit_fallback (LogoutDialogAction action) { @@ -48,14 +57,20 @@ consolekit_fallback (LogoutDialogAction action) g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); break; case LOGOUT_DIALOG_SHUTDOWN: - dbus_g_proxy_call_no_reply(proxy, - "Stop", - G_TYPE_INVALID); + dbus_g_proxy_begin_call(proxy, + "Stop", + console_kit_action_cb, + NULL, /* data */ + NULL, /* destroy notifier */ + G_TYPE_INVALID); break; case LOGOUT_DIALOG_RESTART: - dbus_g_proxy_call_no_reply(proxy, - "Restart", - G_TYPE_INVALID); + dbus_g_proxy_begin_call(proxy, + "Restart", + console_kit_action_cb, + NULL, /* data */ + NULL, /* destroy notifier */ + G_TYPE_INVALID); break; default: g_warning("Unknown action"); -- cgit v1.2.3 From d605a1086d9fd4ca887c42c237aec5c246cda749 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 25 Feb 2010 16:42:30 -0600 Subject: can't really use async as we dont' have a mainloop here --- src/gtk-dialog/gtk-logout-helper.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 7973bfc..c8635e6 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -29,15 +29,6 @@ with this program. If not, see . #include "ck-pk-helper.h" #include "gconf-helper.h" -static void -console_kit_action_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) -{ - g_return_if_fail(DBUS_IS_G_PROXY(proxy)); - g_return_if_fail(call != NULL); - - -} - static void consolekit_fallback (LogoutDialogAction action) { @@ -52,25 +43,23 @@ consolekit_fallback (LogoutDialogAction action) return; } + GError * error = NULL; + switch (action) { case LOGOUT_DIALOG_LOGOUT: g_warning("Unable to fallback to ConsoleKit for logout as it's a session issue. We need some sort of session handler."); break; case LOGOUT_DIALOG_SHUTDOWN: - dbus_g_proxy_begin_call(proxy, - "Stop", - console_kit_action_cb, - NULL, /* data */ - NULL, /* destroy notifier */ - G_TYPE_INVALID); + dbus_g_proxy_call(proxy, + "Stop", + &error, + G_TYPE_INVALID); break; case LOGOUT_DIALOG_RESTART: - dbus_g_proxy_begin_call(proxy, - "Restart", - console_kit_action_cb, - NULL, /* data */ - NULL, /* destroy notifier */ - G_TYPE_INVALID); + dbus_g_proxy_call(proxy, + "Restart", + &error, + G_TYPE_INVALID); break; default: g_warning("Unknown action"); @@ -79,6 +68,11 @@ consolekit_fallback (LogoutDialogAction action) g_object_unref(proxy); + if (error != NULL) { + g_error("Unable to signal ConsoleKit: %s", error->message); + g_error_free(error); + } + return; } -- cgit v1.2.3 From 1513ca78e4685f50051c37efcece4511347fc2f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 1 Mar 2010 21:29:52 -0600 Subject: Stealing the consolekit manager interface out of consolekit --- .bzrignore | 1 + src/Makefile.am | 8 + src/consolekit-manager.xml | 353 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 src/consolekit-manager.xml diff --git a/.bzrignore b/.bzrignore index 0a49cb4..c993ea1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -54,3 +54,4 @@ indicator-session-[0-9].[0-9].[0-9].tar.gz indicator-session-[0-9].[0-9].tar.gz indicator-session-[0-9].[0-9].[0-9].tar.gz.asc indicator-session-[0-9].[0-9].tar.gz.asc +src/consolekit-manager-client.h diff --git a/src/Makefile.am b/src/Makefile.am index fdbf466..a07c782 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,6 +17,12 @@ libsession_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror libsession_la_LIBADD = $(APPLET_LIBS) libsession_la_LDFLAGS = -module -avoid-version +consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml + dbus-binding-tool \ + --prefix=_consolekit_manager_client \ + --mode=glib-client \ + --output=consolekit-manager-client.h \ + $(srcdir)/consolekit-manager.xml users-service-client.h: $(srcdir)/users-service.xml dbus-binding-tool \ @@ -56,11 +62,13 @@ indicator_session_service_LDADD = $(SESSIONSERVICE_LIBS) $(GCONF_LIBS) ############### BUILT_SOURCES = \ + consolekit-manager-client.h \ users-service-client.h \ users-service-marshal.h \ users-service-marshal.c EXTRA_DIST = \ + consolekit-manager.xml \ users-service.xml \ users-service.list diff --git a/src/consolekit-manager.xml b/src/consolekit-manager.xml new file mode 100644 index 0000000..f903b55 --- /dev/null +++ b/src/consolekit-manager.xml @@ -0,0 +1,353 @@ + + + + + + + + + This method initiates a request to restart (ie. reboot) the computer system. + + + + + + + + + + + + + + This method initiates a request to stop (ie. shutdown) the computer system. + + + + + + + + + + + + + + The secret cookie that is used to identify the new session + + + + + This method requests that a new Session + be created for the calling process. The properties of this new Session are set automatically + from information collected about the calling process. + + This new session exists until the calling process disconnects from the system bus or + calls CloseSession(). + + It is the responsibility of the calling process to set the environment variable + XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only + be made available to child processes of the caller so that they may be identified + as members of this session. + + See this simple example: + + DBusError error; + DBusMessage *message; + DBusMessage *reply; + + message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", + "/org/freedesktop/ConsoleKit/Manager", + "org.freedesktop.ConsoleKit.Manager", + "OpenSession"); + if (message == NULL) { + goto out; + } + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connector->connection, + message, + -1, + &error); + if (reply == NULL) { + goto out; + } + + dbus_error_init (&error); + if (! dbus_message_get_args (reply, + &error, + DBUS_TYPE_STRING, &cookie, + DBUS_TYPE_INVALID)) { + goto out; + } + + + + OpenSessionWithParameters() + + + + + + + An array of sets of property names and values + + + + + The secret cookie that is used to identify the new session + + + + + This method requests that a new Session + be created for the calling process. The properties of this new Session are from the + parameters provided. + + This new session exists until the calling process disconnects from the system bus or + calls CloseSession(). + + It is the responsibility of the calling process to set the environment variable + XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only + be made available to child processes of the caller so that they may be identified + as members of this session. + + See the Session properties for a list of valid parameters. + + org.freedesktop.ConsoleKit.Session + This method is restricted to privileged users by D-Bus policy. + + + + + + + The secret cookie that is used to identify the session + + + + + Whether the session was successfully closed + + + + + This method is used to close the session identified by the supplied cookie. + + The session can only be closed by the same process that opened the session. + + + + + + + + + an array of Seat IDs + + + + + This gets a list of all the Seats + that are currently present on the system. + Each Seat ID is an D-Bus object path for the object that implements the + Seat interface. + + org.freedesktop.ConsoleKit.Seat + + + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently present on the system. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + org.freedesktop.ConsoleKit.Session + + + + + + + + The secret cookie that is used to identify the session + + + + + The object identifier for the current session + + + + + Returns the session ID that is associated with the specified cookie. + + + + + + + + + The POSIX process ID + + + + + The object identifier for the current session + + + + + Attempts to determine the session ID for the specified + POSIX process ID (pid). + + + + + + + + + The object identifier for the current session + + + + + Attempts to determine the session ID that the caller belongs to. + + See this example of using dbus-send: + + dbus-send --system --dest=org.freedesktop.ConsoleKit \ + --type=method_call --print-reply --reply-timeout=2000 \ + /org/freedesktop/ConsoleKit/Manager \ + org.freedesktop.ConsoleKit.Manager.GetCurrentSession + + + + + + + + + POSIX User identification + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently open for the specified user. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + User identification + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently open for the specified user. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + + The value of the system-idle-hint + + + + + Returns TRUE if the idle-hint + property of every open session is TRUE or if there are no open sessions. + + + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time of the last change of the system-idle-hint. + + + + + + + + + The Seat ID for the added seat + + + + + Emitted when a Seat has been added to the system. + + + + + + + + The Seat ID for the removed seat + + + + + Emitted when a Seat has been removed from the system. + + + + + + + + The value of the system-idle-hint + + + + + Emitted when the value of the system-idle-hint has changed. + + + + + + -- cgit v1.2.3 From bb12842de3558842bacbc9bafcff40490a8bc409 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 1 Mar 2010 21:34:08 -0600 Subject: Switching to using the dbus client code. --- src/users-service-dbus.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 0e5c922..2b984cd 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -34,6 +34,7 @@ #include "users-service-dbus.h" #include "users-service-client.h" #include "users-service-marshal.h" +#include "consolekit-manager-client.h" static void users_service_dbus_class_init (UsersServiceDbusClass *klass); static void users_service_dbus_init (UsersServiceDbus *self); @@ -509,14 +510,7 @@ add_sessions_for_user (UsersServiceDbus *self, int i; error = NULL; - if (!dbus_g_proxy_call (priv->ck_proxy, - "GetSessionsForUnixUser", - &error, - G_TYPE_UINT, user->uid, - G_TYPE_INVALID, - dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), - &sessions, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Manager_get_sessions_for_unix_user(priv->ck_proxy, user->uid, &sessions, &error)) { g_debug ("Failed to call GetSessionsForUnixUser: %s", error->message); g_error_free (error); -- cgit v1.2.3