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