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