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