Mercurial > pidgin
annotate finch/gntaccount.c @ 29833:834038426c38
Minor cleanup.
* g_free is NULL-safe.
* No need for an extra * on the gpointer.
* Adium doesn't like / in their <img> tags.
* purple_xfer_set_thumbnail should free previous data.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 25 Apr 2010 20:38:17 +0000 |
parents | 259bbfb423d4 |
children | cfdd4d3ba550 |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntaccount.c GNT Account API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15870
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19768
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19768
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19768
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19392
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15817 | 25 */ |
28770
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
28296
diff
changeset
|
26 #include <internal.h> |
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
28296
diff
changeset
|
27 |
15817 | 28 #include <gnt.h> |
29 #include <gntbox.h> | |
30 #include <gntbutton.h> | |
31 #include <gntcheckbox.h> | |
32 #include <gntcombobox.h> | |
33 #include <gntentry.h> | |
34 #include <gntlabel.h> | |
35 #include <gntline.h> | |
36 #include <gnttree.h> | |
18511
7ee0e0597a26
Add utility function to trigger some button when some key is pressed with
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18432
diff
changeset
|
37 #include <gntutils.h> |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
38 #include <gntwindow.h> |
15817 | 39 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18063
diff
changeset
|
40 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18063
diff
changeset
|
41 |
15817 | 42 #include <account.h> |
43 #include <accountopt.h> | |
44 #include <connection.h> | |
45 #include <notify.h> | |
46 #include <plugin.h> | |
47 #include <request.h> | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
48 #include <savedstatuses.h> |
15817 | 49 |
50 #include "gntaccount.h" | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
51 #include "gntblist.h" |
15817 | 52 |
53 #include <string.h> | |
54 | |
55 typedef struct | |
56 { | |
57 GntWidget *window; | |
58 GntWidget *tree; | |
59 } FinchAccountList; | |
60 | |
61 static FinchAccountList accounts; | |
62 | |
63 typedef struct | |
64 { | |
15822 | 65 PurpleAccount *account; /* NULL for a new account */ |
15817 | 66 |
67 GntWidget *window; | |
68 | |
69 GntWidget *protocol; | |
25925
6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents:
24595
diff
changeset
|
70 GntWidget *username; |
15817 | 71 GntWidget *password; |
72 GntWidget *alias; | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
73 |
15817 | 74 GntWidget *splits; |
75 GList *split_entries; | |
76 | |
77 GList *prpl_entries; | |
78 GntWidget *prpls; | |
79 | |
80 GntWidget *newmail; | |
81 GntWidget *remember; | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
82 GntWidget *regserver; |
15817 | 83 } AccountEditDialog; |
84 | |
85 /* This is necessary to close an edit-dialog when an account is deleted */ | |
86 static GList *accountdialogs; | |
87 | |
88 static void | |
15822 | 89 account_add(PurpleAccount *account) |
15817 | 90 { |
91 gnt_tree_add_choice(GNT_TREE(accounts.tree), account, | |
92 gnt_tree_create_row(GNT_TREE(accounts.tree), | |
15822 | 93 purple_account_get_username(account), |
94 purple_account_get_protocol_name(account)), | |
15817 | 95 NULL, NULL); |
96 gnt_tree_set_choice(GNT_TREE(accounts.tree), account, | |
15822 | 97 purple_account_get_enabled(account, FINCH_UI)); |
15817 | 98 } |
99 | |
100 static void | |
101 edit_dialog_destroy(AccountEditDialog *dialog) | |
102 { | |
103 accountdialogs = g_list_remove(accountdialogs, dialog); | |
104 g_list_free(dialog->prpl_entries); | |
105 g_list_free(dialog->split_entries); | |
106 g_free(dialog); | |
107 } | |
108 | |
109 static void | |
110 save_account_cb(AccountEditDialog *dialog) | |
111 { | |
15822 | 112 PurpleAccount *account; |
113 PurplePlugin *plugin; | |
114 PurplePluginProtocolInfo *prplinfo; | |
15817 | 115 const char *value; |
116 GString *username; | |
117 | |
118 /* XXX: Do some error checking first. */ | |
119 | |
120 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
15822 | 121 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 122 |
25925
6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents:
24595
diff
changeset
|
123 /* Username && user-splits */ |
6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents:
24595
diff
changeset
|
124 value = gnt_entry_get_text(GNT_ENTRY(dialog->username)); |
15817 | 125 |
126 if (value == NULL || *value == '\0') | |
127 { | |
15822 | 128 purple_notify_error(NULL, _("Error"), _("Account was not added"), |
22794
cc8903c59d6b
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <mark@kingant.net>
parents:
22257
diff
changeset
|
129 _("Username of an account must be non-empty.")); |
15817 | 130 return; |
131 } | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
132 |
15817 | 133 username = g_string_new(value); |
134 | |
135 if (prplinfo != NULL) | |
136 { | |
137 GList *iter, *entries; | |
138 for (iter = prplinfo->user_splits, entries = dialog->split_entries; | |
139 iter && entries; iter = iter->next, entries = entries->next) | |
140 { | |
15822 | 141 PurpleAccountUserSplit *split = iter->data; |
15817 | 142 GntWidget *entry = entries->data; |
143 | |
144 value = gnt_entry_get_text(GNT_ENTRY(entry)); | |
145 if (value == NULL || *value == '\0') | |
15822 | 146 value = purple_account_user_split_get_default_value(split); |
15817 | 147 g_string_append_printf(username, "%c%s", |
15822 | 148 purple_account_user_split_get_separator(split), |
15817 | 149 value); |
150 } | |
151 } | |
152 | |
153 if (dialog->account == NULL) | |
154 { | |
15822 | 155 account = purple_account_new(username->str, purple_plugin_get_id(plugin)); |
156 purple_accounts_add(account); | |
15817 | 157 } |
158 else | |
159 { | |
160 account = dialog->account; | |
161 | |
162 /* Protocol */ | |
15822 | 163 purple_account_set_protocol_id(account, purple_plugin_get_id(plugin)); |
164 purple_account_set_username(account, username->str); | |
15817 | 165 } |
166 g_string_free(username, TRUE); | |
167 | |
168 /* Alias */ | |
169 value = gnt_entry_get_text(GNT_ENTRY(dialog->alias)); | |
28296
a07e46f20644
Allow unsetting account alias in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27838
diff
changeset
|
170 purple_account_set_alias(account, value); |
15817 | 171 |
172 /* Remember password and password */ | |
15822 | 173 purple_account_set_remember_password(account, |
15817 | 174 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); |
175 value = gnt_entry_get_text(GNT_ENTRY(dialog->password)); | |
19762
656506d8935e
Don't prompt for the password again if the user entered it once in the account window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
176 if (value && *value) |
15822 | 177 purple_account_set_password(account, value); |
15817 | 178 else |
15822 | 179 purple_account_set_password(account, NULL); |
15817 | 180 |
181 /* Mail notification */ | |
15822 | 182 purple_account_set_check_mail(account, |
15817 | 183 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->newmail))); |
184 | |
185 /* Protocol options */ | |
186 if (prplinfo) | |
187 { | |
188 GList *iter, *entries; | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
189 |
15817 | 190 for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries; |
191 iter && entries; iter = iter->next, entries = entries->next) | |
192 { | |
15822 | 193 PurpleAccountOption *option = iter->data; |
15817 | 194 GntWidget *entry = entries->data; |
15822 | 195 PurplePrefType type = purple_account_option_get_type(option); |
196 const char *setting = purple_account_option_get_setting(option); | |
15817 | 197 |
15822 | 198 if (type == PURPLE_PREF_STRING) |
15817 | 199 { |
200 const char *value = gnt_entry_get_text(GNT_ENTRY(entry)); | |
15822 | 201 purple_account_set_string(account, setting, value); |
15817 | 202 } |
15822 | 203 else if (type == PURPLE_PREF_INT) |
15817 | 204 { |
205 const char *str = gnt_entry_get_text(GNT_ENTRY(entry)); | |
206 int value = 0; | |
207 if (str) | |
208 value = atoi(str); | |
15822 | 209 purple_account_set_int(account, setting, value); |
15817 | 210 } |
15822 | 211 else if (type == PURPLE_PREF_BOOLEAN) |
15817 | 212 { |
213 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(entry)); | |
15822 | 214 purple_account_set_bool(account, setting, value); |
15817 | 215 } |
15822 | 216 else if (type == PURPLE_PREF_STRING_LIST) |
15817 | 217 { |
218 /* TODO: */ | |
219 } | |
220 else | |
221 { | |
222 g_assert_not_reached(); | |
223 } | |
224 } | |
225 } | |
226 | |
227 /* XXX: Proxy options */ | |
228 | |
19392
74f7d5e4a605
Focus the modified/created account in the accounts window after modifying/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18829
diff
changeset
|
229 if (accounts.window && accounts.tree) { |
74f7d5e4a605
Focus the modified/created account in the accounts window after modifying/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18829
diff
changeset
|
230 gnt_tree_set_selected(GNT_TREE(accounts.tree), account); |
74f7d5e4a605
Focus the modified/created account in the accounts window after modifying/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18829
diff
changeset
|
231 gnt_box_give_focus_to_child(GNT_BOX(accounts.window), accounts.tree); |
74f7d5e4a605
Focus the modified/created account in the accounts window after modifying/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18829
diff
changeset
|
232 } |
74f7d5e4a605
Focus the modified/created account in the accounts window after modifying/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18829
diff
changeset
|
233 |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
234 if (prplinfo && prplinfo->register_user && |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
235 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->regserver))) { |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
236 purple_account_register(account); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
237 } else if (dialog->account == NULL) { |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
238 /* This is a new account. Set it to the current status. */ |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
239 /* Xerox from gtkaccount.c :D */ |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
240 const PurpleSavedStatus *saved_status; |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
241 saved_status = purple_savedstatus_get_current(); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
242 if (saved_status != NULL) { |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
243 purple_savedstatus_activate_for_account(saved_status, account); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
244 purple_account_set_enabled(account, FINCH_UI, TRUE); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
245 } |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
246 } |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
247 |
15817 | 248 gnt_widget_destroy(dialog->window); |
249 } | |
250 | |
251 static void | |
252 update_user_splits(AccountEditDialog *dialog) | |
253 { | |
254 GntWidget *hbox; | |
15822 | 255 PurplePlugin *plugin; |
256 PurplePluginProtocolInfo *prplinfo; | |
15817 | 257 GList *iter, *entries; |
258 char *username = NULL; | |
259 | |
260 if (dialog->splits) | |
261 { | |
262 gnt_box_remove_all(GNT_BOX(dialog->splits)); | |
263 g_list_free(dialog->split_entries); | |
264 } | |
265 else | |
266 { | |
267 dialog->splits = gnt_vbox_new(FALSE); | |
268 gnt_box_set_pad(GNT_BOX(dialog->splits), 0); | |
269 gnt_box_set_fill(GNT_BOX(dialog->splits), TRUE); | |
270 } | |
271 | |
272 dialog->split_entries = NULL; | |
273 | |
274 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
275 if (!plugin) | |
276 return; | |
15822 | 277 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 278 |
15822 | 279 username = dialog->account ? g_strdup(purple_account_get_username(dialog->account)) : NULL; |
15817 | 280 |
281 for (iter = prplinfo->user_splits; iter; iter = iter->next) | |
282 { | |
15822 | 283 PurpleAccountUserSplit *split = iter->data; |
15817 | 284 GntWidget *entry; |
285 char *buf; | |
286 | |
287 hbox = gnt_hbox_new(TRUE); | |
288 gnt_box_add_widget(GNT_BOX(dialog->splits), hbox); | |
289 | |
15822 | 290 buf = g_strdup_printf("%s:", purple_account_user_split_get_text(split)); |
15817 | 291 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(buf)); |
292 | |
293 entry = gnt_entry_new(NULL); | |
294 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
295 | |
296 dialog->split_entries = g_list_append(dialog->split_entries, entry); | |
297 g_free(buf); | |
298 } | |
299 | |
300 for (iter = g_list_last(prplinfo->user_splits), entries = g_list_last(dialog->split_entries); | |
301 iter && entries; iter = iter->prev, entries = entries->prev) | |
302 { | |
303 GntWidget *entry = entries->data; | |
15822 | 304 PurpleAccountUserSplit *split = iter->data; |
15817 | 305 const char *value = NULL; |
306 char *s; | |
307 | |
308 if (dialog->account) | |
309 { | |
18037
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17346
diff
changeset
|
310 if(purple_account_user_split_get_reverse(split)) |
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17346
diff
changeset
|
311 s = strrchr(username, purple_account_user_split_get_separator(split)); |
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17346
diff
changeset
|
312 else |
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17346
diff
changeset
|
313 s = strchr(username, purple_account_user_split_get_separator(split)); |
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17346
diff
changeset
|
314 |
15817 | 315 if (s != NULL) |
316 { | |
317 *s = '\0'; | |
318 s++; | |
319 value = s; | |
320 } | |
321 } | |
322 if (value == NULL) | |
15822 | 323 value = purple_account_user_split_get_default_value(split); |
15817 | 324 |
325 if (value != NULL) | |
326 gnt_entry_set_text(GNT_ENTRY(entry), value); | |
327 } | |
328 | |
329 if (username != NULL) | |
25925
6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents:
24595
diff
changeset
|
330 gnt_entry_set_text(GNT_ENTRY(dialog->username), username); |
15817 | 331 |
332 g_free(username); | |
333 } | |
334 | |
335 static void | |
336 add_protocol_options(AccountEditDialog *dialog) | |
337 { | |
15822 | 338 PurplePlugin *plugin; |
339 PurplePluginProtocolInfo *prplinfo; | |
15817 | 340 GList *iter; |
341 GntWidget *vbox, *box; | |
15822 | 342 PurpleAccount *account; |
15817 | 343 |
344 if (dialog->prpls) | |
345 gnt_box_remove_all(GNT_BOX(dialog->prpls)); | |
346 else | |
347 { | |
348 dialog->prpls = vbox = gnt_vbox_new(FALSE); | |
349 gnt_box_set_pad(GNT_BOX(vbox), 0); | |
350 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); | |
351 gnt_box_set_fill(GNT_BOX(vbox), TRUE); | |
352 } | |
353 | |
354 if (dialog->prpl_entries) | |
355 { | |
356 g_list_free(dialog->prpl_entries); | |
357 dialog->prpl_entries = NULL; | |
358 } | |
359 | |
360 vbox = dialog->prpls; | |
361 | |
362 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
363 if (!plugin) | |
364 return; | |
365 | |
15822 | 366 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 367 |
368 account = dialog->account; | |
369 | |
370 for (iter = prplinfo->protocol_options; iter; iter = iter->next) | |
371 { | |
15822 | 372 PurpleAccountOption *option = iter->data; |
373 PurplePrefType type = purple_account_option_get_type(option); | |
15817 | 374 |
375 box = gnt_hbox_new(TRUE); | |
376 gnt_box_set_pad(GNT_BOX(box), 0); | |
377 gnt_box_add_widget(GNT_BOX(vbox), box); | |
378 | |
15822 | 379 if (type == PURPLE_PREF_BOOLEAN) |
15817 | 380 { |
15822 | 381 GntWidget *widget = gnt_check_box_new(purple_account_option_get_text(option)); |
15817 | 382 gnt_box_add_widget(GNT_BOX(box), widget); |
383 dialog->prpl_entries = g_list_append(dialog->prpl_entries, widget); | |
384 | |
385 if (account) | |
386 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15822 | 387 purple_account_get_bool(account, |
388 purple_account_option_get_setting(option), | |
389 purple_account_option_get_default_bool(option))); | |
15817 | 390 else |
391 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15822 | 392 purple_account_option_get_default_bool(option)); |
15817 | 393 } |
394 else | |
395 { | |
396 gnt_box_add_widget(GNT_BOX(box), | |
15822 | 397 gnt_label_new(purple_account_option_get_text(option))); |
15817 | 398 |
15822 | 399 if (type == PURPLE_PREF_STRING_LIST) |
15817 | 400 { |
401 /* TODO: Use a combobox */ | |
402 /* Don't forget to append the widget to prpl_entries */ | |
403 } | |
404 else | |
405 { | |
406 GntWidget *entry = gnt_entry_new(NULL); | |
407 gnt_box_add_widget(GNT_BOX(box), entry); | |
408 dialog->prpl_entries = g_list_append(dialog->prpl_entries, entry); | |
409 | |
15822 | 410 if (type == PURPLE_PREF_STRING) |
15817 | 411 { |
15822 | 412 const char *dv = purple_account_option_get_default_string(option); |
15817 | 413 |
414 if (account) | |
415 gnt_entry_set_text(GNT_ENTRY(entry), | |
15822 | 416 purple_account_get_string(account, |
417 purple_account_option_get_setting(option), dv)); | |
15817 | 418 else |
419 gnt_entry_set_text(GNT_ENTRY(entry), dv); | |
420 } | |
15822 | 421 else if (type == PURPLE_PREF_INT) |
15817 | 422 { |
423 char str[32]; | |
15822 | 424 int value = purple_account_option_get_default_int(option); |
15817 | 425 if (account) |
15822 | 426 value = purple_account_get_int(account, |
427 purple_account_option_get_setting(option), value); | |
15817 | 428 snprintf(str, sizeof(str), "%d", value); |
429 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); | |
430 gnt_entry_set_text(GNT_ENTRY(entry), str); | |
431 } | |
432 else | |
433 { | |
434 g_assert_not_reached(); | |
435 } | |
436 } | |
437 } | |
438 } | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
439 |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
440 /* Show the registration checkbox only in a new account dialog, |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
441 * and when the selected prpl has the support for it. */ |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
442 gnt_widget_set_visible(dialog->regserver, account == NULL && |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
443 prplinfo->register_user != NULL); |
15817 | 444 } |
445 | |
446 static void | |
447 update_user_options(AccountEditDialog *dialog) | |
448 { | |
15822 | 449 PurplePlugin *plugin; |
450 PurplePluginProtocolInfo *prplinfo; | |
15817 | 451 |
452 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
453 if (!plugin) | |
454 return; | |
455 | |
15822 | 456 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 457 |
458 if (dialog->newmail == NULL) | |
459 dialog->newmail = gnt_check_box_new(_("New mail notifications")); | |
460 if (dialog->account) | |
461 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), | |
15822 | 462 purple_account_get_check_mail(dialog->account)); |
15817 | 463 if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK)) |
464 gnt_widget_set_visible(dialog->newmail, FALSE); | |
465 else | |
466 gnt_widget_set_visible(dialog->newmail, TRUE); | |
467 | |
468 if (dialog->remember == NULL) | |
469 dialog->remember = gnt_check_box_new(_("Remember password")); | |
470 if (dialog->account) | |
471 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->remember), | |
15822 | 472 purple_account_get_remember_password(dialog->account)); |
15817 | 473 } |
474 | |
475 static void | |
15822 | 476 prpl_changed_cb(GntWidget *combo, PurplePlugin *old, PurplePlugin *new, AccountEditDialog *dialog) |
15817 | 477 { |
478 update_user_splits(dialog); | |
479 add_protocol_options(dialog); | |
480 update_user_options(dialog); /* This may not be necessary here */ | |
481 gnt_box_readjust(GNT_BOX(dialog->window)); | |
482 gnt_widget_draw(dialog->window); | |
483 } | |
484 | |
485 static void | |
15822 | 486 edit_account(PurpleAccount *account) |
15817 | 487 { |
488 GntWidget *window, *hbox; | |
489 GntWidget *combo, *button, *entry; | |
490 GList *list, *iter; | |
491 AccountEditDialog *dialog; | |
27838
3316e5c79a53
Don't crash trying to modify the settings for an account where the prpl is
Stu Tomlinson <stu@nosnilmot.com>
parents:
27587
diff
changeset
|
492 PurplePlugin *plugin; |
15817 | 493 |
494 if (account) | |
495 { | |
496 GList *iter; | |
497 for (iter = accountdialogs; iter; iter = iter->next) | |
498 { | |
499 AccountEditDialog *dlg = iter->data; | |
500 if (dlg->account == account) | |
501 return; | |
502 } | |
503 } | |
504 | |
18432
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
505 list = purple_plugins_get_protocols(); |
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
506 if (list == NULL) { |
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
507 purple_notify_error(NULL, _("Error"), |
24053
81169f04ab1c
datallah reminds me that my strings suck
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24030
diff
changeset
|
508 _("There are no protocol plugins installed."), |
18432
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
509 _("(You probably forgot to 'make install'.)")); |
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
510 return; |
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
511 } |
f5a17e7e4bfa
Do not crash when people run finch without 'make install'ing first.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
512 |
15817 | 513 dialog = g_new0(AccountEditDialog, 1); |
514 accountdialogs = g_list_prepend(accountdialogs, dialog); | |
515 | |
516 dialog->window = window = gnt_vbox_new(FALSE); | |
517 dialog->account = account; | |
518 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
519 gnt_box_set_title(GNT_BOX(window), account ? _("Modify Account") : _("New Account")); | |
520 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
521 gnt_box_set_pad(GNT_BOX(window), 0); | |
522 gnt_widget_set_name(window, "edit-account"); | |
523 gnt_box_set_fill(GNT_BOX(window), TRUE); | |
524 | |
525 hbox = gnt_hbox_new(TRUE); | |
526 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
527 gnt_box_add_widget(GNT_BOX(window), hbox); | |
528 | |
529 dialog->protocol = combo = gnt_combo_box_new(); | |
530 for (iter = list; iter; iter = iter->next) | |
531 { | |
532 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), iter->data, | |
15822 | 533 ((PurplePlugin*)iter->data)->info->name); |
15817 | 534 } |
535 | |
27838
3316e5c79a53
Don't crash trying to modify the settings for an account where the prpl is
Stu Tomlinson <stu@nosnilmot.com>
parents:
27587
diff
changeset
|
536 plugin = purple_plugins_find_with_id(purple_account_get_protocol_id(account)); |
3316e5c79a53
Don't crash trying to modify the settings for an account where the prpl is
Stu Tomlinson <stu@nosnilmot.com>
parents:
27587
diff
changeset
|
537 |
3316e5c79a53
Don't crash trying to modify the settings for an account where the prpl is
Stu Tomlinson <stu@nosnilmot.com>
parents:
27587
diff
changeset
|
538 if (account && plugin) |
3316e5c79a53
Don't crash trying to modify the settings for an account where the prpl is
Stu Tomlinson <stu@nosnilmot.com>
parents:
27587
diff
changeset
|
539 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), plugin); |
15817 | 540 else |
541 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), list->data); | |
542 | |
543 g_signal_connect(G_OBJECT(combo), "selection-changed", G_CALLBACK(prpl_changed_cb), dialog); | |
544 | |
545 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Protocol:"))); | |
546 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
547 | |
548 hbox = gnt_hbox_new(TRUE); | |
549 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
550 gnt_box_add_widget(GNT_BOX(window), hbox); | |
551 | |
25925
6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents:
24595
diff
changeset
|
552 dialog->username = entry = gnt_entry_new(NULL); |
22794
cc8903c59d6b
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <mark@kingant.net>
parents:
22257
diff
changeset
|
553 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Username:"))); |
15817 | 554 gnt_box_add_widget(GNT_BOX(hbox), entry); |
555 | |
556 /* User splits */ | |
557 update_user_splits(dialog); | |
558 gnt_box_add_widget(GNT_BOX(window), dialog->splits); | |
559 | |
560 hbox = gnt_hbox_new(TRUE); | |
561 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
562 gnt_box_add_widget(GNT_BOX(window), hbox); | |
563 | |
564 dialog->password = entry = gnt_entry_new(NULL); | |
565 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); | |
566 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); | |
567 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
568 if (account) | |
15822 | 569 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_password(account)); |
15817 | 570 |
571 hbox = gnt_hbox_new(TRUE); | |
572 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
573 gnt_box_add_widget(GNT_BOX(window), hbox); | |
574 | |
575 dialog->alias = entry = gnt_entry_new(NULL); | |
576 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); | |
577 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
578 if (account) | |
15822 | 579 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_alias(account)); |
15817 | 580 |
581 /* User options */ | |
582 update_user_options(dialog); | |
583 gnt_box_add_widget(GNT_BOX(window), dialog->remember); | |
584 gnt_box_add_widget(GNT_BOX(window), dialog->newmail); | |
585 | |
23083
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
586 /* Register checkbox */ |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
587 dialog->regserver = gnt_check_box_new(_("Create this account on the server")); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
588 gnt_box_add_widget(GNT_BOX(window), dialog->regserver); |
02ef6c5c6650
Allow account registration in a new account dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22794
diff
changeset
|
589 |
15817 | 590 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); |
591 | |
592 /* The advanced box */ | |
593 add_protocol_options(dialog); | |
594 gnt_box_add_widget(GNT_BOX(window), dialog->prpls); | |
595 | |
596 /* TODO: Add proxy options */ | |
597 | |
598 /* The button box */ | |
599 hbox = gnt_hbox_new(FALSE); | |
600 gnt_box_add_widget(GNT_BOX(window), hbox); | |
601 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
602 | |
603 button = gnt_button_new(_("Cancel")); | |
604 gnt_box_add_widget(GNT_BOX(hbox), button); | |
605 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); | |
606 | |
607 button = gnt_button_new(_("Save")); | |
608 gnt_box_add_widget(GNT_BOX(hbox), button); | |
609 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog); | |
610 | |
611 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(edit_dialog_destroy), dialog); | |
612 | |
613 gnt_widget_show(window); | |
614 gnt_box_readjust(GNT_BOX(window)); | |
615 gnt_widget_draw(window); | |
616 } | |
617 | |
618 static void | |
619 add_account_cb(GntWidget *widget, gpointer null) | |
620 { | |
621 edit_account(NULL); | |
622 } | |
623 | |
624 static void | |
625 modify_account_cb(GntWidget *widget, GntTree *tree) | |
626 { | |
15822 | 627 PurpleAccount *account = gnt_tree_get_selection_data(tree); |
15817 | 628 if (!account) |
629 return; | |
630 edit_account(account); | |
631 } | |
632 | |
633 static void | |
15822 | 634 really_delete_account(PurpleAccount *account) |
15817 | 635 { |
636 GList *iter; | |
637 for (iter = accountdialogs; iter; iter = iter->next) | |
638 { | |
639 AccountEditDialog *dlg = iter->data; | |
640 if (dlg->account == account) | |
641 { | |
642 gnt_widget_destroy(dlg->window); | |
643 break; | |
644 } | |
645 } | |
15822 | 646 purple_request_close_with_handle(account); /* Close any other opened delete window */ |
647 purple_accounts_delete(account); | |
15817 | 648 } |
649 | |
650 static void | |
651 delete_account_cb(GntWidget *widget, GntTree *tree) | |
652 { | |
15822 | 653 PurpleAccount *account; |
15817 | 654 char *prompt; |
655 | |
656 account = gnt_tree_get_selection_data(tree); | |
657 if (!account) | |
658 return; | |
659 | |
660 prompt = g_strdup_printf(_("Are you sure you want to delete %s?"), | |
15822 | 661 purple_account_get_username(account)); |
15817 | 662 |
22257
8233bbcf3e86
The Gnome Human Interface Guidelines say, "if pressing this button by
Mark Doliner <mark@kingant.net>
parents:
22213
diff
changeset
|
663 purple_request_action(account, _("Delete Account"), prompt, NULL, |
8233bbcf3e86
The Gnome Human Interface Guidelines say, "if pressing this button by
Mark Doliner <mark@kingant.net>
parents:
22213
diff
changeset
|
664 PURPLE_DEFAULT_ACTION_NONE, |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
665 account, NULL, NULL, account, 2, |
16462
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
666 _("Delete"), really_delete_account, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
667 _("Cancel"), NULL); |
15817 | 668 g_free(prompt); |
669 } | |
670 | |
671 static void | |
672 account_toggled(GntWidget *widget, void *key, gpointer null) | |
673 { | |
15822 | 674 PurpleAccount *account = key; |
26498
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
675 gboolean enabled = gnt_tree_get_choice(GNT_TREE(widget), key); |
15817 | 676 |
26498
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
677 if (enabled) |
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
678 purple_savedstatus_activate_for_account(purple_savedstatus_get_current(), |
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
679 account); |
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
680 |
246081d2d990
Activate the current status for an account being enabled
Richard Nelson <wabz@pidgin.im>
parents:
26347
diff
changeset
|
681 purple_account_set_enabled(account, FINCH_UI, enabled); |
15817 | 682 } |
683 | |
24030
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
684 static gboolean |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
685 account_list_key_pressed_cb(GntWidget *widget, const char *text, gpointer null) |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
686 { |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
687 GntTree *tree = GNT_TREE(widget); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
688 PurpleAccount *account = gnt_tree_get_selection_data(tree); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
689 int move, pos, count; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
690 GList *accounts; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
691 |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
692 if (!account) |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
693 return FALSE; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
694 |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
695 switch (text[0]) { |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
696 case '-': |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
697 move = -1; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
698 break; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
699 case '=': |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
700 move = 2; /* XXX: This seems to be a bug in libpurple */ |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
701 break; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
702 default: |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
703 return FALSE; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
704 } |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
705 |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
706 accounts = purple_accounts_get_all(); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
707 count = g_list_length(accounts); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
708 pos = g_list_index(accounts, account); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
709 pos = (move + pos + count + 1) % (count + 1); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
710 purple_accounts_reorder(account, pos); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
711 |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
712 /* I don't like this, but recreating the entire list seems to be |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
713 * the easiest way of doing it */ |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
714 gnt_tree_remove_all(tree); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
715 accounts = purple_accounts_get_all(); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
716 for (; accounts; accounts = accounts->next) |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
717 account_add(accounts->data); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
718 gnt_tree_set_selected(tree, account); |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
719 |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
720 return TRUE; |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
721 } |
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
722 |
15817 | 723 static void |
724 reset_accounts_win(GntWidget *widget, gpointer null) | |
725 { | |
726 accounts.window = NULL; | |
727 accounts.tree = NULL; | |
728 } | |
729 | |
730 void finch_accounts_show_all() | |
731 { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
732 GList *iter; |
15817 | 733 GntWidget *box, *button; |
734 | |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
735 if (accounts.window) { |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
736 gnt_window_present(accounts.window); |
15817 | 737 return; |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
738 } |
15817 | 739 |
740 accounts.window = gnt_vbox_new(FALSE); | |
741 gnt_box_set_toplevel(GNT_BOX(accounts.window), TRUE); | |
742 gnt_box_set_title(GNT_BOX(accounts.window), _("Accounts")); | |
743 gnt_box_set_pad(GNT_BOX(accounts.window), 0); | |
744 gnt_box_set_alignment(GNT_BOX(accounts.window), GNT_ALIGN_MID); | |
745 gnt_widget_set_name(accounts.window, "accounts"); | |
746 | |
747 gnt_box_add_widget(GNT_BOX(accounts.window), | |
748 gnt_label_new(_("You can enable/disable accounts from the following list."))); | |
749 | |
750 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
751 | |
752 accounts.tree = gnt_tree_new_with_columns(2); | |
753 GNT_WIDGET_SET_FLAGS(accounts.tree, GNT_WIDGET_NO_BORDER); | |
754 | |
15822 | 755 for (iter = purple_accounts_get_all(); iter; iter = iter->next) |
15817 | 756 { |
15822 | 757 PurpleAccount *account = iter->data; |
15817 | 758 account_add(account); |
759 } | |
760 | |
761 g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); | |
24030
84deb53a0a06
Press - or = in the accounts list to reorder accounts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23083
diff
changeset
|
762 g_signal_connect(G_OBJECT(accounts.tree), "key_pressed", G_CALLBACK(account_list_key_pressed_cb), NULL); |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
763 |
15817 | 764 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 0, 40); |
765 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 1, 10); | |
766 gnt_box_add_widget(GNT_BOX(accounts.window), accounts.tree); | |
767 | |
768 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
769 | |
770 box = gnt_hbox_new(FALSE); | |
771 | |
772 button = gnt_button_new(_("Add")); | |
773 gnt_box_add_widget(GNT_BOX(box), button); | |
18511
7ee0e0597a26
Add utility function to trigger some button when some key is pressed with
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18432
diff
changeset
|
774 gnt_util_set_trigger_widget(GNT_WIDGET(accounts.tree), GNT_KEY_INS, button); |
15817 | 775 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account_cb), NULL); |
776 | |
777 button = gnt_button_new(_("Modify")); | |
778 gnt_box_add_widget(GNT_BOX(box), button); | |
779 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(modify_account_cb), accounts.tree); | |
780 | |
781 button = gnt_button_new(_("Delete")); | |
782 gnt_box_add_widget(GNT_BOX(box), button); | |
18511
7ee0e0597a26
Add utility function to trigger some button when some key is pressed with
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18432
diff
changeset
|
783 gnt_util_set_trigger_widget(GNT_WIDGET(accounts.tree), GNT_KEY_DEL, button); |
15817 | 784 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
785 |
15817 | 786 gnt_box_add_widget(GNT_BOX(accounts.window), box); |
787 | |
788 g_signal_connect(G_OBJECT(accounts.window), "destroy", G_CALLBACK(reset_accounts_win), NULL); | |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
789 |
15817 | 790 gnt_widget_show(accounts.window); |
791 } | |
792 | |
19768
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19762
diff
changeset
|
793 void finch_account_dialog_show(PurpleAccount *account) |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19762
diff
changeset
|
794 { |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19762
diff
changeset
|
795 edit_account(account); |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19762
diff
changeset
|
796 } |
41cad24fd6df
Instead of just notifying the user about a connection error, give him options
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19762
diff
changeset
|
797 |
15817 | 798 static gpointer |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21570
diff
changeset
|
799 finch_accounts_get_handle(void) |
15817 | 800 { |
801 static int handle; | |
802 | |
803 return &handle; | |
804 } | |
805 | |
806 static void | |
15822 | 807 account_added_callback(PurpleAccount *account) |
15817 | 808 { |
809 if (accounts.window == NULL) | |
810 return; | |
811 account_add(account); | |
812 gnt_widget_draw(accounts.tree); | |
813 } | |
814 | |
815 static void | |
15822 | 816 account_removed_callback(PurpleAccount *account) |
15817 | 817 { |
818 if (accounts.window == NULL) | |
819 return; | |
820 | |
821 gnt_tree_remove(GNT_TREE(accounts.tree), account); | |
822 } | |
823 | |
17346
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
824 static void |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
825 account_abled_cb(PurpleAccount *account, gpointer user_data) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
826 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
827 if (accounts.window == NULL) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
828 return; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
829 gnt_tree_set_choice(GNT_TREE(accounts.tree), account, |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
830 GPOINTER_TO_INT(user_data)); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
831 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
832 |
15817 | 833 void finch_accounts_init() |
834 { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
835 GList *iter; |
15817 | 836 |
15822 | 837 purple_signal_connect(purple_accounts_get_handle(), "account-added", |
838 finch_accounts_get_handle(), PURPLE_CALLBACK(account_added_callback), | |
15817 | 839 NULL); |
15822 | 840 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
841 finch_accounts_get_handle(), PURPLE_CALLBACK(account_removed_callback), | |
15817 | 842 NULL); |
17346
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
843 purple_signal_connect(purple_accounts_get_handle(), "account-disabled", |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
844 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
845 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
846 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
847 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
848 PURPLE_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
849 |
17816
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
850 iter = purple_accounts_get_all(); |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
851 if (iter) { |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
852 for (; iter; iter = iter->next) { |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
853 if (purple_account_get_enabled(iter->data, FINCH_UI)) |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
854 break; |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
855 } |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
856 if (!iter) |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
857 finch_accounts_show_all(); |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
858 } else { |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
859 edit_account(NULL); |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
860 finch_accounts_show_all(); |
15817 | 861 } |
862 } | |
863 | |
864 void finch_accounts_uninit() | |
865 { | |
866 if (accounts.window) | |
867 gnt_widget_destroy(accounts.window); | |
868 } | |
869 | |
870 /* The following uiops stuff are copied from gtkaccount.c */ | |
871 typedef struct | |
872 { | |
15822 | 873 PurpleAccount *account; |
15817 | 874 char *username; |
875 char *alias; | |
876 } AddUserData; | |
877 | |
878 static char * | |
15822 | 879 make_info(PurpleAccount *account, PurpleConnection *gc, const char *remote_user, |
15817 | 880 const char *id, const char *alias, const char *msg) |
881 { | |
882 if (msg != NULL && *msg == '\0') | |
883 msg = NULL; | |
884 | |
885 return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s"), | |
886 remote_user, | |
887 (alias != NULL ? " (" : ""), | |
888 (alias != NULL ? alias : ""), | |
889 (alias != NULL ? ")" : ""), | |
890 (id != NULL | |
891 ? id | |
15822 | 892 : (purple_connection_get_display_name(gc) != NULL |
893 ? purple_connection_get_display_name(gc) | |
894 : purple_account_get_username(account))), | |
15817 | 895 (msg != NULL ? ": " : "."), |
896 (msg != NULL ? msg : "")); | |
897 } | |
898 | |
899 static void | |
15822 | 900 notify_added(PurpleAccount *account, const char *remote_user, |
15817 | 901 const char *id, const char *alias, |
902 const char *msg) | |
903 { | |
904 char *buffer; | |
15822 | 905 PurpleConnection *gc; |
15817 | 906 |
15822 | 907 gc = purple_account_get_connection(account); |
15817 | 908 |
909 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
910 | |
15822 | 911 purple_notify_info(NULL, NULL, buffer, NULL); |
15817 | 912 |
913 g_free(buffer); | |
914 } | |
915 | |
916 static void | |
917 free_add_user_data(AddUserData *data) | |
918 { | |
919 g_free(data->username); | |
920 | |
921 if (data->alias != NULL) | |
922 g_free(data->alias); | |
923 | |
924 g_free(data); | |
925 } | |
926 | |
927 static void | |
928 add_user_cb(AddUserData *data) | |
929 { | |
15822 | 930 PurpleConnection *gc = purple_account_get_connection(data->account); |
15817 | 931 |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
932 if (g_list_find(purple_connections_get_all(), gc)) |
15817 | 933 { |
15822 | 934 purple_blist_request_add_buddy(data->account, data->username, |
15817 | 935 NULL, data->alias); |
936 } | |
937 | |
938 free_add_user_data(data); | |
939 } | |
940 | |
941 static void | |
15822 | 942 request_add(PurpleAccount *account, const char *remote_user, |
15817 | 943 const char *id, const char *alias, |
944 const char *msg) | |
945 { | |
946 char *buffer; | |
15822 | 947 PurpleConnection *gc; |
15817 | 948 AddUserData *data; |
949 | |
15822 | 950 gc = purple_account_get_connection(account); |
15817 | 951 |
952 data = g_new0(AddUserData, 1); | |
953 data->account = account; | |
954 data->username = g_strdup(remote_user); | |
955 data->alias = (alias != NULL ? g_strdup(alias) : NULL); | |
956 | |
957 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
958 purple_request_action(NULL, NULL, _("Add buddy to your list?"), |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
959 buffer, PURPLE_DEFAULT_ACTION_NONE, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
960 account, remote_user, NULL, |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
961 data, 2, |
15817 | 962 _("Add"), G_CALLBACK(add_user_cb), |
963 _("Cancel"), G_CALLBACK(free_add_user_data)); | |
964 g_free(buffer); | |
965 } | |
966 | |
967 /* Copied from gtkaccount.c */ | |
968 typedef struct { | |
15822 | 969 PurpleAccountRequestAuthorizationCb auth_cb; |
970 PurpleAccountRequestAuthorizationCb deny_cb; | |
15817 | 971 void *data; |
972 char *username; | |
973 char *alias; | |
15822 | 974 PurpleAccount *account; |
15817 | 975 } auth_and_add; |
976 | |
977 static void | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
978 free_auth_and_add(auth_and_add *aa) |
15817 | 979 { |
980 g_free(aa->username); | |
981 g_free(aa->alias); | |
982 g_free(aa); | |
983 } | |
984 | |
985 static void | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
986 authorize_and_add_cb(auth_and_add *aa) |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
987 { |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
988 aa->auth_cb(aa->data); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
989 purple_blist_request_add_buddy(aa->account, aa->username, |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
990 NULL, aa->alias); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
991 } |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
992 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
993 static void |
15817 | 994 deny_no_add_cb(auth_and_add *aa) |
995 { | |
996 aa->deny_cb(aa->data); | |
997 } | |
998 | |
999 static void * | |
18829
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1000 finch_request_authorize(PurpleAccount *account, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1001 const char *remote_user, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1002 const char *id, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1003 const char *alias, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1004 const char *message, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1005 gboolean on_list, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1006 PurpleAccountRequestAuthorizationCb auth_cb, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1007 PurpleAccountRequestAuthorizationCb deny_cb, |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1008 void *user_data) |
15817 | 1009 { |
1010 char *buffer; | |
15822 | 1011 PurpleConnection *gc; |
15817 | 1012 void *uihandle; |
1013 | |
15822 | 1014 gc = purple_account_get_connection(account); |
15817 | 1015 if (message != NULL && *message == '\0') |
1016 message = NULL; | |
1017 | |
18516
15f0c935e699
I changed a string during a string freeze\! Sorry\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18511
diff
changeset
|
1018 buffer = g_strdup_printf(_("%s%s%s%s wants to add %s to his or her buddy list%s%s"), |
15817 | 1019 remote_user, |
1020 (alias != NULL ? " (" : ""), | |
1021 (alias != NULL ? alias : ""), | |
1022 (alias != NULL ? ")" : ""), | |
1023 (id != NULL | |
1024 ? id | |
15822 | 1025 : (purple_connection_get_display_name(gc) != NULL |
1026 ? purple_connection_get_display_name(gc) | |
1027 : purple_account_get_username(account))), | |
18516
15f0c935e699
I changed a string during a string freeze\! Sorry\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18511
diff
changeset
|
1028 (message != NULL ? ": " : "."), |
15817 | 1029 (message != NULL ? message : "")); |
1030 if (!on_list) { | |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1031 GntWidget *widget; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1032 GList *iter; |
15817 | 1033 auth_and_add *aa = g_new(auth_and_add, 1); |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1034 |
18829
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1035 aa->auth_cb = auth_cb; |
7a594763c229
Correct the types of the authorize_cb and deny_cb parameters of
Will Thompson <will.thompson@collabora.co.uk>
parents:
18516
diff
changeset
|
1036 aa->deny_cb = deny_cb; |
15817 | 1037 aa->data = user_data; |
1038 aa->username = g_strdup(remote_user); | |
1039 aa->alias = g_strdup(alias); | |
1040 aa->account = account; | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1041 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1042 uihandle = gnt_vwindow_new(FALSE); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1043 gnt_box_set_title(GNT_BOX(uihandle), _("Authorize buddy?")); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1044 gnt_box_set_pad(GNT_BOX(uihandle), 0); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1045 |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
1046 widget = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
1047 PURPLE_DEFAULT_ACTION_NONE, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
1048 account, remote_user, NULL, |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
1049 aa, 2, |
15817 | 1050 _("Authorize"), authorize_and_add_cb, |
1051 _("Deny"), deny_no_add_cb); | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1052 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1053 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1054 gnt_box_add_widget(GNT_BOX(uihandle), widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1055 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1056 gnt_box_add_widget(GNT_BOX(uihandle), gnt_hline_new()); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1057 |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
1058 widget = finch_retrieve_user_info(purple_account_get_connection(account), remote_user); |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1059 for (iter = GNT_BOX(widget)->list; iter; iter = iter->next) { |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1060 if (GNT_IS_BUTTON(iter->data)) { |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1061 gnt_widget_destroy(iter->data); |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1062 gnt_box_remove(GNT_BOX(widget), iter->data); |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1063 break; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1064 } |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
1065 } |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1066 gnt_box_set_toplevel(GNT_BOX(widget), FALSE); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1067 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1068 gnt_box_add_widget(GNT_BOX(uihandle), widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1069 gnt_widget_show(uihandle); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1070 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
1071 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa); |
15817 | 1072 } else { |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
1073 uihandle = purple_request_action(NULL, _("Authorize buddy?"), buffer, NULL, |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
1074 PURPLE_DEFAULT_ACTION_NONE, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16194
diff
changeset
|
1075 account, remote_user, NULL, |
21570
dccfd999ffe7
merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents:
21244
diff
changeset
|
1076 user_data, 2, |
15817 | 1077 _("Authorize"), auth_cb, |
1078 _("Deny"), deny_cb); | |
1079 } | |
24595
024818afb013
A patch to clean up authorization request related stuff. Fixes #7695.
Paul Aurich <paul@darkrain42.org>
parents:
24053
diff
changeset
|
1080 g_signal_connect(G_OBJECT(uihandle), "destroy", |
024818afb013
A patch to clean up authorization request related stuff. Fixes #7695.
Paul Aurich <paul@darkrain42.org>
parents:
24053
diff
changeset
|
1081 G_CALLBACK(purple_account_request_close), NULL); |
15817 | 1082 g_free(buffer); |
1083 return uihandle; | |
1084 } | |
1085 | |
1086 static void | |
1087 finch_request_close(void *uihandle) | |
1088 { | |
15822 | 1089 purple_request_close(PURPLE_REQUEST_ACTION, uihandle); |
15817 | 1090 } |
1091 | |
15822 | 1092 static PurpleAccountUiOps ui_ops = |
15817 | 1093 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1094 notify_added, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1095 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1096 request_add, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1097 finch_request_authorize, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1098 finch_request_close, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1099 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1100 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1101 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
1102 NULL |
15817 | 1103 }; |
1104 | |
15822 | 1105 PurpleAccountUiOps *finch_accounts_get_ui_ops() |
15817 | 1106 { |
1107 return &ui_ops; | |
1108 } | |
1109 |