From 25abede4d0251f965b5f8b879d26c86129a11453 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Aug 2011 13:48:51 +0100 Subject: put guest item in place and fixed ticked icon on user menu --- src/udev-mgr.c | 6 ++-- src/user-menu-mgr.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/user-widget.c | 26 +++++++++-------- 3 files changed, 96 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/udev-mgr.c b/src/udev-mgr.c index e3328ec..f66d862 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -254,7 +254,7 @@ debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) { - const gchar* vendor; + /*const gchar* vendor; const gchar* product; const gchar* number; const gchar* name; @@ -269,7 +269,7 @@ debug_device (UdevMgr* self, g_strdup(product), g_strdup(number), g_strdup(name)); - + const gchar *const *list; const gchar *const *iter; char propstr[500]; @@ -290,7 +290,7 @@ debug_device (UdevMgr* self, strcat(propstr, " "); strcat(propstr, g_udev_device_get_property(device, *iter)); g_debug("%s", propstr); - } + }*/ } static void udev_mgr_handle_scsi_device (UdevMgr* self, diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index bf3b77f..6f9f53a 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -26,9 +26,12 @@ with this program. If not, see . #include "lock-helper.h" #include "users-service-dbus.h" +#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" + static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; + struct _UserMenuMgr { GObject parent_instance; @@ -56,6 +59,11 @@ static void user_change (UsersServiceDbus *service, gpointer user_data); static void ensure_gconf_client (); +static gboolean check_guest_session (void); +static void activate_guest_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); + G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); @@ -121,6 +129,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) /* Build all of the user switching items */ if (can_activate == TRUE) { + if (check_new_session ()){ switch_menuitem = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (switch_menuitem, @@ -134,8 +143,33 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), self->users_dbus_interface); + } + + if (check_guest_session ()) + { + g_debug ("ADDING GUEST SESSION"); + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (guest_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, + USER_ITEM_PROP_NAME, + _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + FALSE); + dbusmenu_menuitem_child_append (self->root_item, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_guest_session), + self); + users_service_dbus_set_guest_item (self->users_dbus_interface, + guest_mi); } - + else{ + g_debug ("NOT ADDING GUEST SESSION"); + } + GList * users = NULL; users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); @@ -193,7 +227,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, - user->sessions != NULL); + /*user->sessions != NULL*/FALSE); if (user->icon_file != NULL && user->icon_file[0] != '\0') { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); } else { @@ -354,6 +388,49 @@ user_mgr_get_root_item (UserMenuMgr* self) return self->root_item; } +/* Checks to see if we should show the guest suession item */ +static gboolean +check_guest_session (void) +{ + if (geteuid() < 500) { + /* System users shouldn't have guest account shown. Mosly + this would be the case of the guest user itself. */ + return FALSE; + } + if (!g_file_test(GUEST_SESSION_LAUNCHER, G_FILE_TEST_IS_EXECUTABLE)) { + /* It doesn't appear that the Guest session stuff is + installed. So let's not use it then! */ + return FALSE; + } + + return TRUE; +} + +/* Called when someone clicks on the guest session item. */ +static void +activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + GError * error = NULL; + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + if (dbusmenu_menuitem_property_get_bool(mi, USER_ITEM_PROP_LOGGED_IN)) { + if (users_service_dbus_activate_guest_session(service)) { + return; + } + g_warning("Unable to activate guest session, falling back to command line activation."); + } + + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER " --no-lock", &error)) { + g_warning("Unable to start guest session: %s", error->message); + g_error_free(error); + } + + return; +} + /* * Clean Entry Point diff --git a/src/user-widget.c b/src/user-widget.c index 9b046c5..6495e80 100644 --- a/src/user-widget.c +++ b/src/user-widget.c @@ -126,8 +126,6 @@ user_widget_init (UserWidget *self) priv->user_name = gtk_label_new (""); priv->container = gtk_hbox_new (FALSE, 0); - // TODO: - // Delete tick icon and draw primitively. priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", GTK_ICON_SIZE_MENU); gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); @@ -151,6 +149,10 @@ user_widget_init (UserWidget *self) gtk_widget_show_all (priv->container); gtk_container_add (GTK_CONTAINER (self), priv->container); + gtk_widget_show_all (priv->tick_icon); + gtk_widget_set_no_show_all (priv->tick_icon, TRUE); + gtk_widget_hide (priv->tick_icon); + // Fetch the drawing context. #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_after (GTK_WIDGET(self), "draw", @@ -178,11 +180,6 @@ user_widget_finalize (GObject *object) G_OBJECT_CLASS (user_widget_parent_class)->finalize (object); } -/** - * We override the expose method to enable primitive drawing of the - * empty album art image and rounded rectangles on the album art. - */ - #if GTK_CHECK_VERSION(3, 0, 0) // Draw the radio dot and/or green check mark @@ -317,11 +314,16 @@ user_widget_set_twin_item (UserWidget* self, gtk_label_set_label (GTK_LABEL (priv->user_name), dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); - //if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { - // gtk_widget_show(priv->tick_icon); - //} else { - gtk_widget_show(priv->tick_icon); - //} + if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { + g_debug ("%s USER HAS ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_show(priv->tick_icon); + } + else { + g_debug ("%s USER DOESN'T HAVE ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_hide(priv->tick_icon); + } g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(twin_item, USER_ITEM_PROP_NAME), icon_name); -- cgit v1.2.3 From ce792a6c67408779b7741194a8aa19caa86e0ef8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Aug 2011 18:41:49 +0100 Subject: added some trace to the add sessions for user method --- src/users-service-dbus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 83edaa3..07de28e 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -556,7 +556,11 @@ static void add_sessions_for_user (UsersServiceDbus *self, UserData *user) { - g_return_if_fail(IS_USERS_SERVICE_DBUS(self)); + g_return_if_fail (IS_USERS_SERVICE_DBUS(self)); + + g_debug ("!!!!!!!!!! - add_sessions_for_user %i %s", + (int)user->uid, user->user_name); + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error; GPtrArray *sessions; -- cgit v1.2.3 From 4e71b293536e2b3091d323bd92f24538bb41d1a9 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 17 Aug 2011 16:21:53 -0400 Subject: don't start/lock the screensaver from the login screen --- src/lock-helper.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index 9b15070..4c91aa5 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -20,12 +20,12 @@ with this program. If not, see . */ #include -#include +#include #include #include "lock-helper.h" -#define GCONF_DIR "/apps/gnome-screensaver" -#define GCONF_KEY GCONF_DIR "/lock_enabled" +#define SCREENSAVER_SCHEMA "org.gnome.desktop.screensaver" +#define SCREENSAVER_LOCK_ENABLED_KEY "lock-enabled" static DBusGProxy * gss_proxy = NULL; static GMainLoop * gss_mainloop = NULL; @@ -34,7 +34,7 @@ static DBusGProxyCall * cookie_call = NULL; static gboolean is_guest = FALSE; -static GConfClient * gconf_client = NULL; +static GSettings * settings = NULL; void build_gss_proxy (void); @@ -131,11 +131,11 @@ will_lock_screen (void) return FALSE; } - if (gconf_client == NULL) { - gconf_client = gconf_client_get_default(); + if (settings == NULL) { + settings = g_settings_new (SCREENSAVER_SCHEMA); } - return gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); + return g_settings_get_boolean (settings, SCREENSAVER_LOCK_ENABLED_KEY); } /* When the screensave go active, if we've got a mainloop @@ -150,11 +150,22 @@ gss_active_changed (DBusGProxy * proxy, gboolean active, gpointer data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /* Build the gss proxy and set up it's signals */ void build_gss_proxy (void) { if (gss_proxy == NULL) { + if (get_greeter_mode ()) + return; /* Don't start/lock the screensaver from the login screen */ + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_return_if_fail(session_bus != NULL); -- cgit v1.2.3 From f964233610d587af1ef67dd7fa5db84d7cc9ae3c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 15:53:51 -0500 Subject: Updated to DBus interface files currently in ConsoleKit and added the seat files as well --- src/Makefile.am | 21 +- src/consolekit-manager.xml | 353 ----------------------- src/consolekit-session.xml | 435 ----------------------------- src/org.freedesktop.ConsoleKit.Manager.xml | 353 +++++++++++++++++++++++ src/org.freedesktop.ConsoleKit.Seat.xml | 164 +++++++++++ src/org.freedesktop.ConsoleKit.Session.xml | 435 +++++++++++++++++++++++++++++ 6 files changed, 967 insertions(+), 794 deletions(-) delete mode 100644 src/consolekit-manager.xml delete mode 100644 src/consolekit-session.xml create mode 100644 src/org.freedesktop.ConsoleKit.Manager.xml create mode 100644 src/org.freedesktop.ConsoleKit.Seat.xml create mode 100644 src/org.freedesktop.ConsoleKit.Session.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 36a1d1f..3bfd790 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,19 +25,26 @@ libsession_la_CFLAGS = \ libsession_la_LIBADD = $(APPLET_LIBS) libsession_la_LDFLAGS = -module -avoid-version -consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml +consolekit-manager-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml dbus-binding-tool \ --prefix=_consolekit_manager_client \ --mode=glib-client \ --output=consolekit-manager-client.h \ - $(srcdir)/consolekit-manager.xml + $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml -consolekit-session-client.h: $(srcdir)/consolekit-session.xml +consolekit-seat-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + dbus-binding-tool \ + --prefix=_consolekit_seat_client \ + --mode=glib-client \ + --output=consolekit-seat-client.h \ + $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + +consolekit-session-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Session.xml dbus-binding-tool \ --prefix=_consolekit_session_client \ --mode=glib-client \ --output=consolekit-session-client.h \ - $(srcdir)/consolekit-session.xml + $(srcdir)/org.freedesktop.ConsoleKit.Session.xml display-manager-client.h: $(srcdir)/display-manager.xml dbus-binding-tool \ @@ -143,6 +150,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-seat-client.h \ consolekit-session-client.h \ display-manager-client.h \ gen-session-dbus.xml.c \ @@ -152,8 +160,9 @@ BUILT_SOURCES = \ accounts-service-user-client.h EXTRA_DIST = \ - consolekit-manager.xml \ - consolekit-session.xml \ + org.freedesktop.ConsoleKit.Manager.xml \ + org.freedesktop.ConsoleKit.Seat.xml \ + org.freedesktop.ConsoleKit.Session.xml \ display-manager.xml \ session-dbus.xml \ upower.xml \ diff --git a/src/consolekit-manager.xml b/src/consolekit-manager.xml deleted file mode 100644 index f903b55..0000000 --- a/src/consolekit-manager.xml +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - 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. - - - - - - diff --git a/src/consolekit-session.xml b/src/consolekit-session.xml deleted file mode 100644 index b6e1cdb..0000000 --- a/src/consolekit-session.xml +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - Session objects represent and store information - related to a user session. - - The properties associated with the Session - specifically refer to the properties of the "session leader". - - - - - - - Session ID - - - - Returns the ID for Session. - - - - - - - Seat ID - - - - Returns the ID for the Seat the Session is - attached to. - - org.freedesktop.ConsoleKit.Seat - - - - - - Session type - - - - - Returns the type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - session-type - - - - - - User ID - - - - Returns the user that the session belongs to. - - - user - - - - - - POSIX User ID - - - - Returns the POSIX user ID that the session belongs to. - - unix-user - - - - - - The value of the X11 display - - - - Returns the value of the X11 DISPLAY for this session - if one is present. - - x11-display - - - - - - The value of the X11 display device - - - - Returns the value of the display device (aka TTY) that the - X11 display for the session is connected to. If there is no x11-display set then this value - is undefined. - - x11-display-device - - - - - - The value of the display device - - - - Returns the value of the display device (aka TTY) that the - session is connected to. - - display-device - - - - - - The remote host name - - - - Returns the value of the remote host name for the session. - - - remote-host-name - - - - - - The value of the native system login session ID - - - - Returns the value of the login session ID that the - underlying system uses to enforce session boundaries. If there is no login session ID - set then this value is an empty string. - - - - - - - TRUE if the session is active, otherwise FALSE - - - - Returns whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - active - - - - - - TRUE if the session is local, otherwise FALSE - - - - Returns whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - is-local - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time that the session was opened. - - - - - - - - - - Attempt to activate the this session. In most - cases, if successful, this will cause the session to - become visible and become active on the seat that it - is attached to. - - Seat.ActivateSession() - - - - - - - This will cause a Lock - signal to be emitted for this session. - - - This method is restricted to privileged users by D-Bus policy. - Lock signal - - - - - - - This will cause an Unlock - signal to be emitted for this session. - - This can be used by login managers to unlock a session before it is - re-activated during fast-user-switching. - - - This method is restricted to privileged users by D-Bus policy. - Unlock signal - - - - - - - The value of the idle-hint - - - - - Gets the value of the idle-hint - property. - - - idle-hint - - - - - - 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 idle-hint. - - - - - - - - - boolean value to set the idle-hint to - - - - - This may be used by the session to indicate that - it is idle. - - Use of this method is restricted to the user - that owns the session. - - - - - - - - TRUE if the session is active, otherwise FALSE - - - - - Emitted when the active property has changed. - - - - - - - the new value of idle-hint - - - - - Emitted when the idle-hint property has changed. - - - - - - - Emitted in response to a call to the Lock() method. - It is intended that the screensaver for the session should lock the screen in response to this signal. - - - - - - - Emitted in response to a call to the Unlock() method. - It is intended that the screensaver for the session should unlock the screen in response to this signal. - - - - - - - - The user assigned to the session. - - - - - - - The user assigned to the session. - - - - - - - - The type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - - - - - - The remote host name for the session. - - This will be set in situations where the session is - opened and controlled from a remote system. - - For example, this value will be set when the - session is created from an SSH or XDMCP connection. - - - - - - - - The display device (aka TTY) that the - session is connected to. - - - - - - - - Value of the X11 DISPLAY for this session - if one is present. - - - - - - - - - The display device (aka TTY) that the X11 display for the - session is connected to. If there is no x11-display set then - this value is undefined. - - - - - - - - - Whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - - - - - - - Whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - - - - - - - This is a hint used to indicate that the session may be idle. - - - For sessions with a x11-display set (ie. graphical - sessions), it is up to each session to delegate the - responsibility for updating this value. Typically, the - screensaver will set this. - - However, for non-graphical sessions with a display-device set - the Session object itself will periodically update this value based - on the activity detected on the display-device itself. - - - This should not be considered authoritative. - - - - - - - diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml new file mode 100644 index 0000000..f903b55 --- /dev/null +++ b/src/org.freedesktop.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. + + + + + + diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml new file mode 100644 index 0000000..d95990b --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Seat.xml @@ -0,0 +1,164 @@ + + + + + + + A seat is a collection of sessions and a set of hardware (usually at +least a keyboard and mouse). Only one session may be active on a +seat at a time. + + + + + + + Seat ID + + + + + Returns the ID for Seat. + + + + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently attached to this seat. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + an array of devices + + + + + This gets a list of all the devices + that are currently associated with this seat. + Each device is an D-Bus structure that represents + the device type and the device id. + + + + + + + + + Session ID + + + + + Gets the Session ID that is currently active on this Seat. + Returns NULL if there is no active session. + + + + + + + + TRUE if seat supports session activation + + + + Used to determine whether the seat supports session activation. + + + + + + + + + Session ID + + + + + Attempt to activate the specified session. In most + cases, if successful, this will cause the session to + become visible and take control of the hardware that is + associated with this seat. + + Activate() + + + + + + + Session ID + + + + + Emitted when the active session has changed. + + + + + + + Session ID + + + + + Emitted when a session has been added to the seat. + + + + + + + Session ID + + + + + Emitted when a session has been removed from the seat. + + + + + + + Device structure + + + + + Emitted when a device has been associated with the seat. + + + + + + + Device structure + + + + + Emitted when a device has been dissociated from the seat. + + + + + diff --git a/src/org.freedesktop.ConsoleKit.Session.xml b/src/org.freedesktop.ConsoleKit.Session.xml new file mode 100644 index 0000000..b6e1cdb --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Session.xml @@ -0,0 +1,435 @@ + + + + + + + Session objects represent and store information + related to a user session. + + The properties associated with the Session + specifically refer to the properties of the "session leader". + + + + + + + Session ID + + + + Returns the ID for Session. + + + + + + + Seat ID + + + + Returns the ID for the Seat the Session is + attached to. + + org.freedesktop.ConsoleKit.Seat + + + + + + Session type + + + + + Returns the type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + session-type + + + + + + User ID + + + + Returns the user that the session belongs to. + + + user + + + + + + POSIX User ID + + + + Returns the POSIX user ID that the session belongs to. + + unix-user + + + + + + The value of the X11 display + + + + Returns the value of the X11 DISPLAY for this session + if one is present. + + x11-display + + + + + + The value of the X11 display device + + + + Returns the value of the display device (aka TTY) that the + X11 display for the session is connected to. If there is no x11-display set then this value + is undefined. + + x11-display-device + + + + + + The value of the display device + + + + Returns the value of the display device (aka TTY) that the + session is connected to. + + display-device + + + + + + The remote host name + + + + Returns the value of the remote host name for the session. + + + remote-host-name + + + + + + The value of the native system login session ID + + + + Returns the value of the login session ID that the + underlying system uses to enforce session boundaries. If there is no login session ID + set then this value is an empty string. + + + + + + + TRUE if the session is active, otherwise FALSE + + + + Returns whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + active + + + + + + TRUE if the session is local, otherwise FALSE + + + + Returns whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + is-local + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time that the session was opened. + + + + + + + + + + Attempt to activate the this session. In most + cases, if successful, this will cause the session to + become visible and become active on the seat that it + is attached to. + + Seat.ActivateSession() + + + + + + + This will cause a Lock + signal to be emitted for this session. + + + This method is restricted to privileged users by D-Bus policy. + Lock signal + + + + + + + This will cause an Unlock + signal to be emitted for this session. + + This can be used by login managers to unlock a session before it is + re-activated during fast-user-switching. + + + This method is restricted to privileged users by D-Bus policy. + Unlock signal + + + + + + + The value of the idle-hint + + + + + Gets the value of the idle-hint + property. + + + idle-hint + + + + + + 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 idle-hint. + + + + + + + + + boolean value to set the idle-hint to + + + + + This may be used by the session to indicate that + it is idle. + + Use of this method is restricted to the user + that owns the session. + + + + + + + + TRUE if the session is active, otherwise FALSE + + + + + Emitted when the active property has changed. + + + + + + + the new value of idle-hint + + + + + Emitted when the idle-hint property has changed. + + + + + + + Emitted in response to a call to the Lock() method. + It is intended that the screensaver for the session should lock the screen in response to this signal. + + + + + + + Emitted in response to a call to the Unlock() method. + It is intended that the screensaver for the session should unlock the screen in response to this signal. + + + + + + + + The user assigned to the session. + + + + + + + The user assigned to the session. + + + + + + + + The type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + + + + + + The remote host name for the session. + + This will be set in situations where the session is + opened and controlled from a remote system. + + For example, this value will be set when the + session is created from an SSH or XDMCP connection. + + + + + + + + The display device (aka TTY) that the + session is connected to. + + + + + + + + Value of the X11 DISPLAY for this session + if one is present. + + + + + + + + + The display device (aka TTY) that the X11 display for the + session is connected to. If there is no x11-display set then + this value is undefined. + + + + + + + + + Whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + + + + + + + Whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + + + + + + + This is a hint used to indicate that the session may be idle. + + + For sessions with a x11-display set (ie. graphical + sessions), it is up to each session to delegate the + responsibility for updating this value. Typically, the + screensaver will set this. + + However, for non-graphical sessions with a display-device set + the Session object itself will periodically update this value based + on the activity detected on the display-device itself. + + + This should not be considered authoritative. + + + + + + + -- cgit v1.2.3 From 381110b4d8fac1a5d557711c348bb3324624c9ae Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 15:59:40 -0500 Subject: After setting up the signals get the initial list of sessions --- src/users-service-dbus.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 83edaa3..f87d381 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -36,6 +36,7 @@ #include "accounts-service-client.h" #include "consolekit-manager-client.h" #include "consolekit-session-client.h" +#include "consolekit-seat-client.h" #define CK_ADDR "org.freedesktop.ConsoleKit" #define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" @@ -315,6 +316,23 @@ create_ck_proxy (UsersServiceDbus *self) } } +/* Get the initial sessions when starting up */ +static void +get_cksessions_cb (DBusGProxy *proxy, GPtrArray * sessions, GError * error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get initial sessions: %s", error->message); + return; + } + + int i; + for (i = 0; i < sessions->len; i++) { + seat_proxy_session_added(proxy, g_ptr_array_index(sessions, i), USERS_SERVICE_DBUS(userdata)); + } + + return; +} + static void create_seat_proxy (UsersServiceDbus *self) { @@ -363,6 +381,10 @@ create_seat_proxy (UsersServiceDbus *self) G_CALLBACK (seat_proxy_session_removed), self, NULL); + + org_freedesktop_ConsoleKit_Seat_get_sessions_async (priv->seat_proxy, get_cksessions_cb, self); + + return; } static void -- cgit v1.2.3 From c2266fe6e875f30b409b97755aeca512fc2be690 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 16:12:01 -0500 Subject: Debugging info and a protection --- src/users-service-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index f87d381..ec52771 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -325,6 +325,11 @@ get_cksessions_cb (DBusGProxy *proxy, GPtrArray * sessions, GError * error, gpoi return; } + /* If there's no error we should at least get an + array of zero entries */ + g_return_if_fail(sessions != NULL); + g_debug("Got %d initial sessions", sessions->len); + int i; for (i = 0; i < sessions->len; i++) { seat_proxy_session_added(proxy, g_ptr_array_index(sessions, i), USERS_SERVICE_DBUS(userdata)); -- cgit v1.2.3 From dce6ee5caccdf9f9683bad26d062671a889792ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 18 Aug 2011 12:45:50 +0100 Subject: greeter mode uses to flag whether we are showing the user menu or not --- src/session-service.c | 2 +- src/user-menu-mgr.c | 24 +++++++++++++----------- src/user-menu-mgr.h | 3 ++- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fa212fd..753e304 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -118,7 +118,7 @@ main (int argc, char ** argv) if (!greeter_mode) { // Users - UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus, greeter_mode); DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); } diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index f2757ad..72b5802 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -29,7 +29,6 @@ with this program. If not, see . static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; - struct _UserMenuMgr { GObject parent_instance; @@ -50,7 +49,8 @@ static gint compare_users_by_username (const gchar *a, static void activate_online_accounts (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data); -static void user_menu_mgr_rebuild_items (UserMenuMgr *self); +static void user_menu_mgr_rebuild_items (UserMenuMgr *self, + gboolean greeter_mode); static gboolean check_new_session (); static void user_change (UsersServiceDbus *service, const gchar *user_id, @@ -99,7 +99,7 @@ user_menu_mgr_class_init (UserMenuMgrClass *klass) /* Builds up the menu for us */ static void -user_menu_mgr_rebuild_items (UserMenuMgr *self) +user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) { DbusmenuMenuitem *mi = NULL; DbusmenuMenuitem *guest_mi = NULL; @@ -145,7 +145,6 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) if (check_guest_session ()) { - g_debug ("ADDING GUEST SESSION"); guest_mi = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, @@ -164,16 +163,19 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) users_service_dbus_set_guest_item (self->users_dbus_interface, guest_mi); } - else{ - g_debug ("NOT ADDING GUEST SESSION"); - } GList * users = NULL; users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); - g_debug ("USER COUNT = %i", self->user_count); - session_dbus_set_user_menu_visibility (self->session_dbus_interface, self->user_count > 1); + gboolean user_menu_is_visible = FALSE; + + if (!greeter_mode){ + user_menu_is_visible = self->user_count > 1; + } + + session_dbus_set_user_menu_visibility (self->session_dbus_interface, + user_menu_is_visible); if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { users = g_list_sort (users, (GCompareFunc)compare_users_by_username); @@ -418,11 +420,11 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da /* * Clean Entry Point */ -UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus) +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) { UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); user_mgr->session_dbus_interface = session_dbus; - user_menu_mgr_rebuild_items (user_mgr); + user_menu_mgr_rebuild_items (user_mgr, greeter_mode); return user_mgr; } diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h index ff2cb77..01823e7 100644 --- a/src/user-menu-mgr.h +++ b/src/user-menu-mgr.h @@ -45,7 +45,8 @@ struct _UserMenuMgrClass }; GType user_menu_mgr_get_type (void) G_GNUC_CONST; -UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus); +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, + gboolean greeter_mode); DbusmenuMenuitem* user_mgr_get_root_item (UserMenuMgr* self); G_END_DECLS -- cgit v1.2.3