gnome-settings-daemon/SOURCES/0002-account-reshow-the-notification-when-screen-unlocks.patch
2021-09-09 17:49:58 +00:00

272 lines
10 KiB
Diff

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