libpurple/purplecredentialmanager.c

Tue, 19 Oct 2021 03:12:31 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 19 Oct 2021 03:12:31 -0500
changeset 41128
445f5cc52e1a
parent 40987
671f2442e50e
child 41130
afe8c89a8e90
permissions
-rw-r--r--

Make the CredentialManager the only thing in charge of its preferences.

Testing Done:
Started pidgin3 with an empty config directory, verified the notify dialog didn't pop up. Set the preference and exited a few times to make sure everything was working properly.

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

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

mercurial