libpurple/purplecredentialmanager.c

Mon, 18 Oct 2021 01:36:58 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 18 Oct 2021 01:36:58 -0500
changeset 41105
02c3569bc32b
parent 40987
671f2442e50e
child 41128
445f5cc52e1a
permissions
-rw-r--r--

Add gi-docgen as a subproject so we can convert the documentation to it

Testing Done:
Just compiled and verified that our `.wrap` file didn't get overwritten by a `wrap-file` from gplugin.

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

40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * (at your option) any later version.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * GNU General Public License for more details.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * along with this program; if not, see <https://www.gnu.org/licenses/>.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib/gi18n-lib.h>
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include "purplecredentialmanager.h"
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
22
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
23 #include "core.h"
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
24 #include "debug.h"
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
25 #include "prefs.h"
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
26 #include "purplenoopcredentialprovider.h"
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "purpleprivate.h"
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
28 #include "util.h"
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 enum {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
31 SIG_REGISTERED,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
32 SIG_UNREGISTERED,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
33 SIG_ACTIVE_CHANGED,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 N_SIGNALS,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 static guint signals[N_SIGNALS] = {0, };
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 typedef struct {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GHashTable *providers;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
41 PurpleCredentialProvider *active;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 } PurpleCredentialManagerPrivate;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 G_DEFINE_TYPE_WITH_PRIVATE(PurpleCredentialManager, purple_credential_manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 G_TYPE_OBJECT);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static PurpleCredentialManager *default_manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 * Async Callbacks
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 purple_credential_manager_read_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
59 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 gchar *password = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
62 password = purple_credential_provider_read_password_finish(provider, res,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 &error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 if(error != NULL) {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
66 g_task_return_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
68 g_task_return_pointer(task, password, g_free);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 /* Clean up our initial reference to the task. */
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
72 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 purple_credential_manager_write_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
82 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
85 ret = purple_credential_provider_write_password_finish(provider, res,
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
86 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 if(error != NULL) {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
89 g_task_return_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
91 g_task_return_boolean(task, ret);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 /* Clean up our initial reference to the task. */
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
95 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 purple_credential_manager_clear_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
105 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
108 ret = purple_credential_provider_clear_password_finish(provider, res,
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
109 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 if(error != NULL) {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
112 g_task_return_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
114 g_task_return_boolean(task, ret);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 /* Clean up our initial reference to the task. */
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
118 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
121 /******************************************************************************
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
122 * Purple Callbacks
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
123 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
124 static void
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
125 purple_credential_manager_core_init_cb(gpointer data) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
126 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(data);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
127 PurpleCredentialManagerPrivate *priv = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
128
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
129 priv = purple_credential_manager_get_instance_private(manager);
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
130 if(!PURPLE_IS_CREDENTIAL_PROVIDER(priv->active)) {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
131 purple_notify_error(NULL, _("Credential Manager"),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
132 _("Failed to load the selected credential "
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
133 "provider."),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
134 _("Check your system configuration or select "
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
135 "another one in the preferences dialog."), NULL);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
136 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
137 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 * GObject Implementation
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 purple_credential_manager_finalize(GObject *obj) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 PurpleCredentialManager *manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 g_clear_pointer(&priv->providers, g_hash_table_destroy);
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
151 g_clear_object(&priv->active);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 G_OBJECT_CLASS(purple_credential_manager_parent_class)->finalize(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 purple_credential_manager_init(PurpleCredentialManager *manager) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 PurpleCredentialManagerPrivate *priv = NULL;
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
159 PurpleCredentialProvider *noop = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 priv->providers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 g_object_unref);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
165
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
166 noop = purple_noop_credential_provider_new();
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
167 purple_credential_manager_register(manager, noop, NULL);
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
168 g_object_unref(G_OBJECT(noop));
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
169
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
170 /* Connect to the core-initialized signal so we can alert the user if we
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
171 * were unable to find their credential provider.
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
172 */
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
173 purple_signal_connect(purple_get_core(), "core-initialized", manager,
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
174 PURPLE_CALLBACK(purple_credential_manager_core_init_cb),
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
175 manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 purple_credential_manager_class_init(PurpleCredentialManagerClass *klass) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 obj_class->finalize = purple_credential_manager_finalize;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
185 * PurpleCredentialManager::registered:
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 * @manager: The #PurpleCredentialManager instance.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 * @provider: The #PurpleCredentialProvider that was registered.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 * Emitted after @provider has been registered in @manager.
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
190 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
191 * Since: 3.0.0
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
193 signals[SIG_REGISTERED] = g_signal_new(
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
194 "registered",
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 G_OBJECT_CLASS_TYPE(klass),
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 G_SIGNAL_RUN_LAST,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
197 G_STRUCT_OFFSET(PurpleCredentialManagerClass, registered),
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 G_TYPE_NONE,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 1,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 PURPLE_TYPE_CREDENTIAL_PROVIDER);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
206 * PurpleCredentialManager::unregistered:
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 * @manager: The #PurpleCredentialManager instance.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 * @provider: The #PurpleCredentialProvider that was unregistered.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 * Emitted after @provider has been unregistered from @manager.
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
211 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
212 * Since: 3.0.0
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
214 signals[SIG_UNREGISTERED] = g_signal_new(
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
215 "unregistered",
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 G_OBJECT_CLASS_TYPE(klass),
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 G_SIGNAL_RUN_LAST,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
218 G_STRUCT_OFFSET(PurpleCredentialManagerClass, unregistered),
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 G_TYPE_NONE,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 1,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 PURPLE_TYPE_CREDENTIAL_PROVIDER);
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
225
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
226 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
227 * PurpleCredentialManager::active-changed:
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
228 * @manager: The #PurpleCredentialManager instance.
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
229 * @previous: The #PurpleCredentialProvider that was previously active.
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
230 * @current: The #PurpleCredentialProvider that is now currently active.
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
231 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
232 * Emitted after @provider has become the active provider for @manager.
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
233 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
234 * Since: 3.0.0
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
235 */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
236 signals[SIG_ACTIVE_CHANGED] = g_signal_new(
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
237 "active-changed",
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
238 G_OBJECT_CLASS_TYPE(klass),
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
239 G_SIGNAL_RUN_LAST,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
240 G_STRUCT_OFFSET(PurpleCredentialManagerClass, active_changed),
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
241 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
242 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
243 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
244 G_TYPE_NONE,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
245 2,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
246 PURPLE_TYPE_CREDENTIAL_PROVIDER,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
247 PURPLE_TYPE_CREDENTIAL_PROVIDER);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 * Private API
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 purple_credential_manager_startup(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 if(default_manager == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 default_manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 purple_credential_manager_shutdown(void) {
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
262 if(PURPLE_IS_CREDENTIAL_MANAGER(default_manager)) {
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
263 PurpleCredentialManagerPrivate *priv = NULL;
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
264 guint size = 0;
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
265
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
266 priv = purple_credential_manager_get_instance_private(default_manager);
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
267
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
268 size = g_hash_table_size(priv->providers);
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
269 if(size > 0) {
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
270 g_warning("purple_credential_manager_shutdown called while %d "
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
271 "providers were still registered. Skipping shutdown",
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
272 size);
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
273 } else {
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
274 g_clear_object(&default_manager);
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
275 }
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
276 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 * Public API
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 PurpleCredentialManager *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 purple_credential_manager_get_default(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 return default_manager;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
288 purple_credential_manager_register(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
289 PurpleCredentialProvider *provider,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
290 GError **error)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 const gchar *id = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 if(!purple_credential_provider_is_valid(provider, error)) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 /* purple_credential_provider_is_valid sets the error on failure. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 id = purple_credential_provider_get_id(provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 if(g_hash_table_lookup(priv->providers, id) != NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 _("provider %s is already registered"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 g_hash_table_insert(priv->providers, g_strdup(id), g_object_ref(provider));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
316 g_signal_emit(G_OBJECT(manager), signals[SIG_REGISTERED], 0, provider);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
318 /* If we don't currently have an active provider, check if the newly
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
319 * registered provider has the id of the stored provider in preferences.
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
320 * If it is, go ahead and make it the active provider.
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
321 */
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
322 if(!PURPLE_IS_CREDENTIAL_PROVIDER(priv->active)) {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
323 const gchar *wanted = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
324
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
325 wanted = purple_prefs_get_string("/purple/credentials/active-provider");
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
326
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
327 if(purple_strequal(wanted, id)) {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
328 purple_credential_manager_set_active(manager, id, error);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
329 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
330 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
331
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
336 purple_credential_manager_unregister(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
337 PurpleCredentialProvider *provider,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
338 GError **error)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 const gchar *id = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 id = purple_credential_provider_get_id(provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
349 if(provider == priv->active) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 _("provider %s is currently in use"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 if(g_hash_table_remove(priv->providers, id)) {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
357 g_signal_emit(G_OBJECT(manager), signals[SIG_UNREGISTERED], 0,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 _("provider %s is not registered"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
370 purple_credential_manager_set_active(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
371 const gchar *id, GError **error)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 PurpleCredentialManagerPrivate *priv = NULL;
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
374 PurpleCredentialProvider *previous = NULL, *provider = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
380 /* First look up the new provider if we're given one. */
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
381 if(id != NULL) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
382 provider = g_hash_table_lookup(priv->providers, id);
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
383 if(!PURPLE_IS_CREDENTIAL_PROVIDER(provider)) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
384 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
385 "no credential provider found with id %s", id);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
387 return FALSE;
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
388 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
391 if(PURPLE_IS_CREDENTIAL_PROVIDER(priv->active)) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
392 previous = PURPLE_CREDENTIAL_PROVIDER(g_object_ref(priv->active));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
395 if(g_set_object(&priv->active, provider)) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
396 if(PURPLE_IS_CREDENTIAL_PROVIDER(previous)) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
397 purple_credential_provider_deactivate(previous);
40823
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
398 }
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
399
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
400 if(PURPLE_IS_CREDENTIAL_PROVIDER(provider)) {
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
401 purple_credential_provider_activate(provider);
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
402 }
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
403
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
404 g_signal_emit(G_OBJECT(manager), signals[SIG_ACTIVE_CHANGED], 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
405 previous, priv->active);
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
406 }
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
407
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
408 g_clear_object(&previous);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
410 purple_debug_info("credential-manager", "set active provider to '%s'", id);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
411
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
415 PurpleCredentialProvider *
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
416 purple_credential_manager_get_active(PurpleCredentialManager *manager) {
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
417 PurpleCredentialManagerPrivate *priv = NULL;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
418
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
419 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), NULL);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
420
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
421 priv = purple_credential_manager_get_instance_private(manager);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
422
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
423 return priv->active;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
424 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
425
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427 purple_credential_manager_read_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
443 if(priv->active != NULL) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
444 purple_credential_provider_read_password_async(priv->active, account,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
445 cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
446 purple_credential_manager_read_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
447 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
448 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
449 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
450 _("can not read password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
451 "credential provider"));
40749
b7ee9469eccc g_task_return_* refs a task so we need to make sure we remove our reference when we're done with the task.
Gary Kramlich <grim@reaperworld.com>
parents: 40743
diff changeset
452 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 gchar *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 purple_credential_manager_read_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), NULL);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
463 return g_task_propagate_pointer(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 purple_credential_manager_write_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 const gchar *password,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
472 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
484 if(!purple_account_get_remember_password(account)) {
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
485 const gchar *name = purple_account_get_username(account);
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
486
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
487 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
488 _("account \"%s\" is not marked to be stored"),
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
489 name);
40749
b7ee9469eccc g_task_return_* refs a task so we need to make sure we remove our reference when we're done with the task.
Gary Kramlich <grim@reaperworld.com>
parents: 40743
diff changeset
490 g_object_unref(G_OBJECT(task));
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
491
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
492 return;
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
493 }
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
494
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
495 if(priv->active != NULL) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
496 purple_credential_provider_write_password_async(priv->active, account,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
497 password, cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
498 purple_credential_manager_write_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
499 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
500 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
501 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
502 _("can not write password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
503 "credential provider"));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
504
40749
b7ee9469eccc g_task_return_* refs a task so we need to make sure we remove our reference when we're done with the task.
Gary Kramlich <grim@reaperworld.com>
parents: 40743
diff changeset
505 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
506 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
507
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511 purple_credential_manager_write_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
512 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
515 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
516
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
517 return g_task_propagate_boolean(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
520 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521 purple_credential_manager_clear_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
524 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
529
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
532
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
537 if(priv->active != NULL) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
538 purple_credential_provider_clear_password_async(priv->active, account,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
539 cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
540 purple_credential_manager_clear_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
541 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
542 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
543 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
544 _("can not clear password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
545 "credential provider"));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546
40749
b7ee9469eccc g_task_return_* refs a task so we need to make sure we remove our reference when we're done with the task.
Gary Kramlich <grim@reaperworld.com>
parents: 40743
diff changeset
547 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
548 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
549 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
550
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552 purple_credential_manager_clear_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
553 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
554 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
557
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
558 return g_task_propagate_boolean(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
559 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
560
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561 PurpleRequestFields *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
562 purple_credential_manager_read_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
564 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
565 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
567 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
569 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
571 if(priv->active != NULL) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
572 return purple_credential_provider_read_settings(priv->active);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
575 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
576 _("can not read settings, no active credential provider"));
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
577
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
578 return NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582 purple_credential_manager_write_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583 PurpleRequestFields *fields,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
589
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
590 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
592 if(priv->active != NULL) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
593 return purple_credential_provider_write_settings(priv->active, fields);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
596 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
597 _("can not write settings, no active credential provider"));
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
598
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
599 return FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
600 }
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
601
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
602 void
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
603 purple_credential_manager_foreach(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
604 PurpleCredentialManagerForeachFunc func,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
605 gpointer data)
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
606 {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
607 GHashTableIter iter;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
608 PurpleCredentialManagerPrivate *priv = NULL;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
609 gpointer value;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
610
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
611 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
612 g_return_if_fail(func != NULL);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
613
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
614 priv = purple_credential_manager_get_instance_private(manager);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
615
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
616 g_hash_table_iter_init(&iter, priv->providers);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
617 while(g_hash_table_iter_next(&iter, NULL, &value)) {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
618 func(PURPLE_CREDENTIAL_PROVIDER(value), data);
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
619 }
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
620 }
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
621

mercurial