aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-09-27 16:55:41 -0500
committerTed Gould <ted@gould.cx>2011-09-27 16:55:41 -0500
commit1e3f1b724bfbb1283b482ddd11db1ee417e4eeb3 (patch)
tree831776c7d01e111e88cd7767aa3cfc3d9d1f93f6
parenta316c5aac1ea8928f5da7cc916d534ea6eb7ab5e (diff)
parent18f3158453229388605760aa8e738a9adb65109b (diff)
downloadayatana-indicator-session-1e3f1b724bfbb1283b482ddd11db1ee417e4eeb3.tar.gz
ayatana-indicator-session-1e3f1b724bfbb1283b482ddd11db1ee417e4eeb3.tar.bz2
ayatana-indicator-session-1e3f1b724bfbb1283b482ddd11db1ee417e4eeb3.zip
Update to ubuntu-desktop version
-rw-r--r--ChangeLog212
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--data/com.canonical.indicator.session.gschema.xml.in18
-rw-r--r--debian/changelog80
-rw-r--r--debian/source/format1
-rw-r--r--src/apt-transaction.c33
-rw-r--r--src/apt-watcher.c278
-rw-r--r--src/dbus-shared-names.h2
-rw-r--r--src/device-menu-mgr.c59
-rw-r--r--src/gen-session-dbus.xml.c3
-rw-r--r--src/gtk-logout-helper.c23
-rw-r--r--src/indicator-session.c50
-rw-r--r--src/session-dbus.c4
-rw-r--r--src/session-dbus.xml3
-rw-r--r--src/settings-helper.c6
-rw-r--r--src/settings-helper.h16
-rw-r--r--src/udev-mgr.c17
-rw-r--r--src/user-menu-mgr.c81
-rw-r--r--src/users-service-dbus.c59
-rw-r--r--src/users-service-dbus.h2
21 files changed, 697 insertions, 254 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d038ca..1495e9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,217 @@
# Generated by Makefile. Do not edit.
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ fixes for apt handling
+
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ merge further apt handling fixes
+
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ apt property changed reboot required listened for and now the whole apt interaction does not happen until after 60 secs
+
+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
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ added new gsettings entry to control visibility of the user menu
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ updated the schema entry with the correct key
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ updated the schema entry with the correct key
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ change the actual key on the entry
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ live cd user should now be turned off via new gsettings entry by casper
+
+2011-09-06 Conor Curran <conor.curran@canonical.com>
+
+ added new field to gsettings to allow to hide the user menu
+
+2011-09-05 Conor Curran <conor.curran@canonical.com>
+
+ old icon now used when in greeter mode
+
+2011-09-02 Conor Curran <conor.curran@canonical.com>
+
+ make sure to flag restart state in greeter mode also with the right icon
+
+2011-09-02 Conor Curran <conor.curran@canonical.com>
+
+ remove the greeter icon stuff
+
+2011-09-02 Conor Curran <conor.curran@canonical.com>
+
+ bumped version in prep for release
+
+2011-09-02 Conor Curran <conor.curran@canonical.com>
+
+ apt menuitem should now finally be working properly
+
+2011-09-02 Conor Curran <conor.curran@canonical.com>
+
+ final apt menuitem bugs fixes
+
+2011-09-01 Conor Curran <conor.curran@canonical.com>
+
+ ready for 0.3.4.1
+
+2011-09-01 Conor Curran <conor.curran@canonical.com>
+
+ much easier of handling the greeter icon
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ various apt handling fixes
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ set the menuitem's disposition back to normal just in case
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ tidy up
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ make sure to bring up logout dialog from apt menuitem when restart is required
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ tidy up
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ restart signal actually being sent now properly
+
+2011-08-31 Conor Curran <conor.curran@canonical.com>
+
+ apt race condition handled
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ bump for release
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ merge the guest fixes
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ remove guest checking in generic user list, the guest user is never included in the user list returned therefore the check is pointless
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ remove broken logic concerned with displaying the user menu
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ fixed the guest session panel string
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ bump for release
+
+2011-08-30 Conor Curran <conor.curran@canonical.com>
+
+ protect against incorrect webcam detection
+
+2011-08-26 Conor Curran <conor.curran@canonical.com>
+
+ merge in translation fix
+
+2011-08-26 Conor Curran <conor.curran@canonical.com>
+
+ fixed the translation bug
+
2011-08-25 Conor Curran <conor.curran@canonical.com>
ted's str allocation fixes
diff --git a/configure b/configure
index 9bc0aba..ef58f16 100755
--- a/configure
+++ b/configure
@@ -2745,7 +2745,7 @@ fi
# Define the identity of the package.
PACKAGE=indicator-session
- VERSION=0.3.3.2
+ VERSION=0.3.5.1
cat >>confdefs.h <<_ACEOF
diff --git a/configure.ac b/configure.ac
index 8e5ed8b..557a8d2 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.3.2)
+AM_INIT_AUTOMAKE(indicator-session, 0.3.5.1)
AM_MAINTAINER_MODE
diff --git a/data/com.canonical.indicator.session.gschema.xml.in b/data/com.canonical.indicator.session.gschema.xml.in
index d1d7d4c..0ef3d00 100644
--- a/data/com.canonical.indicator.session.gschema.xml.in
+++ b/data/com.canonical.indicator.session.gschema.xml.in
@@ -20,5 +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/debian/changelog b/debian/changelog
index aa1002c..c87796c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,62 @@
-indicator-session (0.3.3.2-0ubuntu2~ppa1) oneiric; urgency=low
+indicator-session (0.3.5.1-0ubuntu1) oneiric; urgency=low
+ * New upstream release.
+ - don't start apt on logging
+ - [UIFe] should say "Restart to Complete Updates…" (LP: #850013)
+
+ -- Didier Roche <didrocks@ubuntu.com> Thu, 15 Sep 2011 10:33:56 +0200
+
+indicator-session (0.3.5.0-0ubuntu1) oneiric; urgency=low
+
+ * New upstream release:
+ - fix the updates menu items randomly working (lp: #842946)
+ - "Guest Session should not show if guest session was disabled in
+ the display manager" (lp: #835084)
+ - segfault fix (lp: #840660)
+ - don't display temporary guest user generated username (lp: #844272)
+ - respect "show-real-name-on-panel" to hide the username (lp: #812728)
+
+ -- Sebastien Bacher <seb128@ubuntu.com> Fri, 09 Sep 2011 11:18:26 +0200
+
+indicator-session (0.3.4.3-0ubuntu1) oneiric; urgency=low
+
+ * New upstream release.
+ - new gsettings key "com.canonical.indicator.session user-show-menu"
+ - "[UIFe]Greeter power menu has cog icon but no settings"
+ (lp: #838546)
+
+ -- Sebastien Bacher <seb128@ubuntu.com> Tue, 06 Sep 2011 22:09:41 +0200
+
+indicator-session (0.3.4.2-0ubuntu1) oneiric; urgency=low
+
+ * New upstream release.
+ - states 'software up-to-date' although there're updates
+ available" (LP: #831650)
+ * -debian/patches/revert_icon_change.patch
+
+ -- Ken VanDine <ken.vandine@canonical.com> Fri, 02 Sep 2011 12:22:03 -0400
+
+indicator-session (0.3.4.1-0ubuntu1) oneiric; urgency=low
+
+ [Ken VanDine]
+ * New upstream release.
+ - in a Guest session user menu is not visible (LP: #834948)
+ - User name shown as [Invalid UTF-8] in live session (LP: #837246)
+ - "Reboot Required" menu opens Update Manager, doesn't reboot (LP: #837658)
+ - indicator-session-service crashed with SIGSEGV in
+ g_str_hash() (LP: #824243)
+ - indicator-session-service crashed with SIGSEGV in
+ g_variant_unref() (LP: #833965)
+ * +debian/patches/revert_icon_change.patch
+ - revert the icon change in greeter mode until a UIF exception is
+ approved
+ * +debian/source/format
+
+ [Ted Gould]
* debian/control: Adding a depend on gnome-settings-daemon to ensure that
the required schemas are available. (LP: #833965)
- -- Ted Gould <ted@ubuntu.com> Wed, 31 Aug 2011 13:45:22 -0500
+ -- Ken VanDine <ken.vandine@canonical.com> Thu, 01 Sep 2011 13:53:50 -0400
indicator-session (0.3.3.2-0ubuntu1) oneiric; urgency=low
@@ -43,29 +96,6 @@ indicator-session (0.3.3-0ubuntu1) oneiric; urgency=low
-- Ken VanDine <ken.vandine@canonical.com> Thu, 25 Aug 2011 08:58:56 -0400
-indicator-session (0.3.2-0ubuntu2~ppa3) UNRELEASED; urgency=low
-
- * Upstream Merge
- * So much stuff...
- * Desktop files for system functions
-
- -- Ted Gould <ted@ubuntu.com> Tue, 23 Aug 2011 11:24:25 -0500
-
-indicator-session (0.3.2-0ubuntu2~ppa2) oneiric; urgency=low
-
- * Upstream Merge
- * GSettings Fixes
-
- -- Ted Gould <ted@ubuntu.com> Fri, 19 Aug 2011 15:10:54 -0500
-
-indicator-session (0.3.2-0ubuntu2~ppa1) oneiric; urgency=low
-
- * Upstream Merge
- * GSettings transition
- * debian/rules: Adding autoreconf
-
- -- Ted Gould <ted@ubuntu.com> Fri, 19 Aug 2011 14:59:20 -0500
-
indicator-session (0.3.2-0ubuntu1) oneiric; urgency=low
* New upstream release.
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/src/apt-transaction.c b/src/apt-transaction.c
index be1c57b..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 a4298a8..2c5ed0b 100644
--- a/src/apt-watcher.c
+++ b/src/apt-watcher.c
@@ -27,6 +27,7 @@ static guint watcher_id;
struct _AptWatcher
{
GObject parent_instance;
+ guint reboot_query;
GCancellable * proxy_cancel;
GDBusProxy * proxy;
SessionDbus* session_dbus_interface;
@@ -55,7 +56,7 @@ static void apt_watcher_upgrade_system_cb (GObject * obj,
static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi,
guint timestamp,
- gchar * type);
+ gpointer userdata);
static void apt_watcher_signal_cb (GDBusProxy* proxy,
gchar* sender_name,
@@ -64,8 +65,14 @@ static void apt_watcher_signal_cb (GDBusProxy* proxy,
gpointer user_data);
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);
+static gboolean apt_watcher_start_apt_interaction (gpointer data);
G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT);
@@ -75,7 +82,18 @@ apt_watcher_init (AptWatcher *self)
self->current_state = UP_TO_DATE;
self->proxy_cancel = g_cancellable_new();
self->proxy = NULL;
- self->current_transaction = NULL;
+ self->reboot_query = 0;
+ self->current_transaction = NULL;
+ g_timeout_add_seconds (60,
+ apt_watcher_start_apt_interaction,
+ self);
+}
+
+static gboolean
+apt_watcher_start_apt_interaction (gpointer data)
+{
+ g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
+ AptWatcher* self = APT_WATCHER (data);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
@@ -85,6 +103,7 @@ apt_watcher_init (AptWatcher *self)
self->proxy_cancel,
fetch_proxy_cb,
self);
+ return FALSE;
}
static void
@@ -141,10 +160,9 @@ fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
g_signal_connect (self->proxy,
"g-signal",
G_CALLBACK(apt_watcher_signal_cb),
- self);
+ self);
}
-
static void
apt_watcher_on_name_appeared (GDBusConnection *connection,
const gchar *name,
@@ -159,6 +177,8 @@ apt_watcher_on_name_appeared (GDBusConnection *connection,
"the system bus",
name_owner);
+ apt_watcher_query_reboot_status (user_data);
+
g_dbus_proxy_call (watcher->proxy,
"UpgradeSystem",
g_variant_new("(b)", TRUE),
@@ -166,9 +186,10 @@ apt_watcher_on_name_appeared (GDBusConnection *connection,
-1,
NULL,
apt_watcher_upgrade_system_cb,
- user_data);
+ user_data);
}
+
static void
apt_watcher_on_name_vanished (GDBusConnection *connection,
const gchar *name,
@@ -213,82 +234,134 @@ apt_watcher_upgrade_system_cb (GObject * obj,
static void
apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
guint timestamp,
- gchar * type)
+ gpointer userdata)
{
GError * error = NULL;
- if (!g_spawn_command_line_async("update-manager", &error))
- {
- g_warning("Unable to show update-manager: %s", error->message);
- g_error_free(error);
- }
+ g_return_if_fail (APT_IS_WATCHER (userdata));
+ AptWatcher* self = APT_WATCHER (userdata);
+ const gchar* disposition = NULL;
+ disposition = dbusmenu_menuitem_property_get (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_DISPOSITION);
+
+ if (g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0){
+ gchar * helper = g_build_filename (LIBEXECDIR, "gtk-logout-helper", NULL);
+ gchar * dialog_line = g_strdup_printf ("%s --%s", helper, "restart");
+ g_free(helper);
+ if (!g_spawn_command_line_async(dialog_line, &error)) {
+ g_warning("Unable to show dialog: %s", error->message);
+ g_error_free(error);
+ }
+ g_free(dialog_line);
+ }
+ else{
+ if (!g_spawn_command_line_async("update-manager", &error))
+ {
+ g_warning("Unable to show update-manager: %s", error->message);
+ g_error_free(error);
+ }
+ }
}
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));
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"));
- // 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;
- }
- }
- 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){
+ if (self->current_state != RESTART_NEEDED)
+ {
+ if (state == UP_TO_DATE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
+ self->current_state = state;
+ }
+ else if (state == UPDATES_AVAILABLE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Updates Available…"));
+ 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){
+ query_again = TRUE;
+ }
+ self->current_state = state;
+
g_object_unref (G_OBJECT(self->current_transaction));
self->current_transaction = NULL;
- }
+
+ // It is impossible to determine from a 'real' transaction whether
+ // updates are available therefore it is necessary to check again via a
+ // simulation whether there are updates 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);
+ }
+ }
}
- else if (state == UPGRADE_IN_PROGRESS){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Updates Installing…"));
- }
- else if (state == FINISHED){
- GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
- "RebootRequired");
- gboolean reboot;
- g_variant_get (reboot_result, "b", &reboot);
- if (reboot == FALSE){
+}
+
+
+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 (self->current_state != RESTART_NEEDED)
+ {
+ if (state == UP_TO_DATE){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
+ _("Software Up to Date"));
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+ self->reboot_query = g_timeout_add_seconds (1,
+ apt_watcher_query_reboot_status,
+ self);
}
- else{
+ else if (state == UPDATES_AVAILABLE){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("Reboot Required"));
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_DISPOSITION,
- DBUSMENU_MENUITEM_DISPOSITION_ALERT);
- session_dbus_restart_required (self->session_dbus_interface);
+ _("Updates Available…"));
}
- g_debug ("Finished with a reboot value of %i", reboot);
+ 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;
+ self->current_transaction = NULL;
}
- self->current_state = state;
}
static void
@@ -298,12 +371,44 @@ 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);
}
}
-// TODO - Ask MVO about this.
-// Signal is of type s not sas which is on d-feet !!!
+static gboolean
+apt_watcher_query_reboot_status (gpointer data)
+{
+ g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
+ AptWatcher* self = APT_WATCHER (data);
+
+ GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
+ "RebootRequired");
+ gboolean reboot;
+ g_variant_get (reboot_result, "b", &reboot);
+ g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
+ if (reboot == FALSE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
+ DBUSMENU_MENUITEM_DISPOSITION_NORMAL);
+
+ }
+ else{
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Restart to complete updates…"));
+ dbusmenu_menuitem_property_set (self->apt_item,
+ 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;
+}
+
static void apt_watcher_signal_cb ( GDBusProxy* proxy,
gchar* sender_name,
gchar* signal_name,
@@ -317,23 +422,54 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy,
GVariant *value = g_variant_get_child_value (parameters, 0);
if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){
- gchar* input = NULL;
- g_variant_get(value, "s", & input);
- if (g_str_has_prefix (input, "/org/debian/apt/transaction/") == TRUE){
- g_debug ("Active Transactions signal - input is null = %i", input == NULL);
-
+ gchar* current = NULL;
+ g_debug ("ActiveTransactionsChanged");
+
+ 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));
self->current_transaction = NULL;
}
- self->current_transaction = apt_transaction_new (input, REAL);
+ 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);
}
}
+ else if (g_strcmp0(signal_name, "PropertyChanged") == 0)
+ {
+ gchar* prop_name= NULL;
+ GVariant* value = NULL;
+ g_variant_get (parameters, "(sv)", &prop_name, &value);
+ g_debug ("transaction prop update - prop = %s", prop_name);
+
+ if (g_strcmp0 (prop_name, "RebootRequired") == 0){
+ gboolean reboot_required = FALSE;
+ g_variant_get (value, "(b)", &reboot_required);
+ if (reboot_required){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Restart to complete updates…"));
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
+ DBUSMENU_MENUITEM_DISPOSITION_ALERT);
+ self->current_state = RESTART_NEEDED;
+ }
+ }
+ }
+
g_variant_unref (parameters);
}
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index c5372e4..5f35903 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -63,5 +63,7 @@ typedef enum {
#define ICON_DEFAULT "system-devices-panel"
#define ICON_RESTART "system-devices-panel-alert"
+#define GREETER_ICON_DEFAULT "system-shutdown-panel"
+#define GREETER_ICON_RESTART "system-shutdown-panel-restart"
#endif /* __DBUS_SHARED_NAMES_H__ */
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index 523ea8d..5a63be3 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -61,7 +61,6 @@ static DBusGProxyCall * hibernate_call = NULL;
static DbusmenuMenuitem * hibernate_mi = NULL;
static DbusmenuMenuitem * suspend_mi = NULL;
static DbusmenuMenuitem * logout_mi = NULL;
-static DbusmenuMenuitem * restart_mi = NULL;
static DbusmenuMenuitem * shutdown_mi = NULL;
static gboolean can_hibernate = TRUE;
@@ -73,7 +72,6 @@ static DBusGProxy * up_main_proxy = NULL;
static DBusGProxy * up_prop_proxy = NULL;
static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self);
-static void setup_restart_watch (DeviceMenuMgr* self);
static void setup_up (DeviceMenuMgr* self);
static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self);
static void lock_if_possible (DeviceMenuMgr* self);
@@ -106,7 +104,6 @@ device_menu_mgr_init (DeviceMenuMgr *self)
{
self->apt_watcher = NULL;
self->root_item = dbusmenu_menuitem_new ();
- setup_restart_watch(self);
setup_up(self);
g_idle_add(lock_screen_setup, NULL);
}
@@ -751,62 +748,6 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self)
can_suspend && allow_suspend);
}
-/* When the directory changes we need to figure out how our menu
- item should look. */
-static void
-restart_dir_changed (gpointer userdata)
-{
- DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata);
- gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);
-
- if (restart_required) {
- if (supress_confirmations()) {
- dbusmenu_menuitem_property_set (restart_mi,
- RESTART_ITEM_LABEL,
- _("Restart to Complete Update"));
- } else {
- dbusmenu_menuitem_property_set (restart_mi,
- RESTART_ITEM_LABEL,
- _("Restart to Complete Update\342\200\246"));
- }
- dbusmenu_menuitem_property_set (restart_mi,
- RESTART_ITEM_ICON,
- "system-restart-panel");
- if (self->session_dbus_interface != NULL) {
- session_dbus_set_name (self->session_dbus_interface, ICON_RESTART);
- }
- } else {
- if (supress_confirmations()) {
- dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart"));
- } else {
- dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246"));
- }
- dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON);
- if (self->session_dbus_interface != NULL) {
- session_dbus_set_name(self->session_dbus_interface, ICON_DEFAULT);
- }
- }
- return;
-}
-
-/* Buids a file watcher for the directory so that when it
- changes we can check to see if our reboot-required is
- there. */
-static void
-setup_restart_watch (DeviceMenuMgr* self)
-{
- GFile * filedir = g_file_new_for_path("/var/run");
- GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL);
- if (filemon != NULL) {
- g_signal_connect (G_OBJECT(filemon),
- "changed",
- G_CALLBACK(restart_dir_changed),
- self);
- }
- restart_dir_changed(self);
- return;
-}
-
/* Ensures that we have a GConf client and if we build one
set up the signal handler. */
static void
diff --git a/src/gen-session-dbus.xml.c b/src/gen-session-dbus.xml.c
index 319f203..11bf4b1 100644
--- a/src/gen-session-dbus.xml.c
+++ b/src/gen-session-dbus.xml.c
@@ -9,9 +9,6 @@ const char * _session_dbus =
" <method name=\"GetUserMenuVisibility\">\n"
" <arg name=\"update\" direction=\"out\" type=\"b\"/>\n"
" </method>\n"
-" <method name=\"IsUpdateNeeded\">\n"
-" <arg name=\"update\" direction=\"out\" type=\"b\"/>\n"
-" </method>\n"
" <signal name=\"UserRealNameUpdated\">\n"
" <arg name=\"name\" type=\"s\"/>\n"
" </signal>\n"
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 fab47b3..833d19b 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -70,6 +70,8 @@ struct _IndicatorSession {
GDBusProxy * service_proxy;
};
+static gboolean greeter_mode;
+
GType indicator_session_get_type (void);
/* Indicator stuff */
@@ -164,10 +166,18 @@ indicator_session_init (IndicatorSession *self)
self->users.label = GTK_LABEL (gtk_label_new (NULL));
+ const gchar *greeter_var;
+ greeter_var = g_getenv("INDICATOR_GREETER_MODE");
+ greeter_mode = g_strcmp0(greeter_var, "1") == 0;
// devices
self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
INDICATOR_SESSION_DBUS_OBJECT));
- self->devices.image = indicator_image_helper (ICON_DEFAULT);
+ if (greeter_mode){
+ self->devices.image = indicator_image_helper (GREETER_ICON_DEFAULT);
+ }
+ else{
+ self->devices.image = indicator_image_helper (ICON_DEFAULT);
+ }
gtk_widget_show (GTK_WIDGET(self->devices.menu));
gtk_widget_show (GTK_WIDGET(self->devices.image));
@@ -497,9 +507,14 @@ receive_signal (GDBusProxy * proxy,
&self->users);
}
}
- else if (g_strcmp0(signal_name, "RebootRequired") == 0) {
- // TODO waiting on design to give me a name.
- self->devices.image = indicator_image_helper (ICON_RESTART);
+ 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);
+ }
}
}
@@ -524,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;
}
@@ -572,7 +593,6 @@ switch_property_change (DbusmenuMenuitem * item,
gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE);
}
}
-
return;
}
@@ -683,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/session-dbus.c b/src/session-dbus.c
index 1cf73ac..232e440 100644
--- a/src/session-dbus.c
+++ b/src/session-dbus.c
@@ -300,11 +300,13 @@ void session_dbus_restart_required (SessionDbus* session)
GError * error = NULL;
if (priv->bus != NULL) {
+ g_debug("About to send RebootRequired signal");
+
g_dbus_connection_emit_signal (priv->bus,
NULL,
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
- "RebootRequired",
+ "RestartRequired",
NULL,
&error);
diff --git a/src/session-dbus.xml b/src/session-dbus.xml
index fd1859f..96e9837 100644
--- a/src/session-dbus.xml
+++ b/src/session-dbus.xml
@@ -8,9 +8,6 @@
<method name="GetUserMenuVisibility">
<arg name="update" direction="out" type="b"/>
</method>
- <method name="IsUpdateNeeded">
- <arg name="update" direction="out" type="b"/>
- </method>
<signal name="UserRealNameUpdated">
<arg name="name" type="s"/>
</signal>
diff --git a/src/settings-helper.c b/src/settings-helper.c
index 5a69d17..d70df95 100644
--- a/src/settings-helper.c
+++ b/src/settings-helper.c
@@ -53,6 +53,12 @@ supress_confirmations (void) {
}
gboolean
+should_show_user_menu (void) {
+ build_settings();
+ return g_settings_get_boolean (settings, SHOW_USER_MENU) ;
+}
+
+gboolean
show_logout (void) {
build_settings();
return !g_settings_get_boolean (settings, LOGOUT_KEY) ;
diff --git a/src/settings-helper.h b/src/settings-helper.h
index 7b377ca..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,11 +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 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"
@@ -56,5 +58,7 @@ gboolean supress_confirmations (void);
gboolean show_logout (void);
gboolean show_restart (void);
gboolean show_shutdown (void);
+gboolean should_show_user_menu (void);
+
#endif /* __GCONF_HELPER__ */
diff --git a/src/udev-mgr.c b/src/udev-mgr.c
index edc2262..5f197d6 100644
--- a/src/udev-mgr.c
+++ b/src/udev-mgr.c
@@ -226,7 +226,11 @@ udev_mgr_handle_webcam (UdevMgr* self,
vendor = g_udev_device_get_property (device, "ID_VENDOR_ID");
product = g_udev_device_get_property (device, "ID_MODEL_ID");
-
+
+ if (!vendor || !product) {
+ return;
+ }
+
if (action == REMOVE){
if (g_hash_table_lookup (self->webcams_present, product) == NULL){
g_warning ("Got a remove event on a webcam device but we don't have that device in our webcam cache");
@@ -316,18 +320,23 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self,
{
const gchar* type = NULL;
type = g_udev_device_get_property (device, "TYPE");
- // apparently anything thats type 3 and SCSI is a Scanner
+
+ if (!type) {
+ return;
+ }
+
+ // apparently anything thats type 6 and SCSI is a Scanner
if (g_strcmp0 (type, "6") == 0 && action == ADD){
const gchar* manufacturer = NULL;
manufacturer = g_udev_device_get_property (device, "ID_VENDOR");
if (manufacturer != NULL){
- gchar * label = format_device_name(self, manufacturer, _("Scanner"), _("%s Scanner"));
+ gchar * label = format_device_name(self, manufacturer, _("Scanner"), _("%s Scanner"));
dbusmenu_menuitem_property_set (self->scanner_item,
DBUSMENU_MENUITEM_PROP_LABEL,
label);
- g_free(label);
+ g_free(label);
}
gchar* random_scanner_name = g_strdup_printf("%p--scanner", self);
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 1b404d3..efb3f7d 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -18,7 +18,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libdbusmenu-glib/client.h>
-
#include "user-menu-mgr.h"
#include "settings-helper.h"
#include "dbus-shared-names.h"
@@ -54,21 +53,19 @@ static void activate_online_accounts (DbusmenuMenuitem *mi,
gpointer user_data);
static void activate_user_accounts (DbusmenuMenuitem *mi,
guint timestamp,
- gpointer user_data);
-
+ gpointer user_data);
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,
gpointer user_data);
-
static void ensure_settings_client ();
-static gboolean check_guest_session (void);
+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);
@@ -133,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,
@@ -148,7 +164,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
self->users_dbus_interface);
}
- if (check_guest_session ())
+ if ( !is_this_guest_session () && guest_enabled)
{
guest_mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (guest_mi,
@@ -168,19 +184,12 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
users_service_dbus_set_guest_item (self->users_dbus_interface,
guest_mi);
}
-
- 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 = FALSE;
-
- if (!greeter_mode){
- user_menu_is_visible = self->user_count > 1 || check_guest_session();
+ else{
+ session_dbus_set_users_real_name (self->session_dbus_interface,
+ _("Guest"));
}
- 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);
@@ -188,37 +197,15 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
for (u = users; u != NULL; u = g_list_next (u)) {
user = u->data;
- //g_debug ("%p: %s", user, user->real_name);
+ g_debug ("%s: %s", user->user_name, user->real_name);
user->service = self->users_dbus_interface;
gboolean current_user = g_strcmp0 (user->user_name, g_get_user_name()) == 0;
if (current_user == TRUE){
- if (check_guest_session()){
- g_debug ("about to set the users real name to %s for user %s",
- user->real_name, user->user_name);
- session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name);
- }
- else{
- g_debug ("about to set the users real name to GUEST");
- session_dbus_set_users_real_name (self->session_dbus_interface,
- _("Guest"));
- }
+ g_debug ("about to set the users real name to %s for user %s",
+ user->real_name, user->user_name);
+ session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name);
}
-
- if (g_strcmp0(user->user_name, "guest") == 0) {
- /* Check to see if the guest has sessions and so therefore should
- get a check mark. */
- dbusmenu_menuitem_property_set_bool (guest_mi,
- USER_ITEM_PROP_LOGGED_IN,
- user->sessions != NULL);
- /* If we're showing user accounts, keep going through the list */
- if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) {
- continue;
- }
- /* If not, we can stop here */
- break;
- }
-
if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) {
mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (mi,
@@ -433,15 +420,15 @@ user_mgr_get_root_item (UserMenuMgr* self)
/* Checks to see if we should show the guest suession item */
static gboolean
-check_guest_session (void)
+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