libpurple/purplecredentialmanager.c

Thu, 25 Aug 2022 23:25:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 23:25:12 -0500
branch
gtk4
changeset 41598
2b34cd990c16
parent 41314
0dc72eacd8bf
child 41661
d8a78f5c982d
permissions
-rw-r--r--

Replace the style-updated signal with GtkIconTheme:changed

Testing Done:
Ran and make sure the `GWarning` went away.

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

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
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
38 struct _PurpleCredentialManager {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
39 GObject parent;
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
40
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 GHashTable *providers;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
43 PurpleCredentialProvider *active;
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
44 };
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
46 G_DEFINE_TYPE(PurpleCredentialManager, purple_credential_manager,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
47 G_TYPE_OBJECT);
40583
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 static PurpleCredentialManager *default_manager = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
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 * Async Callbacks
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 purple_credential_manager_read_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
61 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 gchar *password = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
64 password = purple_credential_provider_read_password_finish(provider, res,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 &error);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 if(error != NULL) {
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_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
70 g_task_return_pointer(task, password, g_free);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 /* 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
74 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 purple_credential_manager_write_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
84 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
87 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
88 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 if(error != NULL) {
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_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
93 g_task_return_boolean(task, ret);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 /* 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
97 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 purple_credential_manager_clear_password_callback(GObject *obj,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 GAsyncResult *res,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GError *error = NULL;
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
107 GTask *task = G_TASK(data);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 gboolean ret = FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
110 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
111 &error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 if(error != NULL) {
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_error(task, error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 } else {
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
116 g_task_return_boolean(task, ret);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 /* 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
120 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
40734
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 * Purple Callbacks
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
125 *****************************************************************************/
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
126 static void
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
127 purple_credential_manager_core_init_cb(gpointer data) {
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
128 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(data);
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
129
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
130 if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 manager = PURPLE_CREDENTIAL_MANAGER(obj);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
161 g_clear_pointer(&manager->providers, g_hash_table_destroy);
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
162 g_clear_object(&manager->active);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 G_OBJECT_CLASS(purple_credential_manager_parent_class)->finalize(obj);
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 purple_credential_manager_init(PurpleCredentialManager *manager) {
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
169 manager->providers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
170 g_object_unref);
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
171
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
172 /* 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
173 * were unable to find their credential provider.
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
174 */
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
175 purple_signal_connect(purple_get_core(), "core-initialized", manager,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41166
diff changeset
176 G_CALLBACK(purple_credential_manager_core_init_cb),
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
177 manager);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 static void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 purple_credential_manager_class_init(PurpleCredentialManagerClass *klass) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 obj_class->finalize = purple_credential_manager_finalize;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
187 * PurpleCredentialManager::registered:
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 * @manager: The #PurpleCredentialManager instance.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 * @provider: The #PurpleCredentialProvider that was registered.
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 * 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
192 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
193 * Since: 3.0.0
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 */
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
195 signals[SIG_REGISTERED] = g_signal_new_class_handler(
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
196 "registered",
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 G_OBJECT_CLASS_TYPE(klass),
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 G_SIGNAL_RUN_LAST,
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
199 NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 G_TYPE_NONE,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 1,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 PURPLE_TYPE_CREDENTIAL_PROVIDER);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
208 * PurpleCredentialManager::unregistered:
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 * @manager: The #PurpleCredentialManager instance.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 * @provider: The #PurpleCredentialProvider that was unregistered.
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 * 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
213 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
214 * Since: 3.0.0
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 */
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
216 signals[SIG_UNREGISTERED] = g_signal_new_class_handler(
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
217 "unregistered",
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 G_OBJECT_CLASS_TYPE(klass),
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 G_SIGNAL_RUN_LAST,
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
220 NULL,
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 NULL,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 G_TYPE_NONE,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 1,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 PURPLE_TYPE_CREDENTIAL_PROVIDER);
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
227
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
228 /**
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
229 * PurpleCredentialManager::active-changed:
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
230 * @manager: The #PurpleCredentialManager instance.
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
231 * @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
232 * @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
233 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
234 * 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
235 *
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
236 * Since: 3.0.0
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
237 */
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
238 signals[SIG_ACTIVE_CHANGED] = g_signal_new_class_handler(
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
239 "active-changed",
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
240 G_OBJECT_CLASS_TYPE(klass),
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
241 G_SIGNAL_RUN_LAST,
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
242 NULL,
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
243 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
244 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
245 NULL,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
246 G_TYPE_NONE,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
247 2,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
248 PURPLE_TYPE_CREDENTIAL_PROVIDER,
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
249 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
250
445f5cc52e1a Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
251 /* 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
252 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
253 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
254 "noop-provider");
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 /******************************************************************************
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 * Private API
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 *****************************************************************************/
41166
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
260
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
261 /* Currently we're auto-registering the noop provider on the default manager,
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
262 * this may get moved to purple core later, so we just want to keep it all in
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
263 * one place for now.
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
264 */
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
265 static PurpleCredentialProvider *noop = NULL;
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
266
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 purple_credential_manager_startup(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 if(default_manager == NULL) {
41166
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
270 GError *error = NULL;
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
271
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 default_manager = g_object_new(PURPLE_TYPE_CREDENTIAL_MANAGER, NULL);
41166
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
273
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
274 noop = purple_noop_credential_provider_new();
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
275 if(!purple_credential_manager_register(default_manager, noop, &error)) {
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
276 g_warning("failed to register the noop credential manager: %s",
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
277 error ? error->message : "unknown");
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
278 g_clear_error(&error);
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
279 g_clear_object(&noop);
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
280 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 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
286 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
287 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
288
41166
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
289 /* If we have an instance of the noop provider we need to unregister
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
290 * it before continuing.
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
291 */
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
292 if(PURPLE_IS_CREDENTIAL_PROVIDER(noop)) {
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
293 GError *error = NULL;
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
294 if(!purple_credential_manager_unregister(default_manager,
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
295 noop, &error))
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
296 {
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
297 g_warning("failed to unregister the noop provider: %s",
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
298 error ? error->message : "unknown");
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
299 g_clear_error(&error);
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
300 }
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
301 g_clear_object(&noop);
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
302 }
20d88cadf7fc Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents: 41130
diff changeset
303
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
304 size = g_hash_table_size(default_manager->providers);
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
305 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
306 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
307 "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
308 size);
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
309 } else {
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
310 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
311 }
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
312 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314
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 * Public API
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 *****************************************************************************/
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 PurpleCredentialManager *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 purple_credential_manager_get_default(void) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 return default_manager;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
324 purple_credential_manager_register(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
325 PurpleCredentialProvider *provider,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
326 GError **error)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 const gchar *id = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 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
331 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
332
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 if(!purple_credential_provider_is_valid(provider, error)) {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 /* purple_credential_provider_is_valid sets the error on failure. */
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 id = purple_credential_provider_get_id(provider);
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
340 if(g_hash_table_lookup(manager->providers, id) != NULL) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 _("provider %s is already registered"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
347 g_hash_table_insert(manager->providers, g_strdup(id),
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
348 g_object_ref(provider));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
350 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
351
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
352 /* 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
353 * 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
354 * 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
355 */
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
356 if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) {
40734
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
357 const gchar *wanted = NULL;
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
358
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
359 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
360
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
361 if(purple_strequal(wanted, id)) {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
362 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
363 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
364 }
c792b39da167 Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents: 40730
diff changeset
365
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
370 purple_credential_manager_unregister(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
371 PurpleCredentialProvider *provider,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
372 GError **error)
40583
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 const gchar *id = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 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
378
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 id = purple_credential_provider_get_id(provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
381 if(provider == manager->active) {
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 _("provider %s is currently in use"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 return FALSE;
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
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
388 if(g_hash_table_remove(manager->providers, id)) {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
389 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
390 provider);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 return TRUE;
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 _("provider %s is not registered"), id);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 return FALSE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 gboolean
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
402 purple_credential_manager_set_active(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
403 const gchar *id, GError **error)
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
405 PurpleCredentialProvider *previous = NULL, *provider = NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 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
408
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
409 /* 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
410 if(id != NULL) {
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
411 provider = g_hash_table_lookup(manager->providers, id);
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
412 if(!PURPLE_IS_CREDENTIAL_PROVIDER(provider)) {
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
413 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
414 "no credential provider found with id %s", id);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
416 return FALSE;
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
417 }
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
420 if(PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
421 previous = PURPLE_CREDENTIAL_PROVIDER(g_object_ref(manager->active));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
424 if(g_set_object(&manager->active, provider)) {
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
425 if(PURPLE_IS_CREDENTIAL_PROVIDER(previous)) {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
426 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
427 }
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
428
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
429 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
430 purple_credential_provider_activate(provider);
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
431 }
338bba38df77 Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents: 40749
diff changeset
432
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
433 g_signal_emit(G_OBJECT(manager), signals[SIG_ACTIVE_CHANGED], 0,
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
434 previous, manager->active);
40670
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
435 }
c4665659625a Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40583
diff changeset
436
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
437 g_clear_object(&previous);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438
41128
445f5cc52e1a Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
439 /* 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
440 if(id != NULL) {
445f5cc52e1a Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
441 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
442 }
445f5cc52e1a Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents: 40987
diff changeset
443
40743
7aa6153abf4d Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents: 40734
diff changeset
444 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
445
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 return TRUE;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
449 PurpleCredentialProvider *
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
450 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
451 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
452
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
453 return manager->active;
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
454 }
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
455
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 purple_credential_manager_read_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
470 if(manager->active != NULL) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
471 purple_credential_provider_read_password_async(manager->active,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
472 account,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
473 cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
474 purple_credential_manager_read_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
475 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
476 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
477 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
478 _("can not read password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
479 "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
480 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482 }
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 gchar *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485 purple_credential_manager_read_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
486 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487 GError **error)
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 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
490
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
491 return g_task_propagate_pointer(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
494 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
495 purple_credential_manager_write_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
496 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497 const gchar *password,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
499 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
500 gpointer data)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
501 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
502 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
503
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
504 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
505 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
506
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
507 task = g_task_new(manager, cancellable, callback, data);
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
509 if(!purple_account_get_remember_password(account)) {
40684
a0c11a532ee7 Fix some broken unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
510 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
511
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
512 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
513 _("account \"%s\" is not marked to be stored"),
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
514 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
515 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
516
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
517 return;
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
518 }
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40679
diff changeset
519
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
520 if(manager->active != NULL) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
521 purple_credential_provider_write_password_async(manager->active,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
522 account,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
523 password, cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
524 purple_credential_manager_write_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
525 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
526 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
527 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
528 _("can not write password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
529 "credential provider"));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530
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
531 g_object_unref(G_OBJECT(task));
40583
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
536 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537 purple_credential_manager_write_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
538 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
539 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
540 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541 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
542
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
543 return g_task_propagate_boolean(G_TASK(result), error);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
546 void
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
547 purple_credential_manager_clear_password_async(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
548 PurpleAccount *account,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
549 GCancellable *cancellable,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
550 GAsyncReadyCallback callback,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551 gpointer data)
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 GTask *task = NULL;
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
554
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555 g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager));
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556 g_return_if_fail(PURPLE_IS_ACCOUNT(account));
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
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
560 if(manager->active != NULL) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
561 purple_credential_provider_clear_password_async(manager->active,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
562 account,
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
563 cancellable,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
564 purple_credential_manager_clear_password_callback,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
565 task);
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
566 } else {
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
567 g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
568 _("can not clear password, no active "
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
569 "credential provider"));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570
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
571 g_object_unref(G_OBJECT(task));
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 purple_credential_manager_clear_password_finish(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577 GAsyncResult *result,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580 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
581
40679
062a4574af3e Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents: 40670
diff changeset
582 return g_task_propagate_boolean(G_TASK(result), error);
40583
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
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585 PurpleRequestFields *
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586 purple_credential_manager_read_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
589 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
590
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
591 if(manager->active != NULL) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
592 return purple_credential_provider_read_settings(manager->active);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
595 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
596 _("can not read settings, no active credential provider"));
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
597
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
598 return NULL;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
599 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
600
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 gboolean
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
602 purple_credential_manager_write_settings(PurpleCredentialManager *manager,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
603 PurpleRequestFields *fields,
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
604 GError **error)
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
605 {
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606 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
607
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
608 if(manager->active != NULL) {
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
609 return purple_credential_provider_write_settings(manager->active,
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
610 fields);
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
611 }
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
612
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
613 g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
614 _("can not write settings, no active credential provider"));
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
615
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
616 return FALSE;
40583
28964322556c Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 }
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
618
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
619 void
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
620 purple_credential_manager_foreach(PurpleCredentialManager *manager,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
621 PurpleCredentialManagerForeachFunc func,
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
622 gpointer data)
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
623 {
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
624 GHashTableIter iter;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
625 gpointer value;
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
626
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
627 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
628 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
629
41130
afe8c89a8e90 Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents: 41128
diff changeset
630 g_hash_table_iter_init(&iter, manager->providers);
40730
12b38cca63d7 Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents: 40684
diff changeset
631 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
632 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
633 }
40987
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
634 }
671f2442e50e Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents: 40823
diff changeset
635

mercurial