libpurple/plugins/libsecret/libsecret.c

Tue, 20 Feb 2024 00:40:30 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 20 Feb 2024 00:40:30 -0600
changeset 42591
aa3f777462d8
parent 42572
f053e7fdd25d
child 42592
6b65c0e4ba15
permissions
-rw-r--r--

Use g_task_set_source_tag on all of our async methods

This is supposed to help with debugging and profiling per the docs for
g_task_set_name, which is automatically called by g_task_set_source_tag in
glib >= 2.76.0 which is our minimum requirement.

Testing Done:
Consulted with the turtles

Reviewed at https://reviews.imfreedom.org/r/2955/

40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
1 /*
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
2 * Purple - Internet Messaging Library
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 *
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
5 * This library is free software; you can redistribute it and/or
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
7 * License as published by the Free Software Foundation; either
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
8 * version 2 of the License, or (at your option) any later version.
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
9 *
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
10 * This library is distributed in the hope that it will be useful,
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
13 * Lesser General Public License for more details.
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
14 *
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 */
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
18
34197
e3507bd26a39 Disable Secret Service keyring, because of its (current) poor quality, far away from being ready to ship
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
19 /* TODO
e3507bd26a39 Disable Secret Service keyring, because of its (current) poor quality, far away from being ready to ship
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
20 *
38157
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
21 * This keyring now works (at the time of this writing), but there are
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
22 * some inconvenient edge cases. When looking up passwords, libsecret
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
23 * doesn't error if the keyring is locked. Therefore, it appears to
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
24 * this plugin that there's no stored password. libpurple seems to
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
25 * handle this as gracefully as possible, but it's still inconvenient.
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
26 * This plugin could possibly be ported to use libsecret's "Complete API"
2db097f95f6a libsecret-keyring: Update TODO to reflect recent changes
Mike Ruprecht <cmaiku@gmail.com>
parents: 38156
diff changeset
27 * to resolve this if desired.
34197
e3507bd26a39 Disable Secret Service keyring, because of its (current) poor quality, far away from being ready to ship
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
28 */
e3507bd26a39 Disable Secret Service keyring, because of its (current) poor quality, far away from being ready to ship
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34155
diff changeset
29
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 39959
diff changeset
30 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 39959
diff changeset
31
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
32 #include <gplugin.h>
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
33 #include <gplugin-native.h>
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
34
39959
e47fcffd061b migrate the libpurple plugins to using purple.h only
Gary Kramlich <grim@reaperworld.com>
parents: 39921
diff changeset
35 #include <purple.h>
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
36
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
37 #include <libsecret/secret.h>
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
38
36136
3e884ce58f23 Add note for translators.
Mark Doliner <mark@kingant.net>
parents: 35362
diff changeset
39 /* Translators: Secret Service is a service that runs on the user's computer.
3e884ce58f23 Add note for translators.
Mark Doliner <mark@kingant.net>
parents: 35362
diff changeset
40 It is one option for where the user's passwords can be stored. It is a
3e884ce58f23 Add note for translators.
Mark Doliner <mark@kingant.net>
parents: 35362
diff changeset
41 project name. It may not be appropriate to translate this string, but
36145
0b3bca55747d s/reason/reasonable/ (thanks, rlaager)
Mark Doliner <mark@kingant.net>
parents: 36136
diff changeset
42 transliterating to your alphabet is reasonable. More info about the
0b3bca55747d s/reason/reasonable/ (thanks, rlaager)
Mark Doliner <mark@kingant.net>
parents: 36136
diff changeset
43 project can be found at https://wiki.gnome.org/Projects/Libsecret */
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
44 #define LIBSECRET_ID "libsecret"
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
45 #define LIBSECRET_NAME N_("libsecret")
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
46 #define LIBSECRET_DESCRIPTION N_("Credential provider for libsecret. Common " \
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
47 "in GNOME and other desktop environments.")
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
48
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
49 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
50 * Globals
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
51 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
52 static PurpleCredentialProvider *instance = NULL;
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
53
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
54 static const SecretSchema purple_libsecret_schema = {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
55 "im.pidgin.Purple3", SECRET_SCHEMA_NONE,
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
56 {
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
57 {"user", SECRET_SCHEMA_ATTRIBUTE_STRING},
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
58 {"protocol", SECRET_SCHEMA_ATTRIBUTE_STRING},
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
59 {"NULL", 0}
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
60 },
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
61 /* Reserved fields */
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
62 0, 0, 0, 0, 0, 0, 0, 0
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
63 };
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
64
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
65 #define PURPLE_TYPE_LIBSECRET (purple_libsecret_get_type())
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
66 G_DECLARE_FINAL_TYPE(PurpleLibSecret, purple_libsecret,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
67 PURPLE, LIBSECRET, PurpleCredentialProvider)
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
69 struct _PurpleLibSecret {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
70 PurpleCredentialProvider parent;
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
71 };
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
72
42572
f053e7fdd25d Make sure all of the final types in the purple plugins are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42076
diff changeset
73 G_DEFINE_DYNAMIC_TYPE_EXTENDED(PurpleLibSecret, purple_libsecret,
f053e7fdd25d Make sure all of the final types in the purple plugins are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42076
diff changeset
74 PURPLE_TYPE_CREDENTIAL_PROVIDER,
f053e7fdd25d Make sure all of the final types in the purple plugins are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42076
diff changeset
75 G_TYPE_FLAG_FINAL, {})
38153
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
76
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
77 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
78 * Callbacks
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
79 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
80 static void
42076
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
81 purple_libsecret_read_password_callback(G_GNUC_UNUSED GObject *obj,
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
82 GAsyncResult *result, gpointer data)
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
83 {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
84 GTask *task = G_TASK(data);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
85 GError *error = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
86 gchar *password = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
87
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
88 password = secret_password_lookup_finish(result, &error);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
89
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
90 if(error != NULL) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
91 g_task_return_error(task, error);
38153
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
92 } else {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
93 g_task_return_pointer(task, password, g_free);
38153
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
94 }
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
95
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
96 g_object_unref(G_OBJECT(task));
38153
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
97 }
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
98
d4cd494a36a5 libsecret-keyring: Factor out GError handling into its own function
Mike Ruprecht <cmaiku@gmail.com>
parents: 38152
diff changeset
99 static void
42076
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
100 purple_libsecret_write_password_callback(G_GNUC_UNUSED GObject *obj,
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
101 GAsyncResult *result, gpointer data)
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
102 {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
103 GTask *task = G_TASK(data);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
104 GError *error = NULL;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
105 gboolean ret = FALSE;
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
106
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
107 ret = secret_password_store_finish(result, &error);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
108
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
109 if(error != NULL) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
110 g_task_return_error(task, error);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
111 } else {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
112 g_task_return_boolean(task, ret);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
113 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
114
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
115 g_object_unref(G_OBJECT(task));
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
116 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
117
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
118 static void
42076
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
119 purple_libsecret_clear_password_callback(G_GNUC_UNUSED GObject *obj,
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
120 GAsyncResult *result, gpointer data)
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
121 {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
122 GTask *task = G_TASK(data);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
123 GError *error = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
124
41031
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
125 /* This returns whether a password was removed or not. Which means that it
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
126 * can return FALSE with error unset. This would complicate all of the other
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
127 * credential API and we don't need to make this distinction, so we just
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
128 * return TRUE unless error is set.
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
129 */
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
130 secret_password_clear_finish(result, &error);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
131
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
132 if(error != NULL) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
133 g_task_return_error(task, error);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
134 } else {
41031
2918459dbd63 Don't error out when trying to remove a password that isn't stored.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
135 g_task_return_boolean(task, TRUE);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
136 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
137
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
138 g_object_unref(G_OBJECT(task));
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
139 }
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
140
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
141 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
142 * PurpleCredentialProvider Implementation
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
143 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
144 static void
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
145 purple_libsecret_read_password_async(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
146 PurpleAccount *account,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
147 GCancellable *cancellable,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
148 GAsyncReadyCallback callback,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
149 gpointer data)
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
150 {
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
151 PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
42591
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
152 GTask *task = NULL;
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
153
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
154 task = g_task_new(G_OBJECT(provider), cancellable, callback, data);
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
155 g_task_set_source_tag(task, purple_libsecret_read_password_async);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
156
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
157 secret_password_lookup(&purple_libsecret_schema, cancellable,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
158 purple_libsecret_read_password_callback, task,
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
159 "user", purple_contact_info_get_username(info),
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
160 "protocol", purple_account_get_protocol_id(account),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
161 NULL);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
162 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
163
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
164 static gchar *
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
165 purple_libsecret_read_password_finish(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
166 GAsyncResult *result,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
167 GError **error)
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
168 {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
169 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
170 g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
171
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
172 return g_task_propagate_pointer(G_TASK(result), error);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
173 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
174
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
175 static void
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
176 purple_libsecret_write_password_async(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
177 PurpleAccount *account,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
178 const gchar *password,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
179 GCancellable *cancellable,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
180 GAsyncReadyCallback callback,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
181 gpointer data)
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
182 {
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
183 PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
184 GTask *task = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
185 gchar *label = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
186 const gchar *username = NULL;
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
187
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
188 task = g_task_new(G_OBJECT(provider), cancellable, callback, data);
42591
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
189 g_task_set_source_tag(task, purple_libsecret_write_password_async);
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
190 username = purple_contact_info_get_username(info);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
191
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
192 label = g_strdup_printf(_("libpurple password for account %s"), username);
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
193 secret_password_store(&purple_libsecret_schema,
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
194 SECRET_COLLECTION_DEFAULT, label, password,
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
195 cancellable,
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
196 purple_libsecret_write_password_callback, task,
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
197 "user", username,
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
198 "protocol", purple_account_get_protocol_id(account),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
199 NULL);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
200 g_free(label);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
201 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
202
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
203 static gboolean
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
204 purple_libsecret_write_password_finish(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
205 GAsyncResult *result,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
206 GError **error)
38154
bb021423c1bb libsecret-keyring: Use correct *_finish() functions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38153
diff changeset
207 {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
208 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
209 g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
38154
bb021423c1bb libsecret-keyring: Use correct *_finish() functions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38153
diff changeset
210
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
211 return g_task_propagate_boolean(G_TASK(result), error);
38154
bb021423c1bb libsecret-keyring: Use correct *_finish() functions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38153
diff changeset
212 }
bb021423c1bb libsecret-keyring: Use correct *_finish() functions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38153
diff changeset
213
bb021423c1bb libsecret-keyring: Use correct *_finish() functions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38153
diff changeset
214 static void
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
215 purple_libsecret_clear_password_async(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
216 PurpleAccount *account,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
217 GCancellable *cancellable,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
218 GAsyncReadyCallback callback,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
219 gpointer data)
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
220 {
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
221 PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
42591
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
222 GTask *task = NULL;
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
223
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
224 task = g_task_new(G_OBJECT(provider), cancellable, callback, data);
aa3f777462d8 Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents: 42572
diff changeset
225 g_task_set_source_tag(task, purple_libsecret_clear_password_async);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
226
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
227 secret_password_clear(&purple_libsecret_schema, cancellable,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
228 purple_libsecret_clear_password_callback, task,
41974
9ad66abc9356 Update the libpurple plugins for the account deprecations
Gary Kramlich <grim@reaperworld.com>
parents: 41172
diff changeset
229 "user", purple_contact_info_get_username(info),
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
230 "protocol", purple_account_get_protocol_id(account),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
231 NULL);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
232 }
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
233
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
234 static gboolean
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
235 purple_libsecret_clear_password_finish(PurpleCredentialProvider *provider,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
236 GAsyncResult *result,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
237 GError **error)
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
238 {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
239 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
240 g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
241
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
242 return g_task_propagate_boolean(G_TASK(result), error);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
243 }
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
244
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
245 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
246 * GObject Implementation
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
247 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
248 static void
42076
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
249 purple_libsecret_init(G_GNUC_UNUSED PurpleLibSecret *libsecret) {
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
250 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
251
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
252 static void
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
253 purple_libsecret_class_init(PurpleLibSecretClass *klass) {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
254 PurpleCredentialProviderClass *provider_class = NULL;
38155
5021b2db0ee5 libsecret-keyring: Implement cancel functionality
Mike Ruprecht <cmaiku@gmail.com>
parents: 38154
diff changeset
255
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
256 provider_class = PURPLE_CREDENTIAL_PROVIDER_CLASS(klass);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
257 provider_class->read_password_async =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
258 purple_libsecret_read_password_async;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
259 provider_class->read_password_finish =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
260 purple_libsecret_read_password_finish;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
261 provider_class->write_password_async =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
262 purple_libsecret_write_password_async;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
263 provider_class->write_password_finish =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
264 purple_libsecret_write_password_finish;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
265 provider_class->clear_password_async =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
266 purple_libsecret_clear_password_async;
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
267 provider_class->clear_password_finish =
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
268 purple_libsecret_clear_password_finish;
38155
5021b2db0ee5 libsecret-keyring: Implement cancel functionality
Mike Ruprecht <cmaiku@gmail.com>
parents: 38154
diff changeset
269 }
5021b2db0ee5 libsecret-keyring: Implement cancel functionality
Mike Ruprecht <cmaiku@gmail.com>
parents: 38154
diff changeset
270
5021b2db0ee5 libsecret-keyring: Implement cancel functionality
Mike Ruprecht <cmaiku@gmail.com>
parents: 38154
diff changeset
271 static void
42076
76417a1fa9b2 Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents: 41974
diff changeset
272 purple_libsecret_class_finalize(G_GNUC_UNUSED PurpleLibSecretClass *klass) {
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
273 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
274
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
275 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
276 * API
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
277 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
278 static PurpleCredentialProvider *
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
279 purple_libsecret_new(void) {
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
280 return g_object_new(
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
281 PURPLE_TYPE_LIBSECRET,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
282 "id", LIBSECRET_ID,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
283 "name", _(LIBSECRET_NAME),
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
284 "description", _(LIBSECRET_DESCRIPTION),
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
285 NULL
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
286 );
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
287 }
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
288
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
289 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
290 * Plugin Exports
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
291 *****************************************************************************/
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
292 static GPluginPluginInfo *
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
293 libsecret_query(G_GNUC_UNUSED GError **error) {
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
294 const gchar * const authors[] = {
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
295 "Pidgin Developers <devel@pidgin.im>",
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
296 NULL
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
297 };
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
298
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
299 return GPLUGIN_PLUGIN_INFO(purple_plugin_info_new(
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
300 "id", "credential-provider-" LIBSECRET_ID,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
301 "name", LIBSECRET_NAME,
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
302 "version", DISPLAY_VERSION,
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
303 "category", N_("Credentials"),
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
304 "summary", "libsecret credential provider",
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
305 "description", N_("Adds support for using libsecret as a credential "
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
306 "provider."),
36642
b8ba53daa445 Updated libpurple to use current GPlugin
Ankit Vani <a@nevitus.org>
parents: 36505
diff changeset
307 "authors", authors,
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
308 "website", PURPLE_WEBSITE,
36505
60c161851325 Integrated purple ABI requirement into GPlugin's "abi-version" property
Ankit Vani <a@nevitus.org>
parents: 36502
diff changeset
309 "abi-version", PURPLE_ABI_VERSION,
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
310 "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
311 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
312 NULL
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
313 ));
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
314 }
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
315
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
316 static gboolean
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
317 libsecret_load(GPluginPlugin *plugin, GError **error) {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
318 PurpleCredentialManager *manager = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
319
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
320 purple_libsecret_register_type(G_TYPE_MODULE(plugin));
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
321
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
322 manager = purple_credential_manager_get_default();
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
323
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
324 instance = purple_libsecret_new();
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
325
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40882
diff changeset
326 return purple_credential_manager_register(manager, instance, error);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
327 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
328
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
329 static gboolean
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
330 libsecret_unload(G_GNUC_UNUSED GPluginPlugin *plugin,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
331 G_GNUC_UNUSED gboolean shutdown,
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
332 GError **error)
41078
84e48180ef67 Update to gplugin 0.35.0
Gary Kramlich <grim@reaperworld.com>
parents: 41031
diff changeset
333 {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
334 PurpleCredentialManager *manager = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
335 gboolean ret = FALSE;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
336
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
337 manager = purple_credential_manager_get_default();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40882
diff changeset
338 ret = purple_credential_manager_unregister(manager, instance, error);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
339 if(!ret) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
340 return ret;
36502
dfce617913fe Refactored keyrings to use the new API
Ankit Vani <a@nevitus.org>
parents: 36459
diff changeset
341 }
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
342
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
343 g_clear_object(&instance);
34107
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
344
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
345 return TRUE;
efe6019c9e91 Add a Secret Service password plugin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
346 }
40882
77df4bdbc750 Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents: 40790
diff changeset
347
41172
db38cdfbc59e Rename the secretservice plugin to libsecret and move it into the plugins directory
Gary Kramlich <grim@reaperworld.com>
parents: 41078
diff changeset
348 GPLUGIN_NATIVE_PLUGIN_DECLARE(libsecret)

mercurial