1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
diff --git a/configure.ac b/configure.ac
index d2a4b87..fd2ec89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,7 +133,7 @@ AC_MSG_RESULT([$with_gtk])
dnl Specify required versions of dependencies
CAIRO_REQUIRED=1.9.10
GLIB_REQUIRED=2.25.11
-KEYRING_REQUIRED=1.1.0
+LIBSECRET_REQUIRED=0.5
case "$with_gtk" in
2.0) GTK_API_VERSION=2.0
@@ -268,12 +268,12 @@ if test "$with_gtk_unix_print" = "yes"; then
fi
# *********************
-# MATE Keyring support
+# Keyring support
# *********************
AC_ARG_WITH(keyring,
[AS_HELP_STRING([--without-keyring],
- [Disable the use of mate-keyring])],
+ [Disable the use of libsecret and keyring])],
[],
[case "$with_platform" in
mate) with_keyring=yes ;;
@@ -283,7 +283,7 @@ AC_ARG_WITH(keyring,
AM_CONDITIONAL([WITH_KEYRING],[test "$with_keyring" = "yes"])
if test "$with_keyring" = "yes"; then
- PKG_CHECK_MODULES(KEYRING, mate-keyring-1 >= $KEYRING_REQUIRED)
+ PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= $LIBSECRET_REQUIRED)
AC_DEFINE([WITH_KEYRING],[1],[Define if KEYRING support is enabled])
fi
@@ -341,8 +341,8 @@ BACKEND_LIBS="$BACKEND_LIBS -lm"
AC_SUBST(BACKEND_CFLAGS)
AC_SUBST(BACKEND_LIBS)
-SHELL_CFLAGS="$SHELL_CORE_CFLAGS $KEYRING_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
-SHELL_LIBS="$SHELL_CORE_LIBS $KEYRING_LIBS -lz -lm"
+SHELL_CFLAGS="$SHELL_CORE_CFLAGS $LIBSECRET_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
+SHELL_LIBS="$SHELL_CORE_LIBS $LIBSECRET_LIBS -lz -lm"
AC_SUBST(SHELL_CFLAGS)
AC_SUBST(SHELL_LIBS)
diff --git a/shell/ev-keyring.c b/shell/ev-keyring.c
index ac1d33a..3a9cd4c 100644
--- a/shell/ev-keyring.c
+++ b/shell/ev-keyring.c
@@ -25,24 +25,25 @@
#include "ev-keyring.h"
#ifdef WITH_KEYRING
-#include <mate-keyring.h>
+#include <libsecret/secret.h>
-static const MateKeyringPasswordSchema doc_password_schema = {
- MATE_KEYRING_ITEM_GENERIC_SECRET,
+static const SecretSchema doc_password_schema = {
+ "org.mate.Atril.Document",
+ SECRET_SCHEMA_DONT_MATCH_NAME,
{
- { "type", MATE_KEYRING_ATTRIBUTE_TYPE_STRING },
- { "uri", MATE_KEYRING_ATTRIBUTE_TYPE_STRING },
+ { "type", SECRET_SCHEMA_ATTRIBUTE_STRING },
+ { "uri", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 }
}
};
-const MateKeyringPasswordSchema *EV_DOCUMENT_PASSWORD_SCHEMA = &doc_password_schema;
+const SecretSchema *EV_DOCUMENT_PASSWORD_SCHEMA = &doc_password_schema;
#endif /* WITH_KEYRING */
gboolean
ev_keyring_is_available (void)
{
#ifdef WITH_KEYRING
- return mate_keyring_is_available ();
+ return TRUE;
#else
return FALSE;
#endif
@@ -51,31 +52,17 @@
gchar *
ev_keyring_lookup_password (const gchar *uri)
{
- gchar *retval = NULL;
#ifdef WITH_KEYRING
- MateKeyringResult result;
- gchar *password = NULL;
-
g_return_val_if_fail (uri != NULL, NULL);
- if (!mate_keyring_is_available ())
- return NULL;
-
- result = mate_keyring_find_password_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
- &password,
- "type", "document_password",
- "uri", uri,
- NULL);
- if (result != MATE_KEYRING_RESULT_OK || !password) {
- if (password)
- mate_keyring_free_password (password);
- return NULL;
- }
-
- retval = g_strdup (password);
- mate_keyring_free_password (password);
+ return secret_password_lookup_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
+ NULL, NULL,
+ "type", "document_password",
+ "uri", uri,
+ NULL);
+#else
+ return NULL;
#endif /* WITH_KEYRING */
- return retval;
}
gboolean
@@ -84,32 +71,29 @@
GPasswordSave flags)
{
#ifdef WITH_KEYRING
- MateKeyringResult result;
- const gchar *keyring;
- gchar *name;
- gchar *unescaped_uri;
+ const gchar *keyring;
+ gchar *name;
+ gchar *unescaped_uri;
+ gboolean retval;
g_return_val_if_fail (uri != NULL, FALSE);
- if (!mate_keyring_is_available ())
- return FALSE;
-
if (flags == G_PASSWORD_SAVE_NEVER)
return FALSE;
- keyring = (flags == G_PASSWORD_SAVE_FOR_SESSION) ? "session" : NULL;
+ keyring = (flags == G_PASSWORD_SAVE_FOR_SESSION) ? SECRET_COLLECTION_SESSION : NULL;
unescaped_uri = g_uri_unescape_string (uri, NULL);
name = g_strdup_printf (_("Password for document %s"), unescaped_uri);
g_free (unescaped_uri);
- result = mate_keyring_store_password_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
- keyring, name, password,
- "type", "document_password",
- "uri", uri,
- NULL);
+ retval = secret_password_store_sync (EV_DOCUMENT_PASSWORD_SCHEMA, keyring,
+ name, password, NULL, NULL,
+ "type", "document_password",
+ "uri", uri,
+ NULL);
g_free (name);
- return (result == MATE_KEYRING_RESULT_OK);
+ return retval;
#else
return FALSE;
#endif /* WITH_KEYRING */
|