Mercurial > pidgin.yaz
annotate src/account.c @ 10921:9f75886e4f1f
[gaim-migrate @ 12688]
Buddy pounce commands now work in non-ASCII paths (win32)
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sun, 15 May 2005 18:55:28 +0000 |
parents | 885377f484b7 |
children | 4a4f2760a9ad |
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 | |
10760 | 281 node = xmlnode_new("account"); |
10427 | 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 { | |
10760 | 301 gaim_debug_error("account", "Attempted to save accounts before " |
10443 | 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 | |
10758 | 770 /* |
771 * TODO: Make the entry box a required field, and add a | |
772 * "save password" checkbox. | |
773 */ | |
10740 | 774 static void |
775 request_password(GaimAccount *account) | |
776 { | |
777 gchar *primary; | |
778 const gchar *username; | |
779 | |
10758 | 780 /* Close any previous password request windows */ |
781 gaim_request_close_with_handle(account); | |
782 | |
10740 | 783 username = gaim_account_get_username(account); |
10774 | 784 primary = g_strdup_printf(_("Enter password for %s (%s)"), username, |
10740 | 785 gaim_account_get_protocol_name(account)); |
786 gaim_request_input(account, _("Enter Password"), primary, NULL, NULL, | |
787 FALSE, TRUE, NULL, | |
788 _("OK"), G_CALLBACK(request_password_ok_cb), | |
789 _("Cancel"), NULL, account); | |
790 g_free(primary); | |
791 } | |
792 | |
793 void | |
10738 | 794 gaim_account_connect(GaimAccount *account) |
5563 | 795 { |
10740 | 796 GaimPlugin *prpl; |
797 GaimPluginProtocolInfo *prpl_info; | |
798 const char *password; | |
799 | |
800 g_return_if_fail(account != NULL); | |
5563 | 801 |
10740 | 802 gaim_debug_info("account", "Connecting to account %s\n", |
803 gaim_account_get_username(account)); | |
5563 | 804 |
10740 | 805 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
806 if (prpl == NULL) | |
807 { | |
808 gchar *message; | |
6036 | 809 |
10740 | 810 message = g_strdup_printf(_("Missing protocol plugin for %s"), |
811 gaim_account_get_username(account)); | |
10758 | 812 gaim_notify_error(account, _("Connection Error"), message, NULL); |
10740 | 813 g_free(message); |
814 return; | |
815 } | |
5563 | 816 |
10740 | 817 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
818 password = gaim_account_get_password(account); | |
819 if ((password == NULL) && | |
820 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && | |
821 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) | |
822 request_password(account); | |
823 else | |
824 gaim_connection_new(account, FALSE, password); | |
5563 | 825 } |
826 | |
827 void | |
828 gaim_account_disconnect(GaimAccount *account) | |
829 { | |
5926
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
830 GaimConnection *gc; |
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
831 |
5563 | 832 g_return_if_fail(account != NULL); |
833 g_return_if_fail(gaim_account_is_connected(account)); | |
834 | |
9944 | 835 gaim_debug_info("account", "Disconnecting account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
836 |
10384 | 837 account->disconnecting = TRUE; |
5563 | 838 |
10742 | 839 gc = gaim_account_get_connection(account); |
840 gaim_connection_destroy(gc); | |
841 gaim_account_set_connection(account, NULL); | |
10384 | 842 |
843 account->disconnecting = FALSE; | |
5563 | 844 } |
845 | |
846 void | |
7166 | 847 gaim_account_notify_added(GaimAccount *account, const char *id, |
848 const char *remote_user, const char *alias, | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
849 const char *message) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
850 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
851 GaimAccountUiOps *ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
852 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
853 g_return_if_fail(account != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
854 g_return_if_fail(remote_user != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
855 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
856 ui_ops = gaim_accounts_get_ui_ops(); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
857 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
858 if (ui_ops != NULL && ui_ops->notify_added != NULL) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
859 ui_ops->notify_added(account, remote_user, id, alias, message); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
860 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
861 |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
862 static void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
863 change_password_cb(GaimAccount *account, GaimRequestFields *fields) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
864 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
865 const char *orig_pass, *new_pass_1, *new_pass_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 orig_pass = gaim_request_fields_get_string(fields, "password"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
868 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
|
869 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
|
870 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
871 if (g_utf8_collate(new_pass_1, new_pass_2)) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
872 { |
10758 | 873 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
874 _("New passwords do not match."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
875 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
876 return; |
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 |
8638 | 879 if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL || |
880 *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
|
881 { |
10758 | 882 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
883 _("Fill out all fields completely."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
884 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
885 } |
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 serv_change_passwd(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
888 orig_pass, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
889 gaim_account_set_password(account, new_pass_1); |
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 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
892 void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
893 gaim_account_request_change_password(GaimAccount *account) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
894 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
895 GaimRequestFields *fields; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
896 GaimRequestFieldGroup *group; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
897 GaimRequestField *field; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
898 char primary[256]; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
899 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
900 g_return_if_fail(account != NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
901 g_return_if_fail(gaim_account_is_connected(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
902 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
903 fields = gaim_request_fields_new(); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
904 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
905 group = gaim_request_field_group_new(NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
906 gaim_request_fields_add_group(fields, group); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
907 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
908 field = gaim_request_field_string_new("password", _("Original password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
909 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
910 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 911 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
912 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
913 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
914 field = gaim_request_field_string_new("new_password_1", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
915 _("New password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
916 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
917 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 918 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
919 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
920 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
921 field = gaim_request_field_string_new("new_password_2", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
922 _("New password (again)"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
923 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
924 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 925 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
926 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
927 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
928 g_snprintf(primary, sizeof(primary), _("Change password for %s"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
929 gaim_account_get_username(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
930 |
7755 | 931 /* I'm sticking this somewhere in the code: bologna */ |
932 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
933 gaim_request_fields(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
934 NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
935 primary, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
936 _("Please enter your current password and your " |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
937 "new password."), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
938 fields, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
939 _("OK"), G_CALLBACK(change_password_cb), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
940 _("Cancel"), NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
941 account); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
942 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
943 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
944 static void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
945 set_user_info_cb(GaimAccount *account, const char *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 GaimConnection *gc; |
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 gaim_account_set_user_info(account, user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
950 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
951 gc = gaim_account_get_connection(account); |
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 if (gc != NULL) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
954 serv_set_info(gaim_account_get_connection(account), user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
955 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
956 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
957 void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
958 gaim_account_request_change_user_info(GaimAccount *account) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
959 { |
8697 | 960 GaimConnection *gc; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
961 char primary[256]; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
962 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
963 g_return_if_fail(account != NULL); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
964 g_return_if_fail(gaim_account_is_connected(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
965 |
8697 | 966 gc = gaim_account_get_connection(account); |
967 | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
968 g_snprintf(primary, sizeof(primary), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
969 _("Change user information for %s"), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
970 gaim_account_get_username(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
971 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
972 gaim_request_input(gaim_account_get_connection(account), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
973 NULL, primary, NULL, |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
974 gaim_account_get_user_info(account), |
8697 | 975 TRUE, FALSE, ((gc != NULL) && |
976 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL), | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
977 _("Save"), G_CALLBACK(set_user_info_cb), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
978 _("Cancel"), NULL, account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
979 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
980 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
981 void |
5563 | 982 gaim_account_set_username(GaimAccount *account, const char *username) |
983 { | |
5711
e33778b9d395
[gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents:
5710
diff
changeset
|
984 g_return_if_fail(account != NULL); |
5563 | 985 |
10740 | 986 g_free(account->username); |
5563 | 987 account->username = (username == NULL ? NULL : g_strdup(username)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
988 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
989 schedule_accounts_save(); |
5563 | 990 } |
991 | |
992 void | |
993 gaim_account_set_password(GaimAccount *account, const char *password) | |
994 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
995 g_return_if_fail(account != NULL); |
5563 | 996 |
10740 | 997 g_free(account->password); |
998 account->password = NULL; | |
999 | |
1000 if (!gaim_account_get_remember_password(account)) | |
1001 return; | |
5563 | 1002 |
1003 account->password = (password == NULL ? NULL : g_strdup(password)); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1004 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1005 schedule_accounts_save(); |
5563 | 1006 } |
1007 | |
1008 void | |
1009 gaim_account_set_alias(GaimAccount *account, const char *alias) | |
1010 { | |
1011 g_return_if_fail(account != NULL); | |
1012 | |
10740 | 1013 g_free(account->alias); |
5563 | 1014 account->alias = (alias == NULL ? NULL : g_strdup(alias)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1015 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1016 schedule_accounts_save(); |
5563 | 1017 } |
1018 | |
1019 void | |
1020 gaim_account_set_user_info(GaimAccount *account, const char *user_info) | |
1021 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1022 g_return_if_fail(account != NULL); |
5563 | 1023 |
10740 | 1024 g_free(account->user_info); |
5563 | 1025 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
|
1026 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1027 schedule_accounts_save(); |
5563 | 1028 } |
1029 | |
1030 void | |
1031 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) | |
1032 { | |
1033 g_return_if_fail(account != NULL); | |
1034 | |
10740 | 1035 g_free(account->buddy_icon); |
5563 | 1036 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); |
10740 | 1037 if (gaim_account_is_connected(account)) |
10742 | 1038 serv_set_buddyicon(gaim_account_get_connection(account), icon); |
10418 | 1039 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1040 schedule_accounts_save(); |
5563 | 1041 } |
1042 | |
1043 void | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1044 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1045 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1046 g_return_if_fail(account != NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1047 g_return_if_fail(protocol_id != NULL); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1048 |
10740 | 1049 g_free(account->protocol_id); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1050 account->protocol_id = g_strdup(protocol_id); |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
1051 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1052 schedule_accounts_save(); |
5563 | 1053 } |
1054 | |
1055 void | |
1056 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc) | |
1057 { | |
1058 g_return_if_fail(account != NULL); | |
1059 | |
1060 account->gc = gc; | |
1061 } | |
1062 | |
1063 void | |
1064 gaim_account_set_remember_password(GaimAccount *account, gboolean value) | |
1065 { | |
1066 g_return_if_fail(account != NULL); | |
1067 | |
1068 account->remember_pass = value; | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1069 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1070 schedule_accounts_save(); |
5563 | 1071 } |
1072 | |
1073 void | |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1074 gaim_account_set_check_mail(GaimAccount *account, gboolean value) |
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 g_return_if_fail(account != NULL); |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1077 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1078 gaim_account_set_bool(account, "check-mail", value); |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1079 } |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1080 |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1081 void |
10400 | 1082 gaim_account_set_enabled(GaimAccount *account, const char *ui, |
1083 gboolean value) | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1084 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1085 g_return_if_fail(account != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1086 g_return_if_fail(ui != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1087 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1088 gaim_account_set_ui_bool(account, ui, "auto-login", value); |
10862 | 1089 if (gaim_presence_is_online(account->presence)) |
1090 gaim_account_connect(account); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1091 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1092 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1093 void |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1094 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1095 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1096 g_return_if_fail(account != NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1097 |
5695
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1098 if (account->proxy_info != NULL) |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1099 gaim_proxy_info_destroy(account->proxy_info); |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1100 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1101 account->proxy_info = info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1102 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1103 schedule_accounts_save(); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1104 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1105 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1106 void |
9944 | 1107 gaim_account_set_status_types(GaimAccount *account, GList *status_types) |
1108 { | |
1109 g_return_if_fail(account != NULL); | |
1110 | |
10005 | 1111 /* Old with the old... */ |
9944 | 1112 if (account->status_types != NULL) |
1113 { | |
1114 GList *l; | |
1115 | |
1116 for (l = account->status_types; l != NULL; l = l->next) | |
1117 gaim_status_type_destroy((GaimStatusType *)l->data); | |
1118 | |
1119 g_list_free(account->status_types); | |
1120 } | |
1121 | |
10005 | 1122 /* In with the new... */ |
9944 | 1123 account->status_types = status_types; |
1124 } | |
1125 | |
1126 void | |
1127 gaim_account_set_status(GaimAccount *account, const char *status_id, | |
1128 gboolean active, ...) | |
1129 { | |
10738 | 1130 va_list args; |
1131 | |
1132 va_start(args, active); | |
1133 gaim_account_set_status_vargs(account, status_id, active, args); | |
1134 va_end(args); | |
1135 } | |
1136 | |
1137 void | |
1138 gaim_account_set_status_vargs(GaimAccount *account, const char *status_id, | |
1139 gboolean active, va_list args) | |
1140 { | |
9944 | 1141 GaimStatus *status; |
1142 | |
1143 g_return_if_fail(account != NULL); | |
1144 g_return_if_fail(status_id != NULL); | |
1145 | |
10760 | 1146 gaim_debug_info("account", "Changing status for %s, setting %s to %d\n", |
1147 gaim_account_get_username(account), status_id, active); | |
1148 | |
9944 | 1149 status = gaim_account_get_status(account, status_id); |
1150 if (status == NULL) | |
1151 { | |
10760 | 1152 gaim_debug_error("account", |
9944 | 1153 "Invalid status ID %s for account %s (%s)\n", |
1154 status_id, gaim_account_get_username(account), | |
1155 gaim_account_get_protocol_id(account)); | |
1156 return; | |
1157 } | |
10720 | 1158 |
10754 | 1159 if (active || gaim_status_is_independent(status)) |
1160 gaim_status_set_active_with_attrs(status, active, args); | |
10862 | 1161 |
1162 /* | |
1163 * Our current statuses are saved to accounts.xml (so that when we | |
1164 * reconnect, we go back to the previous status). | |
1165 */ | |
1166 schedule_accounts_save(); | |
9944 | 1167 } |
1168 | |
1169 void | |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1170 gaim_account_clear_settings(GaimAccount *account) |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1171 { |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1172 g_return_if_fail(account != NULL); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1173 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1174 g_hash_table_destroy(account->settings); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1175 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1176 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
|
1177 g_free, delete_setting); |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1178 } |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1179 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1180 void |
5563 | 1181 gaim_account_set_int(GaimAccount *account, const char *name, int value) |
1182 { | |
1183 GaimAccountSetting *setting; | |
1184 | |
1185 g_return_if_fail(account != NULL); | |
1186 g_return_if_fail(name != NULL); | |
1187 | |
1188 setting = g_new0(GaimAccountSetting, 1); | |
1189 | |
1190 setting->type = GAIM_PREF_INT; | |
1191 setting->value.integer = value; | |
1192 | |
1193 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1194 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1195 schedule_accounts_save(); |
5563 | 1196 } |
1197 | |
1198 void | |
1199 gaim_account_set_string(GaimAccount *account, const char *name, | |
1200 const char *value) | |
1201 { | |
1202 GaimAccountSetting *setting; | |
1203 | |
1204 g_return_if_fail(account != NULL); | |
1205 g_return_if_fail(name != NULL); | |
1206 | |
1207 setting = g_new0(GaimAccountSetting, 1); | |
1208 | |
1209 setting->type = GAIM_PREF_STRING; | |
1210 setting->value.string = g_strdup(value); | |
1211 | |
1212 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1213 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1214 schedule_accounts_save(); |
5563 | 1215 } |
1216 | |
1217 void | |
1218 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value) | |
1219 { | |
1220 GaimAccountSetting *setting; | |
1221 | |
1222 g_return_if_fail(account != NULL); | |
1223 g_return_if_fail(name != NULL); | |
1224 | |
1225 setting = g_new0(GaimAccountSetting, 1); | |
1226 | |
1227 setting->type = GAIM_PREF_BOOLEAN; | |
1228 setting->value.bool = value; | |
1229 | |
1230 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1231 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1232 schedule_accounts_save(); |
5563 | 1233 } |
1234 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1235 static GHashTable * |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1236 get_ui_settings_table(GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1237 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1238 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1239 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1240 table = g_hash_table_lookup(account->ui_settings, ui); |
5979
49ae70ffcea5
[gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents:
5977
diff
changeset
|
1241 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1242 if (table == NULL) { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1243 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
|
1244 delete_setting); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1245 g_hash_table_insert(account->ui_settings, g_strdup(ui), table); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1246 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1247 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1248 return table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1249 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1250 |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1251 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1252 gaim_account_set_ui_int(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1253 const char *name, int value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1254 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1255 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1256 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1257 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1258 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1259 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1260 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1261 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1262 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1263 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1264 setting->type = GAIM_PREF_INT; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1265 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1266 setting->value.integer = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1267 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1268 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1269 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1270 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1271 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1272 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1273 } |
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 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1276 gaim_account_set_ui_string(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1277 const char *name, const char *value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1278 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1279 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1280 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1281 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1282 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1283 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1284 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1285 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1286 setting = g_new0(GaimAccountSetting, 1); |
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 setting->type = GAIM_PREF_STRING; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1289 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1290 setting->value.string = g_strdup(value); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1291 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1292 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1293 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1294 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1295 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1296 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1297 } |
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 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1300 gaim_account_set_ui_bool(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1301 const char *name, gboolean value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1302 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1303 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1304 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1305 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1306 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1307 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1308 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1309 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1310 setting = g_new0(GaimAccountSetting, 1); |
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 setting->type = GAIM_PREF_BOOLEAN; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1313 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1314 setting->value.bool = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1315 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1316 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1317 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1318 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1319 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1320 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1321 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1322 |
5563 | 1323 gboolean |
1324 gaim_account_is_connected(const GaimAccount *account) | |
1325 { | |
9019 | 1326 GaimConnection *gc; |
1327 | |
5563 | 1328 g_return_val_if_fail(account != NULL, FALSE); |
1329 | |
9019 | 1330 gc = gaim_account_get_connection(account); |
1331 | |
10428 | 1332 /* TODO: The first way is better... but it doesn't work quite right yet */ |
9021 | 1333 /* return ((gc != NULL) && GAIM_CONNECTION_IS_CONNECTED(gc)); */ |
1334 return ((gc != NULL) && gaim_connection_get_state(gc) != GAIM_DISCONNECTED); | |
5563 | 1335 } |
1336 | |
1337 const char * | |
1338 gaim_account_get_username(const GaimAccount *account) | |
1339 { | |
1340 g_return_val_if_fail(account != NULL, NULL); | |
1341 | |
1342 return account->username; | |
1343 } | |
1344 | |
1345 const char * | |
1346 gaim_account_get_password(const GaimAccount *account) | |
1347 { | |
1348 g_return_val_if_fail(account != NULL, NULL); | |
1349 | |
1350 return account->password; | |
1351 } | |
1352 | |
1353 const char * | |
1354 gaim_account_get_alias(const GaimAccount *account) | |
1355 { | |
1356 g_return_val_if_fail(account != NULL, NULL); | |
1357 | |
1358 return account->alias; | |
1359 } | |
1360 | |
1361 const char * | |
1362 gaim_account_get_user_info(const GaimAccount *account) | |
1363 { | |
1364 g_return_val_if_fail(account != NULL, NULL); | |
1365 | |
1366 return account->user_info; | |
1367 } | |
1368 | |
1369 const char * | |
1370 gaim_account_get_buddy_icon(const GaimAccount *account) | |
1371 { | |
1372 g_return_val_if_fail(account != NULL, NULL); | |
1373 | |
1374 return account->buddy_icon; | |
1375 } | |
1376 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1377 const char * |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1378 gaim_account_get_protocol_id(const GaimAccount *account) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1379 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1380 g_return_val_if_fail(account != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1381 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1382 return account->protocol_id; |
5563 | 1383 } |
1384 | |
9699 | 1385 const char * |
1386 gaim_account_get_protocol_name(const GaimAccount *account) | |
1387 { | |
9720 | 1388 GaimPlugin *p; |
1389 | |
9699 | 1390 g_return_val_if_fail(account != NULL, NULL); |
1391 | |
9989 | 1392 p = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
9988 | 1393 |
1394 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); | |
1395 } | |
1396 | |
5563 | 1397 GaimConnection * |
1398 gaim_account_get_connection(const GaimAccount *account) | |
1399 { | |
1400 g_return_val_if_fail(account != NULL, NULL); | |
1401 | |
1402 return account->gc; | |
1403 } | |
1404 | |
1405 gboolean | |
1406 gaim_account_get_remember_password(const GaimAccount *account) | |
1407 { | |
1408 g_return_val_if_fail(account != NULL, FALSE); | |
1409 | |
1410 return account->remember_pass; | |
1411 } | |
1412 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1413 gboolean |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1414 gaim_account_get_check_mail(const GaimAccount *account) |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1415 { |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1416 g_return_val_if_fail(account != NULL, FALSE); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1417 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1418 return gaim_account_get_bool(account, "check-mail", FALSE); |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1419 } |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1420 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1421 gboolean |
10400 | 1422 gaim_account_get_enabled(const GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1423 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1424 g_return_val_if_fail(account != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1425 g_return_val_if_fail(ui != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1426 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1427 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1428 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1429 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1430 GaimProxyInfo * |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1431 gaim_account_get_proxy_info(const GaimAccount *account) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1432 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1433 g_return_val_if_fail(account != NULL, NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1434 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1435 return account->proxy_info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1436 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1437 |
9944 | 1438 GaimStatus * |
10738 | 1439 gaim_account_get_active_status(const GaimAccount *account) |
1440 { | |
1441 g_return_val_if_fail(account != NULL, NULL); | |
1442 | |
1443 return gaim_presence_get_active_status(account->presence); | |
1444 } | |
1445 | |
1446 GaimStatus * | |
9944 | 1447 gaim_account_get_status(const GaimAccount *account, const char *status_id) |
1448 { | |
1449 g_return_val_if_fail(account != NULL, NULL); | |
1450 g_return_val_if_fail(status_id != NULL, NULL); | |
1451 | |
1452 return gaim_presence_get_status(account->presence, status_id); | |
1453 } | |
1454 | |
1455 GaimStatusType * | |
1456 gaim_account_get_status_type(const GaimAccount *account, const char *id) | |
1457 { | |
1458 const GList *l; | |
1459 | |
1460 g_return_val_if_fail(account != NULL, NULL); | |
1461 g_return_val_if_fail(id != NULL, NULL); | |
1462 | |
1463 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
1464 { | |
1465 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
1466 | |
1467 if (!strcmp(gaim_status_type_get_id(status_type), id)) | |
1468 return status_type; | |
1469 } | |
1470 | |
1471 return NULL; | |
1472 } | |
1473 | |
1474 GaimPresence * | |
1475 gaim_account_get_presence(const GaimAccount *account) | |
1476 { | |
1477 g_return_val_if_fail(account != NULL, NULL); | |
1478 | |
1479 return account->presence; | |
1480 } | |
1481 | |
1482 gboolean | |
1483 gaim_account_is_status_active(const GaimAccount *account, | |
1484 const char *status_id) | |
1485 { | |
1486 g_return_val_if_fail(account != NULL, FALSE); | |
1487 g_return_val_if_fail(status_id != NULL, FALSE); | |
1488 | |
1489 return gaim_presence_is_status_active(account->presence, status_id); | |
1490 } | |
1491 | |
1492 const GList * | |
1493 gaim_account_get_status_types(const GaimAccount *account) | |
1494 { | |
1495 g_return_val_if_fail(account != NULL, NULL); | |
1496 | |
1497 return account->status_types; | |
1498 } | |
1499 | |
5563 | 1500 int |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1501 gaim_account_get_int(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1502 int default_value) |
5563 | 1503 { |
1504 GaimAccountSetting *setting; | |
1505 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1506 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1507 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1508 |
1509 setting = g_hash_table_lookup(account->settings, name); | |
1510 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1511 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1512 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1513 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1514 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
5563 | 1515 |
1516 return setting->value.integer; | |
1517 } | |
1518 | |
1519 const char * | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1520 gaim_account_get_string(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1521 const char *default_value) |
5563 | 1522 { |
1523 GaimAccountSetting *setting; | |
1524 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1525 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1526 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1527 |
1528 setting = g_hash_table_lookup(account->settings, name); | |
1529 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1530 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1531 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1532 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1533 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
5563 | 1534 |
1535 return setting->value.string; | |
1536 } | |
1537 | |
1538 gboolean | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1539 gaim_account_get_bool(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1540 gboolean default_value) |
5563 | 1541 { |
1542 GaimAccountSetting *setting; | |
1543 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1544 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1545 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1546 |
1547 setting = g_hash_table_lookup(account->settings, name); | |
1548 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1549 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1550 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1551 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1552 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
5563 | 1553 |
1554 return setting->value.bool; | |
1555 } | |
1556 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1557 int |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1558 gaim_account_get_ui_int(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1559 const char *name, int default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1560 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1561 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1562 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1563 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1564 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1565 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1566 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1567 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1568 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1569 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1570 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1571 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1572 return 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 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
|
1575 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1576 return setting->value.integer; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1577 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1578 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1579 const char * |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1580 gaim_account_get_ui_string(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1581 const char *name, const char *default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1582 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1583 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1584 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1585 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1586 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1587 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1588 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1589 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1590 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1591 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1592 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1593 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1594 return 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 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
|
1597 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1598 return setting->value.string; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1599 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1600 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1601 gboolean |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1602 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1603 const char *name, gboolean default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1604 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1605 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1606 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1607 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1608 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1609 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1610 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1611 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1612 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1613 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1614 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1615 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1616 return 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 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
|
1619 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1620 return setting->value.bool; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1621 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1622 |
8573 | 1623 GaimLog * |
1624 gaim_account_get_log(GaimAccount *account) | |
1625 { | |
1626 g_return_val_if_fail(account != NULL, NULL); | |
1627 | |
1628 if(!account->system_log){ | |
8658 | 1629 GaimConnection *gc; |
1630 | |
1631 gc = gaim_account_get_connection(account); | |
1632 | |
8635 | 1633 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, |
1634 gaim_account_get_username(account), account, | |
8658 | 1635 gc != NULL ? gc->login_time : time(NULL)); |
8573 | 1636 } |
1637 | |
1638 return account->system_log; | |
1639 } | |
1640 | |
1641 void | |
1642 gaim_account_destroy_log(GaimAccount *account) | |
1643 { | |
1644 g_return_if_fail(account != NULL); | |
1645 | |
1646 if(account->system_log){ | |
1647 gaim_log_free(account->system_log); | |
1648 account->system_log = NULL; | |
1649 } | |
1650 } | |
1651 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1652 void |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1653 gaim_accounts_add(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1654 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1655 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1656 |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1657 if (g_list_find(accounts, account) != NULL) |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1658 return; |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1659 |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1660 accounts = g_list_append(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1661 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1662 schedule_accounts_save(); |
8134 | 1663 |
1664 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account); | |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1665 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1666 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1667 void |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1668 gaim_accounts_remove(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1669 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1670 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1671 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1672 accounts = g_list_remove(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1673 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1674 schedule_accounts_save(); |
8134 | 1675 |
1676 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1677 } |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1678 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1679 void |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1680 gaim_accounts_delete(GaimAccount *account) |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1681 { |
6695 | 1682 GaimBlistNode *gnode, *cnode, *bnode; |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1683 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1684 g_return_if_fail(account != NULL); |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1685 |
10758 | 1686 gaim_notify_close_with_handle(account); |
1687 gaim_request_close_with_handle(account); | |
1688 | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1689 gaim_accounts_remove(account); |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1690 |
8235 | 1691 /* Remove this account's buddies */ |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1692 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) { |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1693 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1694 continue; |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1695 |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1696 cnode = gnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1697 while (cnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1698 GaimBlistNode *cnode_next = cnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1699 |
6695 | 1700 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1701 bnode = cnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1702 while (bnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1703 GaimBlistNode *bnode_next = bnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1704 |
6695 | 1705 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
1706 GaimBuddy *b = (GaimBuddy *)bnode; | |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1707 |
6695 | 1708 if (b->account == account) |
1709 gaim_blist_remove_buddy(b); | |
1710 } | |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1711 bnode = bnode_next; |
6695 | 1712 } |
1713 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1714 GaimChat *c = (GaimChat *)cnode; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1715 |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1716 if (c->account == account) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1717 gaim_blist_remove_chat(c); |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1718 } |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1719 cnode = cnode_next; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1720 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1721 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1722 |
8235 | 1723 /* Remove this account's pounces */ |
1724 gaim_pounce_destroy_all_by_account(account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1725 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1726 gaim_account_destroy(account); |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1727 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1728 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1729 void |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1730 gaim_accounts_reorder(GaimAccount *account, size_t new_index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1731 { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1732 size_t index; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1733 GList *l; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1734 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1735 g_return_if_fail(account != NULL); |
5620
c9724982ce45
[gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents:
5610
diff
changeset
|
1736 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
|
1737 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1738 index = g_list_index(accounts, account); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1739 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1740 if (index == -1) { |
10760 | 1741 gaim_debug_error("account", |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1742 "Unregistered account (%s) discovered during reorder!\n", |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1743 gaim_account_get_username(account)); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1744 return; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1745 } |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1746 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1747 l = g_list_nth(accounts, index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1748 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1749 if (new_index > index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1750 new_index--; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1751 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1752 /* Remove the old one. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1753 accounts = g_list_delete_link(accounts, l); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1754 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1755 /* Insert it where it should go. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1756 accounts = g_list_insert(accounts, account, new_index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1757 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1758 schedule_accounts_save(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1759 } |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1760 |
5563 | 1761 GList * |
1762 gaim_accounts_get_all(void) | |
1763 { | |
1764 return accounts; | |
1765 } | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1766 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1767 GaimAccount * |
7132 | 1768 gaim_accounts_find(const char *name, const char *protocol_id) |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1769 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1770 GaimAccount *account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1771 GList *l; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1772 char *who; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1773 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1774 g_return_val_if_fail(name != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1775 |
7261 | 1776 who = g_strdup(gaim_normalize(NULL, name)); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1777 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1778 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1779 account = (GaimAccount *)l->data; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1780 |
7261 | 1781 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && |
7132 | 1782 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { |
5943
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 break; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1785 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1786 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1787 account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1788 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1789 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1790 g_free(who); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1791 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1792 return account; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1793 } |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1794 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1795 void |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1796 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1797 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1798 account_ui_ops = ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1799 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1800 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1801 GaimAccountUiOps * |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1802 gaim_accounts_get_ui_ops(void) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1803 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1804 return account_ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1805 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1806 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1807 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1808 gaim_accounts_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1809 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1810 static int handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1811 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1812 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1813 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1814 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1815 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1816 gaim_accounts_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1817 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1818 void *handle = gaim_accounts_get_handle(); |
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 gaim_signal_register(handle, "account-connecting", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1821 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1822 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1823 GAIM_SUBTYPE_ACCOUNT)); |
6485
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 gaim_signal_register(handle, "account-away", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1826 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1827 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1828 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1829 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1830 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1831 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1832 gaim_signal_register(handle, "account-setting-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1833 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1834 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1835 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1836 gaim_value_new(GAIM_TYPE_STRING)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1837 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1838 gaim_signal_register(handle, "account-set-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1839 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1840 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1841 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1842 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1843 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1844 gaim_signal_register(handle, "account-warned", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1845 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1846 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1847 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1848 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
1849 gaim_value_new(GAIM_TYPE_UINT)); |
8134 | 1850 |
1851 gaim_signal_register(handle, "account-added", | |
10447 | 1852 gaim_marshal_VOID__POINTER, NULL, 1, |
1853 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
8134 | 1854 |
1855 gaim_signal_register(handle, "account-removed", | |
10447 | 1856 gaim_marshal_VOID__POINTER, NULL, 1, |
1857 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
10490 | 1858 |
1859 load_accounts(); | |
1860 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1861 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1862 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1863 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1864 gaim_accounts_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1865 { |
10428 | 1866 if (save_timer != 0) |
10427 | 1867 { |
10428 | 1868 gaim_timeout_remove(save_timer); |
1869 save_timer = 0; | |
10427 | 1870 sync_accounts(); |
8235 | 1871 } |
1872 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1873 gaim_signals_unregister_by_instance(gaim_accounts_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
1874 } |