Wed, 14 May 2025 01:54:28 -0500
Create purple_core_new_settings
This is a helper around g_settings_new_with_backend using the settings backend
that the core is using.
Testing Done:
Called in the turtles and connected a few accounts in a devenv without issue.
Reviewed at https://reviews.imfreedom.org/r/4000/
|
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" |
|
42997
368deff13c21
Split purpleprivate.h up into individual files
Gary Kramlich <grim@reaperworld.com>
parents:
42995
diff
changeset
|
26 | #include "purplecredentialmanagerprivate.h" |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
27 | |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
28 | #include "core.h" |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
29 | #include "debug.h" |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
30 | #include "prefs.h" |
|
42997
368deff13c21
Split purpleprivate.h up into individual files
Gary Kramlich <grim@reaperworld.com>
parents:
42995
diff
changeset
|
31 | #include "purplecredentialproviderprivate.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
|
32 | #include "purplenoopcredentialprovider.h" |
|
42832
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
33 | #include "purplenotification.h" |
|
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
34 | #include "purplenotificationmanager.h" |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
35 | #include "util.h" |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | enum { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
38 | PROP_0, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
39 | PROP_ITEM_TYPE, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
40 | PROP_N_ITEMS, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
41 | N_PROPERTIES, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
42 | }; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
43 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
44 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
45 | enum { |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
46 | SIG_ADDED, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
47 | SIG_REMOVED, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
48 | SIG_ACTIVE_CHANGED, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | N_SIGNALS, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | }; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | static guint signals[N_SIGNALS] = {0, }; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
53 | struct _PurpleCredentialManager { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
54 | GObject parent; |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
55 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
56 | GPtrArray *providers; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
58 | PurpleCredentialProvider *active; |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
59 | |
|
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
60 | GSettings *settings; |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
61 | }; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
63 | static PurpleCredentialManager *default_manager = NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
64 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
65 | /****************************************************************************** |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
66 | * Helpers |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
67 | *****************************************************************************/ |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
68 | static PurpleCredentialProvider * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
69 | purple_credential_manager_find_provider_with_id(PurpleCredentialManager *manager, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
70 | const char *id, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
71 | guint *position) |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
72 | { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
73 | g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), NULL); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
75 | for(guint i = 0; i < manager->providers->len; i++) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
76 | PurpleCredentialProvider *provider = NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
77 | const char *provider_id = NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
78 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
79 | provider = g_ptr_array_index(manager->providers, i); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
80 | provider_id = purple_credential_provider_get_id(provider); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
81 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
82 | if(purple_strequal(provider_id, id)) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
83 | if(position != NULL) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
84 | *position = i; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
85 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
86 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
87 | return provider; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
88 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
89 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
90 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
91 | return NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
92 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | * Async Callbacks |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | purple_credential_manager_read_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
104 | GTask *task = G_TASK(data); |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
105 | char *password = NULL; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
107 | password = purple_credential_provider_read_password_finish(provider, res, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | &error); |
|
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 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
111 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
113 | g_task_return_pointer(task, password, g_free); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | /* 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
|
117 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | purple_credential_manager_write_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
127 | GTask *task = G_TASK(data); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
130 | 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
|
131 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
134 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
136 | g_task_return_boolean(task, ret); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | /* 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
|
140 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | purple_credential_manager_clear_password_callback(GObject *obj, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | GAsyncResult *res, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | PurpleCredentialProvider *provider = PURPLE_CREDENTIAL_PROVIDER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | GError *error = NULL; |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
150 | GTask *task = G_TASK(data); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | gboolean ret = FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
153 | 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
|
154 | &error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | if(error != NULL) { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
157 | g_task_return_error(task, error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | } else { |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
159 | g_task_return_boolean(task, ret); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | /* 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
|
163 | g_object_unref(task); |
|
40583
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 | |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
166 | /****************************************************************************** |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
167 | * Purple Callbacks |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
168 | *****************************************************************************/ |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
169 | static void |
|
42995
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
170 | purple_credential_manager_ui_started_cb(G_GNUC_UNUSED PurpleUi *ui, |
|
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
171 | gpointer data) |
|
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
172 | { |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
173 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(data); |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
174 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
175 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) { |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
176 | GError *error = NULL; |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
177 | char *id = NULL; |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
178 | |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
179 | id = g_settings_get_string(manager->settings, "active-provider"); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
180 | |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
181 | if(!purple_credential_manager_set_active(manager, id, &error)) { |
|
42832
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
182 | PurpleNotification *notification = NULL; |
|
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
183 | PurpleNotificationManager *manager = NULL; |
|
42931
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
184 | const char *title = NULL; |
|
42832
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
185 | |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
186 | 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
|
187 | 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
|
188 | |
|
42931
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
189 | title = _("Failed to load the selected credential provider."); |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42931
diff
changeset
|
190 | notification = purple_notification_new(NULL, title); |
|
42931
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
191 | |
|
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
192 | title = _("Check your system configuration or select another one " |
|
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
193 | "in preferences"); |
|
9e8b9ee3cfbb
Update libpurple for the Purple.Notification deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42861
diff
changeset
|
194 | purple_notification_set_subtitle(notification, title); |
|
42832
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
195 | |
|
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
196 | manager = purple_notification_manager_get_default(); |
|
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
197 | purple_notification_manager_add(manager, notification); |
|
4f1a305877aa
Use a notification instead of purple_notify_error when the active credential provider can not be found
Gary Kramlich <grim@reaperworld.com>
parents:
42805
diff
changeset
|
198 | g_clear_object(¬ification); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
199 | } |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
200 | |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
201 | 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
|
202 | g_clear_error(&error); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
203 | } |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
204 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | /****************************************************************************** |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
207 | * GListModel Implementation |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
208 | *****************************************************************************/ |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
209 | static GType |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
210 | purple_credential_manager_get_item_type(G_GNUC_UNUSED GListModel *list) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
211 | return PURPLE_TYPE_CREDENTIAL_PROVIDER; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
212 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
213 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
214 | static guint |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
215 | purple_credential_manager_get_n_items(GListModel *list) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
216 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(list); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
217 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
218 | return manager->providers->len; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
219 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
220 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
221 | static gpointer |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
222 | purple_credential_manager_get_item(GListModel *list, guint position) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
223 | PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(list); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
224 | PurpleCredentialProvider *provider = NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
225 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
226 | if(position < manager->providers->len) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
227 | provider = g_object_ref(g_ptr_array_index(manager->providers, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
228 | position)); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
229 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
230 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
231 | return provider; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
232 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
233 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
234 | static void |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
235 | pidgin_credential_manager_list_model_iface_init(GListModelInterface *iface) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
236 | iface->get_item_type = purple_credential_manager_get_item_type; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
237 | iface->get_n_items = purple_credential_manager_get_n_items; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
238 | iface->get_item = purple_credential_manager_get_item; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
239 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
240 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
241 | /****************************************************************************** |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | * GObject Implementation |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | *****************************************************************************/ |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
244 | G_DEFINE_FINAL_TYPE_WITH_CODE(PurpleCredentialManager, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
245 | purple_credential_manager, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
246 | G_TYPE_OBJECT, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
247 | G_IMPLEMENT_INTERFACE(G_TYPE_LIST_MODEL, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
248 | pidgin_credential_manager_list_model_iface_init)) |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
249 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | purple_credential_manager_finalize(GObject *obj) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | PurpleCredentialManager *manager = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
256 | g_clear_pointer(&manager->providers, g_ptr_array_unref); |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
257 | g_clear_object(&manager->active); |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
258 | g_clear_object(&manager->settings); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | G_OBJECT_CLASS(purple_credential_manager_parent_class)->finalize(obj); |
|
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 | static void |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
264 | purple_credential_manager_get_property(GObject *obj, guint param_id, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
265 | GValue *value, GParamSpec *pspec) |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
266 | { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
267 | GListModel *model = G_LIST_MODEL(obj); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
268 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
269 | switch(param_id) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
270 | case PROP_ITEM_TYPE: |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
271 | g_value_set_gtype(value, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
272 | purple_credential_manager_get_item_type(model)); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
273 | break; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
274 | case PROP_N_ITEMS: |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
275 | g_value_set_uint(value, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
276 | purple_credential_manager_get_n_items(model)); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
277 | break; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
278 | default: |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
279 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
280 | break; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
281 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
282 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
283 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
284 | static void |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | purple_credential_manager_init(PurpleCredentialManager *manager) { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
286 | manager->providers = g_ptr_array_new_full(1, g_object_unref); |
|
40583
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 | static void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | purple_credential_manager_class_init(PurpleCredentialManagerClass *klass) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | obj_class->finalize = purple_credential_manager_finalize; |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
294 | obj_class->get_property = purple_credential_manager_get_property; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
295 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
296 | /** |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
297 | * PurpleCredentialManager:item-type: |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
298 | * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
299 | * The type of items. See [vfunc@Gio.ListModel.get_item_type]. |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
300 | * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
301 | * Since: 3.0 |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
302 | */ |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
303 | properties[PROP_ITEM_TYPE] = g_param_spec_gtype( |
|
43071
071588186662
Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43050
diff
changeset
|
304 | "item-type", NULL, NULL, |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
305 | G_TYPE_OBJECT, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
306 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
307 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
308 | /** |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
309 | * PurpleCredentialManager:n-items: |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
310 | * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
311 | * The number of items. See [vfunc@Gio.ListModel.get_n_items]. |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
312 | * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
313 | * Since: 3.0 |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
314 | */ |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
315 | properties[PROP_N_ITEMS] = g_param_spec_uint( |
|
43071
071588186662
Remove nick and blurb from libpurple properties
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43050
diff
changeset
|
316 | "n-items", NULL, NULL, |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
317 | 0, G_MAXUINT, 0, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
318 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
319 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
320 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | /** |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
323 | * PurpleCredentialManager::added: |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | * @manager: The #PurpleCredentialManager instance. |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
325 | * @provider: The #PurpleCredentialProvider that was added. |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | * |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
327 | * Emitted after @provider has been added to @manager. |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
328 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
329 | * Since: 3.0 |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | */ |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
331 | signals[SIG_ADDED] = g_signal_new_class_handler( |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
332 | "added", |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | G_OBJECT_CLASS_TYPE(klass), |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
335 | NULL, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | G_TYPE_NONE, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | 1, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
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 | /** |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
344 | * PurpleCredentialManager::removed: |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | * @manager: The #PurpleCredentialManager instance. |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
346 | * @provider: The #PurpleCredentialProvider that was removed. |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | * |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
348 | * Emitted after @provider has been removed from @manager. |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
349 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
350 | * Since: 3.0 |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | */ |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
352 | signals[SIG_REMOVED] = g_signal_new_class_handler( |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
353 | "removed", |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | G_OBJECT_CLASS_TYPE(klass), |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
356 | NULL, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | NULL, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | G_TYPE_NONE, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | 1, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
363 | |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
364 | /** |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
365 | * PurpleCredentialManager::active-changed: |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
366 | * @manager: The #PurpleCredentialManager instance. |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
367 | * @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
|
368 | * @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
|
369 | * |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
370 | * 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
|
371 | * |
|
42613
780d7efe37c2
Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents:
42594
diff
changeset
|
372 | * Since: 3.0 |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
373 | */ |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
374 | signals[SIG_ACTIVE_CHANGED] = g_signal_new_class_handler( |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
375 | "active-changed", |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
376 | G_OBJECT_CLASS_TYPE(klass), |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
377 | G_SIGNAL_RUN_LAST, |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
378 | NULL, |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
379 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
380 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
381 | NULL, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
382 | G_TYPE_NONE, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
383 | 2, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
384 | PURPLE_TYPE_CREDENTIAL_PROVIDER, |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
385 | PURPLE_TYPE_CREDENTIAL_PROVIDER); |
|
40583
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 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | * Private API |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | *****************************************************************************/ |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
391 | |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
392 | /* 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
|
393 | * 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
|
394 | * one place for now. |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
395 | */ |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
396 | static PurpleCredentialProvider *noop = NULL; |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
397 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | void |
|
42995
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
399 | purple_credential_manager_startup(G_GNUC_UNUSED PurpleCore *core) { |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | if(default_manager == NULL) { |
|
42995
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
401 | PurpleUi *ui = NULL; |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
402 | GError *error = NULL; |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
403 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | 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
|
405 | |
|
43253
0cc00d7d6215
Create purple_core_new_settings
Gary Kramlich <grim@reaperworld.com>
parents:
43128
diff
changeset
|
406 | default_manager->settings = purple_core_new_settings("im.pidgin.Purple.Credentials"); |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
407 | |
|
42995
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
408 | ui = purple_core_get_ui(); |
|
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
409 | g_signal_connect_object(ui, "started", |
|
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
410 | G_CALLBACK(purple_credential_manager_ui_started_cb), |
|
006b071042ed
Replace the core-initialized signal with Purple.Ui::started
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
411 | default_manager, G_CONNECT_DEFAULT); |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
412 | |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
413 | noop = purple_noop_credential_provider_new(); |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
414 | if(!purple_credential_manager_add(default_manager, noop, &error)) { |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
415 | 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
|
416 | error ? error->message : "unknown"); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
417 | g_clear_error(&error); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
418 | g_clear_object(&noop); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
419 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | void |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
424 | purple_credential_manager_shutdown(G_GNUC_UNUSED PurpleCore *core) { |
|
40743
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
425 | if(PURPLE_IS_CREDENTIAL_MANAGER(default_manager)) { |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
426 | /* 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
|
427 | * it before continuing. |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
428 | */ |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
429 | 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
|
430 | GError *error = NULL; |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
431 | if(!purple_credential_manager_remove(default_manager, noop, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
432 | &error)) |
|
41166
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
433 | { |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
434 | 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
|
435 | error ? error->message : "unknown"); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
436 | g_clear_error(&error); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
437 | } |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
438 | g_clear_object(&noop); |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
439 | } |
|
20d88cadf7fc
Clean up some issues during shutdown that were outputting warnings
Gary Kramlich <grim@reaperworld.com>
parents:
41130
diff
changeset
|
440 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
441 | if(default_manager->providers->len > 0) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
442 | g_warning("purple_credential_manager_shutdown called while %u " |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
443 | "providers were still registered. Skipping shutdown", |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
444 | default_manager->providers->len); |
|
40743
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
445 | } else { |
|
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
446 | 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
|
447 | } |
|
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
448 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | /****************************************************************************** |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | * Public API |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
453 | *****************************************************************************/ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
454 | gboolean |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
455 | purple_credential_manager_add(PurpleCredentialManager *manager, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
456 | PurpleCredentialProvider *provider, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
457 | GError **error) |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
459 | PurpleCredentialProvider *existing = NULL; |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
460 | const char *id = NULL; |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
461 | guint position = 0; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
463 | 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
|
464 | 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
|
465 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | if(!purple_credential_provider_is_valid(provider, error)) { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | /* purple_credential_provider_is_valid sets the error on failure. */ |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | id = purple_credential_provider_get_id(provider); |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
473 | existing = purple_credential_manager_find_provider_with_id(manager, id, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
474 | NULL); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
475 | if(PURPLE_IS_CREDENTIAL_PROVIDER(existing)) { |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
477 | _("provider %s has already been added"), id); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | return FALSE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
482 | /* Store the position to avoid doing math after adding. */ |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
483 | position = manager->providers->len; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
484 | g_ptr_array_add(manager->providers, g_object_ref(provider)); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
486 | g_signal_emit(G_OBJECT(manager), signals[SIG_ADDED], 0, provider); |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
487 | g_list_model_items_changed(G_LIST_MODEL(manager), position, 0, 1); |
|
43128
1ce3ad90614c
Make sure we notify on the n-items property for all objects that have it
Gary Kramlich <grim@reaperworld.com>
parents:
43071
diff
changeset
|
488 | g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
490 | /* 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
|
491 | * 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
|
492 | * 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
|
493 | */ |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
494 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(manager->active) && |
|
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
495 | G_IS_SETTINGS(manager->settings)) |
|
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
496 | { |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
497 | char *wanted = NULL; |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
498 | |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
499 | wanted = g_settings_get_string(manager->settings, "active-provider"); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
500 | |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
501 | if(purple_strequal(wanted, id)) { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
502 | 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
|
503 | } |
|
41661
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
504 | |
|
d8a78f5c982d
Port credential manager to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
505 | g_free(wanted); |
|
40734
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
506 | } |
|
c792b39da167
Port the secretservice keyring to PurpleCredentialProvider
Gary Kramlich <grim@reaperworld.com>
parents:
40730
diff
changeset
|
507 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
508 | return TRUE; |
|
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 | |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
511 | PurpleCredentialManager * |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
512 | purple_credential_manager_get_default(void) { |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
513 | return default_manager; |
|
40583
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 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
516 | GListModel * |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
517 | purple_credential_manager_get_default_as_model(void) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
518 | if(PURPLE_IS_CREDENTIAL_MANAGER(default_manager)) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
519 | return G_LIST_MODEL(default_manager); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
520 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
521 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
522 | return NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
523 | } |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
524 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | gboolean |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
526 | purple_credential_manager_set_active(PurpleCredentialManager *manager, |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
527 | const char *id, GError **error) |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
529 | PurpleCredentialProvider *previous = NULL; |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
530 | PurpleCredentialProvider *provider = NULL; |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
533 | |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
534 | /* 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
|
535 | if(id != NULL) { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
536 | provider = purple_credential_manager_find_provider_with_id(manager, id, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
537 | NULL); |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
538 | if(!PURPLE_IS_CREDENTIAL_PROVIDER(provider)) { |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
539 | 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
|
540 | "no credential provider found with id %s", id); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
541 | |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
542 | return FALSE; |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
543 | } |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
544 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
546 | if(PURPLE_IS_CREDENTIAL_PROVIDER(manager->active)) { |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
547 | previous = g_object_ref(manager->active); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
548 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
550 | if(g_set_object(&manager->active, provider)) { |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
551 | if(PURPLE_IS_CREDENTIAL_PROVIDER(previous)) { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
552 | 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
|
553 | } |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
554 | |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
555 | 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
|
556 | purple_credential_provider_activate(provider); |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
557 | } |
|
338bba38df77
Port the KWallet Keyring to the new CredentialProvider API.
Gary Kramlich <grim@reaperworld.com>
parents:
40749
diff
changeset
|
558 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
559 | 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
|
560 | previous, manager->active); |
|
40670
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
561 | } |
|
c4665659625a
Add an active-provider-changed signal to PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40583
diff
changeset
|
562 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
563 | g_clear_object(&previous); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
564 | |
|
41802
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
565 | /* 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
|
566 | * 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
|
567 | * setting. |
|
487d13861ae4
Remember CredentialProvider setting while exiting
Gary Kramlich <grim@reaperworld.com>
parents:
41734
diff
changeset
|
568 | */ |
|
42861
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
569 | if(id != NULL && G_IS_SETTINGS(manager->settings)) { |
|
563d56738460
Change the way the CredentialManager interacts with the core
Gary Kramlich <grim@reaperworld.com>
parents:
42834
diff
changeset
|
570 | g_settings_set_string(manager->settings, "active-provider", id); |
|
41128
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
571 | } |
|
445f5cc52e1a
Make the CredentialManager the only thing in charge of its preferences.
Gary Kramlich <grim@reaperworld.com>
parents:
40987
diff
changeset
|
572 | |
|
40743
7aa6153abf4d
Create a no operation credential provider and fix a number of other issues
Gary Kramlich <grim@reaperworld.com>
parents:
40734
diff
changeset
|
573 | 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
|
574 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | return TRUE; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
576 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
577 | |
|
40730
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
578 | PurpleCredentialProvider * |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
579 | 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
|
580 | 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
|
581 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
582 | 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
|
583 | } |
|
12b38cca63d7
Create a new PidginCredentialsPage and associated widgets for the preferences window
Gary Kramlich <grim@reaperworld.com>
parents:
40684
diff
changeset
|
584 | |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
585 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | purple_credential_manager_read_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
587 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
588 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
589 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
590 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
591 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
592 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
593 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
594 | g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
595 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
596 | 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
|
597 | 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
|
598 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
599 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
600 | purple_credential_provider_read_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
601 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
602 | cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
603 | purple_credential_manager_read_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
604 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
605 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
606 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
607 | _("can not read password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
608 | "credential provider")); |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
609 | g_object_unref(task); |
|
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 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
612 | |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
613 | char * |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
614 | purple_credential_manager_read_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
615 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
616 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
617 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
618 | 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
|
619 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
620 | return g_task_propagate_pointer(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
621 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
622 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
623 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
624 | purple_credential_manager_write_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
625 | PurpleAccount *account, |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
626 | const char *password, |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
627 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
628 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
629 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
630 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
632 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
633 | g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
634 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
635 | 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
|
636 | 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
|
637 | purple_credential_manager_write_password_async); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
638 | |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
639 | if(!purple_account_get_remember_password(account)) { |
|
42626
c36543f2ec67
Some cleanups for PurpleCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
42613
diff
changeset
|
640 | const char *name = NULL; |
|
41976
49969fa9a664
Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents:
41802
diff
changeset
|
641 | |
|
42805
3e77e81168a5
Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42725
diff
changeset
|
642 | name = purple_account_get_username(account); |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
643 | |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
644 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
645 | _("account \"%s\" is not marked to be stored"), |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
646 | name); |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
647 | g_object_unref(task); |
|
40680
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
648 | |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
649 | return; |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
650 | } |
|
f9ea6d5e8992
Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents:
40679
diff
changeset
|
651 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
652 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
653 | purple_credential_provider_write_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
654 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
655 | password, cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
656 | purple_credential_manager_write_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
657 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
658 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
659 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
660 | _("can not write password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
661 | "credential provider")); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
662 | |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
663 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
664 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
665 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
666 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
667 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
668 | gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
669 | purple_credential_manager_write_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
670 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
671 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
672 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
673 | 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
|
674 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
675 | return g_task_propagate_boolean(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
676 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
677 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
678 | void |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
679 | purple_credential_manager_clear_password_async(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
680 | PurpleAccount *account, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
681 | GCancellable *cancellable, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
682 | GAsyncReadyCallback callback, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
683 | gpointer data) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
684 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
685 | GTask *task = NULL; |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
686 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
687 | g_return_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
688 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
689 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
690 | 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
|
691 | 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
|
692 | purple_credential_manager_clear_password_async); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
693 | |
|
41130
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
694 | if(manager->active != NULL) { |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
695 | purple_credential_provider_clear_password_async(manager->active, |
|
afe8c89a8e90
Make PurpleCredentialManager a final type
Gary Kramlich <grim@reaperworld.com>
parents:
41128
diff
changeset
|
696 | account, |
|
40987
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
697 | cancellable, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
698 | purple_credential_manager_clear_password_callback, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
699 | task); |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
700 | } else { |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
701 | g_task_return_new_error(task, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
702 | _("can not clear password, no active " |
|
671f2442e50e
Clean up PidginCredentialManager
Gary Kramlich <grim@reaperworld.com>
parents:
40823
diff
changeset
|
703 | "credential provider")); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
704 | |
|
42592
6b65c0e4ba15
Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents:
42591
diff
changeset
|
705 | g_object_unref(task); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
706 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
707 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
708 | |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
709 | gboolean |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
710 | purple_credential_manager_clear_password_finish(PurpleCredentialManager *manager, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
711 | GAsyncResult *result, |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
712 | GError **error) |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
713 | { |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
714 | 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
|
715 | |
|
40679
062a4574af3e
Remove the account parameter from purple_credential_provider_*_finish functions.
Gary Kramlich <grim@reaperworld.com>
parents:
40670
diff
changeset
|
716 | return g_task_propagate_boolean(G_TASK(result), error); |
|
40583
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
717 | } |
|
28964322556c
Add the new PurpleCredentialManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
718 | |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
719 | gboolean |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
720 | purple_credential_manager_remove(PurpleCredentialManager *manager, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
721 | PurpleCredentialProvider *provider, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
722 | GError **error) |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
723 | { |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
724 | PurpleCredentialProvider *candidate = NULL; |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
725 | const char *id = NULL; |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
726 | guint position = 0; |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
727 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
728 | g_return_val_if_fail(PURPLE_IS_CREDENTIAL_MANAGER(manager), FALSE); |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
729 | g_return_val_if_fail(PURPLE_IS_CREDENTIAL_PROVIDER(provider), FALSE); |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
730 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
731 | id = purple_credential_provider_get_id(provider); |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
732 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
733 | if(provider == manager->active) { |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
734 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
735 | _("provider %s is currently in use"), id); |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
736 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
737 | return FALSE; |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
738 | } |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
739 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
740 | g_object_ref(provider); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
741 | candidate = purple_credential_manager_find_provider_with_id(manager, id, |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
742 | &position); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
743 | if(PURPLE_IS_CREDENTIAL_PROVIDER(candidate)) { |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
744 | g_ptr_array_remove_index(manager->providers, position); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
745 | |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
746 | g_signal_emit(G_OBJECT(manager), signals[SIG_REMOVED], 0, provider); |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
747 | g_list_model_items_changed(G_LIST_MODEL(manager), position, 1, 0); |
|
43128
1ce3ad90614c
Make sure we notify on the n-items property for all objects that have it
Gary Kramlich <grim@reaperworld.com>
parents:
43071
diff
changeset
|
748 | g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_N_ITEMS]); |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
749 | |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
750 | g_object_unref(provider); |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
751 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
752 | return TRUE; |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
753 | } |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
754 | |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
755 | g_set_error(error, PURPLE_CREDENTIAL_MANAGER_DOMAIN, 0, |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
756 | _("provider %s has not been added"), id); |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
757 | |
|
43048
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
758 | g_object_unref(provider); |
|
45a4e977eff7
Update Purple.CredentialManager to implement Gio.ListModel
Gary Kramlich <grim@reaperworld.com>
parents:
43027
diff
changeset
|
759 | |
|
43027
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
760 | return FALSE; |
|
581af7cd0603
Rename Purple.CredentialManager.register/unregister to add/remove
Gary Kramlich <grim@reaperworld.com>
parents:
42999
diff
changeset
|
761 | } |