From 9da9edc5c66534d80ab211bad95f8c97b72c180c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 5 Sep 2011 12:25:24 +0100 Subject: protect against a null pointer in the user-dbus-manager --- src/users-service-dbus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 4b41f4b..0fa751d 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -931,9 +931,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; } -- cgit v1.2.3 From 00618412f6db4570b9708f9e4ee61bb64ce37c1b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 6 Sep 2011 10:57:44 +0100 Subject: another bug found within the apt-menuitem --- src/apt-watcher.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 480e174..167b847 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -380,11 +380,17 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, gchar* current = NULL; g_debug ("ActiveTransactionsChanged"); - //gchar** queued = NULL; g_variant_get(value, "s", ¤t); + 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)); -- cgit v1.2.3 From 46db1068e1684293f02125872361f75204399e8f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 6 Sep 2011 17:59:18 +0100 Subject: refactor the apt state callback because the use case of real and simulation were proving far too disparate --- src/apt-watcher.c | 95 ++++++++++++++++++++++++++++++++----------------- src/indicator-session.c | 3 +- 2 files changed, 65 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 167b847..b0d9688 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,34 +252,23 @@ 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)); 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; - } 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); @@ -281,27 +277,15 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, 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){ - g_object_unref (G_OBJECT(self->current_transaction)); - self->current_transaction = NULL; - - if (self->current_state == UPDATES_AVAILABLE){ - return; - } if (self->reboot_query != 0){ g_source_remove (self->reboot_query); @@ -312,11 +296,57 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, self->reboot_query = g_timeout_add_seconds (1, apt_watcher_query_reboot_status, self); + } + + 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 +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; + } + self->reboot_query = g_timeout_add_seconds (1, + 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 +356,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 +389,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; @@ -384,7 +415,7 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, 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); @@ -400,7 +431,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/indicator-session.c b/src/indicator-session.c index 2f1764f..f41c841 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); } } -- cgit v1.2.3 From d0d4fd57cf3a25547c570139cc6a311ce05eed44 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 12:04:16 +0100 Subject: more revelations with regards the behaviour of the apt dbus 'api' --- src/apt-transaction.c | 33 ++++++++++++++++----------------- src/apt-watcher.c | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 31 deletions(-) (limited to 'src') 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", ¤t_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", ¤t_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 b0d9688..1f88868 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -269,7 +269,7 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, g_source_remove (self->reboot_query); self->reboot_query = 0; } - self->reboot_query = g_timeout_add_seconds (1, + self->reboot_query = g_timeout_add_seconds (2, apt_watcher_query_reboot_status, self); } @@ -277,27 +277,27 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, 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){ - - if (self->reboot_query != 0){ - g_source_remove (self->reboot_query); - self->reboot_query = 0; + // 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); } - // 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); } - + // Set the current state self->current_state = state; if (self->current_state != UPGRADE_IN_PROGRESS){ @@ -326,7 +326,7 @@ apt_watcher_transaction_state_simulation_update_cb (AptTransaction* trans, g_source_remove (self->reboot_query); self->reboot_query = 0; } - self->reboot_query = g_timeout_add_seconds (1, + self->reboot_query = g_timeout_add_seconds (2, apt_watcher_query_reboot_status, self); } -- cgit v1.2.3 From bc14f0aeb2dbd61c077f1f61c41303f0db4b9781 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 15:34:50 +0100 Subject: more hoop jumping for apt --- src/apt-watcher.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 1f88868..d2cd1b5 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -272,18 +272,23 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, self->reboot_query = g_timeout_add_seconds (2, 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…")); + 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){ @@ -296,14 +301,30 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, apt_watcher_query_reboot_status, self); } - } - // Set the current state - self->current_state = state; - - if (self->current_state != UPGRADE_IN_PROGRESS){ + else{ + query_again = TRUE; + } + self->current_state = state; + g_object_unref (G_OBJECT(self->current_transaction)); self->current_transaction = NULL; - } + // Mental ah yes, because a real transaction (like one which is manually triggered by the user + // by hitting check on update-mgr) does not return a 'dependency' prop update which means + // I cannot figure out from that transaction if an update is available. + // Only when it finishes and I'm confident it was not an transaction concerned with actually updating should i then fire off another transaction, + // this time being a simulation which 'should' figure out if an update is available. + // The Reality is all APT transactions behave differently, an obsolutely nightmare of an API to use. + 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); + } + } } -- cgit v1.2.3 From 058f9cbcbfbe0ed93ce14ad31c5a7ccd14b6d61c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 16:03:22 +0100 Subject: more hoop jumping for apt --- src/apt-watcher.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/apt-watcher.c b/src/apt-watcher.c index d2cd1b5..bbb541a 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -261,17 +261,11 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, 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; - } - self->reboot_query = g_timeout_add_seconds (2, - apt_watcher_query_reboot_status, - self); self->current_state = state; } else if (state == UPDATES_AVAILABLE){ -- cgit v1.2.3 From 0bef37124f305aef894fa19f01911bc3553df3c5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 21:02:44 +0100 Subject: display manager HasGuestAccount now supported --- src/user-menu-mgr.c | 41 +++++++++++++++++++++----------------- src/users-service-dbus.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-- src/users-service-dbus.h | 2 ++ 3 files changed, 74 insertions(+), 20 deletions(-) (limited to 'src') 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..7054a22 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 ("HAS GUEST ACCOUNT = %i", g_value_get_boolean (&has_guest_session)); + priv->guest_session_enabled = g_value_get_boolean (&has_guest_session); } static void @@ -954,3 +992,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 -- cgit v1.2.3 From 9c24a238b2338b3a4af7629e8e4d4a6493499ac2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 21:05:44 +0100 Subject: tidy up --- src/users-service-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 7054a22..dfb330d 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -280,7 +280,7 @@ create_display_manager_proxy (UsersServiceDbus *self) g_error_free (error); return; } - g_debug ("HAS GUEST ACCOUNT = %i", g_value_get_boolean (&has_guest_session)); + 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); } -- cgit v1.2.3 From b85f29bbd848238a4b60fe2eccf3ead06c47b979 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 7 Sep 2011 21:20:42 +0100 Subject: tidy up --- src/apt-watcher.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/apt-watcher.c b/src/apt-watcher.c index bbb541a..e5e1d0e 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -302,12 +302,9 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, g_object_unref (G_OBJECT(self->current_transaction)); self->current_transaction = NULL; - // Mental ah yes, because a real transaction (like one which is manually triggered by the user - // by hitting check on update-mgr) does not return a 'dependency' prop update which means - // I cannot figure out from that transaction if an update is available. - // Only when it finishes and I'm confident it was not an transaction concerned with actually updating should i then fire off another transaction, - // this time being a simulation which 'should' figure out if an update is available. - // The Reality is all APT transactions behave differently, an obsolutely nightmare of an API to use. + + // It is impossible to determine from a 'real' transaction whether + // updates are available ? if (query_again){ g_dbus_proxy_call (self->proxy, "UpgradeSystem", -- cgit v1.2.3 From 693bdc8faee826e4cde13dfb0b1aff8dd294a6dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 7 Sep 2011 22:09:01 -0500 Subject: Lots of debug messages for the logout helper --- src/gtk-logout-helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') 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 . 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; } -- cgit v1.2.3 From 6174b1bac576198e5d3df35f93971598937e71c6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 8 Sep 2011 14:01:36 +0100 Subject: user correct string on switch item unless user actually wants to show username --- src/indicator-session.c | 11 ++++++++--- src/settings-helper.h | 15 ++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index f41c841..20fc643 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -539,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; } @@ -587,7 +593,6 @@ switch_property_change (DbusmenuMenuitem * item, gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); } } - return; } 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 . #ifndef __GCONF_HELPER_H__ -#define __GCONF_HELPER_H__ 1 +#define __GCONF_HELPER_H__ #include @@ -31,12 +31,13 @@ with this program. If not, see . #include #include -#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" -- cgit v1.2.3 From d446a9d9bf96e5d3dd9b6065adceb1aeb25fcd98 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 8 Sep 2011 18:30:52 +0100 Subject: add the new gsettings entry for toggling the visibility of the real name on the panel --- src/indicator-session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index f41c841..1f58aba 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -705,6 +705,7 @@ indicator_session_update_users_label (IndicatorSession* self, gtk_widget_hide(GTK_WIDGET(self->users.label)); return; } + gtk_label_set_text (self->users.label, g_strdup(name)); gtk_widget_show(GTK_WIDGET(self->users.label)); } -- cgit v1.2.3