Thu, 25 Aug 2022 23:25:12 -0500
Replace the style-updated signal with GtkIconTheme:changed
Testing Done:
Ran and make sure the `GWarning` went away.
Reviewed at https://reviews.imfreedom.org/r/1653/
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include "purpleaccountmanager.h" |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | #include "purpleprivate.h" |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | #include "account.h" |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "accounts.h" |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #include "core.h" |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | enum { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | SIG_ADDED, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | SIG_REMOVED, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | N_SIGNALS, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | }; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | static guint signals[N_SIGNALS] = {0, }; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | struct _PurpleAccountManager { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | GObject parent; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | GList *accounts; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | }; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | static PurpleAccountManager *default_manager = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | G_DEFINE_TYPE(PurpleAccountManager, purple_account_manager, G_TYPE_OBJECT) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | /****************************************************************************** |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | * GObject Implementation |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | *****************************************************************************/ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | static void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | purple_account_manager_finalize(GObject *obj) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | PurpleAccountManager *manager = PURPLE_ACCOUNT_MANAGER(obj); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | GList *l = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | g_object_unref(l->data); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | G_OBJECT_CLASS(purple_account_manager_parent_class)->finalize(obj); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | static void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | purple_account_manager_init(PurpleAccountManager *manager) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | static void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | purple_account_manager_class_init(PurpleAccountManagerClass *klass) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | obj_class->finalize = purple_account_manager_finalize; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | /** |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | * PurpleAccountManager::added: |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | * @manager: The account manager instance. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | * @account: The account that was added. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | * Emitted after @account was added to @manager. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | * Since: 3.0.0 |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | signals[SIG_ADDED] = g_signal_new_class_handler( |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | "added", |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | G_OBJECT_CLASS_TYPE(klass), |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | G_SIGNAL_RUN_LAST, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | G_TYPE_NONE, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | 1, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | PURPLE_TYPE_ACCOUNT); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | /** |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | * PurpleAccountManager::removed: |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | * @manager: The account manager instance. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | * @account: The account that was removed. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | * Emitted after @account was removed from @manager. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | * Since: 3.0.0 |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | signals[SIG_REMOVED] = g_signal_new_class_handler( |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | "removed", |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | G_OBJECT_CLASS_TYPE(klass), |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | G_SIGNAL_RUN_LAST, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | NULL, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | G_TYPE_NONE, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | 1, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | PURPLE_TYPE_ACCOUNT); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | /****************************************************************************** |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | * Private API |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | *****************************************************************************/ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | purple_account_manager_startup(void) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | if(!PURPLE_IS_ACCOUNT_MANAGER(default_manager)) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | default_manager = g_object_new(PURPLE_TYPE_ACCOUNT_MANAGER, NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | purple_account_manager_shutdown(void) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | g_clear_object(&default_manager); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | /****************************************************************************** |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | * Public API |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | *****************************************************************************/ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | PurpleAccountManager * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | purple_account_manager_get_default(void) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | return default_manager; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | purple_account_manager_add(PurpleAccountManager *manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | PurpleAccount *account) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | g_return_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | /* If the manager already knows about the account, we do nothing. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | if(g_list_find(manager->accounts, account) != NULL) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | return; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | /* Since the manager doesn't know about the account, put the new account |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | * at the start of the list as that's likely to be the first one in user |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | * interfaces and the most likely to have configuration issues as it's a |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | * new account. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | manager->accounts = g_list_prepend(manager->accounts, account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | purple_accounts_schedule_save(); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | g_signal_emit(manager, signals[SIG_ADDED], 0, account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | /* Finally emit the old purple signal that will eventually be removed. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | purple_signal_emit(purple_accounts_get_handle(), "account-added", account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | purple_account_manager_remove(PurpleAccountManager *manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | PurpleAccount *account) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | g_return_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | manager->accounts = g_list_remove(manager->accounts, account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | purple_accounts_schedule_save(); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | /* Clearing the error ensures that account-error-changed is emitted, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | * which is the end of the guarantee that the error's pointer is valid. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | purple_account_clear_current_error(account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | g_signal_emit(manager, signals[SIG_REMOVED], 0, account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | /* Finally emit the old purple signal that will eventually be removed. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | purple_signal_emit(purple_accounts_get_handle(), "account-removed", |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | GList * |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | purple_account_manager_get_all(PurpleAccountManager *manager) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | return manager->accounts; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | GList * |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
192 | purple_account_manager_get_enabled(PurpleAccountManager *manager) { |
|
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
193 | GList *enabled = NULL, *l = NULL; |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | PurpleAccount *account = PURPLE_ACCOUNT(l->data); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | |
|
41392
b5c84f55d5d2
Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents:
41315
diff
changeset
|
200 | if(purple_account_get_enabled(account)) { |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
201 | enabled = g_list_append(enabled, account); |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
205 | return enabled; |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
208 | GList * |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
209 | purple_account_manager_get_disabled(PurpleAccountManager *manager) { |
|
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
210 | GList *disabled = NULL, *l = NULL; |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
211 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
212 | g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
213 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
214 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
215 | PurpleAccount *account = l->data; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
216 | |
|
41392
b5c84f55d5d2
Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents:
41315
diff
changeset
|
217 | if(!purple_account_get_enabled(account)) { |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
218 | disabled = g_list_append(disabled, account); |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
219 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
220 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
221 | |
|
41451
e587ef39e02e
Update the account manager to use enabled/disabled for accounts rather than active/inactive.
Gary Kramlich <grim@reaperworld.com>
parents:
41392
diff
changeset
|
222 | return disabled; |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
223 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
224 | |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | purple_account_manager_reorder(PurpleAccountManager *manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | PurpleAccount *account, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | guint new_index) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | GList *l = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | gboolean found = FALSE; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | guint index = 0; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | g_return_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | g_return_if_fail(PURPLE_IS_ACCOUNT(account)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | /* Iterate over the known accounts until we have found a matching account |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | * or exhausted the list. For each iteration increment idx. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | for(l = manager->accounts; l != NULL; l = l->next, index++) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | if(PURPLE_ACCOUNT(l->data) == account) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | manager->accounts = g_list_delete_link(manager->accounts, l); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | found = TRUE; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | /* If new_index is greater than the current index, we need to |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | * decrement new_index by 1 to account for the move as we'll be |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | * inserting into a list with one less item. |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | if(new_index > index) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | new_index--; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | break; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | if(!found) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | g_critical("Unregistered account (%s) found during reorder!", |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | purple_account_get_username(account)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | return; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | /* Insert the account into its new position. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | manager->accounts = g_list_insert(manager->accounts, account, new_index); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | purple_accounts_schedule_save(); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | PurpleAccount * |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
271 | purple_account_manager_find_by_id(PurpleAccountManager *manager, |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
272 | const gchar *id) |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
273 | { |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
274 | GList *l = NULL; |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
275 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
276 | g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL); |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
277 | g_return_val_if_fail(id != NULL, NULL); |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
278 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
279 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
280 | PurpleAccount *account = PURPLE_ACCOUNT(l->data); |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
281 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
282 | if(purple_strequal(purple_account_get_id(account), id)) { |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
283 | return account; |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
284 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
285 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
286 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
287 | return NULL; |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
288 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
289 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
41181
diff
changeset
|
290 | PurpleAccount * |
|
41181
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | purple_account_manager_find(PurpleAccountManager *manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | const gchar *username, const gchar *protocol_id) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | GList *l; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | g_return_val_if_fail(username != NULL, NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | g_return_val_if_fail(protocol_id != NULL, NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | PurpleAccount *account = PURPLE_ACCOUNT(l->data); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | gchar *normalized = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | const gchar *existing_protocol_id = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | const gchar *existing_username = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | const gchar *existing_normalized = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | /* Check if the protocol id matches what the user asked for. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | existing_protocol_id = purple_account_get_protocol_id(account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | if(!purple_strequal(existing_protocol_id, protocol_id)) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | continue; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | /* Finally verify the username. */ |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | existing_username = purple_account_get_username(account); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | normalized = g_strdup(purple_normalize(account, username)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | existing_normalized = purple_normalize(account, existing_username); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | if(purple_strequal(existing_normalized, normalized)) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | g_free(normalized); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | return account; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | g_free(normalized); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | return NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | void |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | purple_account_manager_foreach(PurpleAccountManager *manager, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | PurpleAccountManagerForeachFunc callback, |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | gpointer data) |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | GList *l = NULL; |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | g_return_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager)); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | g_return_if_fail(callback != NULL); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | for(l = manager->accounts; l != NULL; l = l->next) { |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | callback(PURPLE_ACCOUNT(l->data), data); |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | } |
|
e859c41d8996
Create the PurpleAccountManager API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | } |