libpurple/purplecredentialmanager.c

Mon, 22 Mar 2021 04:08:31 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 22 Mar 2021 04:08:31 -0500
changeset 40823
338bba38df77
parent 40749
b7ee9469eccc
child 40987
671f2442e50e
permissions
-rw-r--r--

Port the KWallet Keyring to the new CredentialProvider API.

Testing Done:
* connected account with wallet locked, verified that we weren't prompted for a password until the wallet was unlocked.
* connected account, didn't save password, made sure it connected and wasn't stored in kwalletmanager5
* connected account, saved password, made sure it connected and verified the password was stored in kwalletmanager5
* reconnected account, made sure the account connected without prompting
* reopened pidgin, made sure the account connected without prompting.
* disconnected pidgin from kwalletmanager5, re-connected account, verified it reconnected via debug and kwalletmanager5
* force closed the wallet in kwalletmanager5, re-connected account, unlocked wallet, verified no password prompts and that the account connected.
* removed the account and verified the password was removed from kwalletmanager5

Bugs closed: PIDGIN-17488

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

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 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 SIG_PROVIDER_REGISTERED,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 SIG_PROVIDER_UNREGISTERED,
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
33 SIG_ACTIVE_PROVIDER_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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PurpleCredentialProvider *active_provider;
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);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
130 if(!PURPLE_IS_CREDENTIAL_PROVIDER(priv->active_provider)) {
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);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 g_clear_object(&priv->active_provider);
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();
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
167 purple_credential_manager_register_provider(manager, noop, NULL);
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 /**
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 * PurpleCredentialManager::provider-registered:
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 */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 signals[SIG_PROVIDER_REGISTERED] = g_signal_new(
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 "provider-registered",
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,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 G_STRUCT_OFFSET(PurpleCredentialManagerClass, provider_registered),
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 /**
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 * PurpleCredentialManager::provider-unregistered:
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 */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 signals[SIG_PROVIDER_UNREGISTERED] = g_signal_new(
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 "provider-unregistered",
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,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 G_STRUCT_OFFSET(PurpleCredentialManagerClass, provider_unregistered),
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 /**
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
227 * PurpleCredentialManager::active-provider-changed:
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
228 * @manager: The #PurpleCredentialManager instance.
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
229 * @old: 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 */
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
236 signals[SIG_ACTIVE_PROVIDER_CHANGED] = g_signal_new(
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
237 "active-provider-changed",
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,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
240 G_STRUCT_OFFSET(PurpleCredentialManagerClass, active_provider_changed),
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 purple_credential_manager_register_provider(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 PurpleCredentialProvider *provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 GError **error)
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 g_signal_emit(G_OBJECT(manager), signals[SIG_PROVIDER_REGISTERED], 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
319 /* 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
320 * 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
321 * 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
322 */
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
323 if(!PURPLE_IS_CREDENTIAL_PROVIDER(priv->active_provider)) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
324 const gchar *wanted = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
325
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
326 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
327
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
328 if(purple_strequal(wanted, id)) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
329 purple_credential_manager_set_active_provider(manager, id, error);
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 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
332
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 return TRUE;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 purple_credential_manager_unregister_provider(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 PurpleCredentialProvider *provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 const gchar *id = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 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
345 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
346
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 id = purple_credential_provider_get_id(provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 if(provider == priv->active_provider) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 _("provider %s is currently in use"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 return FALSE;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 if(g_hash_table_remove(priv->providers, id)) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 g_signal_emit(G_OBJECT(manager), signals[SIG_PROVIDER_UNREGISTERED], 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 return TRUE;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 _("provider %s is not registered"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 return FALSE;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 purple_credential_manager_set_active_provider(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 const gchar *id, GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 PurpleCredentialManagerPrivate *priv = NULL;
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
375 PurpleCredentialProvider *old = NULL, *provider = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 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
378
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
381 /* 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
382 if(id != NULL) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
383 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
384 if(!PURPLE_IS_CREDENTIAL_PROVIDER(provider)) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
385 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
386 "no credential provider found with id %s", id);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
388 return FALSE;
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
389 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
392 if(PURPLE_IS_CREDENTIAL_PROVIDER(priv->active_provider)) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
393 old = PURPLE_CREDENTIAL_PROVIDER(g_object_ref(priv->active_provider));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
396 if(g_set_object(&priv->active_provider, provider)) {
40823
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
397 if(PURPLE_IS_CREDENTIAL_PROVIDER(old)) {
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
398 purple_credential_provider_deactivate(old);
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
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
401 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
402 purple_credential_provider_activate(provider);
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
403 }
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
404
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
405 g_signal_emit(G_OBJECT(manager), signals[SIG_ACTIVE_PROVIDER_CHANGED],
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
406 0, old, priv->active_provider);
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
407 }
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
408
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
409 g_clear_object(&old);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
411 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
412
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
416 PurpleCredentialProvider *
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
417 purple_credential_manager_get_active_provider(PurpleCredentialManager *manager)
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 PurpleCredentialManagerPrivate *priv = 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 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
422
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
423 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
424
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
425 return priv->active_provider;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
426 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
427
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 purple_credential_manager_read_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
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 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445 if(priv->active_provider == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 error = g_error_new_literal(PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 _("can not read password, no active "
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 "credential provider"));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 g_task_return_error(task, error);
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
453 g_object_unref(G_OBJECT(task));
40583
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 return;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 purple_credential_provider_read_password_async(priv->active_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 purple_credential_manager_read_password_callback,
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
462 task);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 }
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 gchar *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 purple_credential_manager_read_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 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
471
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
472 return g_task_propagate_pointer(G_TASK(result), error);
40583
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476 purple_credential_manager_write_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 const gchar *password,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
484 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
486 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
488
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
490
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
493 if(!purple_account_get_remember_password(account)) {
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
494 GError *error = NULL;
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
495 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
496
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
497 error = g_error_new(PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
498 _("account \"%s\" is not marked to be stored"),
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
499 name);
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
500
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
501 g_task_return_error(task, error);
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
502 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
503
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
504 return;
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
505 }
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
506
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
507 if(priv->active_provider == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 GError *error = NULL;
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 error = g_error_new_literal(PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511 _("can not write password, no active "
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
512 "credential provider"));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 g_task_return_error(task, error);
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
515 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
516
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517 return;
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 purple_credential_provider_write_password_async(priv->active_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
521 account, password,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
522 cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523 purple_credential_manager_write_password_callback,
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
524 task);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525 }
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 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
528 purple_credential_manager_write_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
529 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
532 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
533
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
534 return g_task_propagate_boolean(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
538 purple_credential_manager_clear_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
542 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
543 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
547 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
548 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
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 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
553
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
554 if(priv->active_provider == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 GError *error = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
557 error = g_error_new_literal(PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
558 _("can not clear password, no active "
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
559 "credential provider"));
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 g_task_return_error(task, error);
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
562 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
564 return;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
565 }
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 purple_credential_provider_clear_password_async(priv->active_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568 account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
569 cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570 purple_credential_manager_clear_password_callback,
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
571 task);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572 }
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 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 purple_credential_manager_clear_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 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
580
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
581 return g_task_propagate_boolean(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 PurpleRequestFields *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585 purple_credential_manager_read_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586 GError **error)
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 PurpleCredentialManagerPrivate *priv = NULL;
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 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
591
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 if(priv->active_provider == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596 _("can not read settings, no active credential provider"));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
598 return NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
599 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
600
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 return purple_credential_provider_read_settings(priv->active_provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
602 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
603
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
604 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
605 purple_credential_manager_write_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606 PurpleRequestFields *fields,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
607 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
608 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
609 PurpleCredentialManagerPrivate *priv = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
610
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
611 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
612
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
613 priv = purple_credential_manager_get_instance_private(manager);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
614
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
615 if(priv->active_provider == NULL) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
616 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 _("can not write settings, no active credential provider"));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
618
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
620 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
621
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
622 return purple_credential_provider_write_settings(priv->active_provider,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
623 fields);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
624 }
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
625
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
626 void
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
627 purple_credential_manager_foreach_provider(PurpleCredentialManager *manager,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
628 PurpleCredentialManagerForeachFunc func,
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
629 gpointer data)
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
630 {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
631 GHashTableIter iter;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
632 PurpleCredentialManagerPrivate *priv = NULL;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
633 gpointer value;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
634
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
635 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
636 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
637
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
638 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
639
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
640 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
641 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
642 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
643 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
644 }

mercurial