Mercurial > pidgin.yaz
annotate finch/gntaccount.c @ 18046:58e28ccf08e6
merge of '9d95292d55daedb7f74c7df323ad2c69d347d384'
and 'fc5f9423f83f31e42ce80066eec30cdbbae7be01'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 05 Jun 2007 01:38:09 +0000 |
parents | e2e709e5446b e3e42a99070e |
children | 4ca97b26a8fb |
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 { | |
18037
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17419
diff
changeset
|
285 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:
17419
diff
changeset
|
286 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:
17419
diff
changeset
|
287 else |
e3e42a99070e
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
17419
diff
changeset
|
288 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:
17419
diff
changeset
|
289 |
15818 | 290 if (s != NULL) |
291 { | |
292 *s = '\0'; | |
293 s++; | |
294 value = s; | |
295 } | |
296 } | |
297 if (value == NULL) | |
15823 | 298 value = purple_account_user_split_get_default_value(split); |
15818 | 299 |
300 if (value != NULL) | |
301 gnt_entry_set_text(GNT_ENTRY(entry), value); | |
302 } | |
303 | |
304 if (username != NULL) | |
305 gnt_entry_set_text(GNT_ENTRY(dialog->screenname), username); | |
306 | |
307 g_free(username); | |
308 } | |
309 | |
310 static void | |
311 add_protocol_options(AccountEditDialog *dialog) | |
312 { | |
15823 | 313 PurplePlugin *plugin; |
314 PurplePluginProtocolInfo *prplinfo; | |
15818 | 315 GList *iter; |
316 GntWidget *vbox, *box; | |
15823 | 317 PurpleAccount *account; |
15818 | 318 |
319 if (dialog->prpls) | |
320 gnt_box_remove_all(GNT_BOX(dialog->prpls)); | |
321 else | |
322 { | |
323 dialog->prpls = vbox = gnt_vbox_new(FALSE); | |
324 gnt_box_set_pad(GNT_BOX(vbox), 0); | |
325 gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); | |
326 gnt_box_set_fill(GNT_BOX(vbox), TRUE); | |
327 } | |
328 | |
329 if (dialog->prpl_entries) | |
330 { | |
331 g_list_free(dialog->prpl_entries); | |
332 dialog->prpl_entries = NULL; | |
333 } | |
334 | |
335 vbox = dialog->prpls; | |
336 | |
337 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
338 if (!plugin) | |
339 return; | |
340 | |
15823 | 341 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15818 | 342 |
343 account = dialog->account; | |
344 | |
345 for (iter = prplinfo->protocol_options; iter; iter = iter->next) | |
346 { | |
15823 | 347 PurpleAccountOption *option = iter->data; |
348 PurplePrefType type = purple_account_option_get_type(option); | |
15818 | 349 |
350 box = gnt_hbox_new(TRUE); | |
351 gnt_box_set_pad(GNT_BOX(box), 0); | |
352 gnt_box_add_widget(GNT_BOX(vbox), box); | |
353 | |
15823 | 354 if (type == PURPLE_PREF_BOOLEAN) |
15818 | 355 { |
15823 | 356 GntWidget *widget = gnt_check_box_new(purple_account_option_get_text(option)); |
15818 | 357 gnt_box_add_widget(GNT_BOX(box), widget); |
358 dialog->prpl_entries = g_list_append(dialog->prpl_entries, widget); | |
359 | |
360 if (account) | |
361 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15823 | 362 purple_account_get_bool(account, |
363 purple_account_option_get_setting(option), | |
364 purple_account_option_get_default_bool(option))); | |
15818 | 365 else |
366 gnt_check_box_set_checked(GNT_CHECK_BOX(widget), | |
15823 | 367 purple_account_option_get_default_bool(option)); |
15818 | 368 } |
369 else | |
370 { | |
371 gnt_box_add_widget(GNT_BOX(box), | |
15823 | 372 gnt_label_new(purple_account_option_get_text(option))); |
15818 | 373 |
15823 | 374 if (type == PURPLE_PREF_STRING_LIST) |
15818 | 375 { |
376 /* TODO: Use a combobox */ | |
377 /* Don't forget to append the widget to prpl_entries */ | |
378 } | |
379 else | |
380 { | |
381 GntWidget *entry = gnt_entry_new(NULL); | |
382 gnt_box_add_widget(GNT_BOX(box), entry); | |
383 dialog->prpl_entries = g_list_append(dialog->prpl_entries, entry); | |
384 | |
15823 | 385 if (type == PURPLE_PREF_STRING) |
15818 | 386 { |
15823 | 387 const char *dv = purple_account_option_get_default_string(option); |
15818 | 388 |
389 if (account) | |
390 gnt_entry_set_text(GNT_ENTRY(entry), | |
15823 | 391 purple_account_get_string(account, |
392 purple_account_option_get_setting(option), dv)); | |
15818 | 393 else |
394 gnt_entry_set_text(GNT_ENTRY(entry), dv); | |
395 } | |
15823 | 396 else if (type == PURPLE_PREF_INT) |
15818 | 397 { |
398 char str[32]; | |
15823 | 399 int value = purple_account_option_get_default_int(option); |
15818 | 400 if (account) |
15823 | 401 value = purple_account_get_int(account, |
402 purple_account_option_get_setting(option), value); | |
15818 | 403 snprintf(str, sizeof(str), "%d", value); |
404 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); | |
405 gnt_entry_set_text(GNT_ENTRY(entry), str); | |
406 } | |
407 else | |
408 { | |
409 g_assert_not_reached(); | |
410 } | |
411 } | |
412 } | |
413 } | |
414 } | |
415 | |
416 static void | |
417 update_user_options(AccountEditDialog *dialog) | |
418 { | |
15823 | 419 PurplePlugin *plugin; |
420 PurplePluginProtocolInfo *prplinfo; | |
15818 | 421 |
422 plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); | |
423 if (!plugin) | |
424 return; | |
425 | |
15823 | 426 prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15818 | 427 |
428 if (dialog->newmail == NULL) | |
429 dialog->newmail = gnt_check_box_new(_("New mail notifications")); | |
430 if (dialog->account) | |
431 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), | |
15823 | 432 purple_account_get_check_mail(dialog->account)); |
15818 | 433 if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK)) |
434 gnt_widget_set_visible(dialog->newmail, FALSE); | |
435 else | |
436 gnt_widget_set_visible(dialog->newmail, TRUE); | |
437 | |
438 if (dialog->remember == NULL) | |
439 dialog->remember = gnt_check_box_new(_("Remember password")); | |
440 if (dialog->account) | |
441 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->remember), | |
15823 | 442 purple_account_get_remember_password(dialog->account)); |
15818 | 443 } |
444 | |
445 static void | |
15823 | 446 prpl_changed_cb(GntWidget *combo, PurplePlugin *old, PurplePlugin *new, AccountEditDialog *dialog) |
15818 | 447 { |
448 update_user_splits(dialog); | |
449 add_protocol_options(dialog); | |
450 update_user_options(dialog); /* This may not be necessary here */ | |
451 gnt_box_readjust(GNT_BOX(dialog->window)); | |
452 gnt_widget_draw(dialog->window); | |
453 } | |
454 | |
455 static void | |
15823 | 456 edit_account(PurpleAccount *account) |
15818 | 457 { |
458 GntWidget *window, *hbox; | |
459 GntWidget *combo, *button, *entry; | |
460 GList *list, *iter; | |
461 AccountEditDialog *dialog; | |
462 | |
463 if (account) | |
464 { | |
465 GList *iter; | |
466 for (iter = accountdialogs; iter; iter = iter->next) | |
467 { | |
468 AccountEditDialog *dlg = iter->data; | |
469 if (dlg->account == account) | |
470 return; | |
471 } | |
472 } | |
473 | |
474 dialog = g_new0(AccountEditDialog, 1); | |
475 accountdialogs = g_list_prepend(accountdialogs, dialog); | |
476 | |
477 dialog->window = window = gnt_vbox_new(FALSE); | |
478 dialog->account = account; | |
479 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
480 gnt_box_set_title(GNT_BOX(window), account ? _("Modify Account") : _("New Account")); | |
481 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
482 gnt_box_set_pad(GNT_BOX(window), 0); | |
483 gnt_widget_set_name(window, "edit-account"); | |
484 gnt_box_set_fill(GNT_BOX(window), TRUE); | |
485 | |
486 hbox = gnt_hbox_new(TRUE); | |
487 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
488 gnt_box_add_widget(GNT_BOX(window), hbox); | |
489 | |
490 dialog->protocol = combo = gnt_combo_box_new(); | |
15823 | 491 list = purple_plugins_get_protocols(); |
15818 | 492 for (iter = list; iter; iter = iter->next) |
493 { | |
494 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), iter->data, | |
15823 | 495 ((PurplePlugin*)iter->data)->info->name); |
15818 | 496 } |
497 | |
498 if (account) | |
499 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), | |
15823 | 500 purple_plugins_find_with_id(purple_account_get_protocol_id(account))); |
15818 | 501 else |
502 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), list->data); | |
503 | |
504 g_signal_connect(G_OBJECT(combo), "selection-changed", G_CALLBACK(prpl_changed_cb), dialog); | |
505 | |
506 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Protocol:"))); | |
507 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
508 | |
509 hbox = gnt_hbox_new(TRUE); | |
510 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
511 gnt_box_add_widget(GNT_BOX(window), hbox); | |
512 | |
513 dialog->screenname = entry = gnt_entry_new(NULL); | |
514 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Screen name:"))); | |
515 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
516 | |
517 /* User splits */ | |
518 update_user_splits(dialog); | |
519 gnt_box_add_widget(GNT_BOX(window), dialog->splits); | |
520 | |
521 hbox = gnt_hbox_new(TRUE); | |
522 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
523 gnt_box_add_widget(GNT_BOX(window), hbox); | |
524 | |
525 dialog->password = entry = gnt_entry_new(NULL); | |
526 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); | |
527 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); | |
528 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
529 if (account) | |
15823 | 530 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_password(account)); |
15818 | 531 |
532 hbox = gnt_hbox_new(TRUE); | |
533 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
534 gnt_box_add_widget(GNT_BOX(window), hbox); | |
535 | |
536 dialog->alias = entry = gnt_entry_new(NULL); | |
537 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); | |
538 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
539 if (account) | |
15823 | 540 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_alias(account)); |
15818 | 541 |
542 /* User options */ | |
543 update_user_options(dialog); | |
544 gnt_box_add_widget(GNT_BOX(window), dialog->remember); | |
545 gnt_box_add_widget(GNT_BOX(window), dialog->newmail); | |
546 | |
547 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
548 | |
549 /* The advanced box */ | |
550 add_protocol_options(dialog); | |
551 gnt_box_add_widget(GNT_BOX(window), dialog->prpls); | |
552 | |
553 /* TODO: Add proxy options */ | |
554 | |
555 /* The button box */ | |
556 hbox = gnt_hbox_new(FALSE); | |
557 gnt_box_add_widget(GNT_BOX(window), hbox); | |
558 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
559 | |
560 button = gnt_button_new(_("Cancel")); | |
561 gnt_box_add_widget(GNT_BOX(hbox), button); | |
562 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); | |
563 | |
564 button = gnt_button_new(_("Save")); | |
565 gnt_box_add_widget(GNT_BOX(hbox), button); | |
566 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(save_account_cb), dialog); | |
567 | |
568 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(edit_dialog_destroy), dialog); | |
569 | |
570 gnt_widget_show(window); | |
571 gnt_box_readjust(GNT_BOX(window)); | |
572 gnt_widget_draw(window); | |
573 } | |
574 | |
575 static void | |
576 add_account_cb(GntWidget *widget, gpointer null) | |
577 { | |
578 edit_account(NULL); | |
579 } | |
580 | |
581 static void | |
582 modify_account_cb(GntWidget *widget, GntTree *tree) | |
583 { | |
15823 | 584 PurpleAccount *account = gnt_tree_get_selection_data(tree); |
15818 | 585 if (!account) |
586 return; | |
587 edit_account(account); | |
588 } | |
589 | |
590 static void | |
15823 | 591 really_delete_account(PurpleAccount *account) |
15818 | 592 { |
593 GList *iter; | |
594 for (iter = accountdialogs; iter; iter = iter->next) | |
595 { | |
596 AccountEditDialog *dlg = iter->data; | |
597 if (dlg->account == account) | |
598 { | |
599 gnt_widget_destroy(dlg->window); | |
600 break; | |
601 } | |
602 } | |
15823 | 603 purple_request_close_with_handle(account); /* Close any other opened delete window */ |
604 purple_accounts_delete(account); | |
15818 | 605 } |
606 | |
607 static void | |
608 delete_account_cb(GntWidget *widget, GntTree *tree) | |
609 { | |
15823 | 610 PurpleAccount *account; |
15818 | 611 char *prompt; |
612 | |
613 account = gnt_tree_get_selection_data(tree); | |
614 if (!account) | |
615 return; | |
616 | |
617 prompt = g_strdup_printf(_("Are you sure you want to delete %s?"), | |
15823 | 618 purple_account_get_username(account)); |
15818 | 619 |
16465
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16442
diff
changeset
|
620 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
|
621 account, NULL, NULL, account, 2, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16442
diff
changeset
|
622 _("Delete"), really_delete_account, |
4b6d81d26b56
Fix a warning introduced with the request api changes.
Gary Kramlich <grim@reaperworld.com>
parents:
16442
diff
changeset
|
623 _("Cancel"), NULL); |
15818 | 624 g_free(prompt); |
625 } | |
626 | |
627 static void | |
628 account_toggled(GntWidget *widget, void *key, gpointer null) | |
629 { | |
15823 | 630 PurpleAccount *account = key; |
15818 | 631 |
15823 | 632 purple_account_set_enabled(account, FINCH_UI, gnt_tree_get_choice(GNT_TREE(widget), key)); |
15818 | 633 } |
634 | |
635 static void | |
636 reset_accounts_win(GntWidget *widget, gpointer null) | |
637 { | |
638 accounts.window = NULL; | |
639 accounts.tree = NULL; | |
640 } | |
641 | |
642 void finch_accounts_show_all() | |
643 { | |
644 GList *iter; | |
645 GntWidget *box, *button; | |
646 | |
647 if (accounts.window) | |
648 return; | |
649 | |
650 accounts.window = gnt_vbox_new(FALSE); | |
651 gnt_box_set_toplevel(GNT_BOX(accounts.window), TRUE); | |
652 gnt_box_set_title(GNT_BOX(accounts.window), _("Accounts")); | |
653 gnt_box_set_pad(GNT_BOX(accounts.window), 0); | |
654 gnt_box_set_alignment(GNT_BOX(accounts.window), GNT_ALIGN_MID); | |
655 gnt_widget_set_name(accounts.window, "accounts"); | |
656 | |
657 gnt_box_add_widget(GNT_BOX(accounts.window), | |
658 gnt_label_new(_("You can enable/disable accounts from the following list."))); | |
659 | |
660 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
661 | |
662 accounts.tree = gnt_tree_new_with_columns(2); | |
663 GNT_WIDGET_SET_FLAGS(accounts.tree, GNT_WIDGET_NO_BORDER); | |
664 | |
15823 | 665 for (iter = purple_accounts_get_all(); iter; iter = iter->next) |
15818 | 666 { |
15823 | 667 PurpleAccount *account = iter->data; |
15818 | 668 account_add(account); |
669 } | |
670 | |
671 g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); | |
672 | |
673 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 0, 40); | |
674 gnt_tree_set_col_width(GNT_TREE(accounts.tree), 1, 10); | |
675 gnt_box_add_widget(GNT_BOX(accounts.window), accounts.tree); | |
676 | |
677 gnt_box_add_widget(GNT_BOX(accounts.window), gnt_line_new(FALSE)); | |
678 | |
679 box = gnt_hbox_new(FALSE); | |
680 | |
681 button = gnt_button_new(_("Add")); | |
682 gnt_box_add_widget(GNT_BOX(box), button); | |
683 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account_cb), NULL); | |
684 | |
685 button = gnt_button_new(_("Modify")); | |
686 gnt_box_add_widget(GNT_BOX(box), button); | |
687 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(modify_account_cb), accounts.tree); | |
688 | |
689 button = gnt_button_new(_("Delete")); | |
690 gnt_box_add_widget(GNT_BOX(box), button); | |
691 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); | |
692 | |
693 gnt_box_add_widget(GNT_BOX(accounts.window), box); | |
694 | |
695 g_signal_connect(G_OBJECT(accounts.window), "destroy", G_CALLBACK(reset_accounts_win), NULL); | |
696 | |
697 gnt_widget_show(accounts.window); | |
698 } | |
699 | |
700 static gpointer | |
701 finch_accounts_get_handle() | |
702 { | |
703 static int handle; | |
704 | |
705 return &handle; | |
706 } | |
707 | |
708 static void | |
15823 | 709 account_added_callback(PurpleAccount *account) |
15818 | 710 { |
711 if (accounts.window == NULL) | |
712 return; | |
713 account_add(account); | |
714 gnt_widget_draw(accounts.tree); | |
715 } | |
716 | |
717 static void | |
15823 | 718 account_removed_callback(PurpleAccount *account) |
15818 | 719 { |
720 if (accounts.window == NULL) | |
721 return; | |
722 | |
723 gnt_tree_remove(GNT_TREE(accounts.tree), account); | |
724 } | |
725 | |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
726 static void |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
727 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
|
728 { |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
729 if (accounts.window == NULL) |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
730 return; |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
731 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
|
732 GPOINTER_TO_INT(user_data)); |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
733 } |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
734 |
15818 | 735 void finch_accounts_init() |
736 { | |
737 GList *iter; | |
738 | |
15823 | 739 purple_signal_connect(purple_accounts_get_handle(), "account-added", |
740 finch_accounts_get_handle(), PURPLE_CALLBACK(account_added_callback), | |
15818 | 741 NULL); |
15823 | 742 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
743 finch_accounts_get_handle(), PURPLE_CALLBACK(account_removed_callback), | |
15818 | 744 NULL); |
17419
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
745 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
|
746 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
747 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
|
748 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
|
749 finch_accounts_get_handle(), |
8c3a3407af58
Finch autoreconnecting (largely copy/paste from pidgin)
Richard Nelson <wabz@pidgin.im>
parents:
17104
diff
changeset
|
750 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
|
751 |
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
|
752 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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 } |
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 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
|
759 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
|
760 } 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
|
761 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
|
762 finch_accounts_show_all(); |
15818 | 763 } |
764 } | |
765 | |
766 void finch_accounts_uninit() | |
767 { | |
768 if (accounts.window) | |
769 gnt_widget_destroy(accounts.window); | |
770 } | |
771 | |
772 /* The following uiops stuff are copied from gtkaccount.c */ | |
773 typedef struct | |
774 { | |
15823 | 775 PurpleAccount *account; |
15818 | 776 char *username; |
777 char *alias; | |
778 } AddUserData; | |
779 | |
780 static char * | |
15823 | 781 make_info(PurpleAccount *account, PurpleConnection *gc, const char *remote_user, |
15818 | 782 const char *id, const char *alias, const char *msg) |
783 { | |
784 if (msg != NULL && *msg == '\0') | |
785 msg = NULL; | |
786 | |
787 return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s"), | |
788 remote_user, | |
789 (alias != NULL ? " (" : ""), | |
790 (alias != NULL ? alias : ""), | |
791 (alias != NULL ? ")" : ""), | |
792 (id != NULL | |
793 ? id | |
15823 | 794 : (purple_connection_get_display_name(gc) != NULL |
795 ? purple_connection_get_display_name(gc) | |
796 : purple_account_get_username(account))), | |
15818 | 797 (msg != NULL ? ": " : "."), |
798 (msg != NULL ? msg : "")); | |
799 } | |
800 | |
801 static void | |
15823 | 802 notify_added(PurpleAccount *account, const char *remote_user, |
15818 | 803 const char *id, const char *alias, |
804 const char *msg) | |
805 { | |
806 char *buffer; | |
15823 | 807 PurpleConnection *gc; |
15818 | 808 |
15823 | 809 gc = purple_account_get_connection(account); |
15818 | 810 |
811 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
812 | |
15823 | 813 purple_notify_info(NULL, NULL, buffer, NULL); |
15818 | 814 |
815 g_free(buffer); | |
816 } | |
817 | |
818 static void | |
819 free_add_user_data(AddUserData *data) | |
820 { | |
821 g_free(data->username); | |
822 | |
823 if (data->alias != NULL) | |
824 g_free(data->alias); | |
825 | |
826 g_free(data); | |
827 } | |
828 | |
829 static void | |
830 add_user_cb(AddUserData *data) | |
831 { | |
15823 | 832 PurpleConnection *gc = purple_account_get_connection(data->account); |
15818 | 833 |
15823 | 834 if (g_list_find(purple_connections_get_all(), gc)) |
15818 | 835 { |
15823 | 836 purple_blist_request_add_buddy(data->account, data->username, |
15818 | 837 NULL, data->alias); |
838 } | |
839 | |
840 free_add_user_data(data); | |
841 } | |
842 | |
843 static void | |
15823 | 844 request_add(PurpleAccount *account, const char *remote_user, |
15818 | 845 const char *id, const char *alias, |
846 const char *msg) | |
847 { | |
848 char *buffer; | |
15823 | 849 PurpleConnection *gc; |
15818 | 850 AddUserData *data; |
851 | |
15823 | 852 gc = purple_account_get_connection(account); |
15818 | 853 |
854 data = g_new0(AddUserData, 1); | |
855 data->account = account; | |
856 data->username = g_strdup(remote_user); | |
857 data->alias = (alias != NULL ? g_strdup(alias) : NULL); | |
858 | |
859 buffer = make_info(account, gc, remote_user, id, alias, msg); | |
15823 | 860 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
|
861 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
|
862 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
|
863 data, 2, |
15818 | 864 _("Add"), G_CALLBACK(add_user_cb), |
865 _("Cancel"), G_CALLBACK(free_add_user_data)); | |
866 g_free(buffer); | |
867 } | |
868 | |
869 /* Copied from gtkaccount.c */ | |
870 typedef struct { | |
15823 | 871 PurpleAccountRequestAuthorizationCb auth_cb; |
872 PurpleAccountRequestAuthorizationCb deny_cb; | |
15818 | 873 void *data; |
874 char *username; | |
875 char *alias; | |
15823 | 876 PurpleAccount *account; |
15818 | 877 } auth_and_add; |
878 | |
879 static void | |
17520
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
880 free_auth_and_add(auth_and_add *aa) |
15818 | 881 { |
882 g_free(aa->username); | |
883 g_free(aa->alias); | |
884 g_free(aa); | |
885 } | |
886 | |
887 static void | |
17520
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
888 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
|
889 { |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
890 aa->auth_cb(aa->data); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
891 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
|
892 NULL, aa->alias); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
893 } |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
894 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
895 static void |
15818 | 896 deny_no_add_cb(auth_and_add *aa) |
897 { | |
898 aa->deny_cb(aa->data); | |
899 } | |
900 | |
901 static void * | |
15823 | 902 finch_request_authorize(PurpleAccount *account, const char *remote_user, |
15818 | 903 const char *id, const char *alias, const char *message, gboolean on_list, |
904 GCallback auth_cb, GCallback deny_cb, void *user_data) | |
905 { | |
906 char *buffer; | |
15823 | 907 PurpleConnection *gc; |
15818 | 908 void *uihandle; |
909 | |
15823 | 910 gc = purple_account_get_connection(account); |
15818 | 911 if (message != NULL && *message == '\0') |
912 message = NULL; | |
913 | |
914 buffer = g_strdup_printf(_("%s%s%s%s wants to add %s to his or her buddy list%s%s"), | |
915 remote_user, | |
916 (alias != NULL ? " (" : ""), | |
917 (alias != NULL ? alias : ""), | |
918 (alias != NULL ? ")" : ""), | |
919 (id != NULL | |
920 ? id | |
15823 | 921 : (purple_connection_get_display_name(gc) != NULL |
922 ? purple_connection_get_display_name(gc) | |
923 : purple_account_get_username(account))), | |
15818 | 924 (message != NULL ? ": " : "."), |
925 (message != NULL ? message : "")); | |
926 if (!on_list) { | |
17521
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17520
diff
changeset
|
927 GntWidget *widget; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17520
diff
changeset
|
928 GList *iter; |
15818 | 929 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
|
930 |
15823 | 931 aa->auth_cb = (PurpleAccountRequestAuthorizationCb)auth_cb; |
932 aa->deny_cb = (PurpleAccountRequestAuthorizationCb)deny_cb; | |
15818 | 933 aa->data = user_data; |
934 aa->username = g_strdup(remote_user); | |
935 aa->alias = g_strdup(alias); | |
936 aa->account = account; | |
17520
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 uihandle = gnt_vwindow_new(FALSE); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
939 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
|
940 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
|
941 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
942 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
|
943 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
|
944 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
|
945 aa, 2, |
15818 | 946 _("Authorize"), authorize_and_add_cb, |
947 _("Deny"), deny_no_add_cb); | |
17520
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
948 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
949 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
|
950 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
|
951 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
952 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
|
953 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
954 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
|
955 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
|
956 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
|
957 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
|
958 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
|
959 break; |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17520
diff
changeset
|
960 } |
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17520
diff
changeset
|
961 } |
17520
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
962 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
|
963 gnt_screen_release(widget); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
964 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
|
965 gnt_widget_show(uihandle); |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
966 |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
967 g_signal_connect_swapped(G_OBJECT(uihandle), "destroy", G_CALLBACK(free_auth_and_add), aa); |
15818 | 968 } else { |
15823 | 969 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
|
970 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
|
971 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
|
972 user_data, 2, |
15818 | 973 _("Authorize"), auth_cb, |
974 _("Deny"), deny_cb); | |
975 } | |
976 g_free(buffer); | |
977 return uihandle; | |
978 } | |
979 | |
980 static void | |
981 finch_request_close(void *uihandle) | |
982 { | |
15823 | 983 purple_request_close(PURPLE_REQUEST_ACTION, uihandle); |
15818 | 984 } |
985 | |
15823 | 986 static PurpleAccountUiOps ui_ops = |
15818 | 987 { |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
988 notify_added, |
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 request_add, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
991 finch_request_authorize, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
992 finch_request_close, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
993 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
994 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
995 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16465
diff
changeset
|
996 NULL |
15818 | 997 }; |
998 | |
15823 | 999 PurpleAccountUiOps *finch_accounts_get_ui_ops() |
15818 | 1000 { |
1001 return &ui_ops; | |
1002 } | |
1003 |