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