Mercurial > pidgin
annotate finch/gntaccount.c @ 18960:6831c126bcf3
- Fixed an inverted assertion
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Wed, 27 Jun 2007 01:09:43 +0000 |
parents | b8572b937c09 |
children | 2d4df5ef0090 |
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 |
15817 | 4 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
5 * finch |
15817 | 6 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include <gnt.h> | |
26 #include <gntbox.h> | |
27 #include <gntbutton.h> | |
28 #include <gntcheckbox.h> | |
29 #include <gntcombobox.h> | |
30 #include <gntentry.h> | |
31 #include <gntlabel.h> | |
32 #include <gntline.h> | |
33 #include <gnttree.h> | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
34 #include <gntwindow.h> |
15817 | 35 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18063
diff
changeset
|
36 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18063
diff
changeset
|
37 |
15817 | 38 #include <account.h> |
39 #include <accountopt.h> | |
40 #include <connection.h> | |
41 #include <notify.h> | |
42 #include <plugin.h> | |
43 #include <request.h> | |
44 | |
45 #include "gntaccount.h" | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
46 #include "gntblist.h" |
15817 | 47 |
48 #include <string.h> | |
49 | |
50 typedef struct | |
51 { | |
52 GntWidget *window; | |
53 GntWidget *tree; | |
54 } FinchAccountList; | |
55 | |
56 static FinchAccountList accounts; | |
57 | |
58 typedef struct | |
59 { | |
15822 | 60 PurpleAccount *account; /* NULL for a new account */ |
15817 | 61 |
62 GntWidget *window; | |
63 | |
64 GntWidget *protocol; | |
65 GntWidget *screenname; | |
66 GntWidget *password; | |
67 GntWidget *alias; | |
68 | |
69 GntWidget *splits; | |
70 GList *split_entries; | |
71 | |
72 GList *prpl_entries; | |
73 GntWidget *prpls; | |
74 | |
75 GntWidget *newmail; | |
76 GntWidget *remember; | |
77 } AccountEditDialog; | |
78 | |
79 /* This is necessary to close an edit-dialog when an account is deleted */ | |
80 static GList *accountdialogs; | |
81 | |
82 static void | |
15822 | 83 account_add(PurpleAccount *account) |
15817 | 84 { |
85 gnt_tree_add_choice(GNT_TREE(accounts.tree), account, | |
86 gnt_tree_create_row(GNT_TREE(accounts.tree), | |
15822 | 87 purple_account_get_username(account), |
88 purple_account_get_protocol_name(account)), | |
15817 | 89 NULL, NULL); |
90 gnt_tree_set_choice(GNT_TREE(accounts.tree), account, | |
15822 | 91 purple_account_get_enabled(account, FINCH_UI)); |
15817 | 92 } |
93 | |
94 static void | |
95 edit_dialog_destroy(AccountEditDialog *dialog) | |
96 { | |
97 accountdialogs = g_list_remove(accountdialogs, dialog); | |
98 g_list_free(dialog->prpl_entries); | |
99 g_list_free(dialog->split_entries); | |
100 g_free(dialog); | |
101 } | |
102 | |
103 static void | |
104 save_account_cb(AccountEditDialog *dialog) | |
105 { | |
15822 | 106 PurpleAccount *account; |
107 PurplePlugin *plugin; | |
108 PurplePluginProtocolInfo *prplinfo; | |
15817 | 109 const char *value; |
110 GString *username; | |
111 | |
112 /* XXX: Do some error checking first. */ | |
113 | |
114 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
15822 | 115 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 116 |
117 /* Screenname && user-splits */ | |
118 value = gnt_entry_get_text(GNT_ENTRY(dialog->screenname)); | |
119 | |
120 if (value == NULL || *value == '\0') | |
121 { | |
15822 | 122 purple_notify_error(NULL, _("Error"), _("Account was not added"), |
15817 | 123 _("Screenname of an account must be non-empty.")); |
124 return; | |
125 } | |
126 | |
127 username = g_string_new(value); | |
128 | |
129 if (prplinfo != NULL) | |
130 { | |
131 GList *iter, *entries; | |
132 for (iter = prplinfo->user_splits, entries = dialog->split_entries; | |
133 iter && entries; iter = iter->next, entries = entries->next) | |
134 { | |
15822 | 135 PurpleAccountUserSplit *split = iter->data; |
15817 | 136 GntWidget *entry = entries->data; |
137 | |
138 value = gnt_entry_get_text(GNT_ENTRY(entry)); | |
139 if (value == NULL || *value == '\0') | |
15822 | 140 value = purple_account_user_split_get_default_value(split); |
15817 | 141 g_string_append_printf(username, "%c%s", |
15822 | 142 purple_account_user_split_get_separator(split), |
15817 | 143 value); |
144 } | |
145 } | |
146 | |
147 if (dialog->account == NULL) | |
148 { | |
15822 | 149 account = purple_account_new(username->str, purple_plugin_get_id(plugin)); |
150 purple_accounts_add(account); | |
15817 | 151 } |
152 else | |
153 { | |
154 account = dialog->account; | |
155 | |
156 /* Protocol */ | |
15822 | 157 purple_account_set_protocol_id(account, purple_plugin_get_id(plugin)); |
158 purple_account_set_username(account, username->str); | |
15817 | 159 } |
160 g_string_free(username, TRUE); | |
161 | |
162 /* Alias */ | |
163 value = gnt_entry_get_text(GNT_ENTRY(dialog->alias)); | |
164 if (value && *value) | |
15822 | 165 purple_account_set_alias(account, value); |
15817 | 166 |
167 /* Remember password and password */ | |
15822 | 168 purple_account_set_remember_password(account, |
15817 | 169 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); |
170 value = gnt_entry_get_text(GNT_ENTRY(dialog->password)); | |
15822 | 171 if (value && *value && purple_account_get_remember_password(account)) |
172 purple_account_set_password(account, value); | |
15817 | 173 else |
15822 | 174 purple_account_set_password(account, NULL); |
15817 | 175 |
176 /* Mail notification */ | |
15822 | 177 purple_account_set_check_mail(account, |
15817 | 178 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->newmail))); |
179 | |
180 /* Protocol options */ | |
181 if (prplinfo) | |
182 { | |
183 GList *iter, *entries; | |
184 | |
185 for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries; | |
186 iter && entries; iter = iter->next, entries = entries->next) | |
187 { | |
15822 | 188 PurpleAccountOption *option = iter->data; |
15817 | 189 GntWidget *entry = entries->data; |
15822 | 190 PurplePrefType type = purple_account_option_get_type(option); |
191 const char *setting = purple_account_option_get_setting(option); | |
15817 | 192 |
15822 | 193 if (type == PURPLE_PREF_STRING) |
15817 | 194 { |
195 const char *value = gnt_entry_get_text(GNT_ENTRY(entry)); | |
15822 | 196 purple_account_set_string(account, setting, value); |
15817 | 197 } |
15822 | 198 else if (type == PURPLE_PREF_INT) |
15817 | 199 { |
200 const char *str = gnt_entry_get_text(GNT_ENTRY(entry)); | |
201 int value = 0; | |
202 if (str) | |
203 value = atoi(str); | |
15822 | 204 purple_account_set_int(account, setting, value); |
15817 | 205 } |
15822 | 206 else if (type == PURPLE_PREF_BOOLEAN) |
15817 | 207 { |
208 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(entry)); | |
15822 | 209 purple_account_set_bool(account, setting, value); |
15817 | 210 } |
15822 | 211 else if (type == PURPLE_PREF_STRING_LIST) |
15817 | 212 { |
213 /* TODO: */ | |
214 } | |
215 else | |
216 { | |
217 g_assert_not_reached(); | |
218 } | |
219 } | |
220 } | |
221 | |
222 /* XXX: Proxy options */ | |
223 | |
224 gnt_widget_destroy(dialog->window); | |
225 } | |
226 | |
227 static void | |
228 update_user_splits(AccountEditDialog *dialog) | |
229 { | |
230 GntWidget *hbox; | |
15822 | 231 PurplePlugin *plugin; |
232 PurplePluginProtocolInfo *prplinfo; | |
15817 | 233 GList *iter, *entries; |
234 char *username = NULL; | |
235 | |
236 if (dialog->splits) | |
237 { | |
238 gnt_box_remove_all(GNT_BOX(dialog->splits)); | |
239 g_list_free(dialog->split_entries); | |
240 } | |
241 else | |
242 { | |
243 dialog->splits = gnt_vbox_new(FALSE); | |
244 gnt_box_set_pad(GNT_BOX(dialog->splits), 0); | |
245 gnt_box_set_fill(GNT_BOX(dialog->splits), TRUE); | |
246 } | |
247 | |
248 dialog->split_entries = NULL; | |
249 | |
250 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
251 if (!plugin) | |
252 return; | |
15822 | 253 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 254 |
15822 | 255 username = dialog->account ? g_strdup(purple_account_get_username(dialog->account)) : NULL; |
15817 | 256 |
257 for (iter = prplinfo->user_splits; iter; iter = iter->next) | |
258 { | |
15822 | 259 PurpleAccountUserSplit *split = iter->data; |
15817 | 260 GntWidget *entry; |
261 char *buf; | |
262 | |
263 hbox = gnt_hbox_new(TRUE); | |
264 gnt_box_add_widget(GNT_BOX(dialog->splits), hbox); | |
265 | |
15822 | 266 buf = g_strdup_printf("%s:", purple_account_user_split_get_text(split)); |
15817 | 267 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(buf)); |
268 | |
269 entry = gnt_entry_new(NULL); | |
270 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
271 | |
272 dialog->split_entries = g_list_append(dialog->split_entries, entry); | |
273 g_free(buf); | |
274 } | |
275 | |
276 for (iter = g_list_last(prplinfo->user_splits), entries = g_list_last(dialog->split_entries); | |
277 iter && entries; iter = iter->prev, entries = entries->prev) | |
278 { | |
279 GntWidget *entry = entries->data; | |
15822 | 280 PurpleAccountUserSplit *split = iter->data; |
15817 | 281 const char *value = NULL; |
282 char *s; | |
283 | |
284 if (dialog->account) | |
285 { | |
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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 |
15817 | 291 if (s != NULL) |
292 { | |
293 *s = '\0'; | |
294 s++; | |
295 value = s; | |
296 } | |
297 } | |
298 if (value == NULL) | |
15822 | 299 value = purple_account_user_split_get_default_value(split); |
15817 | 300 |
301 if (value != NULL) | |
302 gnt_entry_set_text(GNT_ENTRY(entry), value); | |
303 } | |
304 | |
305 if (username != NULL) | |
306 gnt_entry_set_text(GNT_ENTRY(dialog->screenname), username); | |
307 | |
308 g_free(username); | |
309 } | |
310 | |
311 static void | |
312 add_protocol_options(AccountEditDialog *dialog) | |
313 { | |
15822 | 314 PurplePlugin *plugin; |
315 PurplePluginProtocolInfo *prplinfo; | |
15817 | 316 GList *iter; |
317 GntWidget *vbox, *box; | |
15822 | 318 PurpleAccount *account; |
15817 | 319 |
320 if (dialog->prpls) | |
321 gnt_box_remove_all(GNT_BOX(dialog->prpls)); | |
322 else | |
323 { | |
324 dialog->prpls = vbox = gnt_vbox_new(FALSE); | |
325 gnt_box_set_pad(GNT_BOX(vbox), 0); | |
326 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); | |
327 gnt_box_set_fill(GNT_BOX(vbox), TRUE); | |
328 } | |
329 | |
330 if (dialog->prpl_entries) | |
331 { | |
332 g_list_free(dialog->prpl_entries); | |
333 dialog->prpl_entries = NULL; | |
334 } | |
335 | |
336 vbox = dialog->prpls; | |
337 | |
338 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
339 if (!plugin) | |
340 return; | |
341 | |
15822 | 342 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 343 |
344 account = dialog->account; | |
345 | |
346 for (iter = prplinfo->protocol_options; iter; iter = iter->next) | |
347 { | |
15822 | 348 PurpleAccountOption *option = iter->data; |
349 PurplePrefType type = purple_account_option_get_type(option); | |
15817 | 350 |
351 box = gnt_hbox_new(TRUE); | |
352 gnt_box_set_pad(GNT_BOX(box), 0); | |
353 gnt_box_add_widget(GNT_BOX(vbox), box); | |
354 | |
15822 | 355 if (type == PURPLE_PREF_BOOLEAN) |
15817 | 356 { |
15822 | 357 GntWidget *widget = gnt_check_box_new(purple_account_option_get_text(option)); |
15817 | 358 gnt_box_add_widget(GNT_BOX(box), widget); |
359 dialog->prpl_entries = g_list_append(dialog->prpl_entries, widget); | |
360 | |
361 if (account) | |
362 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15822 | 363 purple_account_get_bool(account, |
364 purple_account_option_get_setting(option), | |
365 purple_account_option_get_default_bool(option))); | |
15817 | 366 else |
367 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15822 | 368 purple_account_option_get_default_bool(option)); |
15817 | 369 } |
370 else | |
371 { | |
372 gnt_box_add_widget(GNT_BOX(box), | |
15822 | 373 gnt_label_new(purple_account_option_get_text(option))); |
15817 | 374 |
15822 | 375 if (type == PURPLE_PREF_STRING_LIST) |
15817 | 376 { |
377 /* TODO: Use a combobox */ | |
378 /* Don't forget to append the widget to prpl_entries */ | |
379 } | |
380 else | |
381 { | |
382 GntWidget *entry = gnt_entry_new(NULL); | |
383 gnt_box_add_widget(GNT_BOX(box), entry); | |
384 dialog->prpl_entries = g_list_append(dialog->prpl_entries, entry); | |
385 | |
15822 | 386 if (type == PURPLE_PREF_STRING) |
15817 | 387 { |
15822 | 388 const char *dv = purple_account_option_get_default_string(option); |
15817 | 389 |
390 if (account) | |
391 gnt_entry_set_text(GNT_ENTRY(entry), | |
15822 | 392 purple_account_get_string(account, |
393 purple_account_option_get_setting(option), dv)); | |
15817 | 394 else |
395 gnt_entry_set_text(GNT_ENTRY(entry), dv); | |
396 } | |
15822 | 397 else if (type == PURPLE_PREF_INT) |
15817 | 398 { |
399 char str[32]; | |
15822 | 400 int value = purple_account_option_get_default_int(option); |
15817 | 401 if (account) |
15822 | 402 value = purple_account_get_int(account, |
403 purple_account_option_get_setting(option), value); | |
15817 | 404 snprintf(str, sizeof(str), "%d", value); |
405 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); | |
406 gnt_entry_set_text(GNT_ENTRY(entry), str); | |
407 } | |
408 else | |
409 { | |
410 g_assert_not_reached(); | |
411 } | |
412 } | |
413 } | |
414 } | |
415 } | |
416 | |
417 static void | |
418 update_user_options(AccountEditDialog *dialog) | |
419 { | |
15822 | 420 PurplePlugin *plugin; |
421 PurplePluginProtocolInfo *prplinfo; | |
15817 | 422 |
423 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
424 if (!plugin) | |
425 return; | |
426 | |
15822 | 427 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15817 | 428 |
429 if (dialog->newmail == NULL) | |
430 dialog->newmail = gnt_check_box_new(_("New mail notifications")); | |
431 if (dialog->account) | |
432 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), | |
15822 | 433 purple_account_get_check_mail(dialog->account)); |
15817 | 434 if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK)) |
435 gnt_widget_set_visible(dialog->newmail, FALSE); | |
436 else | |
437 gnt_widget_set_visible(dialog->newmail, TRUE); | |
438 | |
439 if (dialog->remember == NULL) | |
440 dialog->remember = gnt_check_box_new(_("Remember password")); | |
441 if (dialog->account) | |
442 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->remember), | |
15822 | 443 purple_account_get_remember_password(dialog->account)); |
15817 | 444 } |
445 | |
446 static void | |
15822 | 447 prpl_changed_cb(GntWidget *combo, PurplePlugin *old, PurplePlugin *new, AccountEditDialog *dialog) |
15817 | 448 { |
449 update_user_splits(dialog); | |
450 add_protocol_options(dialog); | |
451 update_user_options(dialog); /* This may not be necessary here */ | |
452 gnt_box_readjust(GNT_BOX(dialog->window)); | |
453 gnt_widget_draw(dialog->window); | |
454 } | |
455 | |
456 static void | |
15822 | 457 edit_account(PurpleAccount *account) |
15817 | 458 { |
459 GntWidget *window, *hbox; | |
460 GntWidget *combo, *button, *entry; | |
461 GList *list, *iter; | |
462 AccountEditDialog *dialog; | |
463 | |
464 if (account) | |
465 { | |
466 GList *iter; | |
467 for (iter = accountdialogs; iter; iter = iter->next) | |
468 { | |
469 AccountEditDialog *dlg = iter->data; | |
470 if (dlg->account == account) | |
471 return; | |
472 } | |
473 } | |
474 | |
475 dialog = g_new0(AccountEditDialog, 1); | |
476 accountdialogs = g_list_prepend(accountdialogs, dialog); | |
477 | |
478 dialog->window = window = gnt_vbox_new(FALSE); | |
479 dialog->account = account; | |
480 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
481 gnt_box_set_title(GNT_BOX(window), account ? _("Modify Account") : _("New Account")); | |
482 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
483 gnt_box_set_pad(GNT_BOX(window), 0); | |
484 gnt_widget_set_name(window, "edit-account"); | |
485 gnt_box_set_fill(GNT_BOX(window), TRUE); | |
486 | |
487 hbox = gnt_hbox_new(TRUE); | |
488 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
489 gnt_box_add_widget(GNT_BOX(window), hbox); | |
490 | |
491 dialog->protocol = combo = gnt_combo_box_new(); | |
15822 | 492 list = purple_plugins_get_protocols(); |
15817 | 493 for (iter = list; iter; iter = iter->next) |
494 { | |
495 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), iter->data, | |
15822 | 496 ((PurplePlugin*)iter->data)->info->name); |
15817 | 497 } |
498 | |
499 if (account) | |
500 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), | |
15822 | 501 purple_plugins_find_with_id(purple_account_get_protocol_id(account))); |
15817 | 502 else |
503 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), list->data); | |
504 | |
505 g_signal_connect(G_OBJECT(combo), "selection-changed", G_CALLBACK(prpl_changed_cb), dialog); | |
506 | |
507 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Protocol:"))); | |
508 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
509 | |
510 hbox = gnt_hbox_new(TRUE); | |
511 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
512 gnt_box_add_widget(GNT_BOX(window), hbox); | |
513 | |
514 dialog->screenname = entry = gnt_entry_new(NULL); | |
515 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Screen name:"))); | |
516 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
517 | |
518 /* User splits */ | |
519 update_user_splits(dialog); | |
520 gnt_box_add_widget(GNT_BOX(window), dialog->splits); | |
521 | |
522 hbox = gnt_hbox_new(TRUE); | |
523 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
524 gnt_box_add_widget(GNT_BOX(window), hbox); | |
525 | |
526 dialog->password = entry = gnt_entry_new(NULL); | |
527 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); | |
528 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); | |
529 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
530 if (account) | |
15822 | 531 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_password(account)); |
15817 | 532 |
533 hbox = gnt_hbox_new(TRUE); | |
534 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
535 gnt_box_add_widget(GNT_BOX(window), hbox); | |
536 | |
537 dialog->alias = entry = gnt_entry_new(NULL); | |
538 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); | |
539 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
540 if (account) | |
15822 | 541 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_alias(account)); |
15817 | 542 |
543 /* User options */ | |
544 update_user_options(dialog); | |
545 gnt_box_add_widget(GNT_BOX(window), dialog->remember); | |
546 gnt_box_add_widget(GNT_BOX(window), dialog->newmail); | |
547 | |
548 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
549 | |
550 /* The advanced box */ | |
551 add_protocol_options(dialog); | |
552 gnt_box_add_widget(GNT_BOX(window), dialog->prpls); | |
553 | |
554 /* TODO: Add proxy options */ | |
555 | |
556 /* The button box */ | |
557 hbox = gnt_hbox_new(FALSE); | |
558 gnt_box_add_widget(GNT_BOX(window), hbox); | |
559 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
560 | |
561 button = gnt_button_new(_("Cancel")); | |
562 gnt_box_add_widget(GNT_BOX(hbox), button); | |
563 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); | |
564 | |
565 button = gnt_button_new(_("Save")); | |
566 gnt_box_add_widget(GNT_BOX(hbox), button); | |
567 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog); | |
568 | |
569 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(edit_dialog_destroy), dialog); | |
570 | |
571 gnt_widget_show(window); | |
572 gnt_box_readjust(GNT_BOX(window)); | |
573 gnt_widget_draw(window); | |
574 } | |
575 | |
576 static void | |
577 add_account_cb(GntWidget *widget, gpointer null) | |
578 { | |
579 edit_account(NULL); | |
580 } | |
581 | |
582 static void | |
583 modify_account_cb(GntWidget *widget, GntTree *tree) | |
584 { | |
15822 | 585 PurpleAccount *account = gnt_tree_get_selection_data(tree); |
15817 | 586 if (!account) |
587 return; | |
588 edit_account(account); | |
589 } | |
590 | |
591 static void | |
15822 | 592 really_delete_account(PurpleAccount *account) |
15817 | 593 { |
594 GList *iter; | |
595 for (iter = accountdialogs; iter; iter = iter->next) | |
596 { | |
597 AccountEditDialog *dlg = iter->data; | |
598 if (dlg->account == account) | |
599 { | |
600 gnt_widget_destroy(dlg->window); | |
601 break; | |
602 } | |
603 } | |
15822 | 604 purple_request_close_with_handle(account); /* Close any other opened delete window */ |
605 purple_accounts_delete(account); | |
15817 | 606 } |
607 | |
608 static void | |
609 delete_account_cb(GntWidget *widget, GntTree *tree) | |
610 { | |
15822 | 611 PurpleAccount *account; |
15817 | 612 char *prompt; |
613 | |
614 account = gnt_tree_get_selection_data(tree); | |
615 if (!account) | |
616 return; | |
617 | |
618 prompt = g_strdup_printf(_("Are you sure you want to delete %s?"), | |
15822 | 619 purple_account_get_username(account)); |
15817 | 620 |
16462
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
621 purple_request_action(account, _("Delete Account"), prompt, NULL, 0, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
622 account, NULL, NULL, account, 2, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
623 _("Delete"), really_delete_account, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16439
diff
changeset
|
624 _("Cancel"), NULL); |
15817 | 625 g_free(prompt); |
626 } | |
627 | |
628 static void | |
629 account_toggled(GntWidget *widget, void *key, gpointer null) | |
630 { | |
15822 | 631 PurpleAccount *account = key; |
15817 | 632 |
15822 | 633 purple_account_set_enabled(account, FINCH_UI, gnt_tree_get_choice(GNT_TREE(widget), key)); |
15817 | 634 } |
635 | |
636 static void | |
637 reset_accounts_win(GntWidget *widget, gpointer null) | |
638 { | |
639 accounts.window = NULL; | |
640 accounts.tree = NULL; | |
641 } | |
642 | |
643 void finch_accounts_show_all() | |
644 { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
645 GList *iter; |
15817 | 646 GntWidget *box, *button; |
647 | |
648 if (accounts.window) | |
649 return; | |
650 | |
651 accounts.window = gnt_vbox_new(FALSE); | |
652 gnt_box_set_toplevel(GNT_BOX(accounts.window), TRUE); | |
653 gnt_box_set_title(GNT_BOX(accounts.window), _("Accounts")); | |
654 gnt_box_set_pad(GNT_BOX(accounts.window), 0); | |
655 gnt_box_set_alignment(GNT_BOX(accounts.window), GNT_ALIGN_MID); | |
656 gnt_widget_set_name(accounts.window, "accounts"); | |
657 | |
658 gnt_box_add_widget(GNT_BOX(accounts.window), | |
659 gnt_label_new(_("You can enable/disable accounts from the following list."))); | |
660 | |
661 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
662 | |
663 accounts.tree = gnt_tree_new_with_columns(2); | |
664 GNT_WIDGET_SET_FLAGS(accounts.tree, GNT_WIDGET_NO_BORDER); | |
665 | |
15822 | 666 for (iter = purple_accounts_get_all(); iter; iter = iter->next) |
15817 | 667 { |
15822 | 668 PurpleAccount *account = iter->data; |
15817 | 669 account_add(account); |
670 } | |
671 | |
672 g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); | |
673 | |
674 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 0, 40); | |
675 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 1, 10); | |
676 gnt_box_add_widget(GNT_BOX(accounts.window), accounts.tree); | |
677 | |
678 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
679 | |
680 box = gnt_hbox_new(FALSE); | |
681 | |
682 button = gnt_button_new(_("Add")); | |
683 gnt_box_add_widget(GNT_BOX(box), button); | |
684 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account_cb), NULL); | |
685 | |
686 button = gnt_button_new(_("Modify")); | |
687 gnt_box_add_widget(GNT_BOX(box), button); | |
688 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(modify_account_cb), accounts.tree); | |
689 | |
690 button = gnt_button_new(_("Delete")); | |
691 gnt_box_add_widget(GNT_BOX(box), button); | |
692 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); | |
693 | |
694 gnt_box_add_widget(GNT_BOX(accounts.window), box); | |
695 | |
696 g_signal_connect(G_OBJECT(accounts.window), "destroy", G_CALLBACK(reset_accounts_win), NULL); | |
697 | |
698 gnt_widget_show(accounts.window); | |
699 } | |
700 | |
701 static gpointer | |
702 finch_accounts_get_handle() | |
703 { | |
704 static int handle; | |
705 | |
706 return &handle; | |
707 } | |
708 | |
709 static void | |
15822 | 710 account_added_callback(PurpleAccount *account) |
15817 | 711 { |
712 if (accounts.window == NULL) | |
713 return; | |
714 account_add(account); | |
715 gnt_widget_draw(accounts.tree); | |
716 } | |
717 | |
718 static void | |
15822 | 719 account_removed_callback(PurpleAccount *account) |
15817 | 720 { |
721 if (accounts.window == NULL) | |
722 return; | |
723 | |
724 gnt_tree_remove(GNT_TREE(accounts.tree), account); | |
725 } | |
726 | |
17346
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
727 static void |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
728 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
|
729 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
730 if (accounts.window == NULL) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
731 return; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
732 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
|
733 GPOINTER_TO_INT(user_data)); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
734 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
735 |
15817 | 736 void finch_accounts_init() |
737 { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
738 GList *iter; |
15817 | 739 |
15822 | 740 purple_signal_connect(purple_accounts_get_handle(), "account-added", |
741 finch_accounts_get_handle(), PURPLE_CALLBACK(account_added_callback), | |
15817 | 742 NULL); |
15822 | 743 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
744 finch_accounts_get_handle(), PURPLE_CALLBACK(account_removed_callback), | |
15817 | 745 NULL); |
17346
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
746 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
|
747 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
748 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
|
749 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
|
750 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
751 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
|
752 |
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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 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
|
758 } |
e2e709e5446b
If there's no account at startup, sohw the 'New Account' dialog too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17807
diff
changeset
|
759 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
|
760 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
|
761 } 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
|
762 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
|
763 finch_accounts_show_all(); |
15817 | 764 } |
765 } | |
766 | |
767 void finch_accounts_uninit() | |
768 { | |
769 if (accounts.window) | |
770 gnt_widget_destroy(accounts.window); | |
771 } | |
772 | |
773 /* The following uiops stuff are copied from gtkaccount.c */ | |
774 typedef struct | |
775 { | |
15822 | 776 PurpleAccount *account; |
15817 | 777 char *username; |
778 char *alias; | |
779 } AddUserData; | |
780 | |
781 static char * | |
15822 | 782 make_info(PurpleAccount *account, PurpleConnection *gc, const char *remote_user, |
15817 | 783 const char *id, const char *alias, const char *msg) |
784 { | |
785 if (msg != NULL && *msg == '\0') | |
786 msg = NULL; | |
787 | |
788 return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s"), | |
789 remote_user, | |
790 (alias != NULL ? " (" : ""), | |
791 (alias != NULL ? alias : ""), | |
792 (alias != NULL ? ")" : ""), | |
793 (id != NULL | |
794 ? id | |
15822 | 795 : (purple_connection_get_display_name(gc) != NULL |
796 ? purple_connection_get_display_name(gc) | |
797 : purple_account_get_username(account))), | |
15817 | 798 (msg != NULL ? ": " : "."), |
799 (msg != NULL ? msg : "")); | |
800 } | |
801 | |
802 static void | |
15822 | 803 notify_added(PurpleAccount *account, const char *remote_user, |
15817 | 804 const char *id, const char *alias, |
805 const char *msg) | |
806 { | |
807 char *buffer; | |
15822 | 808 PurpleConnection *gc; |
15817 | 809 |
15822 | 810 gc = purple_account_get_connection(account); |
15817 | 811 |
812 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
813 | |
15822 | 814 purple_notify_info(NULL, NULL, buffer, NULL); |
15817 | 815 |
816 g_free(buffer); | |
817 } | |
818 | |
819 static void | |
820 free_add_user_data(AddUserData *data) | |
821 { | |
822 g_free(data->username); | |
823 | |
824 if (data->alias != NULL) | |
825 g_free(data->alias); | |
826 | |
827 g_free(data); | |
828 } | |
829 | |
830 static void | |
831 add_user_cb(AddUserData *data) | |
832 { | |
15822 | 833 PurpleConnection *gc = purple_account_get_connection(data->account); |
15817 | 834 |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
835 if (g_list_find(purple_connections_get_all(), gc)) |
15817 | 836 { |
15822 | 837 purple_blist_request_add_buddy(data->account, data->username, |
15817 | 838 NULL, data->alias); |
839 } | |
840 | |
841 free_add_user_data(data); | |
842 } | |
843 | |
844 static void | |
15822 | 845 request_add(PurpleAccount *account, const char *remote_user, |
15817 | 846 const char *id, const char *alias, |
847 const char *msg) | |
848 { | |
849 char *buffer; | |
15822 | 850 PurpleConnection *gc; |
15817 | 851 AddUserData *data; |
852 | |
15822 | 853 gc = purple_account_get_connection(account); |
15817 | 854 |
855 data = g_new0(AddUserData, 1); | |
856 data->account = account; | |
857 data->username = g_strdup(remote_user); | |
858 data->alias = (alias != NULL ? g_strdup(alias) : NULL); | |
859 | |
860 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
15822 | 861 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
|
862 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
|
863 account, remote_user, NULL, |
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
|
864 data, 2, |
15817 | 865 _("Add"), G_CALLBACK(add_user_cb), |
866 _("Cancel"), G_CALLBACK(free_add_user_data)); | |
867 g_free(buffer); | |
868 } | |
869 | |
870 /* Copied from gtkaccount.c */ | |
871 typedef struct { | |
15822 | 872 PurpleAccountRequestAuthorizationCb auth_cb; |
873 PurpleAccountRequestAuthorizationCb deny_cb; | |
15817 | 874 void *data; |
875 char *username; | |
876 char *alias; | |
15822 | 877 PurpleAccount *account; |
15817 | 878 } auth_and_add; |
879 | |
880 static void | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
881 free_auth_and_add(auth_and_add *aa) |
15817 | 882 { |
883 g_free(aa->username); | |
884 g_free(aa->alias); | |
885 g_free(aa); | |
886 } | |
887 | |
888 static void | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
889 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
|
890 { |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
891 aa->auth_cb(aa->data); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
892 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
|
893 NULL, aa->alias); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
894 } |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
895 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
896 static void |
15817 | 897 deny_no_add_cb(auth_and_add *aa) |
898 { | |
899 aa->deny_cb(aa->data); | |
900 } | |
901 | |
902 static void * | |
15822 | 903 finch_request_authorize(PurpleAccount *account, const char *remote_user, |
15817 | 904 const char *id, const char *alias, const char *message, gboolean on_list, |
905 GCallback auth_cb, GCallback deny_cb, void *user_data) | |
906 { | |
907 char *buffer; | |
15822 | 908 PurpleConnection *gc; |
15817 | 909 void *uihandle; |
910 | |
15822 | 911 gc = purple_account_get_connection(account); |
15817 | 912 if (message != NULL && *message == '\0') |
913 message = NULL; | |
914 | |
915 buffer = g_strdup_printf(_("%s%s%s%s wants to add %s to his or her buddy list%s%s"), | |
916 remote_user, | |
917 (alias != NULL ? " (" : ""), | |
918 (alias != NULL ? alias : ""), | |
919 (alias != NULL ? ")" : ""), | |
920 (id != NULL | |
921 ? id | |
15822 | 922 : (purple_connection_get_display_name(gc) != NULL |
923 ? purple_connection_get_display_name(gc) | |
924 : purple_account_get_username(account))), | |
15817 | 925 (message != NULL ? ": " : "."), |
926 (message != NULL ? message : "")); | |
927 if (!on_list) { | |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
928 GntWidget *widget; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
929 GList *iter; |
15817 | 930 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
|
931 |
15822 | 932 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; |
933 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; | |
15817 | 934 aa->data = user_data; |
935 aa->username = g_strdup(remote_user); | |
936 aa->alias = g_strdup(alias); | |
937 aa->account = account; | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
938 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
939 uihandle = gnt_vwindow_new(FALSE); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
940 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
|
941 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
|
942 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
943 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
|
944 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
|
945 account, remote_user, NULL, |
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
|
946 aa, 2, |
15817 | 947 _("Authorize"), authorize_and_add_cb, |
948 _("Deny"), deny_no_add_cb); | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
949 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
950 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
|
951 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
|
952 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
953 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
|
954 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
955 widget = finch_retrieve_user_info(account->gc, remote_user); |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
956 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
|
957 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
|
958 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
|
959 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
|
960 break; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
961 } |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
962 } |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
963 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
|
964 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
965 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
|
966 gnt_widget_show(uihandle); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
967 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
968 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa); |
15817 | 969 } else { |
15822 | 970 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
|
971 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
|
972 account, remote_user, NULL, |
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
|
973 user_data, 2, |
15817 | 974 _("Authorize"), auth_cb, |
975 _("Deny"), deny_cb); | |
976 } | |
977 g_free(buffer); | |
978 return uihandle; | |
979 } | |
980 | |
981 static void | |
982 finch_request_close(void *uihandle) | |
983 { | |
15822 | 984 purple_request_close(PURPLE_REQUEST_ACTION, uihandle); |
15817 | 985 } |
986 | |
15822 | 987 static PurpleAccountUiOps ui_ops = |
15817 | 988 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
989 notify_added, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
990 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
991 request_add, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
992 finch_request_authorize, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
993 finch_request_close, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
994 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
995 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
996 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16462
diff
changeset
|
997 NULL |
15817 | 998 }; |
999 | |
15822 | 1000 PurpleAccountUiOps *finch_accounts_get_ui_ops() |
15817 | 1001 { |
1002 return &ui_ops; | |
1003 } | |
1004 |