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