summaryrefslogtreecommitdiff
path: root/src/gpm-control.c
diff options
context:
space:
mode:
authorNP-Hardass <[email protected]>2020-08-03 01:49:47 -0400
committerraveit65 <[email protected]>2020-10-20 10:34:23 +0200
commitf7bcd6312be1f987572c9a8f20535ebe8eeeec5e (patch)
tree03c3ac320f1276d8e5c5a9e1afaa2410d2fed0d6 /src/gpm-control.c
parent8a2b582dbec78dfb2d60170c691af2948e55a960 (diff)
downloadmate-power-manager-f7bcd6312be1f987572c9a8f20535ebe8eeeec5e.tar.bz2
mate-power-manager-f7bcd6312be1f987572c9a8f20535ebe8eeeec5e.tar.xz
gpm-control.c: Add libsecret implementation to gpm_control_suspend()
Diffstat (limited to 'src/gpm-control.c')
-rw-r--r--src/gpm-control.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gpm-control.c b/src/gpm-control.c
index 4834a05..221ed60 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -39,6 +39,9 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
+#ifdef WITH_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* WITH_LIBSECRET */
#ifdef WITH_KEYRING
#include <gnome-keyring.h>
#endif /* WITH_KEYRING */
@@ -210,6 +213,13 @@ gpm_control_suspend (GpmControl *control, GError **error)
EggConsoleKit *console;
GpmScreensaver *screensaver;
guint32 throttle_cookie = 0;
+#ifdef WITH_LIBSECRET
+ gboolean lock_libsecret;
+ GCancellable *libsecret_cancellable = NULL;
+ SecretService *secretservice_proxy = NULL;
+ gint num_secrets_locked;
+ GList *libsecret_collections = NULL;
+#endif /* WITH_LIBSECRET */
#ifdef WITH_KEYRING
gboolean lock_gnome_keyring;
GnomeKeyringResult keyres;
@@ -233,6 +243,36 @@ gpm_control_suspend (GpmControl *control, GError **error)
}
}
+#ifdef WITH_LIBSECRET
+ /* we should perhaps lock keyrings when sleeping #375681 */
+ lock_libsecret = g_settings_get_boolean (control->priv->settings,
+ GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+ if (lock_libsecret) {
+ libsecret_cancellable = g_cancellable_new ();
+ secretservice_proxy = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS,
+ libsecret_cancellable,
+ error);
+ if (secretservice_proxy == NULL) {
+ g_warning ("failed to connect to secret service");
+ } else {
+ libsecret_collections = secret_service_get_collections (secretservice_proxy);
+ if ( libsecret_collections == NULL) {
+ g_warning ("failed to get secret collections");
+ } else {
+ num_secrets_locked = secret_service_lock_sync (secretservice_proxy,
+ libsecret_collections,
+ libsecret_cancellable,
+ NULL,
+ error);
+ if (num_secrets_locked <= 0)
+ g_warning ("could not lock keyring");
+ g_list_free (libsecret_collections);
+ }
+ g_object_unref (secretservice_proxy);
+ }
+ g_object_unref (libsecret_cancellable);
+ }
+#endif /* WITH_LIBSECRET */
#ifdef WITH_KEYRING
/* we should perhaps lock keyrings when sleeping #375681 */
lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_SUSPEND);