Thu, 29 Feb 2024 21:35:42 -0600
Remove the micro version from since tags for libpurple part 2
This has been split up into multiple commits because otherwise it's just too
many files.
Testing Done:
Compiled
Reviewed at https://reviews.imfreedom.org/r/2989/
|
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 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
7 | * source distribution. |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify it |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
10 | * under the terms of the GNU General Public License as published by the Free |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
11 | * Software Foundation; either version 2 of the License, or (at your option) |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
12 | * any later version. |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42594
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, but WITHOUT |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
17 | * more details. |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
18 | * |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License along with |
|
eddde70cedd8
Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents:
42592
diff
changeset
|
20 | * this library; if not, see <https://www.gnu.org/licenses/>. |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purplecredentialmanager.h" |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
26 | |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
27 | #include "core.h" |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
28 | #include "debug.h" |
|
42557
e868bfcc092a
Only include headers when they're necessary for header files
Gary Kramlich <grim@reaperworld.com>
parents:
41982
diff
changeset
|
29 | #include "notify.h" |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
30 | #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
|
31 | #include "purplenoopcredentialprovider.h" |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | #include "purpleprivate.h" |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
33 | #include "util.h" |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | enum { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
36 | SIG_REGISTERED, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
37 | SIG_UNREGISTERED, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
38 | SIG_ACTIVE_CHANGED, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | N_SIGNALS, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | }; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | static guint signals[N_SIGNALS] = {0, }; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
43 | struct _PurpleCredentialManager { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
44 | GObject parent; |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
45 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | GHashTable *providers; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
48 | PurpleCredentialProvider *active; |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
49 | }; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
42576
ab1ca778ddb2
Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents:
42557
diff
changeset
|
51 | G_DEFINE_FINAL_TYPE(PurpleCredentialManager, purple_credential_manager, |
|
ab1ca778ddb2
Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents:
42557
diff
changeset
|
52 | G_TYPE_OBJECT); |
|
40583
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 PurpleCredentialManager *default_manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | * Async Callbacks |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | purple_credential_manager_read_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
66 | GTask *task = G_TASK(data); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | gchar *password = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
69 | password = purple_credential_provider_read_password_finish(provider, res, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | &error); |
|
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 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
73 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
75 | g_task_return_pointer(task, password, g_free); |
|
40583
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | /* Clean up our initial reference to the task. */ |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
79 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | purple_credential_manager_write_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
89 | GTask *task = G_TASK(data); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
92 | 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
|
93 | &error); |
|
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 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
96 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
98 | g_task_return_boolean(task, ret); |
|
40583
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | /* Clean up our initial reference to the task. */ |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
102 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | } |
|
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | purple_credential_manager_clear_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
112 | GTask *task = G_TASK(data); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
115 | 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
|
116 | &error); |
|
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 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
119 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
121 | g_task_return_boolean(task, ret); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | /* Clean up our initial reference to the task. */ |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
125 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
128 | /****************************************************************************** |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
129 | * Purple Callbacks |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
130 | *****************************************************************************/ |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
131 | static void |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
132 | purple_credential_manager_core_init_cb(gpointer data) { |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
133 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(data); |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
134 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
135 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) { |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
136 | GSettings *settings = NULL; |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
137 | GError *error = NULL; |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
138 | gchar *id = NULL; |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
139 | |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
140 | settings = g_settings_new_with_backend("im.pidgin.Purple.Credentials", |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
141 | purple_core_get_settings_backend()); |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
142 | id = g_settings_get_string(settings, "active-provider"); |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
143 | g_object_unref(settings); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
144 | |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
149 | 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
|
150 | _("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
|
151 | "provider."), |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
152 | _("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
|
153 | "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
|
154 | NULL); |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
155 | } |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
156 | |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
157 | g_free(id); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
158 | g_clear_error(&error); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
159 | } |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
160 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | * GObject Implementation |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | purple_credential_manager_finalize(GObject *obj) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
171 | g_clear_pointer(&manager->providers, g_hash_table_destroy); |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
172 | g_clear_object(&manager->active); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | G_OBJECT_CLASS(purple_credential_manager_parent_class)->finalize(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | purple_credential_manager_init(PurpleCredentialManager *manager) { |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
179 | 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
|
180 | g_object_unref); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
181 | |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
182 | /* 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
|
183 | * were unable to find their credential provider. |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
184 | */ |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
185 | 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
|
186 | 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
|
187 | manager); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | purple_credential_manager_class_init(PurpleCredentialManagerClass *klass) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | obj_class->finalize = purple_credential_manager_finalize; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | /** |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
197 | * PurpleCredentialManager::registered: |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | * @manager: The #PurpleCredentialManager instance. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | * @provider: The #PurpleCredentialProvider that was registered. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | * 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
|
202 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
203 | * Since: 3.0 |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | */ |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
205 | signals[SIG_REGISTERED] = g_signal_new_class_handler( |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
206 | "registered", |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | G_OBJECT_CLASS_TYPE(klass), |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
209 | NULL, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | G_TYPE_NONE, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | 1, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | /** |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
218 | * PurpleCredentialManager::unregistered: |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | * @manager: The #PurpleCredentialManager instance. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | * @provider: The #PurpleCredentialProvider that was unregistered. |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | * 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
|
223 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
224 | * Since: 3.0 |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | */ |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
226 | signals[SIG_UNREGISTERED] = g_signal_new_class_handler( |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
227 | "unregistered", |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | G_OBJECT_CLASS_TYPE(klass), |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
230 | NULL, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | G_TYPE_NONE, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | 1, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
237 | |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
238 | /** |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
239 | * PurpleCredentialManager::active-changed: |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
240 | * @manager: The #PurpleCredentialManager instance. |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
241 | * @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
|
242 | * @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
|
243 | * |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
244 | * 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
|
245 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
246 | * Since: 3.0 |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
247 | */ |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
248 | signals[SIG_ACTIVE_CHANGED] = g_signal_new_class_handler( |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
249 | "active-changed", |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
250 | G_OBJECT_CLASS_TYPE(klass), |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
251 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
252 | NULL, |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
253 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
254 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
255 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
256 | G_TYPE_NONE, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
257 | 2, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
258 | PURPLE_TYPE_CREDENTIAL_PROVIDER, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
259 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | * Private API |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | *****************************************************************************/ |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
265 | |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
266 | /* 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
|
267 | * 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
|
268 | * one place for now. |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
269 | */ |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
270 | static PurpleCredentialProvider *noop = 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 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | purple_credential_manager_startup(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | 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
|
275 | GError *error = NULL; |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
276 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | 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
|
278 | |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
279 | 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
|
280 | 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
|
281 | 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
|
282 | error ? error->message : "unknown"); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
283 | g_clear_error(&error); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
284 | g_clear_object(&noop); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
285 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | 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
|
291 | 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
|
292 | 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
|
293 | |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
294 | /* 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
|
295 | * it before continuing. |
|
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 | 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
|
298 | GError *error = NULL; |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
299 | 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
|
300 | noop, &error)) |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
301 | { |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
302 | 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
|
303 | error ? error->message : "unknown"); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
304 | g_clear_error(&error); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
305 | } |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
306 | g_clear_object(&noop); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
307 | } |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
308 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | "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
|
313 | size); |
|
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
314 | } else { |
|
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
315 | 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
|
316 | } |
|
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
317 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | * Public API |
|
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 | PurpleCredentialManager * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | purple_credential_manager_get_default(void) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | return default_manager; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | } |
|
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 | gboolean |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
329 | purple_credential_manager_register(PurpleCredentialManager *manager, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
330 | PurpleCredentialProvider *provider, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
331 | GError **error) |
|
40583
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 | const gchar *id = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | 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
|
336 | 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
|
337 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | if(!purple_credential_provider_is_valid(provider, error)) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | /* purple_credential_provider_is_valid sets the error on failure. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | id = purple_credential_provider_get_id(provider); |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
345 | if(g_hash_table_lookup(manager->providers, id) != NULL) { |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | _("provider %s is already registered"), id); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
352 | g_hash_table_insert(manager->providers, g_strdup(id), |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
353 | g_object_ref(provider)); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
355 | 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
|
356 | |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
357 | /* 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
|
358 | * 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
|
359 | * 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
|
360 | */ |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
361 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) { |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
362 | GSettings *settings = NULL; |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
363 | gchar *wanted = NULL; |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
364 | |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
365 | settings = g_settings_new_with_backend("im.pidgin.Purple.Credentials", |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
366 | purple_core_get_settings_backend()); |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
367 | wanted = g_settings_get_string(settings, "active-provider"); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
368 | |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
369 | if(purple_strequal(wanted, id)) { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
370 | 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
|
371 | } |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
372 | |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
373 | g_free(wanted); |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
374 | g_object_unref(settings); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
375 | } |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
376 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | return TRUE; |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | gboolean |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
381 | purple_credential_manager_unregister(PurpleCredentialManager *manager, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
382 | PurpleCredentialProvider *provider, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
383 | GError **error) |
|
40583
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 | const gchar *id = NULL; |
|
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 | 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
|
388 | 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
|
389 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | id = purple_credential_provider_get_id(provider); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
392 | if(provider == manager->active) { |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | _("provider %s is currently in use"), id); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | return FALSE; |
|
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 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
399 | if(g_hash_table_remove(manager->providers, id)) { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
400 | 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
|
401 | provider); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | return TRUE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | _("provider %s is not registered"), id); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
412 | gboolean |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
413 | purple_credential_manager_set_active(PurpleCredentialManager *manager, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
414 | const gchar *id, GError **error) |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
416 | PurpleCredentialProvider *previous = NULL, *provider = NULL; |
|
41734
a708bd1edc77
Clean up setting handling for the credential manager and make its unit tests don't mess up the others
Gary Kramlich <grim@reaperworld.com>
parents:
41661
diff
changeset
|
417 | GSettings *settings = NULL; |
|
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 | 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
|
420 | |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
421 | /* 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
|
422 | if(id != NULL) { |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
423 | 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
|
424 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(provider)) { |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
425 | 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
|
426 | "no credential provider found with id %s", id); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
428 | return FALSE; |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
429 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
432 | if(PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) { |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
433 | previous = g_object_ref(manager->active); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
436 | if(g_set_object(&manager->active, provider)) { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
437 | if(PURPLE_IS_CREDENTIAL_PROVIDER(previous)) { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
438 | 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
|
439 | } |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
440 | |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
441 | 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
|
442 | purple_credential_provider_activate(provider); |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
443 | } |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
444 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
445 | 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
|
446 | previous, manager->active); |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
447 | } |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
448 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
449 | g_clear_object(&previous); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | |
|
41802
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
451 | /* Finally update the preference if we were given a new id. We assume, that |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
452 | * a NULL id means we're shutting down and thus shouldn't update the |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
453 | * setting. |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
454 | */ |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
455 | if(id != NULL) { |
|
41802
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
456 | settings = g_settings_new_with_backend("im.pidgin.Purple.Credentials", |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
457 | purple_core_get_settings_backend()); |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
458 | |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
459 | g_settings_set_string(settings, "active-provider", id); |
|
41802
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
460 | |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
461 | g_object_unref(settings); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
462 | } |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
463 | |
|
40743
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
464 | 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
|
465 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | return TRUE; |
|
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 | |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
469 | PurpleCredentialProvider * |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
470 | 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
|
471 | 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
|
472 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
473 | 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
|
474 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
475 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | purple_credential_manager_read_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
487 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
488 | task = g_task_new(manager, cancellable, callback, data); |
|
42591
aa3f777462d8
Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents:
42576
diff
changeset
|
489 | g_task_set_source_tag(task, purple_credential_manager_read_password_async); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
491 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
492 | purple_credential_provider_read_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
493 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
494 | cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
495 | purple_credential_manager_read_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
496 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
497 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
498 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
499 | _("can not read password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
500 | "credential provider")); |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
501 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
502 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
503 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
504 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
505 | gchar * |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
506 | purple_credential_manager_read_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
507 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
508 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
509 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | 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
|
511 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
512 | return g_task_propagate_pointer(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
513 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
514 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
515 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
516 | purple_credential_manager_write_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
517 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
518 | const gchar *password, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
519 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
520 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
521 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | task = g_task_new(manager, cancellable, callback, data); |
|
42591
aa3f777462d8
Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents:
42576
diff
changeset
|
529 | g_task_set_source_tag(task, |
|
aa3f777462d8
Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents:
42576
diff
changeset
|
530 | purple_credential_manager_write_password_async); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
532 | if(!purple_account_get_remember_password(account)) { |
|
41976
49969fa9a664
Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents:
41802
diff
changeset
|
533 | const gchar *name = NULL; |
|
49969fa9a664
Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents:
41802
diff
changeset
|
534 | |
|
49969fa9a664
Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents:
41802
diff
changeset
|
535 | name = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)); |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
536 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
537 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
538 | _("account \"%s\" is not marked to be stored"), |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
539 | name); |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
540 | g_object_unref(task); |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
541 | |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
542 | return; |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
543 | } |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
544 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
545 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
546 | purple_credential_provider_write_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
547 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
548 | password, cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
549 | purple_credential_manager_write_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
550 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
551 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
552 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
553 | _("can not write password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
554 | "credential provider")); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
556 | g_object_unref(task); |
|
40583
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
559 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
560 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
562 | purple_credential_manager_write_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
563 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
564 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
565 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
566 | 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
|
567 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
568 | return g_task_propagate_boolean(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
571 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
572 | purple_credential_manager_clear_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
573 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
574 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
576 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
577 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
578 | GTask *task = NULL; |
|
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_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
581 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
582 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
583 | task = g_task_new(manager, cancellable, callback, data); |
|
42591
aa3f777462d8
Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents:
42576
diff
changeset
|
584 | g_task_set_source_tag(task, |
|
aa3f777462d8
Use g_task_set_source_tag on all of our async methods
Gary Kramlich <grim@reaperworld.com>
parents:
42576
diff
changeset
|
585 | purple_credential_manager_clear_password_async); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
587 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
588 | purple_credential_provider_clear_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
589 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
590 | cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
591 | purple_credential_manager_clear_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
592 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
593 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
594 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
595 | _("can not clear password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
596 | "credential provider")); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
597 | |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
598 | g_object_unref(task); |
|
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
602 | gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
603 | purple_credential_manager_clear_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
604 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
605 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
606 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
607 | 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
|
608 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
609 | return g_task_propagate_boolean(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
610 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
611 | |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
612 | void |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
613 | purple_credential_manager_foreach(PurpleCredentialManager *manager, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
614 | PurpleCredentialManagerForeachFunc func, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
615 | gpointer data) |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
616 | { |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
617 | GHashTableIter iter; |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
618 | gpointer value; |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
619 | |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
620 | 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
|
621 | 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
|
622 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
623 | 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
|
624 | 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
|
625 | 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
|
626 | } |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
627 | } |