Mercurial > pidgin
annotate src/account.c @ 10749:3839df4f7074
[gaim-migrate @ 12351]
This fixes the auto-reconnect plugin bug. The whole "wants_to_die"
thing feels a little dirty. Eh, it's fine for now.
Also, the gtkstatusbox starts off in the "available" state instead
of using the GaimStatus of whatever account is online. This negates
the effect of saving the GaimStatuses for an account.
More tomorrow...
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 27 Mar 2005 05:17:18 +0000 |
parents | 279eee07dd42 |
children | 8a97b59f0071 |
rev | line source |
---|---|
5865
412c5a0f9ef1
[gaim-migrate @ 6296]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
1 /** |
5563 | 2 * @file account.c Account API |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
10 * |
5563 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5870
diff
changeset
|
25 #include "internal.h" |
5563 | 26 #include "account.h" |
5717 | 27 #include "debug.h" |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
28 #include "notify.h" |
8235 | 29 #include "pounce.h" |
5563 | 30 #include "prefs.h" |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
31 #include "prpl.h" |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
32 #include "request.h" |
9944 | 33 #include "server.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
34 #include "signals.h" |
9944 | 35 #include "status.h" |
5717 | 36 #include "util.h" |
10423 | 37 #include "xmlnode.h" |
5563 | 38 |
10429 | 39 /* TODO: Should use GaimValue instead of this? What about "ui"? */ |
5563 | 40 typedef struct |
41 { | |
42 GaimPrefType type; | |
43 | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
44 char *ui; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
45 |
5563 | 46 union |
47 { | |
48 int integer; | |
49 char *string; | |
50 gboolean bool; | |
51 | |
52 } value; | |
53 | |
54 } GaimAccountSetting; | |
55 | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
56 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
57 static GaimAccountUiOps *account_ui_ops = NULL; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
58 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
59 static GList *accounts = NULL; |
10428 | 60 static guint save_timer = 0; |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
61 static gboolean accounts_loaded = FALSE; |
5563 | 62 |
10427 | 63 |
10428 | 64 /********************************************************************* |
10429 | 65 * Writing to disk * |
10428 | 66 *********************************************************************/ |
10427 | 67 |
68 static void | |
69 setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
70 { | |
71 const char *name; | |
72 GaimAccountSetting *setting; | |
73 xmlnode *node, *child; | |
74 char buf[20]; | |
75 | |
76 name = (const char *)key; | |
77 setting = (GaimAccountSetting *)value; | |
78 node = (xmlnode *)user_data; | |
79 | |
80 child = xmlnode_new_child(node, "setting"); | |
81 xmlnode_set_attrib(child, "name", name); | |
82 | |
83 if (setting->type == GAIM_PREF_INT) { | |
84 xmlnode_set_attrib(child, "type", "int"); | |
85 snprintf(buf, sizeof(buf), "%d", setting->value.integer); | |
86 xmlnode_insert_data(child, buf, -1); | |
87 } | |
88 else if (setting->type == GAIM_PREF_STRING && setting->value.string != NULL) { | |
89 xmlnode_set_attrib(child, "type", "string"); | |
90 xmlnode_insert_data(child, setting->value.string, -1); | |
91 } | |
92 else if (setting->type == GAIM_PREF_BOOLEAN) { | |
93 xmlnode_set_attrib(child, "type", "bool"); | |
94 snprintf(buf, sizeof(buf), "%d", setting->value.bool); | |
95 xmlnode_insert_data(child, buf, -1); | |
96 } | |
97 } | |
98 | |
99 static void | |
100 ui_setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
101 { | |
102 const char *ui; | |
103 GHashTable *table; | |
104 xmlnode *node, *child; | |
105 | |
106 ui = (const char *)key; | |
107 table = (GHashTable *)value; | |
108 node = (xmlnode *)user_data; | |
109 | |
110 if (g_hash_table_size(table) > 0) | |
111 { | |
112 child = xmlnode_new_child(node, "settings"); | |
113 xmlnode_set_attrib(child, "ui", ui); | |
114 g_hash_table_foreach(table, setting_to_xmlnode, child); | |
115 } | |
116 } | |
117 | |
118 static xmlnode * | |
10738 | 119 status_to_xmlnode(const GaimStatus *status) |
120 { | |
121 xmlnode *node; | |
122 | |
123 node = xmlnode_new("status"); | |
124 xmlnode_set_attrib(node, "type", gaim_status_get_id(status)); | |
125 if (gaim_status_get_name(status) != NULL) | |
126 xmlnode_set_attrib(node, "name", gaim_status_get_name(status)); | |
127 xmlnode_set_attrib(node, "active", gaim_status_is_active(status) ? "true" : "false"); | |
128 | |
129 /* QQQ: Need to save status->attr_values */ | |
130 | |
131 return node; | |
132 } | |
133 | |
134 static xmlnode * | |
135 statuses_to_xmlnode(const GaimPresence *presence) | |
136 { | |
137 xmlnode *node, *child; | |
138 const GList *statuses, *status; | |
139 | |
140 node = xmlnode_new("statuses"); | |
141 | |
142 statuses = gaim_presence_get_statuses(presence); | |
143 for (status = statuses; status != NULL; status = status->next) | |
144 { | |
145 child = status_to_xmlnode((GaimStatus *)status->data); | |
146 xmlnode_insert_child(node, child); | |
147 } | |
148 | |
149 return node; | |
150 } | |
151 | |
152 static xmlnode * | |
10427 | 153 proxy_settings_to_xmlnode(GaimProxyInfo *proxy_info) |
154 { | |
155 xmlnode *node, *child; | |
156 GaimProxyType proxy_type; | |
157 const char *value; | |
158 int int_value; | |
159 char buf[20]; | |
160 | |
161 proxy_type = gaim_proxy_info_get_type(proxy_info); | |
162 | |
163 node = xmlnode_new("proxy"); | |
164 | |
165 child = xmlnode_new_child(node, "type"); | |
166 xmlnode_insert_data(child, | |
167 (proxy_type == GAIM_PROXY_USE_GLOBAL ? "global" : | |
168 proxy_type == GAIM_PROXY_NONE ? "none" : | |
169 proxy_type == GAIM_PROXY_HTTP ? "http" : | |
170 proxy_type == GAIM_PROXY_SOCKS4 ? "socks4" : | |
171 proxy_type == GAIM_PROXY_SOCKS5 ? "socks5" : | |
172 proxy_type == GAIM_PROXY_USE_ENVVAR ? "envvar" : "unknown"), -1); | |
173 | |
174 if (proxy_type != GAIM_PROXY_USE_GLOBAL && | |
175 proxy_type != GAIM_PROXY_NONE && | |
176 proxy_type != GAIM_PROXY_USE_ENVVAR) | |
177 { | |
178 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL) | |
179 { | |
180 child = xmlnode_new_child(node, "host"); | |
181 xmlnode_insert_data(child, value, -1); | |
182 } | |
183 | |
184 if ((int_value = gaim_proxy_info_get_port(proxy_info)) != 0) | |
185 { | |
186 snprintf(buf, sizeof(buf), "%d", int_value); | |
187 child = xmlnode_new_child(node, "port"); | |
188 xmlnode_insert_data(child, buf, -1); | |
189 } | |
190 | |
191 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL) | |
192 { | |
193 child = xmlnode_new_child(node, "username"); | |
194 xmlnode_insert_data(child, value, -1); | |
195 } | |
196 | |
197 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL) | |
198 { | |
199 child = xmlnode_new_child(node, "password"); | |
200 xmlnode_insert_data(child, value, -1); | |
201 } | |
202 } | |
203 | |
204 return node; | |
205 } | |
206 | |
207 static xmlnode * | |
208 account_to_xmlnode(GaimAccount *account) | |
209 { | |
210 xmlnode *node, *child; | |
211 const char *tmp; | |
10738 | 212 GaimPresence *presence; |
10427 | 213 GaimProxyInfo *proxy_info; |
214 | |
215 node = xmlnode_new("account"); | |
216 | |
217 child = xmlnode_new_child(node, "protocol"); | |
218 xmlnode_insert_data(child, gaim_account_get_protocol_id(account), -1); | |
219 | |
220 child = xmlnode_new_child(node, "name"); | |
221 xmlnode_insert_data(child, gaim_account_get_username(account), -1); | |
222 | |
223 if (gaim_account_get_remember_password(account) && | |
224 ((tmp = gaim_account_get_password(account)) != NULL)) | |
225 { | |
226 child = xmlnode_new_child(node, "password"); | |
227 xmlnode_insert_data(child, tmp, -1); | |
228 } | |
229 | |
230 if ((tmp = gaim_account_get_alias(account)) != NULL) | |
231 { | |
232 child = xmlnode_new_child(node, "alias"); | |
233 xmlnode_insert_data(child, tmp, -1); | |
234 } | |
235 | |
10738 | 236 if ((presence = gaim_account_get_presence(account)) != NULL) |
237 { | |
238 child = statuses_to_xmlnode(presence); | |
239 xmlnode_insert_child(node, child); | |
240 } | |
241 | |
10427 | 242 if ((tmp = gaim_account_get_user_info(account)) != NULL) |
243 { | |
244 /* TODO: Do we need to call gaim_str_strip_cr(tmp) here? */ | |
245 child = xmlnode_new_child(node, "userinfo"); | |
246 xmlnode_insert_data(child, tmp, -1); | |
247 } | |
248 | |
249 if ((tmp = gaim_account_get_buddy_icon(account)) != NULL) | |
250 { | |
251 child = xmlnode_new_child(node, "buddyicon"); | |
252 xmlnode_insert_data(child, tmp, -1); | |
253 } | |
254 | |
255 if (g_hash_table_size(account->settings) > 0) | |
256 { | |
257 child = xmlnode_new_child(node, "settings"); | |
258 g_hash_table_foreach(account->settings, setting_to_xmlnode, child); | |
259 } | |
260 | |
261 if (g_hash_table_size(account->ui_settings) > 0) | |
262 { | |
263 g_hash_table_foreach(account->ui_settings, ui_setting_to_xmlnode, node); | |
264 } | |
265 | |
266 if ((proxy_info = gaim_account_get_proxy_info(account)) != NULL) | |
267 { | |
268 child = proxy_settings_to_xmlnode(proxy_info); | |
269 xmlnode_insert_child(node, child); | |
270 } | |
271 | |
272 return node; | |
273 } | |
274 | |
275 static xmlnode * | |
276 accounts_to_xmlnode(void) | |
277 { | |
278 xmlnode *node, *child; | |
279 GList *cur; | |
280 | |
281 node = xmlnode_new("accounts"); | |
282 xmlnode_set_attrib(node, "version", "1.0"); | |
283 | |
284 for (cur = gaim_accounts_get_all(); cur != NULL; cur = cur->next) | |
285 { | |
286 child = account_to_xmlnode(cur->data); | |
287 xmlnode_insert_child(node, child); | |
288 } | |
289 | |
290 return node; | |
291 } | |
292 | |
293 static void | |
294 sync_accounts(void) | |
295 { | |
296 xmlnode *node; | |
297 char *data; | |
298 | |
10428 | 299 if (!accounts_loaded) |
300 { | |
10443 | 301 gaim_debug_error("accounts", "Attempted to save accounts before " |
302 "they were read!\n"); | |
303 return; | |
10427 | 304 } |
305 | |
306 node = accounts_to_xmlnode(); | |
307 data = xmlnode_to_formatted_str(node, NULL); | |
308 gaim_util_write_data_to_file("accounts.xml", data, -1); | |
309 g_free(data); | |
310 xmlnode_free(node); | |
311 } | |
312 | |
313 static gboolean | |
314 save_cb(gpointer data) | |
315 { | |
316 sync_accounts(); | |
10428 | 317 save_timer = 0; |
10427 | 318 return FALSE; |
319 } | |
320 | |
321 static void | |
322 schedule_accounts_save() | |
323 { | |
10428 | 324 if (save_timer == 0) |
325 save_timer = gaim_timeout_add(5000, save_cb, NULL); | |
10427 | 326 } |
327 | |
328 | |
10428 | 329 /********************************************************************* |
330 * Reading from disk * | |
331 *********************************************************************/ | |
10427 | 332 |
333 static void | |
334 parse_settings(xmlnode *node, GaimAccount *account) | |
335 { | |
336 const char *ui; | |
337 xmlnode *child; | |
338 | |
339 /* Get the UI string, if these are UI settings */ | |
340 ui = xmlnode_get_attrib(node, "ui"); | |
341 | |
342 /* Read settings, one by one */ | |
343 for (child = xmlnode_get_child(node, "setting"); child != NULL; | |
344 child = xmlnode_get_next_twin(child)) | |
345 { | |
346 const char *name, *str_type; | |
347 GaimPrefType type; | |
348 char *data; | |
349 | |
350 name = xmlnode_get_attrib(child, "name"); | |
351 if (name == NULL) | |
352 /* Ignore this setting */ | |
353 continue; | |
354 | |
355 str_type = xmlnode_get_attrib(child, "type"); | |
10448 | 356 if (str_type == NULL) |
357 /* Ignore this setting */ | |
358 continue; | |
359 | |
10427 | 360 if (!strcmp(str_type, "string")) |
361 type = GAIM_PREF_STRING; | |
362 else if (!strcmp(str_type, "int")) | |
363 type = GAIM_PREF_INT; | |
364 else if (!strcmp(str_type, "bool")) | |
365 type = GAIM_PREF_BOOLEAN; | |
366 else | |
367 /* Ignore this setting */ | |
368 continue; | |
369 | |
370 data = xmlnode_get_data(child); | |
371 if (data == NULL) | |
372 /* Ignore this setting */ | |
373 continue; | |
374 | |
375 if (ui == NULL) | |
376 { | |
377 if (type == GAIM_PREF_STRING) | |
378 gaim_account_set_string(account, name, data); | |
379 else if (type == GAIM_PREF_INT) | |
380 gaim_account_set_int(account, name, atoi(data)); | |
381 else if (type == GAIM_PREF_BOOLEAN) | |
382 gaim_account_set_bool(account, name, | |
383 (*data == '0' ? FALSE : TRUE)); | |
384 } else { | |
385 if (type == GAIM_PREF_STRING) | |
386 gaim_account_set_ui_string(account, ui, name, data); | |
387 else if (type == GAIM_PREF_INT) | |
388 gaim_account_set_ui_int(account, ui, name, atoi(data)); | |
389 else if (type == GAIM_PREF_BOOLEAN) | |
390 gaim_account_set_ui_bool(account, ui, name, | |
391 (*data == '0' ? FALSE : TRUE)); | |
392 } | |
393 | |
394 g_free(data); | |
395 } | |
396 } | |
397 | |
398 static void | |
10738 | 399 parse_status(xmlnode *node, GaimAccount *account) |
400 { | |
401 gboolean active = FALSE; | |
402 const char *data; | |
403 const char *type; | |
404 xmlnode *child; | |
405 | |
406 /* Get the active/inactive state */ | |
407 child = xmlnode_get_child(node, "active"); | |
408 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
409 { | |
410 if (strcasecmp(data, "true") == 0) | |
411 active = TRUE; | |
412 else if (strcasecmp(data, "false") == 0) | |
413 active = FALSE; | |
414 else | |
415 return; | |
416 } | |
417 else | |
418 return; | |
419 | |
420 /* Get the type of the status */ | |
421 child = xmlnode_get_child(node, "type"); | |
422 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
423 { | |
424 type = data; | |
425 } | |
426 else | |
427 return; | |
428 | |
429 /* QQQ: Need to read attributes into a vargs */ | |
430 | |
431 /* QQQ: This needs to do a better job of adding attributes and stuff */ | |
432 /* Use gaim_account_set_status_vargs(); */ | |
433 gaim_account_set_status(account, type, active); | |
434 } | |
435 | |
436 static void | |
437 parse_statuses(xmlnode *node, GaimAccount *account) | |
438 { | |
439 xmlnode *child; | |
440 | |
441 for (child = xmlnode_get_child(node, "status"); child != NULL; | |
442 child = xmlnode_get_next_twin(child)) | |
443 { | |
444 parse_status(child, account); | |
445 } | |
446 } | |
447 | |
448 static void | |
10427 | 449 parse_proxy_info(xmlnode *node, GaimAccount *account) |
450 { | |
451 GaimProxyInfo *proxy_info; | |
452 xmlnode *child; | |
453 char *data; | |
454 | |
455 proxy_info = gaim_proxy_info_new(); | |
456 | |
457 /* Use the global proxy settings, by default */ | |
458 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
459 | |
460 /* Read proxy type */ | |
461 child = xmlnode_get_child(node, "type"); | |
462 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
463 { | |
464 if (!strcmp(data, "global")) | |
465 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
466 else if (!strcmp(data, "none")) | |
467 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_NONE); | |
468 else if (!strcmp(data, "http")) | |
469 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_HTTP); | |
470 else if (!strcmp(data, "socks4")) | |
471 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS4); | |
472 else if (!strcmp(data, "socks5")) | |
473 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS5); | |
474 else if (!strcmp(data, "envvar")) | |
475 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_ENVVAR); | |
476 else | |
477 { | |
478 gaim_debug_error("account", "Invalid proxy type found when " | |
479 "loading account information for %s\n", | |
480 gaim_account_get_username(account)); | |
481 } | |
482 g_free(data); | |
483 } | |
484 | |
485 /* Read proxy host */ | |
486 child = xmlnode_get_child(node, "host"); | |
487 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
488 { | |
489 gaim_proxy_info_set_host(proxy_info, data); | |
490 g_free(data); | |
491 } | |
492 | |
493 /* Read proxy port */ | |
494 child = xmlnode_get_child(node, "port"); | |
495 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
496 { | |
497 gaim_proxy_info_set_port(proxy_info, atoi(data)); | |
498 g_free(data); | |
499 } | |
500 | |
501 /* Read proxy username */ | |
502 child = xmlnode_get_child(node, "username"); | |
503 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
504 { | |
505 gaim_proxy_info_set_username(proxy_info, data); | |
506 g_free(data); | |
507 } | |
508 | |
509 /* Read proxy password */ | |
510 child = xmlnode_get_child(node, "password"); | |
511 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
512 { | |
513 gaim_proxy_info_set_password(proxy_info, data); | |
514 g_free(data); | |
515 } | |
516 | |
517 /* If there are no values set then proxy_infourn NULL */ | |
518 if ((gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_GLOBAL) && | |
519 (gaim_proxy_info_get_host(proxy_info) == NULL) && | |
520 (gaim_proxy_info_get_port(proxy_info) == 0) && | |
521 (gaim_proxy_info_get_username(proxy_info) == NULL) && | |
522 (gaim_proxy_info_get_password(proxy_info) == NULL)) | |
523 { | |
524 gaim_proxy_info_destroy(proxy_info); | |
525 return; | |
526 } | |
527 | |
528 gaim_account_set_proxy_info(account, proxy_info); | |
529 } | |
530 | |
531 static GaimAccount * | |
532 parse_account(xmlnode *node) | |
533 { | |
534 GaimAccount *ret; | |
535 xmlnode *child; | |
536 char *protocol_id = NULL; | |
537 char *name = NULL; | |
538 char *data; | |
539 | |
540 child = xmlnode_get_child(node, "protocol"); | |
541 if (child != NULL) | |
542 protocol_id = xmlnode_get_data(child); | |
543 | |
544 child = xmlnode_get_child(node, "name"); | |
545 if (child != NULL) | |
546 name = xmlnode_get_data(child); | |
547 if (name == NULL) | |
548 { | |
549 /* Do we really need to do this? */ | |
550 child = xmlnode_get_child(node, "username"); | |
551 if (child != NULL) | |
552 name = xmlnode_get_data(child); | |
553 } | |
554 | |
555 if ((protocol_id == NULL) || (name == NULL)) | |
556 { | |
557 free(protocol_id); | |
558 free(name); | |
559 return NULL; | |
560 } | |
561 | |
562 ret = gaim_account_new(name, protocol_id); | |
563 free(name); | |
564 free(protocol_id); | |
565 | |
566 /* Read the password */ | |
567 child = xmlnode_get_child(node, "password"); | |
568 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
569 { | |
10743 | 570 gaim_account_set_remember_password(ret, TRUE); |
10427 | 571 gaim_account_set_password(ret, data); |
572 g_free(data); | |
573 } | |
574 | |
575 /* Read the alias */ | |
576 child = xmlnode_get_child(node, "alias"); | |
577 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
578 { | |
579 gaim_account_set_alias(ret, data); | |
580 g_free(data); | |
581 } | |
582 | |
10738 | 583 /* Read the statuses */ |
584 child = xmlnode_get_child(node, "statuses"); | |
585 if (child != NULL) | |
586 { | |
587 parse_statuses(child, ret); | |
588 } | |
589 | |
10427 | 590 /* Read the userinfo */ |
591 child = xmlnode_get_child(node, "userinfo"); | |
592 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
593 { | |
594 gaim_account_set_user_info(ret, data); | |
595 g_free(data); | |
596 } | |
597 | |
598 /* Read the buddyicon */ | |
599 child = xmlnode_get_child(node, "buddyicon"); | |
600 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
601 { | |
602 gaim_account_set_buddy_icon(ret, data); | |
603 g_free(data); | |
604 } | |
605 | |
606 /* Read settings (both core and UI) */ | |
607 for (child = xmlnode_get_child(node, "settings"); child != NULL; | |
608 child = xmlnode_get_next_twin(child)) | |
609 { | |
610 parse_settings(child, ret); | |
611 } | |
612 | |
613 /* Read proxy */ | |
614 child = xmlnode_get_child(node, "proxy"); | |
615 if (child != NULL) | |
616 { | |
617 parse_proxy_info(child, ret); | |
618 } | |
619 | |
620 return ret; | |
621 } | |
622 | |
623 static void | |
624 load_accounts(void) | |
625 { | |
626 xmlnode *node, *child; | |
627 | |
628 accounts_loaded = TRUE; | |
629 | |
630 node = gaim_util_read_xml_from_file("accounts.xml", _("accounts")); | |
631 | |
632 if (node == NULL) | |
633 return; | |
634 | |
635 for (child = xmlnode_get_child(node, "account"); child != NULL; | |
636 child = xmlnode_get_next_twin(child)) | |
637 { | |
10490 | 638 GaimAccount *new_acct; |
639 new_acct = parse_account(child); | |
640 gaim_accounts_add(new_acct); | |
10427 | 641 } |
642 } | |
643 | |
644 | |
5563 | 645 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
646 delete_setting(void *data) |
5563 | 647 { |
648 GaimAccountSetting *setting = (GaimAccountSetting *)data; | |
649 | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
650 if (setting->ui != NULL) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
651 g_free(setting->ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
652 |
5563 | 653 if (setting->type == GAIM_PREF_STRING) |
654 g_free(setting->value.string); | |
655 | |
656 g_free(setting); | |
657 } | |
658 | |
659 GaimAccount * | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
660 gaim_account_new(const char *username, const char *protocol_id) |
5563 | 661 { |
6067 | 662 GaimAccount *account = NULL; |
10012 | 663 GaimPlugin *prpl = NULL; |
664 GaimPluginProtocolInfo *prpl_info = NULL; | |
5563 | 665 |
9944 | 666 g_return_val_if_fail(username != NULL, NULL); |
9971 | 667 g_return_val_if_fail(protocol_id != NULL, NULL); |
5563 | 668 |
9971 | 669 account = gaim_accounts_find(username, protocol_id); |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
670 |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 if (account != NULL) |
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
672 return account; |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
673 |
5563 | 674 account = g_new0(GaimAccount, 1); |
675 | |
6067 | 676 gaim_account_set_username(account, username); |
677 | |
9971 | 678 gaim_account_set_protocol_id(account, protocol_id); |
5563 | 679 |
680 account->settings = g_hash_table_new_full(g_str_hash, g_str_equal, | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
681 g_free, delete_setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
682 account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
683 g_free, (GDestroyNotify)g_hash_table_destroy); |
8573 | 684 account->system_log = NULL; |
10720 | 685 |
9944 | 686 account->presence = gaim_presence_new_for_account(account); |
687 | |
10447 | 688 prpl = gaim_find_prpl(protocol_id); |
10052 | 689 |
10012 | 690 if (prpl == NULL) |
691 return account; | |
10052 | 692 |
10738 | 693 /* TODO: Should maybe use gaim_prpl_get_statuses()? */ |
10012 | 694 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
10738 | 695 if (prpl_info != NULL && prpl_info->status_types != NULL) |
10012 | 696 gaim_account_set_status_types(account, prpl_info->status_types(account)); |
697 | |
10052 | 698 gaim_presence_set_status_active(account->presence, "offline", TRUE); |
699 | |
5563 | 700 return account; |
701 } | |
702 | |
703 void | |
704 gaim_account_destroy(GaimAccount *account) | |
705 { | |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
706 GList *l; |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
707 |
5563 | 708 g_return_if_fail(account != NULL); |
709 | |
9944 | 710 gaim_debug_info("account", "Destroying account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
711 |
10742 | 712 if (gaim_account_is_connected(account)) |
713 gaim_account_disconnect(account); | |
5563 | 714 |
9944 | 715 gaim_debug_info("account", "Continuing to destroy account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
716 |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
717 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
718 { |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
719 GaimConversation *conv = (GaimConversation *)l->data; |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
720 |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
721 if (gaim_conversation_get_account(conv) == account) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
722 gaim_conversation_set_account(conv, NULL); |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
723 } |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
724 |
5643
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
725 if (account->username != NULL) g_free(account->username); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
726 if (account->alias != NULL) g_free(account->alias); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
727 if (account->password != NULL) g_free(account->password); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
728 if (account->user_info != NULL) g_free(account->user_info); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
729 if (account->protocol_id != NULL) g_free(account->protocol_id); |
5563 | 730 |
731 g_hash_table_destroy(account->settings); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
732 g_hash_table_destroy(account->ui_settings); |
5563 | 733 |
9944 | 734 gaim_account_set_status_types(account, NULL); |
735 | |
736 gaim_presence_destroy(account->presence); | |
737 | |
8573 | 738 if(account->system_log) |
739 gaim_log_free(account->system_log); | |
740 | |
5563 | 741 g_free(account); |
742 } | |
743 | |
10740 | 744 void |
6581 | 745 gaim_account_register(GaimAccount *account) |
746 { | |
10740 | 747 g_return_if_fail(account != NULL); |
6581 | 748 |
10740 | 749 gaim_debug_info("account", "Registering account %s\n", |
750 gaim_account_get_username(account)); | |
6581 | 751 |
10740 | 752 gaim_connection_new(account, TRUE, NULL); |
753 } | |
6581 | 754 |
10740 | 755 static void |
756 request_password_ok_cb(GaimAccount *account, const char *entry) | |
757 { | |
758 if (!entry || !*entry) | |
759 { | |
760 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL); | |
761 return; | |
762 } | |
6581 | 763 |
10740 | 764 if (gaim_account_get_remember_password(account)) |
765 gaim_account_set_password(account, entry); | |
6581 | 766 |
10740 | 767 gaim_connection_new(account, FALSE, entry); |
6581 | 768 } |
769 | |
10740 | 770 static void |
771 request_password(GaimAccount *account) | |
772 { | |
773 gchar *primary; | |
774 gchar *escaped; | |
775 const gchar *username; | |
776 | |
777 username = gaim_account_get_username(account); | |
778 escaped = g_markup_escape_text(username, strlen(username)); | |
779 primary = g_strdup_printf(_("Enter password for %s (%s)"), escaped, | |
780 gaim_account_get_protocol_name(account)); | |
781 gaim_request_input(account, _("Enter Password"), primary, NULL, NULL, | |
782 FALSE, TRUE, NULL, | |
783 _("OK"), G_CALLBACK(request_password_ok_cb), | |
784 _("Cancel"), NULL, account); | |
785 g_free(primary); | |
786 g_free(escaped); | |
787 } | |
788 | |
789 void | |
10738 | 790 gaim_account_connect(GaimAccount *account) |
5563 | 791 { |
10740 | 792 GaimPlugin *prpl; |
793 GaimPluginProtocolInfo *prpl_info; | |
794 const char *password; | |
795 | |
796 g_return_if_fail(account != NULL); | |
5563 | 797 |
10740 | 798 gaim_debug_info("account", "Connecting to account %s\n", |
799 gaim_account_get_username(account)); | |
5563 | 800 |
10740 | 801 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
802 if (prpl == NULL) | |
803 { | |
804 gchar *message; | |
6036 | 805 |
10740 | 806 message = g_strdup_printf(_("Missing protocol plugin for %s"), |
807 gaim_account_get_username(account)); | |
808 gaim_notify_error(NULL, _("Connection Error"), message, NULL); | |
809 g_free(message); | |
810 return; | |
811 } | |
5563 | 812 |
10740 | 813 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
814 password = gaim_account_get_password(account); | |
815 if ((password == NULL) && | |
816 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && | |
817 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) | |
818 request_password(account); | |
819 else | |
820 gaim_connection_new(account, FALSE, password); | |
5563 | 821 } |
822 | |
823 void | |
824 gaim_account_disconnect(GaimAccount *account) | |
825 { | |
5926
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
826 GaimConnection *gc; |
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
827 |
5563 | 828 g_return_if_fail(account != NULL); |
829 g_return_if_fail(gaim_account_is_connected(account)); | |
830 | |
9944 | 831 gaim_debug_info("account", "Disconnecting account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
832 |
10384 | 833 account->disconnecting = TRUE; |
5563 | 834 |
10742 | 835 gc = gaim_account_get_connection(account); |
836 gaim_connection_destroy(gc); | |
837 gaim_account_set_connection(account, NULL); | |
10384 | 838 |
839 account->disconnecting = FALSE; | |
5563 | 840 } |
841 | |
842 void | |
7166 | 843 gaim_account_notify_added(GaimAccount *account, const char *id, |
844 const char *remote_user, const char *alias, | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
845 const char *message) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
846 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
847 GaimAccountUiOps *ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
848 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
849 g_return_if_fail(account != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
850 g_return_if_fail(remote_user != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
851 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
852 ui_ops = gaim_accounts_get_ui_ops(); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
853 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
854 if (ui_ops != NULL && ui_ops->notify_added != NULL) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
855 ui_ops->notify_added(account, remote_user, id, alias, message); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
856 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
857 |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
858 static void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
859 change_password_cb(GaimAccount *account, GaimRequestFields *fields) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
860 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
861 const char *orig_pass, *new_pass_1, *new_pass_2; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
862 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
863 orig_pass = gaim_request_fields_get_string(fields, "password"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
864 new_pass_1 = gaim_request_fields_get_string(fields, "new_password_1"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
865 new_pass_2 = gaim_request_fields_get_string(fields, "new_password_2"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
866 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
867 if (g_utf8_collate(new_pass_1, new_pass_2)) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
868 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
869 gaim_notify_error(NULL, NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
870 _("New passwords do not match."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
871 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
872 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
873 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
874 |
8638 | 875 if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL || |
876 *orig_pass == '\0' || *new_pass_1 == '\0' || *new_pass_2 == '\0') | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
877 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
878 gaim_notify_error(NULL, NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
879 _("Fill out all fields completely."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
880 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
881 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
882 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
883 serv_change_passwd(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
884 orig_pass, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
885 gaim_account_set_password(account, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
886 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
887 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
888 void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
889 gaim_account_request_change_password(GaimAccount *account) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
890 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
891 GaimRequestFields *fields; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
892 GaimRequestFieldGroup *group; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
893 GaimRequestField *field; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
894 char primary[256]; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
895 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
896 g_return_if_fail(account != NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
897 g_return_if_fail(gaim_account_is_connected(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
898 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
899 fields = gaim_request_fields_new(); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
900 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
901 group = gaim_request_field_group_new(NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
902 gaim_request_fields_add_group(fields, group); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
903 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
904 field = gaim_request_field_string_new("password", _("Original password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
905 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
906 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 907 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
908 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
909 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
910 field = gaim_request_field_string_new("new_password_1", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
911 _("New password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
912 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
913 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 914 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
915 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
916 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
917 field = gaim_request_field_string_new("new_password_2", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
918 _("New password (again)"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
919 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
920 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 921 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
922 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
923 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
924 g_snprintf(primary, sizeof(primary), _("Change password for %s"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
925 gaim_account_get_username(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
926 |
7755 | 927 /* I'm sticking this somewhere in the code: bologna */ |
928 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
929 gaim_request_fields(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
930 NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
931 primary, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
932 _("Please enter your current password and your " |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
933 "new password."), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
934 fields, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
935 _("OK"), G_CALLBACK(change_password_cb), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
936 _("Cancel"), NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
937 account); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
938 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
939 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
940 static void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
941 set_user_info_cb(GaimAccount *account, const char *user_info) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
942 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
943 GaimConnection *gc; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
944 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
945 gaim_account_set_user_info(account, user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
946 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
947 gc = gaim_account_get_connection(account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
948 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
949 if (gc != NULL) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
950 serv_set_info(gaim_account_get_connection(account), user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
951 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
952 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
953 void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
954 gaim_account_request_change_user_info(GaimAccount *account) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
955 { |
8697 | 956 GaimConnection *gc; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
957 char primary[256]; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
958 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
959 g_return_if_fail(account != NULL); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
960 g_return_if_fail(gaim_account_is_connected(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
961 |
8697 | 962 gc = gaim_account_get_connection(account); |
963 | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
964 g_snprintf(primary, sizeof(primary), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
965 _("Change user information for %s"), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
966 gaim_account_get_username(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
967 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
968 gaim_request_input(gaim_account_get_connection(account), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
969 NULL, primary, NULL, |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
970 gaim_account_get_user_info(account), |
8697 | 971 TRUE, FALSE, ((gc != NULL) && |
972 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL), | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
973 _("Save"), G_CALLBACK(set_user_info_cb), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
974 _("Cancel"), NULL, account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
975 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
976 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
977 void |
5563 | 978 gaim_account_set_username(GaimAccount *account, const char *username) |
979 { | |
5711
e33778b9d395
[gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents:
5710
diff
changeset
|
980 g_return_if_fail(account != NULL); |
5563 | 981 |
10740 | 982 g_free(account->username); |
5563 | 983 account->username = (username == NULL ? NULL : g_strdup(username)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
984 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
985 schedule_accounts_save(); |
5563 | 986 } |
987 | |
988 void | |
989 gaim_account_set_password(GaimAccount *account, const char *password) | |
990 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
991 g_return_if_fail(account != NULL); |
5563 | 992 |
10740 | 993 g_free(account->password); |
994 account->password = NULL; | |
995 | |
996 if (!gaim_account_get_remember_password(account)) | |
997 return; | |
5563 | 998 |
999 account->password = (password == NULL ? NULL : g_strdup(password)); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1000 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1001 schedule_accounts_save(); |
5563 | 1002 } |
1003 | |
1004 void | |
1005 gaim_account_set_alias(GaimAccount *account, const char *alias) | |
1006 { | |
1007 g_return_if_fail(account != NULL); | |
1008 | |
10740 | 1009 g_free(account->alias); |
5563 | 1010 account->alias = (alias == NULL ? NULL : g_strdup(alias)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1011 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1012 schedule_accounts_save(); |
5563 | 1013 } |
1014 | |
1015 void | |
1016 gaim_account_set_user_info(GaimAccount *account, const char *user_info) | |
1017 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1018 g_return_if_fail(account != NULL); |
5563 | 1019 |
10740 | 1020 g_free(account->user_info); |
5563 | 1021 account->user_info = (user_info == NULL ? NULL : g_strdup(user_info)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1022 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1023 schedule_accounts_save(); |
5563 | 1024 } |
1025 | |
1026 void | |
1027 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) | |
1028 { | |
1029 g_return_if_fail(account != NULL); | |
1030 | |
10740 | 1031 g_free(account->buddy_icon); |
5563 | 1032 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); |
10740 | 1033 if (gaim_account_is_connected(account)) |
10742 | 1034 serv_set_buddyicon(gaim_account_get_connection(account), icon); |
10418 | 1035 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1036 schedule_accounts_save(); |
5563 | 1037 } |
1038 | |
1039 void | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1040 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1041 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1042 g_return_if_fail(account != NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1043 g_return_if_fail(protocol_id != NULL); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1044 |
10740 | 1045 g_free(account->protocol_id); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1046 account->protocol_id = g_strdup(protocol_id); |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
1047 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1048 schedule_accounts_save(); |
5563 | 1049 } |
1050 | |
1051 void | |
1052 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc) | |
1053 { | |
1054 g_return_if_fail(account != NULL); | |
1055 | |
1056 account->gc = gc; | |
1057 } | |
1058 | |
1059 void | |
1060 gaim_account_set_remember_password(GaimAccount *account, gboolean value) | |
1061 { | |
1062 g_return_if_fail(account != NULL); | |
1063 | |
1064 account->remember_pass = value; | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1065 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1066 schedule_accounts_save(); |
5563 | 1067 } |
1068 | |
1069 void | |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1070 gaim_account_set_check_mail(GaimAccount *account, gboolean value) |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1071 { |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1072 g_return_if_fail(account != NULL); |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1073 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1074 gaim_account_set_bool(account, "check-mail", value); |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1075 } |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1076 |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1077 void |
10400 | 1078 gaim_account_set_enabled(GaimAccount *account, const char *ui, |
1079 gboolean value) | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1080 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1081 g_return_if_fail(account != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1082 g_return_if_fail(ui != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1083 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1084 gaim_account_set_ui_bool(account, ui, "auto-login", value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1085 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1086 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1087 void |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1088 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1089 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1090 g_return_if_fail(account != NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1091 |
5695
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1092 if (account->proxy_info != NULL) |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1093 gaim_proxy_info_destroy(account->proxy_info); |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1094 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1095 account->proxy_info = info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1096 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1097 schedule_accounts_save(); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1098 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1099 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1100 void |
9944 | 1101 gaim_account_set_status_types(GaimAccount *account, GList *status_types) |
1102 { | |
1103 g_return_if_fail(account != NULL); | |
1104 | |
10005 | 1105 /* Old with the old... */ |
9944 | 1106 if (account->status_types != NULL) |
1107 { | |
1108 GList *l; | |
1109 | |
1110 for (l = account->status_types; l != NULL; l = l->next) | |
1111 gaim_status_type_destroy((GaimStatusType *)l->data); | |
1112 | |
1113 g_list_free(account->status_types); | |
1114 } | |
1115 | |
10005 | 1116 /* In with the new... */ |
9944 | 1117 account->status_types = status_types; |
1118 } | |
1119 | |
1120 void | |
1121 gaim_account_set_status(GaimAccount *account, const char *status_id, | |
1122 gboolean active, ...) | |
1123 { | |
10738 | 1124 va_list args; |
1125 | |
1126 va_start(args, active); | |
1127 gaim_account_set_status_vargs(account, status_id, active, args); | |
1128 va_end(args); | |
1129 } | |
1130 | |
1131 void | |
1132 gaim_account_set_status_vargs(GaimAccount *account, const char *status_id, | |
1133 gboolean active, va_list args) | |
1134 { | |
9944 | 1135 GaimStatus *status; |
10714 | 1136 GaimStatusType *status_type; |
9944 | 1137 |
1138 g_return_if_fail(account != NULL); | |
1139 g_return_if_fail(status_id != NULL); | |
1140 | |
1141 status = gaim_account_get_status(account, status_id); | |
1142 if (status == NULL) | |
1143 { | |
10309 | 1144 gaim_debug_error("accounts", |
9944 | 1145 "Invalid status ID %s for account %s (%s)\n", |
1146 status_id, gaim_account_get_username(account), | |
1147 gaim_account_get_protocol_id(account)); | |
1148 return; | |
1149 } | |
10720 | 1150 status_type = gaim_status_get_type(status); |
1151 | |
1152 /* | |
1153 * If this account should be disconnected, but is online, then disconnect. | |
1154 */ | |
1155 if (active && | |
1156 (gaim_status_type_get_primitive(status_type) == GAIM_STATUS_OFFLINE) && | |
1157 gaim_account_is_connected(account)) | |
1158 { | |
10749 | 1159 account->gc->wants_to_die = TRUE; |
10720 | 1160 gaim_account_disconnect(account); |
1161 | |
1162 /* No need to actually set the status, so we just exit */ | |
1163 return; | |
1164 } | |
1165 | |
1166 /* TODO: Record the status in accounts.xml? */ | |
9944 | 1167 |
10204 | 1168 gaim_status_set_active_with_attrs(status, active, args); |
10738 | 1169 gaim_presence_set_status_active(gaim_account_get_presence(account), status_id, active); |
10714 | 1170 |
1171 /* | |
1172 * If this account should be connected, but is not, then connect. | |
1173 */ | |
1174 if (active && | |
1175 (gaim_status_type_get_primitive(status_type) != GAIM_STATUS_OFFLINE) && | |
1176 !gaim_account_is_connected(account)) | |
1177 { | |
10738 | 1178 gaim_account_connect(account); |
10714 | 1179 } |
9944 | 1180 } |
1181 | |
1182 void | |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1183 gaim_account_clear_settings(GaimAccount *account) |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1184 { |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1185 g_return_if_fail(account != NULL); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1186 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1187 g_hash_table_destroy(account->settings); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1188 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1189 account->settings = g_hash_table_new_full(g_str_hash, g_str_equal, |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1190 g_free, delete_setting); |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1191 } |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1192 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1193 void |
5563 | 1194 gaim_account_set_int(GaimAccount *account, const char *name, int value) |
1195 { | |
1196 GaimAccountSetting *setting; | |
1197 | |
1198 g_return_if_fail(account != NULL); | |
1199 g_return_if_fail(name != NULL); | |
1200 | |
1201 setting = g_new0(GaimAccountSetting, 1); | |
1202 | |
1203 setting->type = GAIM_PREF_INT; | |
1204 setting->value.integer = value; | |
1205 | |
1206 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1207 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1208 schedule_accounts_save(); |
5563 | 1209 } |
1210 | |
1211 void | |
1212 gaim_account_set_string(GaimAccount *account, const char *name, | |
1213 const char *value) | |
1214 { | |
1215 GaimAccountSetting *setting; | |
1216 | |
1217 g_return_if_fail(account != NULL); | |
1218 g_return_if_fail(name != NULL); | |
1219 | |
1220 setting = g_new0(GaimAccountSetting, 1); | |
1221 | |
1222 setting->type = GAIM_PREF_STRING; | |
1223 setting->value.string = g_strdup(value); | |
1224 | |
1225 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1226 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1227 schedule_accounts_save(); |
5563 | 1228 } |
1229 | |
1230 void | |
1231 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value) | |
1232 { | |
1233 GaimAccountSetting *setting; | |
1234 | |
1235 g_return_if_fail(account != NULL); | |
1236 g_return_if_fail(name != NULL); | |
1237 | |
1238 setting = g_new0(GaimAccountSetting, 1); | |
1239 | |
1240 setting->type = GAIM_PREF_BOOLEAN; | |
1241 setting->value.bool = value; | |
1242 | |
1243 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1244 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1245 schedule_accounts_save(); |
5563 | 1246 } |
1247 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1248 static GHashTable * |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1249 get_ui_settings_table(GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1250 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1251 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1252 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1253 table = g_hash_table_lookup(account->ui_settings, ui); |
5979
49ae70ffcea5
[gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents:
5977
diff
changeset
|
1254 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1255 if (table == NULL) { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1256 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1257 delete_setting); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1258 g_hash_table_insert(account->ui_settings, g_strdup(ui), table); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1259 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1260 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1261 return table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1262 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1263 |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1264 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1265 gaim_account_set_ui_int(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1266 const char *name, int value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1267 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1268 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1269 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1270 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1271 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1272 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1273 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1274 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1275 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1276 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1277 setting->type = GAIM_PREF_INT; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1278 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1279 setting->value.integer = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1280 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1281 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1282 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1283 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1284 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1285 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1286 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1287 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1288 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1289 gaim_account_set_ui_string(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1290 const char *name, const char *value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1291 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1292 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1293 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1294 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1295 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1296 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1297 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1298 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1299 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1300 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1301 setting->type = GAIM_PREF_STRING; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1302 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1303 setting->value.string = g_strdup(value); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1304 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1305 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1306 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1307 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1308 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1309 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1310 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1311 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1312 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1313 gaim_account_set_ui_bool(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1314 const char *name, gboolean value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1315 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1316 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1317 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1318 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1319 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1320 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1321 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1322 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1323 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1324 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1325 setting->type = GAIM_PREF_BOOLEAN; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1326 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1327 setting->value.bool = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1328 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1329 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1330 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1331 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1332 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1333 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1334 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1335 |
5563 | 1336 gboolean |
1337 gaim_account_is_connected(const GaimAccount *account) | |
1338 { | |
9019 | 1339 GaimConnection *gc; |
1340 | |
5563 | 1341 g_return_val_if_fail(account != NULL, FALSE); |
1342 | |
9019 | 1343 gc = gaim_account_get_connection(account); |
1344 | |
10428 | 1345 /* TODO: The first way is better... but it doesn't work quite right yet */ |
9021 | 1346 /* return ((gc != NULL) && GAIM_CONNECTION_IS_CONNECTED(gc)); */ |
1347 return ((gc != NULL) && gaim_connection_get_state(gc) != GAIM_DISCONNECTED); | |
5563 | 1348 } |
1349 | |
1350 const char * | |
1351 gaim_account_get_username(const GaimAccount *account) | |
1352 { | |
1353 g_return_val_if_fail(account != NULL, NULL); | |
1354 | |
1355 return account->username; | |
1356 } | |
1357 | |
1358 const char * | |
1359 gaim_account_get_password(const GaimAccount *account) | |
1360 { | |
1361 g_return_val_if_fail(account != NULL, NULL); | |
1362 | |
1363 return account->password; | |
1364 } | |
1365 | |
1366 const char * | |
1367 gaim_account_get_alias(const GaimAccount *account) | |
1368 { | |
1369 g_return_val_if_fail(account != NULL, NULL); | |
1370 | |
1371 return account->alias; | |
1372 } | |
1373 | |
1374 const char * | |
1375 gaim_account_get_user_info(const GaimAccount *account) | |
1376 { | |
1377 g_return_val_if_fail(account != NULL, NULL); | |
1378 | |
1379 return account->user_info; | |
1380 } | |
1381 | |
1382 const char * | |
1383 gaim_account_get_buddy_icon(const GaimAccount *account) | |
1384 { | |
1385 g_return_val_if_fail(account != NULL, NULL); | |
1386 | |
1387 return account->buddy_icon; | |
1388 } | |
1389 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1390 const char * |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1391 gaim_account_get_protocol_id(const GaimAccount *account) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1392 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1393 g_return_val_if_fail(account != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1394 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1395 return account->protocol_id; |
5563 | 1396 } |
1397 | |
9699 | 1398 const char * |
1399 gaim_account_get_protocol_name(const GaimAccount *account) | |
1400 { | |
9720 | 1401 GaimPlugin *p; |
1402 | |
9699 | 1403 g_return_val_if_fail(account != NULL, NULL); |
1404 | |
9989 | 1405 p = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
9988 | 1406 |
1407 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); | |
1408 } | |
1409 | |
5563 | 1410 GaimConnection * |
1411 gaim_account_get_connection(const GaimAccount *account) | |
1412 { | |
1413 g_return_val_if_fail(account != NULL, NULL); | |
1414 | |
1415 return account->gc; | |
1416 } | |
1417 | |
1418 gboolean | |
1419 gaim_account_get_remember_password(const GaimAccount *account) | |
1420 { | |
1421 g_return_val_if_fail(account != NULL, FALSE); | |
1422 | |
1423 return account->remember_pass; | |
1424 } | |
1425 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1426 gboolean |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1427 gaim_account_get_check_mail(const GaimAccount *account) |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1428 { |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1429 g_return_val_if_fail(account != NULL, FALSE); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1430 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1431 return gaim_account_get_bool(account, "check-mail", FALSE); |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1432 } |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1433 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1434 gboolean |
10400 | 1435 gaim_account_get_enabled(const GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1436 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1437 g_return_val_if_fail(account != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1438 g_return_val_if_fail(ui != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1439 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1440 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1441 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1442 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1443 GaimProxyInfo * |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1444 gaim_account_get_proxy_info(const GaimAccount *account) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1445 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1446 g_return_val_if_fail(account != NULL, NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1447 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1448 return account->proxy_info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1449 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1450 |
9944 | 1451 GaimStatus * |
10738 | 1452 gaim_account_get_active_status(const GaimAccount *account) |
1453 { | |
1454 g_return_val_if_fail(account != NULL, NULL); | |
1455 | |
1456 return gaim_presence_get_active_status(account->presence); | |
1457 } | |
1458 | |
1459 GaimStatus * | |
9944 | 1460 gaim_account_get_status(const GaimAccount *account, const char *status_id) |
1461 { | |
1462 g_return_val_if_fail(account != NULL, NULL); | |
1463 g_return_val_if_fail(status_id != NULL, NULL); | |
1464 | |
1465 return gaim_presence_get_status(account->presence, status_id); | |
1466 } | |
1467 | |
1468 GaimStatusType * | |
1469 gaim_account_get_status_type(const GaimAccount *account, const char *id) | |
1470 { | |
1471 const GList *l; | |
1472 | |
1473 g_return_val_if_fail(account != NULL, NULL); | |
1474 g_return_val_if_fail(id != NULL, NULL); | |
1475 | |
1476 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
1477 { | |
1478 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
1479 | |
1480 if (!strcmp(gaim_status_type_get_id(status_type), id)) | |
1481 return status_type; | |
1482 } | |
1483 | |
1484 return NULL; | |
1485 } | |
1486 | |
1487 GaimPresence * | |
1488 gaim_account_get_presence(const GaimAccount *account) | |
1489 { | |
1490 g_return_val_if_fail(account != NULL, NULL); | |
1491 | |
1492 return account->presence; | |
1493 } | |
1494 | |
1495 gboolean | |
1496 gaim_account_is_status_active(const GaimAccount *account, | |
1497 const char *status_id) | |
1498 { | |
1499 g_return_val_if_fail(account != NULL, FALSE); | |
1500 g_return_val_if_fail(status_id != NULL, FALSE); | |
1501 | |
1502 return gaim_presence_is_status_active(account->presence, status_id); | |
1503 } | |
1504 | |
1505 const GList * | |
1506 gaim_account_get_status_types(const GaimAccount *account) | |
1507 { | |
1508 g_return_val_if_fail(account != NULL, NULL); | |
1509 | |
1510 return account->status_types; | |
1511 } | |
1512 | |
5563 | 1513 int |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1514 gaim_account_get_int(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1515 int default_value) |
5563 | 1516 { |
1517 GaimAccountSetting *setting; | |
1518 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1519 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1520 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1521 |
1522 setting = g_hash_table_lookup(account->settings, name); | |
1523 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1524 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1525 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1526 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1527 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
5563 | 1528 |
1529 return setting->value.integer; | |
1530 } | |
1531 | |
1532 const char * | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1533 gaim_account_get_string(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1534 const char *default_value) |
5563 | 1535 { |
1536 GaimAccountSetting *setting; | |
1537 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1538 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1539 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1540 |
1541 setting = g_hash_table_lookup(account->settings, name); | |
1542 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1543 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1544 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1545 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1546 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
5563 | 1547 |
1548 return setting->value.string; | |
1549 } | |
1550 | |
1551 gboolean | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1552 gaim_account_get_bool(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1553 gboolean default_value) |
5563 | 1554 { |
1555 GaimAccountSetting *setting; | |
1556 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1557 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1558 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1559 |
1560 setting = g_hash_table_lookup(account->settings, name); | |
1561 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1562 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1563 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1564 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1565 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
5563 | 1566 |
1567 return setting->value.bool; | |
1568 } | |
1569 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1570 int |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1571 gaim_account_get_ui_int(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1572 const char *name, int default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1573 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1574 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1575 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1576 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1577 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1578 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1579 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1580 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1581 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1582 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1583 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1584 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1585 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1586 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1587 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1588 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1589 return setting->value.integer; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1590 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1591 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1592 const char * |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1593 gaim_account_get_ui_string(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1594 const char *name, const char *default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1595 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1596 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1597 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1598 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1599 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1600 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1601 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1602 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1603 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1604 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1605 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1606 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1607 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1608 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1609 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1610 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1611 return setting->value.string; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1612 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1613 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1614 gboolean |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1615 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1616 const char *name, gboolean default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1617 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1618 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1619 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1620 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1621 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1622 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1623 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1624 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1625 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1626 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1627 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1628 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1629 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1630 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1631 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1632 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1633 return setting->value.bool; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1634 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1635 |
8573 | 1636 GaimLog * |
1637 gaim_account_get_log(GaimAccount *account) | |
1638 { | |
1639 g_return_val_if_fail(account != NULL, NULL); | |
1640 | |
1641 if(!account->system_log){ | |
8658 | 1642 GaimConnection *gc; |
1643 | |
1644 gc = gaim_account_get_connection(account); | |
1645 | |
8635 | 1646 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, |
1647 gaim_account_get_username(account), account, | |
8658 | 1648 gc != NULL ? gc->login_time : time(NULL)); |
8573 | 1649 } |
1650 | |
1651 return account->system_log; | |
1652 } | |
1653 | |
1654 void | |
1655 gaim_account_destroy_log(GaimAccount *account) | |
1656 { | |
1657 g_return_if_fail(account != NULL); | |
1658 | |
1659 if(account->system_log){ | |
1660 gaim_log_free(account->system_log); | |
1661 account->system_log = NULL; | |
1662 } | |
1663 } | |
1664 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1665 void |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1666 gaim_accounts_add(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1667 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1668 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1669 |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1670 if (g_list_find(accounts, account) != NULL) |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1671 return; |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1672 |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1673 accounts = g_list_append(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1674 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1675 schedule_accounts_save(); |
8134 | 1676 |
1677 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account); | |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1678 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1679 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1680 void |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1681 gaim_accounts_remove(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1682 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1683 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1684 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1685 accounts = g_list_remove(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1686 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1687 schedule_accounts_save(); |
8134 | 1688 |
1689 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1690 } |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1691 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1692 void |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1693 gaim_accounts_delete(GaimAccount *account) |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1694 { |
6695 | 1695 GaimBlistNode *gnode, *cnode, *bnode; |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1696 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1697 g_return_if_fail(account != NULL); |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1698 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1699 gaim_accounts_remove(account); |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1700 |
8235 | 1701 /* Remove this account's buddies */ |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1702 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) { |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1703 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1704 continue; |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1705 |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1706 cnode = gnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1707 while (cnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1708 GaimBlistNode *cnode_next = cnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1709 |
6695 | 1710 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1711 bnode = cnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1712 while (bnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1713 GaimBlistNode *bnode_next = bnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1714 |
6695 | 1715 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
1716 GaimBuddy *b = (GaimBuddy *)bnode; | |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1717 |
6695 | 1718 if (b->account == account) |
1719 gaim_blist_remove_buddy(b); | |
1720 } | |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1721 bnode = bnode_next; |
6695 | 1722 } |
1723 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1724 GaimChat *c = (GaimChat *)cnode; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1725 |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1726 if (c->account == account) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1727 gaim_blist_remove_chat(c); |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1728 } |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1729 cnode = cnode_next; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1730 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1731 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1732 |
8235 | 1733 /* Remove this account's pounces */ |
1734 gaim_pounce_destroy_all_by_account(account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1735 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1736 gaim_account_destroy(account); |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1737 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1738 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1739 void |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1740 gaim_accounts_reorder(GaimAccount *account, size_t new_index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1741 { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1742 size_t index; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1743 GList *l; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1744 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1745 g_return_if_fail(account != NULL); |
5620
c9724982ce45
[gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents:
5610
diff
changeset
|
1746 g_return_if_fail(new_index >= 0 && new_index <= g_list_length(accounts)); |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1747 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1748 index = g_list_index(accounts, account); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1749 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1750 if (index == -1) { |
10309 | 1751 gaim_debug_error("accounts", |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1752 "Unregistered account (%s) discovered during reorder!\n", |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1753 gaim_account_get_username(account)); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1754 return; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1755 } |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1756 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1757 l = g_list_nth(accounts, index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1758 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1759 if (new_index > index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1760 new_index--; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1761 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1762 /* Remove the old one. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1763 accounts = g_list_delete_link(accounts, l); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1764 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1765 /* Insert it where it should go. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1766 accounts = g_list_insert(accounts, account, new_index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1767 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1768 schedule_accounts_save(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1769 } |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1770 |
5563 | 1771 GList * |
1772 gaim_accounts_get_all(void) | |
1773 { | |
1774 return accounts; | |
1775 } | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1776 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1777 GaimAccount * |
7132 | 1778 gaim_accounts_find(const char *name, const char *protocol_id) |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1779 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1780 GaimAccount *account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1781 GList *l; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1782 char *who; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1783 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1784 g_return_val_if_fail(name != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1785 |
7261 | 1786 who = g_strdup(gaim_normalize(NULL, name)); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1787 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1788 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1789 account = (GaimAccount *)l->data; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1790 |
7261 | 1791 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && |
7132 | 1792 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1793 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1794 break; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1795 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1796 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1797 account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1798 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1799 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1800 g_free(who); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1801 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1802 return account; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1803 } |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1804 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1805 void |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1806 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1807 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1808 account_ui_ops = ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1809 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1810 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1811 GaimAccountUiOps * |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1812 gaim_accounts_get_ui_ops(void) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1813 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1814 return account_ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1815 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1816 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1817 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1818 gaim_accounts_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1819 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1820 static int handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1821 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1822 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1823 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1824 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1825 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1826 gaim_accounts_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1827 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1828 void *handle = gaim_accounts_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1829 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1830 gaim_signal_register(handle, "account-connecting", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1831 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1832 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1833 GAIM_SUBTYPE_ACCOUNT)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1834 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1835 gaim_signal_register(handle, "account-away", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1836 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1837 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1838 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1839 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1840 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1841 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1842 gaim_signal_register(handle, "account-setting-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1843 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1844 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1845 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1846 gaim_value_new(GAIM_TYPE_STRING)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1847 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1848 gaim_signal_register(handle, "account-set-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1849 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1850 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1851 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1852 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1853 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1854 gaim_signal_register(handle, "account-warned", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1855 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1856 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1857 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1858 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1859 gaim_value_new(GAIM_TYPE_UINT)); |
8134 | 1860 |
1861 gaim_signal_register(handle, "account-added", | |
10447 | 1862 gaim_marshal_VOID__POINTER, NULL, 1, |
1863 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
8134 | 1864 |
1865 gaim_signal_register(handle, "account-removed", | |
10447 | 1866 gaim_marshal_VOID__POINTER, NULL, 1, |
1867 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
10490 | 1868 |
1869 load_accounts(); | |
1870 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1871 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1872 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1873 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1874 gaim_accounts_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1875 { |
10428 | 1876 if (save_timer != 0) |
10427 | 1877 { |
10428 | 1878 gaim_timeout_remove(save_timer); |
1879 save_timer = 0; | |
10427 | 1880 sync_accounts(); |
8235 | 1881 } |
1882 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1883 gaim_signals_unregister_by_instance(gaim_accounts_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1884 } |