Blame SOURCES/0002-account-reshow-the-notification-when-screen-unlocks.patch

c8e532
From 1a3c72c8c6abcc3c08e69c5c238636a2dc56ed2d Mon Sep 17 00:00:00 2001
c8e532
From: Ray Strode <rstrode@redhat.com>
c8e532
Date: Mon, 6 Nov 2017 15:49:58 -0500
c8e532
Subject: [PATCH 2/3] account: reshow the notification when screen unlocks
c8e532
c8e532
---
c8e532
 plugins/account/gsd-account-manager.c | 48 ++++++++++++++++++++++++---
c8e532
 1 file changed, 43 insertions(+), 5 deletions(-)
c8e532
c8e532
diff --git a/plugins/account/gsd-account-manager.c b/plugins/account/gsd-account-manager.c
c8e532
index 40b91cb6..cb37f466 100644
c8e532
--- a/plugins/account/gsd-account-manager.c
c8e532
+++ b/plugins/account/gsd-account-manager.c
c8e532
@@ -11,72 +11,75 @@
c8e532
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
c8e532
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c8e532
  * GNU General Public License for more details.
c8e532
  *
c8e532
  * You should have received a copy of the GNU General Public License
c8e532
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
c8e532
  *
c8e532
  */
c8e532
 
c8e532
 #include "config.h"
c8e532
 
c8e532
 #include <sys/types.h>
c8e532
 #include <sys/wait.h>
c8e532
 #include <stdlib.h>
c8e532
 #include <stdio.h>
c8e532
 #include <unistd.h>
c8e532
 #include <string.h>
c8e532
 #include <errno.h>
c8e532
 
c8e532
 #include <locale.h>
c8e532
 
c8e532
 #include <glib.h>
c8e532
 #include <glib/gi18n.h>
c8e532
 #include <glib/gstdio.h>
c8e532
 
c8e532
 #include <cups/cups.h>
c8e532
 #include <cups/ppd.h>
c8e532
 #include <libnotify/notify.h>
c8e532
 
c8e532
 #include "gnome-settings-profile.h"
c8e532
+#include "gnome-settings-bus.h"
c8e532
 #include "gsd-account-manager.h"
c8e532
 #include "org.freedesktop.Accounts.h"
c8e532
 #include "org.freedesktop.Accounts.User.h"
c8e532
 
c8e532
 #define GSD_ACCOUNT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_ACCOUNT_MANAGER, GsdAccountManagerPrivate))
c8e532
 
c8e532
 struct GsdAccountManagerPrivate
c8e532
 {
c8e532
         GsdAccounts          *accounts_proxy;
c8e532
         GsdAccountsUser      *accounts_user_proxy;
c8e532
         GCancellable         *cancellable;
c8e532
 
c8e532
+        GsdScreenSaver       *screensaver_proxy;
c8e532
+
c8e532
         gint64                expiration_time;
c8e532
         gint64                last_change_time;
c8e532
         gint64                min_days_between_changes;
c8e532
         gint64                max_days_between_changes;
c8e532
         gint64                days_to_warn;
c8e532
         gint64                days_after_expiration_until_lock;
c8e532
 
c8e532
         NotifyNotification   *notification;
c8e532
 };
c8e532
 
c8e532
 static void     gsd_account_manager_class_init  (GsdAccountManagerClass *klass);
c8e532
 static void     gsd_account_manager_init        (GsdAccountManager      *account_manager);
c8e532
 static void     gsd_account_manager_finalize    (GObject                *object);
c8e532
 
c8e532
 G_DEFINE_TYPE (GsdAccountManager, gsd_account_manager, G_TYPE_OBJECT)
c8e532
 
c8e532
 static gpointer manager_object = NULL;
c8e532
 
c8e532
 static void
c8e532
 on_notification_closed (NotifyNotification *notification,
c8e532
                         gpointer            user_data)
c8e532
 {
c8e532
         GsdAccountManager *manager = user_data;
c8e532
 
c8e532
         g_clear_object (&manager->priv->notification);
c8e532
 }
c8e532
 
c8e532
 static void
c8e532
 hide_notification (GsdAccountManager *manager)
c8e532
 {
c8e532
@@ -221,77 +224,111 @@ on_got_password_expiration_policy (GsdAccountsUser *accounts_user_proxy,
c8e532
         gint64             days_after_expiration_until_lock;
c8e532
 
c8e532
         gnome_settings_profile_start (NULL);
c8e532
         succeeded = gsd_accounts_user_call_get_password_expiration_policy_finish (accounts_user_proxy,
c8e532
                                                                                   &expiration_time,
c8e532
                                                                                   &last_change_time,
c8e532
                                                                                   &min_days_between_changes,
c8e532
                                                                                   &max_days_between_changes,
c8e532
                                                                                   &days_to_warn,
c8e532
                                                                                   &days_after_expiration_until_lock,
c8e532
                                                                                   res,
c8e532
                                                                                   &error);
c8e532
 
c8e532
         if (!succeeded) {
c8e532
                 g_warning ("Failed to get password expiration policy for user: %s", error->message);
c8e532
                 goto out;
c8e532
         }
c8e532
 
c8e532
         set_policy_number (&manager->priv->expiration_time, expiration_time);
c8e532
         set_policy_number (&manager->priv->last_change_time, last_change_time);
c8e532
         set_policy_number (&manager->priv->min_days_between_changes, min_days_between_changes);
c8e532
         set_policy_number (&manager->priv->max_days_between_changes, max_days_between_changes);
c8e532
         set_policy_number (&manager->priv->days_to_warn, days_to_warn);
c8e532
         set_policy_number (&manager->priv->days_after_expiration_until_lock, days_after_expiration_until_lock);
c8e532
 
c8e532
         update_password_notification (manager);
c8e532
 out:
c8e532
         gnome_settings_profile_end (NULL);
c8e532
 }
c8e532
 
c8e532
+static void
c8e532
+fetch_password_expiration_policy (GsdAccountManager *manager)
c8e532
+{
c8e532
+        gsd_accounts_user_call_get_password_expiration_policy (manager->priv->accounts_user_proxy,
c8e532
+                                                               manager->priv->cancellable,
c8e532
+                                                               (GAsyncReadyCallback)
c8e532
+                                                               on_got_password_expiration_policy,
c8e532
+                                                               manager);
c8e532
+}
c8e532
+
c8e532
+static void
c8e532
+on_screensaver_signal (GDBusProxy  *proxy,
c8e532
+                       const gchar *sender_name,
c8e532
+                       const gchar *signal_name,
c8e532
+                       GVariant    *parameters,
c8e532
+                       gpointer     user_data)
c8e532
+{
c8e532
+        GsdAccountManager *manager = user_data;
c8e532
+
c8e532
+        if (g_strcmp0 (signal_name, "ActiveChanged") == 0) {
c8e532
+                gboolean active;
c8e532
+
c8e532
+                g_variant_get (parameters, "(b)", &active);
c8e532
+
c8e532
+                if (!active) {
c8e532
+                        fetch_password_expiration_policy (manager);
c8e532
+                }
c8e532
+        }
c8e532
+}
c8e532
+
c8e532
 static void
c8e532
 on_got_accounts_user_proxy (GObject      *source_object,
c8e532
                             GAsyncResult *res,
c8e532
                             gpointer      user_data)
c8e532
 {
c8e532
         GsdAccountManager *manager = user_data;
c8e532
         g_autoptr(GError)  error = NULL;
c8e532
 
c8e532
         gnome_settings_profile_start (NULL);
c8e532
         manager->priv->accounts_user_proxy = gsd_accounts_user_proxy_new_finish (res, &error);
c8e532
 
c8e532
         if (manager->priv->accounts_user_proxy != NULL) {
c8e532
-                gsd_accounts_user_call_get_password_expiration_policy (manager->priv->accounts_user_proxy,
c8e532
-                                                                       manager->priv->cancellable,
c8e532
-                                                                       (GAsyncReadyCallback)
c8e532
-                                                                       on_got_password_expiration_policy,
c8e532
-                                                                       manager);
c8e532
+                fetch_password_expiration_policy (manager);
c8e532
+
c8e532
+                manager->priv->screensaver_proxy = gnome_settings_bus_get_screen_saver_proxy ();
c8e532
+
c8e532
+                g_signal_connect (manager->priv->screensaver_proxy,
c8e532
+                                  "g-signal",
c8e532
+                                  G_CALLBACK (on_screensaver_signal),
c8e532
+                                  manager);
c8e532
+
c8e532
         } else {
c8e532
                 g_warning ("Failed to get user proxy to accounts service: %s", error->message);
c8e532
                 goto out;
c8e532
         }
c8e532
 
c8e532
 out:
c8e532
         gnome_settings_profile_end (NULL);
c8e532
 }
c8e532
 
c8e532
 static void
c8e532
 on_got_user_object_path (GsdAccounts  *accounts_proxy,
c8e532
                          GAsyncResult *res,
c8e532
                          gpointer      user_data)
c8e532
 {
c8e532
         GsdAccountManager *manager = user_data;
c8e532
         g_autoptr(GError)  error = NULL;
c8e532
         gboolean           succeeded;
c8e532
         gchar             *object_path;
c8e532
         GDBusConnection   *connection;
c8e532
 
c8e532
         gnome_settings_profile_start (NULL);
c8e532
 
c8e532
         succeeded = gsd_accounts_call_find_user_by_id_finish (accounts_proxy,
c8e532
                                                               &object_path,
c8e532
                                                               res,
c8e532
                                                               &error);
c8e532
 
c8e532
         if (!succeeded) {
c8e532
                 g_warning ("Unable to find current user in accounts service: %s",
c8e532
                            error->message);
c8e532
@@ -343,60 +380,61 @@ gsd_account_manager_start (GsdAccountManager  *manager,
c8e532
         g_debug ("Starting accounts manager");
c8e532
 
c8e532
         gnome_settings_profile_start (NULL);
c8e532
         manager->priv->cancellable = g_cancellable_new ();
c8e532
         gsd_accounts_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
c8e532
                                         G_DBUS_PROXY_FLAGS_NONE,
c8e532
                                         "org.freedesktop.Accounts",
c8e532
                                         "/org/freedesktop/Accounts",
c8e532
                                         manager->priv->cancellable,
c8e532
                                         (GAsyncReadyCallback)
c8e532
                                         on_got_accounts_proxy,
c8e532
                                         manager);
c8e532
         gnome_settings_profile_end (NULL);
c8e532
 
c8e532
         return TRUE;
c8e532
 }
c8e532
 
c8e532
 void
c8e532
 gsd_account_manager_stop (GsdAccountManager *manager)
c8e532
 {
c8e532
         g_debug ("Stopping accounts manager");
c8e532
 
c8e532
         if (manager->priv->cancellable != NULL) {
c8e532
                 g_cancellable_cancel (manager->priv->cancellable);
c8e532
                 g_clear_object (&manager->priv->cancellable);
c8e532
         }
c8e532
 
c8e532
         g_clear_object (&manager->priv->accounts_proxy);
c8e532
         g_clear_object (&manager->priv->accounts_user_proxy);
c8e532
         g_clear_object (&manager->priv->notification);
c8e532
+        g_clear_object (&manager->priv->screensaver_proxy);
c8e532
 }
c8e532
 
c8e532
 static void
c8e532
 gsd_account_manager_class_init (GsdAccountManagerClass *klass)
c8e532
 {
c8e532
         GObjectClass   *object_class = G_OBJECT_CLASS (klass);
c8e532
 
c8e532
         object_class->finalize = gsd_account_manager_finalize;
c8e532
 
c8e532
         notify_init ("gnome-settings-daemon");
c8e532
 
c8e532
         g_type_class_add_private (klass, sizeof (GsdAccountManagerPrivate));
c8e532
 }
c8e532
 
c8e532
 static void
c8e532
 gsd_account_manager_init (GsdAccountManager *manager)
c8e532
 {
c8e532
         manager->priv = GSD_ACCOUNT_MANAGER_GET_PRIVATE (manager);
c8e532
 }
c8e532
 
c8e532
 static void
c8e532
 gsd_account_manager_finalize (GObject *object)
c8e532
 {
c8e532
         GsdAccountManager *manager;
c8e532
 
c8e532
         g_return_if_fail (object != NULL);
c8e532
         g_return_if_fail (GSD_IS_ACCOUNT_MANAGER (object));
c8e532
 
c8e532
         manager = GSD_ACCOUNT_MANAGER (object);
c8e532
 
c8e532
-- 
c8e532
2.17.0
c8e532