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

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