aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog76
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--data/com.canonical.indicator.session.gschema.xml.in12
-rw-r--r--src/apt-transaction.c33
-rw-r--r--src/apt-watcher.c131
-rw-r--r--src/gtk-logout-helper.c23
-rw-r--r--src/indicator-session.c30
-rw-r--r--src/settings-helper.h15
-rw-r--r--src/user-menu-mgr.c41
-rw-r--r--src/users-service-dbus.c59
-rw-r--r--src/users-service-dbus.h2
12 files changed, 328 insertions, 98 deletions
diff --git a/ChangeLog b/ChangeLog
index a4f152f..539f720 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,81 @@
# Generated by Makefile. Do not edit.
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ bump for release
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ various switches for the strings on the panel and on the switch item
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ show/hide the name from the panel
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ user correct string on switch item unless user actually wants to show username
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ add the new gsettings entry for toggling the visibility of the real name on the panel
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ debugs for mystery bug
+
+2011-09-07 Ted Gould <ted@gould.cx>
+
+ Lots of debug messages for the logout helper
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ merge the display manager's has-guest-account work
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ tidy up
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ display manager HasGuestAccount now supported
+
+2011-09-08 Conor Curran <conor.curran@canonical.com>
+
+ merge the apt handling fixes
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ tidy up
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ more hoop jumping for apt
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ more hoop jumping for apt
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ more revelations with regards the behaviour of the apt dbus 'api'
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ refactor the apt state callback because the use case of real and simulation were proving far too disparate
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ another bug found within the apt-menuitem
+
+2011-09-07 Conor Curran <conor.curran@canonical.com>
+
+ merge null protection branch
+
+2011-09-05 Conor Curran <conor.curran@canonical.com>
+
+ protect against a null pointer in the user-dbus-manager
+
2011-09-06 Conor Curran <conor.curran@canonical.com>
bump version for release
diff --git a/configure b/configure
index 2a2e8b0..26210d8 100755
--- a/configure
+++ b/configure
@@ -2745,7 +2745,7 @@ fi
# Define the identity of the package.
PACKAGE=indicator-session
- VERSION=0.3.4.3
+ VERSION=0.3.5.0
cat >>confdefs.h <<_ACEOF
diff --git a/configure.ac b/configure.ac
index a89c30d..6efac90 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.3.4.3)
+AM_INIT_AUTOMAKE(indicator-session, 0.3.5.0)
AM_MAINTAINER_MODE
diff --git a/data/com.canonical.indicator.session.gschema.xml.in b/data/com.canonical.indicator.session.gschema.xml.in
index e0d14c3..0ef3d00 100644
--- a/data/com.canonical.indicator.session.gschema.xml.in
+++ b/data/com.canonical.indicator.session.gschema.xml.in
@@ -20,11 +20,23 @@
<_summary>Remove the shutdown item from the session menu</_summary>
<_description>Makes it so that the shutdown button doesn’t show in the session menu.</_description>
</key>
+ <key type="b" name="show-real-name-on-panel">
+ <default>true</default>
+ <summary>Determine the visibility of the User's real name on the panel</summary>
+ <description>Allow for the Removal of the users name from the panel</description>
+ </key>
<key type="b" name="user-show-menu">
<default>true</default>
<summary>Determine the visibility of the User Menu</summary>
<description>Allow for the user menu to be hidden by the user.</description>
</key>
+ <key type="b" name="use-username-in-switch-item">
+ <default>false</default>
+ <summary>Determine what string to use for the user's name in the switch menuitem.</summary>
+ <description>The switch menuitem as part of the user menu should be default have the label 'Switch User Account'.
+ This settings gives the user the potential to have the label read 'Switch from $username'</description>
+ </key>
+
</schema>
</schemalist>
diff --git a/src/apt-transaction.c b/src/apt-transaction.c
index cd9e131..317d74a 100644
--- a/src/apt-transaction.c
+++ b/src/apt-transaction.c
@@ -160,7 +160,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy,
AptTransaction* self = APT_TRANSACTION(user_data);
AptState current_state = DONT_KNOW;
- if (g_strcmp0(signal_name, "PropertyChanged") == 0 && self->type == SIMULATION)
+ if (g_strcmp0(signal_name, "PropertyChanged") == 0)
{
gchar* prop_name= NULL;
GVariant* value = NULL;
@@ -204,23 +204,22 @@ apt_transaction_receive_signal (GDBusProxy * proxy,
current_state = UP_TO_DATE;
}
}
- }
- else if (g_strcmp0(signal_name, "PropertyChanged") == 0 &&
- self->type == REAL)
- {
- GVariant* role = g_dbus_proxy_get_cached_property (self->proxy,
- "Role");
- if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){
- gchar* current_role = NULL;
- g_variant_get (role, "s", &current_role);
- //g_debug ("Current transaction role = %s", current_role);
- if (g_strcmp0 (current_role, "role-commit-packages") == 0 ||
- g_strcmp0 (current_role, "role-upgrade-system") == 0){
- g_debug ("UPGRADE IN PROGRESS");
- current_state = UPGRADE_IN_PROGRESS;
+ if (self->type == REAL)
+ {
+ GVariant* role = g_dbus_proxy_get_cached_property (self->proxy,
+ "Role");
+ if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){
+ gchar* current_role = NULL;
+ g_variant_get (role, "s", &current_role);
+ //g_debug ("Current transaction role = %s", current_role);
+ if (g_strcmp0 (current_role, "role-commit-packages") == 0 ||
+ g_strcmp0 (current_role, "role-upgrade-system") == 0){
+ g_debug ("UPGRADE IN PROGRESS");
+ current_state = UPGRADE_IN_PROGRESS;
+ }
}
- }
- }
+ }
+ }
else if (g_strcmp0(signal_name, "Finished") == 0)
{
g_debug ("TRANSACTION Finished");
diff --git a/src/apt-watcher.c b/src/apt-watcher.c
index 480e174..e5e1d0e 100644
--- a/src/apt-watcher.c
+++ b/src/apt-watcher.c
@@ -66,6 +66,13 @@ static void apt_watcher_signal_cb (GDBusProxy* proxy,
static void apt_watcher_manage_transactions (AptWatcher* self,
gchar* transaction_id);
static gboolean apt_watcher_query_reboot_status (gpointer self);
+static void apt_watcher_transaction_state_simulation_update_cb (AptTransaction* trans,
+ gint update,
+ gpointer user_data);
+static void apt_watcher_transaction_state_real_update_cb (AptTransaction* trans,
+ gint update,
+ gpointer user_data);
+
@@ -245,9 +252,9 @@ apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
}
static void
-apt_watcher_transaction_state_update_cb (AptTransaction* trans,
- gint update,
- gpointer user_data)
+apt_watcher_transaction_state_real_update_cb (AptTransaction* trans,
+ gint update,
+ gpointer user_data)
{
g_debug ("apt-watcher -transaction update %i", update);
g_return_if_fail (APT_IS_WATCHER (user_data));
@@ -259,64 +266,99 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans,
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
_("Software Up to Date"));
- // Simulations don't send a finished signal for some reason
- // Anyway from a simulation we just need one state update
- // (updates available or not)
- if (apt_transaction_get_transaction_type (self->current_transaction)
- == SIMULATION){
- g_object_unref (G_OBJECT(self->current_transaction));
- self->current_transaction = NULL;
- }
- if (self->reboot_query != 0){
- g_source_remove (self->reboot_query);
- self->reboot_query = 0;
- }
- // Wait a sec before querying for reboot status,
- // race condition with Apt has been observed.
- self->reboot_query = g_timeout_add_seconds (1,
- apt_watcher_query_reboot_status,
- self);
+ self->current_state = state;
}
else if (state == UPDATES_AVAILABLE){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
_("Updates Available…"));
- // Simulations don't send a finished signal for some reason
- // Anyway from a simulation we just need one state update
- // (updates available or not)
- if (apt_transaction_get_transaction_type (self->current_transaction)
- == SIMULATION){
- g_object_unref (G_OBJECT(self->current_transaction));
- self->current_transaction = NULL;
- }
+ self->current_state = state;
}
else if (state == UPGRADE_IN_PROGRESS){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
_("Updates Installing…"));
+ self->current_state = state;
}
else if (state == FINISHED){
+ gboolean query_again = FALSE;
+
+ // Only query if the previous state was an upgrade.
+ if (self->current_state == UPGRADE_IN_PROGRESS){
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+ // Wait a sec before querying for reboot status,
+ // race condition with Apt has been observed.
+ self->reboot_query = g_timeout_add_seconds (2,
+ apt_watcher_query_reboot_status,
+ self);
+ }
+ else{
+ query_again = TRUE;
+ }
+ self->current_state = state;
+
g_object_unref (G_OBJECT(self->current_transaction));
- self->current_transaction = NULL;
+ self->current_transaction = NULL;
+
+ // It is impossible to determine from a 'real' transaction whether
+ // updates are available ?
+ if (query_again){
+ g_dbus_proxy_call (self->proxy,
+ "UpgradeSystem",
+ g_variant_new("(b)", TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ apt_watcher_upgrade_system_cb,
+ self);
+ }
+ }
+}
- if (self->current_state == UPDATES_AVAILABLE){
- return;
- }
-
+
+static void
+apt_watcher_transaction_state_simulation_update_cb (AptTransaction* trans,
+ gint update,
+ gpointer user_data)
+{
+ g_debug ("apt-watcher -transaction update %i", update);
+ g_return_if_fail (APT_IS_WATCHER (user_data));
+ AptWatcher* self = APT_WATCHER (user_data);
+
+ AptState state = (AptState)update;
+
+ if (state == UP_TO_DATE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
if (self->reboot_query != 0){
g_source_remove (self->reboot_query);
self->reboot_query = 0;
}
- // Wait a sec before querying for reboot status,
- // race condition with Apt has been observed.
- self->reboot_query = g_timeout_add_seconds (1,
+ self->reboot_query = g_timeout_add_seconds (2,
apt_watcher_query_reboot_status,
self);
+ }
+ else if (state == UPDATES_AVAILABLE){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("Finished Updating…"));
+ _("Updates Available…"));
}
+ else if (state == UPGRADE_IN_PROGRESS){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Updates Installing…"));
+ }
+
self->current_state = state;
+
+ if (self->current_state != UPGRADE_IN_PROGRESS){
+ g_object_unref (G_OBJECT(self->current_transaction));
+ self->current_transaction = NULL;
+ }
}
static void
@@ -326,7 +368,7 @@ apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id)
self->current_transaction = apt_transaction_new (transaction_id, SIMULATION);
g_signal_connect (G_OBJECT(self->current_transaction),
"state-update",
- G_CALLBACK(apt_watcher_transaction_state_update_cb), self);
+ G_CALLBACK(apt_watcher_transaction_state_simulation_update_cb), self);
}
}
@@ -359,6 +401,7 @@ apt_watcher_query_reboot_status (gpointer data)
DBUSMENU_MENUITEM_PROP_DISPOSITION,
DBUSMENU_MENUITEM_DISPOSITION_ALERT);
session_dbus_restart_required (self->session_dbus_interface);
+ self->current_state = RESTART_NEEDED;
}
self->reboot_query = 0;
return FALSE;
@@ -380,11 +423,17 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy,
gchar* current = NULL;
g_debug ("ActiveTransactionsChanged");
- //gchar** queued = NULL;
g_variant_get(value, "s", &current);
+
if (g_str_has_prefix (current, "/org/debian/apt/transaction/") == TRUE){
g_debug ("ActiveTransactionsChanged - current is %s", current);
-
+
+ // Cancel all existing operations.
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+
if (self->current_transaction != NULL)
{
g_object_unref (G_OBJECT(self->current_transaction));
@@ -394,7 +443,7 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy,
self->current_transaction = apt_transaction_new (current, REAL);
g_signal_connect (G_OBJECT(self->current_transaction),
"state-update",
- G_CALLBACK(apt_watcher_transaction_state_update_cb), self);
+ G_CALLBACK(apt_watcher_transaction_state_real_update_cb), self);
}
}
g_variant_unref (parameters);
diff --git a/src/gtk-logout-helper.c b/src/gtk-logout-helper.c
index 33dce3a..9c1e6dd 100644
--- a/src/gtk-logout-helper.c
+++ b/src/gtk-logout-helper.c
@@ -31,6 +31,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
static void
consolekit_fallback (LogoutDialogType action)
{
+ g_debug("Falling back to using ConsoleKit for 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",
@@ -49,12 +51,14 @@ consolekit_fallback (LogoutDialogType 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_TYPE_SHUTDOWN:
+ g_debug("Telling ConsoleKit to 'Stop'");
dbus_g_proxy_call(proxy,
"Stop",
&error,
G_TYPE_INVALID);
break;
case LOGOUT_DIALOG_TYPE_RESTART:
+ g_debug("Telling ConsoleKit to 'Restart'");
dbus_g_proxy_call(proxy,
"Restart",
&error,
@@ -104,12 +108,15 @@ session_action (LogoutDialogType action)
g_clear_error (&error);
if (action == LOGOUT_DIALOG_TYPE_LOG_OUT) {
+ g_debug("Asking Session manager to 'Logout'");
res = dbus_g_proxy_call_with_timeout (sm_proxy, "Logout", INT_MAX, &error,
G_TYPE_UINT, 1, G_TYPE_INVALID, G_TYPE_INVALID);
} else if (action == LOGOUT_DIALOG_TYPE_SHUTDOWN) {
+ g_debug("Asking Session manager to 'RequestShutdown'");
res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestShutdown", INT_MAX, &error,
G_TYPE_INVALID, G_TYPE_INVALID);
} else if (action == LOGOUT_DIALOG_TYPE_RESTART) {
+ g_debug("Asking Session manager to 'RequestReboot'");
res = dbus_g_proxy_call_with_timeout (sm_proxy, "RequestReboot", INT_MAX, &error,
G_TYPE_INVALID, G_TYPE_INVALID);
} else {
@@ -122,6 +129,8 @@ session_action (LogoutDialogType action)
} else {
g_warning ("SessionManager action failed: unknown error");
}
+
+ consolekit_fallback(action);
}
g_object_unref(sm_proxy);
@@ -139,6 +148,7 @@ static gboolean
option_logout (const gchar * arg, const gchar * value, gpointer data, GError * error)
{
type = LOGOUT_DIALOG_TYPE_LOG_OUT;
+ g_debug("Dialog type: logout");
return TRUE;
}
@@ -146,6 +156,7 @@ static gboolean
option_shutdown (const gchar * arg, const gchar * value, gpointer data, GError * error)
{
type = LOGOUT_DIALOG_TYPE_SHUTDOWN;
+ g_debug("Dialog type: shutdown");
return TRUE;
}
@@ -153,6 +164,7 @@ static gboolean
option_restart (const gchar * arg, const gchar * value, gpointer data, GError * error)
{
type = LOGOUT_DIALOG_TYPE_RESTART;
+ g_debug("Dialog type: restart");
return TRUE;
}
@@ -193,6 +205,7 @@ main (int argc, char * argv[])
GtkWidget * dialog = NULL;
if (!supress_confirmations()) {
+ g_debug("Showing dialog to ask for user confirmation");
dialog = GTK_WIDGET(logout_dialog_new(type));
}
@@ -200,17 +213,27 @@ main (int argc, char * argv[])
GtkResponseType response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_hide(dialog);
+ if (response == GTK_RESPONSE_OK) {
+ g_debug("Dialog return response: 'okay'");
+ } else if (response == GTK_RESPONSE_HELP) {
+ g_debug("Dialog return response: 'help'");
+ } else {
+ g_debug("Dialog return response: %d", response);
+ }
+
if (response == GTK_RESPONSE_HELP) {
type = LOGOUT_DIALOG_TYPE_RESTART;
response = GTK_RESPONSE_OK;
}
if (response != GTK_RESPONSE_OK) {
+ g_debug("Final response was not okay, quiting");
return 0;
}
}
session_action(type);
+ g_debug("Finished action, quiting");
return 0;
}
diff --git a/src/indicator-session.c b/src/indicator-session.c
index 2f1764f..833d19b 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -507,11 +507,12 @@ receive_signal (GDBusProxy * proxy,
&self->users);
}
}
- else if (g_strcmp0(signal_name, "RestartRequired") == 0) {
+ else if (g_strcmp0(signal_name, "RestartRequired") == 0) {
if (greeter_mode == TRUE){
self->devices.image = indicator_image_helper (GREETER_ICON_RESTART);
}
else{
+ g_debug ("reboot required");
self->devices.image = indicator_image_helper (ICON_RESTART);
}
}
@@ -538,10 +539,16 @@ switch_property_change (DbusmenuMenuitem * item,
if (g_strcmp0(translate, "1") != 0) {
no_name_in_lang = TRUE;
}
+
+ GSettings* settings = g_settings_new ("com.canonical.indicator.session");
+ gboolean use_username = g_settings_get_boolean (settings,
+ "use-username-in-switch-item");
+ g_object_unref (settings);
if (variant == NULL || g_variant_get_string(variant, NULL) == NULL ||
- g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) {
- finalstring = _("Switch User…");
+ g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang
+ || use_username == FALSE) {
+ finalstring = _("Switch User Account…");
set_ellipsize = FALSE;
}
@@ -586,7 +593,6 @@ switch_property_change (DbusmenuMenuitem * item,
gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE);
}
}
-
return;
}
@@ -697,13 +703,21 @@ build_menu_switch (DbusmenuMenuitem * newitem,
static void
indicator_session_update_users_label (IndicatorSession* self,
const gchar* name)
-{
- g_debug ("update users label");
-
+{
if (name == NULL){
gtk_widget_hide(GTK_WIDGET(self->users.label));
return;
}
+
+ GSettings* settings = g_settings_new ("com.canonical.indicator.session");
+ gboolean use_name = g_settings_get_boolean (settings,
+ "show-real-name-on-panel");
+ g_object_unref (settings);
gtk_label_set_text (self->users.label, g_strdup(name));
- gtk_widget_show(GTK_WIDGET(self->users.label));
+ if (use_name){
+ gtk_widget_show(GTK_WIDGET(self->users.label));
+ }
+ else{
+ gtk_widget_hide(GTK_WIDGET(self->users.label));
+ }
}
diff --git a/src/settings-helper.h b/src/settings-helper.h
index ae57575..ea0c99f 100644
--- a/src/settings-helper.h
+++ b/src/settings-helper.h
@@ -21,7 +21,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __GCONF_HELPER_H__
-#define __GCONF_HELPER_H__ 1
+#define __GCONF_HELPER_H__
#include <glib/gi18n.h>
@@ -31,12 +31,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-glib/menuitem.h>
-#define SESSION_SCHEMA "com.canonical.indicator.session"
-#define SUPPRESS_KEY "suppress-logout-restart-shutdown"
-#define LOGOUT_KEY "suppress-logout-menuitem"
-#define RESTART_KEY "suppress-restart-menuitem"
-#define SHUTDOWN_KEY "suppress-shutdown-menuitem"
-#define SHOW_USER_MENU "user-show-menu"
+#define SESSION_SCHEMA "com.canonical.indicator.session"
+#define SUPPRESS_KEY "suppress-logout-restart-shutdown"
+#define LOGOUT_KEY "suppress-logout-menuitem"
+#define RESTART_KEY "suppress-restart-menuitem"
+#define SHUTDOWN_KEY "suppress-shutdown-menuitem"
+#define SHOW_USER_MENU "user-show-menu"
+#define USER_USERNAME_IN_SWITCH_ITEM "use-username-in-switch-item"
#define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown"
#define LOCKDOWN_KEY_USER "disable-user-switching"
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 16c6e3b..efb3f7d 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -65,6 +65,7 @@ static gboolean is_this_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);
@@ -129,6 +130,25 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
if (can_activate == TRUE)
{
+ gboolean guest_enabled = users_service_dbus_guest_session_enabled (self->users_dbus_interface);
+ GList * users = NULL;
+ users = users_service_dbus_get_user_list (self->users_dbus_interface);
+ self->user_count = g_list_length(users);
+
+ gboolean gsettings_user_menu_is_visible = should_show_user_menu();
+
+ if (gsettings_user_menu_is_visible == FALSE || greeter_mode == TRUE){
+ session_dbus_set_user_menu_visibility (self->session_dbus_interface,
+ FALSE);
+ }
+ else{
+ // This needs to be updated once the ability to query guest session support is available
+ session_dbus_set_user_menu_visibility (self->session_dbus_interface,
+ guest_enabled || self->user_count > 1);
+ }
+
+ // TODO we should really return here if the menu is not going to be shown.
+
if (check_new_session ()){
switch_menuitem = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (switch_menuitem,
@@ -144,7 +164,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
self->users_dbus_interface);
}
- if (is_this_guest_session ())
+ if ( !is_this_guest_session () && guest_enabled)
{
guest_mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (guest_mi,
@@ -169,21 +189,6 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
_("Guest"));
}
- GList * users = NULL;
- users = users_service_dbus_get_user_list (self->users_dbus_interface);
- self->user_count = g_list_length(users);
-
- gboolean user_menu_is_visible = should_show_user_menu();
-
- if (user_menu_is_visible == FALSE || greeter_mode == TRUE){
- session_dbus_set_user_menu_visibility (self->session_dbus_interface,
- FALSE);
- }
- else{
- // This needs to be updated once the ability to query guest session support is available
- 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) {
@@ -420,10 +425,10 @@ is_this_guest_session (void)
if (geteuid() < 500) {
/* System users shouldn't have guest account shown. Mostly
this would be the case of the guest user itself. */
- return FALSE;
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
/* Called when someone clicks on the guest session item. */
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index 4b41f4b..0bab8c8 100644
--- a/src/users-service-dbus.c
+++ b/src/users-service-dbus.c
@@ -86,6 +86,7 @@ struct _UsersServiceDbusPrivate
DBusGProxy *accounts_service_proxy;
DBusGProxy *display_manager_proxy;
+ DBusGProxy *display_manager_props_proxy;
DBusGProxy *ck_proxy;
DBusGProxy *seat_proxy;
DBusGProxy *session_proxy;
@@ -95,6 +96,7 @@ struct _UsersServiceDbusPrivate
DbusmenuMenuitem * guest_item;
gchar * guest_session_id;
+ gboolean guest_session_enabled;
};
#define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate))
@@ -148,6 +150,8 @@ users_service_dbus_init (UsersServiceDbus *self)
priv->count = 0;
priv->guest_item = NULL;
priv->guest_session_id = NULL;
+
+ priv->guest_session_enabled = FALSE;
/* Get the system bus */
priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -194,6 +198,7 @@ users_service_dbus_finalize (GObject *object)
G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
}
+
static void
create_display_manager_proxy (UsersServiceDbus *self)
{
@@ -202,7 +207,7 @@ create_display_manager_proxy (UsersServiceDbus *self)
GError *error = NULL;
const gchar *cookie = NULL;
gchar *seat = NULL;
-
+
cookie = g_getenv ("XDG_SESSION_COOKIE");
if (cookie == NULL || cookie[0] == 0)
{
@@ -232,11 +237,18 @@ create_display_manager_proxy (UsersServiceDbus *self)
return;
}
g_object_unref (dm_proxy);
-
+ g_debug ("CREATING DM PROXIES WITH %s", seat);
priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
"org.freedesktop.DisplayManager",
seat,
"org.freedesktop.DisplayManager.Seat");
+
+ priv->display_manager_props_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
+ "org.freedesktop.DisplayManager",
+ seat,
+ "org.freedesktop.DBus.Properties");
+
+
g_free (seat);
if (!priv->display_manager_proxy)
@@ -244,6 +256,32 @@ create_display_manager_proxy (UsersServiceDbus *self)
g_warning ("Failed to get DisplayManager seat proxy.");
return;
}
+ if (!priv->display_manager_props_proxy)
+ {
+ g_warning ("Failed to get DisplayManager Properties seat proxy.");
+ return;
+ }
+
+ GValue has_guest_session = {0};
+ g_value_init (&has_guest_session, G_TYPE_BOOLEAN);
+ if (!dbus_g_proxy_call (priv->display_manager_props_proxy,
+ "Get",
+ &error,
+ G_TYPE_STRING,
+ "org.freedesktop.DisplayManager.Seat",
+ G_TYPE_STRING,
+ "HasGuestAccount",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE,
+ &has_guest_session,
+ G_TYPE_INVALID))
+ {
+ g_warning ("Failed to get the HasGuestSession property from the DisplayManager Properties seat proxy. error: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ g_debug ("Does seat have a guest account = %i", g_value_get_boolean (&has_guest_session));
+ priv->guest_session_enabled = g_value_get_boolean (&has_guest_session);
}
static void
@@ -931,9 +969,11 @@ users_service_dbus_can_activate_session (UsersServiceDbus *self)
G_TYPE_BOOLEAN, &can_activate,
G_TYPE_INVALID))
{
- g_warning ("Failed to determine if seat can activate sessions: %s", error->message);
- g_error_free (error);
-
+ if (error != NULL){
+ g_warning ("Failed to determine if seat can activate sessions: %s",
+ error->message);
+ g_error_free (error);
+ }
return FALSE;
}
@@ -954,3 +994,12 @@ users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * m
return;
}
+
+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self)
+{
+ g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE);
+ UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
+
+ return priv->guest_session_enabled;
+}
+
diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h
index 4dbf2a4..25942df 100644
--- a/src/users-service-dbus.h
+++ b/src/users-service-dbus.h
@@ -85,6 +85,8 @@ gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self);
void users_service_dbus_set_guest_item (UsersServiceDbus * self,
DbusmenuMenuitem * mi);
+gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self);
+
G_END_DECLS
#endif