Mercurial > pidgin
annotate src/account.c @ 11956:c8b8d4f8d070
[gaim-migrate @ 14247]
sf patch #1346502, from Levi Bard
"Make text repl attach to existing conversations on load"
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 03 Nov 2005 04:40:52 +0000 |
parents | 52f27ffe68a5 |
children | 0fab529c01fc |
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" |
11053
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
27 #include "core.h" |
11067 | 28 #include "dbus-maybe.h" |
5717 | 29 #include "debug.h" |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
30 #include "notify.h" |
8235 | 31 #include "pounce.h" |
5563 | 32 #include "prefs.h" |
10945 | 33 #include "privacy.h" |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
34 #include "prpl.h" |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
35 #include "request.h" |
9944 | 36 #include "server.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
37 #include "signals.h" |
9944 | 38 #include "status.h" |
5717 | 39 #include "util.h" |
10423 | 40 #include "xmlnode.h" |
5563 | 41 |
10429 | 42 /* TODO: Should use GaimValue instead of this? What about "ui"? */ |
5563 | 43 typedef struct |
44 { | |
45 GaimPrefType type; | |
46 | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
47 char *ui; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
48 |
5563 | 49 union |
50 { | |
51 int integer; | |
52 char *string; | |
53 gboolean bool; | |
54 | |
55 } value; | |
56 | |
57 } GaimAccountSetting; | |
58 | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
59 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
60 static GaimAccountUiOps *account_ui_ops = NULL; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
61 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
62 static GList *accounts = NULL; |
10428 | 63 static guint save_timer = 0; |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
64 static gboolean accounts_loaded = FALSE; |
5563 | 65 |
10427 | 66 |
10428 | 67 /********************************************************************* |
10429 | 68 * Writing to disk * |
10428 | 69 *********************************************************************/ |
10427 | 70 |
71 static void | |
72 setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
73 { | |
74 const char *name; | |
75 GaimAccountSetting *setting; | |
76 xmlnode *node, *child; | |
77 char buf[20]; | |
78 | |
79 name = (const char *)key; | |
80 setting = (GaimAccountSetting *)value; | |
81 node = (xmlnode *)user_data; | |
82 | |
83 child = xmlnode_new_child(node, "setting"); | |
84 xmlnode_set_attrib(child, "name", name); | |
85 | |
86 if (setting->type == GAIM_PREF_INT) { | |
87 xmlnode_set_attrib(child, "type", "int"); | |
88 snprintf(buf, sizeof(buf), "%d", setting->value.integer); | |
89 xmlnode_insert_data(child, buf, -1); | |
90 } | |
91 else if (setting->type == GAIM_PREF_STRING && setting->value.string != NULL) { | |
92 xmlnode_set_attrib(child, "type", "string"); | |
93 xmlnode_insert_data(child, setting->value.string, -1); | |
94 } | |
95 else if (setting->type == GAIM_PREF_BOOLEAN) { | |
96 xmlnode_set_attrib(child, "type", "bool"); | |
97 snprintf(buf, sizeof(buf), "%d", setting->value.bool); | |
98 xmlnode_insert_data(child, buf, -1); | |
99 } | |
100 } | |
101 | |
102 static void | |
103 ui_setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
104 { | |
105 const char *ui; | |
106 GHashTable *table; | |
107 xmlnode *node, *child; | |
108 | |
109 ui = (const char *)key; | |
110 table = (GHashTable *)value; | |
111 node = (xmlnode *)user_data; | |
112 | |
113 if (g_hash_table_size(table) > 0) | |
114 { | |
115 child = xmlnode_new_child(node, "settings"); | |
116 xmlnode_set_attrib(child, "ui", ui); | |
117 g_hash_table_foreach(table, setting_to_xmlnode, child); | |
118 } | |
119 } | |
120 | |
121 static xmlnode * | |
11249 | 122 status_attr_to_xmlnode(const GaimStatus *status, const GaimStatusType *type, const GaimStatusAttr *attr) |
123 { | |
124 xmlnode *node; | |
125 const char *id; | |
126 char *value = NULL; | |
127 GaimStatusAttr *default_attr; | |
128 GaimValue *default_value; | |
129 GaimType attr_type; | |
130 GaimValue *attr_value; | |
131 | |
132 id = gaim_status_attr_get_id(attr); | |
133 g_return_val_if_fail(id, NULL); | |
134 | |
135 attr_value = gaim_status_get_attr_value(status, id); | |
136 g_return_val_if_fail(attr_value, NULL); | |
137 attr_type = gaim_value_get_type(attr_value); | |
138 | |
139 /* | |
140 * If attr_value is a different type than it should be | |
141 * then don't write it to the file. | |
142 */ | |
143 default_attr = gaim_status_type_get_attr(type, id); | |
144 default_value = gaim_status_attr_get_value(default_attr); | |
145 if (attr_type != gaim_value_get_type(default_value)) | |
146 return NULL; | |
147 | |
148 /* | |
149 * If attr_value is the same as the default for this status | |
150 * then there is no need to write it to the file. | |
151 */ | |
152 if (attr_type == GAIM_TYPE_STRING) | |
153 { | |
154 const char *string_value = gaim_value_get_string(attr_value); | |
155 const char *default_string_value = gaim_value_get_string(default_value); | |
156 if (((string_value == NULL) && (default_string_value == NULL)) || | |
157 ((string_value != NULL) && (default_string_value != NULL) && | |
158 !strcmp(string_value, default_string_value))) | |
159 return NULL; | |
160 value = g_strdup(gaim_value_get_string(attr_value)); | |
161 } | |
162 else if (attr_type == GAIM_TYPE_INT) | |
163 { | |
164 int int_value = gaim_value_get_int(attr_value); | |
165 if (int_value == gaim_value_get_int(default_value)) | |
166 return NULL; | |
167 value = g_strdup_printf("%d", int_value); | |
168 } | |
169 else if (attr_type == GAIM_TYPE_BOOLEAN) | |
170 { | |
171 gboolean boolean_value = gaim_value_get_boolean(attr_value); | |
172 if (boolean_value == gaim_value_get_boolean(default_value)) | |
173 return NULL; | |
174 value = g_strdup(boolean_value ? | |
175 "true" : "false"); | |
176 } | |
177 else | |
178 { | |
179 return NULL; | |
180 } | |
181 | |
182 g_return_val_if_fail(value, NULL); | |
183 | |
184 node = xmlnode_new("attribute"); | |
185 | |
186 xmlnode_set_attrib(node, "id", id); | |
187 xmlnode_set_attrib(node, "value", value); | |
188 | |
189 g_free(value); | |
190 | |
191 return node; | |
192 } | |
193 | |
194 static xmlnode * | |
195 status_attrs_to_xmlnode(const GaimStatus *status) | |
196 { | |
197 GaimStatusType *type = gaim_status_get_type(status); | |
198 xmlnode *node, *child; | |
199 const GList *attrs, *attr; | |
200 | |
201 node = xmlnode_new("attributes"); | |
202 | |
203 attrs = gaim_status_type_get_attrs(type); | |
204 for (attr = attrs; attr != NULL; attr = attr->next) | |
205 { | |
206 child = status_attr_to_xmlnode(status, type, (const GaimStatusAttr *)attr->data); | |
207 if (child) | |
208 xmlnode_insert_child(node, child); | |
209 } | |
210 | |
211 return node; | |
212 } | |
213 | |
214 static xmlnode * | |
10738 | 215 status_to_xmlnode(const GaimStatus *status) |
216 { | |
11249 | 217 xmlnode *node, *child; |
10738 | 218 |
219 node = xmlnode_new("status"); | |
220 xmlnode_set_attrib(node, "type", gaim_status_get_id(status)); | |
221 if (gaim_status_get_name(status) != NULL) | |
222 xmlnode_set_attrib(node, "name", gaim_status_get_name(status)); | |
223 xmlnode_set_attrib(node, "active", gaim_status_is_active(status) ? "true" : "false"); | |
224 | |
11249 | 225 child = status_attrs_to_xmlnode(status); |
226 xmlnode_insert_child(node, child); | |
10738 | 227 |
228 return node; | |
229 } | |
230 | |
231 static xmlnode * | |
232 statuses_to_xmlnode(const GaimPresence *presence) | |
233 { | |
234 xmlnode *node, *child; | |
235 const GList *statuses, *status; | |
236 | |
237 node = xmlnode_new("statuses"); | |
238 | |
239 statuses = gaim_presence_get_statuses(presence); | |
240 for (status = statuses; status != NULL; status = status->next) | |
241 { | |
242 child = status_to_xmlnode((GaimStatus *)status->data); | |
243 xmlnode_insert_child(node, child); | |
244 } | |
245 | |
246 return node; | |
247 } | |
248 | |
249 static xmlnode * | |
10427 | 250 proxy_settings_to_xmlnode(GaimProxyInfo *proxy_info) |
251 { | |
252 xmlnode *node, *child; | |
253 GaimProxyType proxy_type; | |
254 const char *value; | |
255 int int_value; | |
256 char buf[20]; | |
257 | |
258 proxy_type = gaim_proxy_info_get_type(proxy_info); | |
259 | |
260 node = xmlnode_new("proxy"); | |
261 | |
262 child = xmlnode_new_child(node, "type"); | |
263 xmlnode_insert_data(child, | |
264 (proxy_type == GAIM_PROXY_USE_GLOBAL ? "global" : | |
265 proxy_type == GAIM_PROXY_NONE ? "none" : | |
266 proxy_type == GAIM_PROXY_HTTP ? "http" : | |
267 proxy_type == GAIM_PROXY_SOCKS4 ? "socks4" : | |
268 proxy_type == GAIM_PROXY_SOCKS5 ? "socks5" : | |
269 proxy_type == GAIM_PROXY_USE_ENVVAR ? "envvar" : "unknown"), -1); | |
270 | |
271 if (proxy_type != GAIM_PROXY_USE_GLOBAL && | |
272 proxy_type != GAIM_PROXY_NONE && | |
273 proxy_type != GAIM_PROXY_USE_ENVVAR) | |
274 { | |
275 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL) | |
276 { | |
277 child = xmlnode_new_child(node, "host"); | |
278 xmlnode_insert_data(child, value, -1); | |
279 } | |
280 | |
281 if ((int_value = gaim_proxy_info_get_port(proxy_info)) != 0) | |
282 { | |
283 snprintf(buf, sizeof(buf), "%d", int_value); | |
284 child = xmlnode_new_child(node, "port"); | |
285 xmlnode_insert_data(child, buf, -1); | |
286 } | |
287 | |
288 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL) | |
289 { | |
290 child = xmlnode_new_child(node, "username"); | |
291 xmlnode_insert_data(child, value, -1); | |
292 } | |
293 | |
294 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL) | |
295 { | |
296 child = xmlnode_new_child(node, "password"); | |
297 xmlnode_insert_data(child, value, -1); | |
298 } | |
299 } | |
300 | |
301 return node; | |
302 } | |
303 | |
304 static xmlnode * | |
305 account_to_xmlnode(GaimAccount *account) | |
306 { | |
307 xmlnode *node, *child; | |
308 const char *tmp; | |
10738 | 309 GaimPresence *presence; |
10427 | 310 GaimProxyInfo *proxy_info; |
311 | |
312 node = xmlnode_new("account"); | |
313 | |
314 child = xmlnode_new_child(node, "protocol"); | |
315 xmlnode_insert_data(child, gaim_account_get_protocol_id(account), -1); | |
316 | |
317 child = xmlnode_new_child(node, "name"); | |
318 xmlnode_insert_data(child, gaim_account_get_username(account), -1); | |
319 | |
320 if (gaim_account_get_remember_password(account) && | |
321 ((tmp = gaim_account_get_password(account)) != NULL)) | |
322 { | |
323 child = xmlnode_new_child(node, "password"); | |
324 xmlnode_insert_data(child, tmp, -1); | |
325 } | |
326 | |
327 if ((tmp = gaim_account_get_alias(account)) != NULL) | |
328 { | |
329 child = xmlnode_new_child(node, "alias"); | |
330 xmlnode_insert_data(child, tmp, -1); | |
331 } | |
332 | |
10738 | 333 if ((presence = gaim_account_get_presence(account)) != NULL) |
334 { | |
335 child = statuses_to_xmlnode(presence); | |
336 xmlnode_insert_child(node, child); | |
337 } | |
338 | |
10427 | 339 if ((tmp = gaim_account_get_user_info(account)) != NULL) |
340 { | |
11920 | 341 /* TODO: Do we need to call gaim_str_strip_char(tmp, '\r') here? */ |
10427 | 342 child = xmlnode_new_child(node, "userinfo"); |
343 xmlnode_insert_data(child, tmp, -1); | |
344 } | |
345 | |
346 if ((tmp = gaim_account_get_buddy_icon(account)) != NULL) | |
347 { | |
348 child = xmlnode_new_child(node, "buddyicon"); | |
349 xmlnode_insert_data(child, tmp, -1); | |
350 } | |
351 | |
352 if (g_hash_table_size(account->settings) > 0) | |
353 { | |
354 child = xmlnode_new_child(node, "settings"); | |
355 g_hash_table_foreach(account->settings, setting_to_xmlnode, child); | |
356 } | |
357 | |
358 if (g_hash_table_size(account->ui_settings) > 0) | |
359 { | |
360 g_hash_table_foreach(account->ui_settings, ui_setting_to_xmlnode, node); | |
361 } | |
362 | |
363 if ((proxy_info = gaim_account_get_proxy_info(account)) != NULL) | |
364 { | |
365 child = proxy_settings_to_xmlnode(proxy_info); | |
366 xmlnode_insert_child(node, child); | |
367 } | |
368 | |
369 return node; | |
370 } | |
371 | |
372 static xmlnode * | |
373 accounts_to_xmlnode(void) | |
374 { | |
375 xmlnode *node, *child; | |
376 GList *cur; | |
377 | |
10760 | 378 node = xmlnode_new("account"); |
10427 | 379 xmlnode_set_attrib(node, "version", "1.0"); |
380 | |
381 for (cur = gaim_accounts_get_all(); cur != NULL; cur = cur->next) | |
382 { | |
383 child = account_to_xmlnode(cur->data); | |
384 xmlnode_insert_child(node, child); | |
385 } | |
386 | |
387 return node; | |
388 } | |
389 | |
390 static void | |
391 sync_accounts(void) | |
392 { | |
393 xmlnode *node; | |
394 char *data; | |
395 | |
10428 | 396 if (!accounts_loaded) |
397 { | |
10760 | 398 gaim_debug_error("account", "Attempted to save accounts before " |
10443 | 399 "they were read!\n"); |
400 return; | |
10427 | 401 } |
402 | |
403 node = accounts_to_xmlnode(); | |
404 data = xmlnode_to_formatted_str(node, NULL); | |
405 gaim_util_write_data_to_file("accounts.xml", data, -1); | |
406 g_free(data); | |
407 xmlnode_free(node); | |
408 } | |
409 | |
410 static gboolean | |
411 save_cb(gpointer data) | |
412 { | |
413 sync_accounts(); | |
10428 | 414 save_timer = 0; |
10427 | 415 return FALSE; |
416 } | |
417 | |
418 static void | |
419 schedule_accounts_save() | |
420 { | |
10428 | 421 if (save_timer == 0) |
422 save_timer = gaim_timeout_add(5000, save_cb, NULL); | |
10427 | 423 } |
424 | |
425 | |
10428 | 426 /********************************************************************* |
427 * Reading from disk * | |
428 *********************************************************************/ | |
10427 | 429 |
430 static void | |
431 parse_settings(xmlnode *node, GaimAccount *account) | |
432 { | |
433 const char *ui; | |
434 xmlnode *child; | |
435 | |
436 /* Get the UI string, if these are UI settings */ | |
437 ui = xmlnode_get_attrib(node, "ui"); | |
438 | |
439 /* Read settings, one by one */ | |
440 for (child = xmlnode_get_child(node, "setting"); child != NULL; | |
441 child = xmlnode_get_next_twin(child)) | |
442 { | |
443 const char *name, *str_type; | |
444 GaimPrefType type; | |
445 char *data; | |
446 | |
447 name = xmlnode_get_attrib(child, "name"); | |
448 if (name == NULL) | |
449 /* Ignore this setting */ | |
450 continue; | |
451 | |
452 str_type = xmlnode_get_attrib(child, "type"); | |
10448 | 453 if (str_type == NULL) |
454 /* Ignore this setting */ | |
455 continue; | |
456 | |
10427 | 457 if (!strcmp(str_type, "string")) |
458 type = GAIM_PREF_STRING; | |
459 else if (!strcmp(str_type, "int")) | |
460 type = GAIM_PREF_INT; | |
461 else if (!strcmp(str_type, "bool")) | |
462 type = GAIM_PREF_BOOLEAN; | |
463 else | |
464 /* Ignore this setting */ | |
465 continue; | |
466 | |
467 data = xmlnode_get_data(child); | |
468 if (data == NULL) | |
469 /* Ignore this setting */ | |
470 continue; | |
471 | |
472 if (ui == NULL) | |
473 { | |
474 if (type == GAIM_PREF_STRING) | |
475 gaim_account_set_string(account, name, data); | |
476 else if (type == GAIM_PREF_INT) | |
477 gaim_account_set_int(account, name, atoi(data)); | |
478 else if (type == GAIM_PREF_BOOLEAN) | |
479 gaim_account_set_bool(account, name, | |
480 (*data == '0' ? FALSE : TRUE)); | |
481 } else { | |
482 if (type == GAIM_PREF_STRING) | |
483 gaim_account_set_ui_string(account, ui, name, data); | |
484 else if (type == GAIM_PREF_INT) | |
485 gaim_account_set_ui_int(account, ui, name, atoi(data)); | |
486 else if (type == GAIM_PREF_BOOLEAN) | |
487 gaim_account_set_ui_bool(account, ui, name, | |
488 (*data == '0' ? FALSE : TRUE)); | |
489 } | |
490 | |
491 g_free(data); | |
492 } | |
493 } | |
494 | |
11249 | 495 static GList * |
496 parse_status_attrs(xmlnode *node, GaimStatus *status) | |
497 { | |
498 GList *list = NULL; | |
499 xmlnode *child; | |
500 GaimValue *attr_value; | |
501 | |
502 for (child = xmlnode_get_child(node, "attribute"); child != NULL; | |
503 child = xmlnode_get_next_twin(child)) | |
504 { | |
505 const char *id = xmlnode_get_attrib(child, "id"); | |
506 const char *value = xmlnode_get_attrib(child, "value"); | |
507 | |
508 if (!id || !*id || !value || !*value) | |
509 continue; | |
510 | |
511 attr_value = gaim_status_get_attr_value(status, id); | |
512 if (!attr_value) | |
513 continue; | |
514 | |
515 list = g_list_append(list, (char *)id); | |
516 | |
517 switch (gaim_value_get_type(attr_value)) | |
518 { | |
519 case GAIM_TYPE_STRING: | |
520 list = g_list_append(list, (char *)value); | |
521 break; | |
522 case GAIM_TYPE_INT: | |
523 case GAIM_TYPE_BOOLEAN: | |
524 { | |
525 int v; | |
526 if (sscanf(value, "%d", &v) == 1) | |
527 list = g_list_append(list, GINT_TO_POINTER(v)); | |
528 else | |
529 list = g_list_remove(list, id); | |
530 break; | |
531 } | |
532 default: | |
533 break; | |
534 } | |
535 } | |
536 | |
537 return list; | |
538 } | |
539 | |
10427 | 540 static void |
10738 | 541 parse_status(xmlnode *node, GaimAccount *account) |
542 { | |
543 gboolean active = FALSE; | |
544 const char *data; | |
545 const char *type; | |
11249 | 546 xmlnode *child; |
547 GList *attrs = NULL; | |
10738 | 548 |
549 /* Get the active/inactive state */ | |
11075 | 550 data = xmlnode_get_attrib(node, "active"); |
11076 | 551 if (data == NULL) |
552 return; | |
553 if (strcasecmp(data, "true") == 0) | |
554 active = TRUE; | |
555 else if (strcasecmp(data, "false") == 0) | |
556 active = FALSE; | |
10738 | 557 else |
558 return; | |
559 | |
560 /* Get the type of the status */ | |
11075 | 561 type = xmlnode_get_attrib(node, "type"); |
562 if (type == NULL) | |
10738 | 563 return; |
564 | |
11249 | 565 /* Read attributes into a GList */ |
566 child = xmlnode_get_child(node, "attributes"); | |
567 if (child != NULL) | |
568 { | |
569 attrs = parse_status_attrs(child, | |
570 gaim_account_get_status(account, type)); | |
571 } | |
10738 | 572 |
11249 | 573 gaim_account_set_status_list(account, type, active, attrs); |
574 | |
575 g_list_free(attrs); | |
10738 | 576 } |
577 | |
578 static void | |
579 parse_statuses(xmlnode *node, GaimAccount *account) | |
580 { | |
581 xmlnode *child; | |
582 | |
583 for (child = xmlnode_get_child(node, "status"); child != NULL; | |
584 child = xmlnode_get_next_twin(child)) | |
585 { | |
586 parse_status(child, account); | |
587 } | |
588 } | |
589 | |
590 static void | |
10427 | 591 parse_proxy_info(xmlnode *node, GaimAccount *account) |
592 { | |
593 GaimProxyInfo *proxy_info; | |
594 xmlnode *child; | |
595 char *data; | |
596 | |
597 proxy_info = gaim_proxy_info_new(); | |
598 | |
599 /* Use the global proxy settings, by default */ | |
600 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
601 | |
602 /* Read proxy type */ | |
603 child = xmlnode_get_child(node, "type"); | |
604 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
605 { | |
606 if (!strcmp(data, "global")) | |
607 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL); | |
608 else if (!strcmp(data, "none")) | |
609 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_NONE); | |
610 else if (!strcmp(data, "http")) | |
611 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_HTTP); | |
612 else if (!strcmp(data, "socks4")) | |
613 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS4); | |
614 else if (!strcmp(data, "socks5")) | |
615 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS5); | |
616 else if (!strcmp(data, "envvar")) | |
617 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_ENVVAR); | |
618 else | |
619 { | |
620 gaim_debug_error("account", "Invalid proxy type found when " | |
621 "loading account information for %s\n", | |
622 gaim_account_get_username(account)); | |
623 } | |
624 g_free(data); | |
625 } | |
626 | |
627 /* Read proxy host */ | |
628 child = xmlnode_get_child(node, "host"); | |
629 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
630 { | |
631 gaim_proxy_info_set_host(proxy_info, data); | |
632 g_free(data); | |
633 } | |
634 | |
635 /* Read proxy port */ | |
636 child = xmlnode_get_child(node, "port"); | |
637 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
638 { | |
639 gaim_proxy_info_set_port(proxy_info, atoi(data)); | |
640 g_free(data); | |
641 } | |
642 | |
643 /* Read proxy username */ | |
644 child = xmlnode_get_child(node, "username"); | |
645 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
646 { | |
647 gaim_proxy_info_set_username(proxy_info, data); | |
648 g_free(data); | |
649 } | |
650 | |
651 /* Read proxy password */ | |
652 child = xmlnode_get_child(node, "password"); | |
653 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
654 { | |
655 gaim_proxy_info_set_password(proxy_info, data); | |
656 g_free(data); | |
657 } | |
658 | |
659 /* If there are no values set then proxy_infourn NULL */ | |
660 if ((gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_GLOBAL) && | |
661 (gaim_proxy_info_get_host(proxy_info) == NULL) && | |
662 (gaim_proxy_info_get_port(proxy_info) == 0) && | |
663 (gaim_proxy_info_get_username(proxy_info) == NULL) && | |
664 (gaim_proxy_info_get_password(proxy_info) == NULL)) | |
665 { | |
666 gaim_proxy_info_destroy(proxy_info); | |
667 return; | |
668 } | |
669 | |
670 gaim_account_set_proxy_info(account, proxy_info); | |
671 } | |
672 | |
673 static GaimAccount * | |
674 parse_account(xmlnode *node) | |
675 { | |
676 GaimAccount *ret; | |
677 xmlnode *child; | |
678 char *protocol_id = NULL; | |
679 char *name = NULL; | |
680 char *data; | |
681 | |
682 child = xmlnode_get_child(node, "protocol"); | |
683 if (child != NULL) | |
684 protocol_id = xmlnode_get_data(child); | |
685 | |
686 child = xmlnode_get_child(node, "name"); | |
687 if (child != NULL) | |
688 name = xmlnode_get_data(child); | |
689 if (name == NULL) | |
690 { | |
691 /* Do we really need to do this? */ | |
692 child = xmlnode_get_child(node, "username"); | |
693 if (child != NULL) | |
694 name = xmlnode_get_data(child); | |
695 } | |
696 | |
697 if ((protocol_id == NULL) || (name == NULL)) | |
698 { | |
699 free(protocol_id); | |
700 free(name); | |
701 return NULL; | |
702 } | |
703 | |
704 ret = gaim_account_new(name, protocol_id); | |
705 free(name); | |
706 free(protocol_id); | |
707 | |
708 /* Read the password */ | |
709 child = xmlnode_get_child(node, "password"); | |
710 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
711 { | |
10743 | 712 gaim_account_set_remember_password(ret, TRUE); |
10427 | 713 gaim_account_set_password(ret, data); |
714 g_free(data); | |
715 } | |
716 | |
717 /* Read the alias */ | |
718 child = xmlnode_get_child(node, "alias"); | |
719 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
720 { | |
11247 | 721 if (*data != '\0') |
722 gaim_account_set_alias(ret, data); | |
10427 | 723 g_free(data); |
724 } | |
725 | |
10738 | 726 /* Read the statuses */ |
727 child = xmlnode_get_child(node, "statuses"); | |
728 if (child != NULL) | |
729 { | |
730 parse_statuses(child, ret); | |
731 } | |
732 | |
10427 | 733 /* Read the userinfo */ |
734 child = xmlnode_get_child(node, "userinfo"); | |
735 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
736 { | |
737 gaim_account_set_user_info(ret, data); | |
738 g_free(data); | |
739 } | |
740 | |
741 /* Read the buddyicon */ | |
742 child = xmlnode_get_child(node, "buddyicon"); | |
743 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL)) | |
744 { | |
745 gaim_account_set_buddy_icon(ret, data); | |
746 g_free(data); | |
747 } | |
748 | |
749 /* Read settings (both core and UI) */ | |
750 for (child = xmlnode_get_child(node, "settings"); child != NULL; | |
751 child = xmlnode_get_next_twin(child)) | |
752 { | |
753 parse_settings(child, ret); | |
754 } | |
755 | |
756 /* Read proxy */ | |
757 child = xmlnode_get_child(node, "proxy"); | |
758 if (child != NULL) | |
759 { | |
760 parse_proxy_info(child, ret); | |
761 } | |
762 | |
763 return ret; | |
764 } | |
765 | |
766 static void | |
767 load_accounts(void) | |
768 { | |
769 xmlnode *node, *child; | |
770 | |
771 accounts_loaded = TRUE; | |
772 | |
773 node = gaim_util_read_xml_from_file("accounts.xml", _("accounts")); | |
774 | |
775 if (node == NULL) | |
776 return; | |
777 | |
778 for (child = xmlnode_get_child(node, "account"); child != NULL; | |
779 child = xmlnode_get_next_twin(child)) | |
780 { | |
10490 | 781 GaimAccount *new_acct; |
782 new_acct = parse_account(child); | |
783 gaim_accounts_add(new_acct); | |
10427 | 784 } |
11593
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
785 |
4b7fb30b8926
[gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11562
diff
changeset
|
786 xmlnode_free(node); |
10427 | 787 } |
788 | |
789 | |
5563 | 790 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
791 delete_setting(void *data) |
5563 | 792 { |
793 GaimAccountSetting *setting = (GaimAccountSetting *)data; | |
794 | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
795 if (setting->ui != NULL) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
796 g_free(setting->ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
797 |
5563 | 798 if (setting->type == GAIM_PREF_STRING) |
799 g_free(setting->value.string); | |
800 | |
801 g_free(setting); | |
802 } | |
803 | |
804 GaimAccount * | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
805 gaim_account_new(const char *username, const char *protocol_id) |
5563 | 806 { |
6067 | 807 GaimAccount *account = NULL; |
10012 | 808 GaimPlugin *prpl = NULL; |
809 GaimPluginProtocolInfo *prpl_info = NULL; | |
5563 | 810 |
9944 | 811 g_return_val_if_fail(username != NULL, NULL); |
9971 | 812 g_return_val_if_fail(protocol_id != NULL, NULL); |
5563 | 813 |
9971 | 814 account = gaim_accounts_find(username, protocol_id); |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
815 |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
816 if (account != NULL) |
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
817 return account; |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
818 |
5563 | 819 account = g_new0(GaimAccount, 1); |
11146 | 820 GAIM_DBUS_REGISTER_POINTER(account, GaimAccount); |
5563 | 821 |
6067 | 822 gaim_account_set_username(account, username); |
823 | |
9971 | 824 gaim_account_set_protocol_id(account, protocol_id); |
5563 | 825 |
826 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
|
827 g_free, delete_setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
828 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
|
829 g_free, (GDestroyNotify)g_hash_table_destroy); |
8573 | 830 account->system_log = NULL; |
10944 | 831 /* 0 is not a valid privacy setting */ |
10945 | 832 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; |
10720 | 833 |
9944 | 834 account->presence = gaim_presence_new_for_account(account); |
835 | |
10447 | 836 prpl = gaim_find_prpl(protocol_id); |
10052 | 837 |
10012 | 838 if (prpl == NULL) |
839 return account; | |
10052 | 840 |
10738 | 841 /* TODO: Should maybe use gaim_prpl_get_statuses()? */ |
10012 | 842 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
10738 | 843 if (prpl_info != NULL && prpl_info->status_types != NULL) |
10012 | 844 gaim_account_set_status_types(account, prpl_info->status_types(account)); |
845 | |
10052 | 846 gaim_presence_set_status_active(account->presence, "offline", TRUE); |
847 | |
5563 | 848 return account; |
849 } | |
850 | |
851 void | |
852 gaim_account_destroy(GaimAccount *account) | |
853 { | |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
854 GList *l; |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
855 |
5563 | 856 g_return_if_fail(account != NULL); |
857 | |
9944 | 858 gaim_debug_info("account", "Destroying account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
859 |
10742 | 860 if (gaim_account_is_connected(account)) |
861 gaim_account_disconnect(account); | |
5563 | 862 |
9944 | 863 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
|
864 |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
865 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
866 { |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
867 GaimConversation *conv = (GaimConversation *)l->data; |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
868 |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
869 if (gaim_conversation_get_account(conv) == account) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
870 gaim_conversation_set_account(conv, NULL); |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
871 } |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
872 |
5643
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
873 if (account->username != NULL) g_free(account->username); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
874 if (account->alias != NULL) g_free(account->alias); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
875 if (account->password != NULL) g_free(account->password); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
876 if (account->user_info != NULL) g_free(account->user_info); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
877 if (account->protocol_id != NULL) g_free(account->protocol_id); |
5563 | 878 |
879 g_hash_table_destroy(account->settings); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
880 g_hash_table_destroy(account->ui_settings); |
5563 | 881 |
9944 | 882 gaim_account_set_status_types(account, NULL); |
883 | |
884 gaim_presence_destroy(account->presence); | |
885 | |
8573 | 886 if(account->system_log) |
887 gaim_log_free(account->system_log); | |
888 | |
11067 | 889 GAIM_DBUS_UNREGISTER_POINTER(account); |
5563 | 890 g_free(account); |
891 } | |
892 | |
10740 | 893 void |
6581 | 894 gaim_account_register(GaimAccount *account) |
895 { | |
10740 | 896 g_return_if_fail(account != NULL); |
6581 | 897 |
10740 | 898 gaim_debug_info("account", "Registering account %s\n", |
899 gaim_account_get_username(account)); | |
6581 | 900 |
10740 | 901 gaim_connection_new(account, TRUE, NULL); |
902 } | |
6581 | 903 |
10740 | 904 static void |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
905 request_password_ok_cb(GaimAccount *account, GaimRequestFields *fields) |
10740 | 906 { |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
907 const char *entry; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
908 gboolean remember; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
909 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
910 entry = gaim_request_fields_get_string(fields, "password"); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
911 remember = gaim_request_fields_get_bool(fields, "remember"); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
912 |
10740 | 913 if (!entry || !*entry) |
914 { | |
915 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL); | |
916 return; | |
917 } | |
6581 | 918 |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
919 if(remember) |
11562 | 920 gaim_account_set_remember_password(account, TRUE); |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
921 |
11562 | 922 gaim_account_set_password(account, entry); |
6581 | 923 |
10740 | 924 gaim_connection_new(account, FALSE, entry); |
6581 | 925 } |
926 | |
10740 | 927 static void |
928 request_password(GaimAccount *account) | |
929 { | |
930 gchar *primary; | |
931 const gchar *username; | |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
932 GaimRequestFieldGroup *group; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
933 GaimRequestField *field; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
934 GaimRequestFields *fields; |
10740 | 935 |
10758 | 936 /* Close any previous password request windows */ |
937 gaim_request_close_with_handle(account); | |
938 | |
10740 | 939 username = gaim_account_get_username(account); |
10774 | 940 primary = g_strdup_printf(_("Enter password for %s (%s)"), username, |
10740 | 941 gaim_account_get_protocol_name(account)); |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
942 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
943 fields = gaim_request_fields_new(); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
944 group = gaim_request_field_group_new(NULL); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
945 gaim_request_fields_add_group(fields, group); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
946 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
947 field = gaim_request_field_string_new("password", _("Enter Password"), NULL, FALSE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
948 gaim_request_field_string_set_masked(field, TRUE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
949 gaim_request_field_set_required(field, TRUE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
950 gaim_request_field_group_add_field(group, field); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
951 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
952 field = gaim_request_field_bool_new("remember", _("Save password"), FALSE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
953 gaim_request_field_group_add_field(group, field); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
954 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
955 gaim_request_fields(account, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
956 NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
957 primary, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
958 NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
959 fields, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
960 _("OK"), G_CALLBACK(request_password_ok_cb), |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
961 _("Cancel"), NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
962 account); |
10740 | 963 g_free(primary); |
964 } | |
965 | |
966 void | |
10738 | 967 gaim_account_connect(GaimAccount *account) |
5563 | 968 { |
10740 | 969 GaimPlugin *prpl; |
970 GaimPluginProtocolInfo *prpl_info; | |
971 const char *password; | |
972 | |
973 g_return_if_fail(account != NULL); | |
5563 | 974 |
10740 | 975 gaim_debug_info("account", "Connecting to account %s\n", |
976 gaim_account_get_username(account)); | |
5563 | 977 |
11722 | 978 if (!gaim_account_get_enabled(account, gaim_core_get_ui())) |
979 return; | |
980 | |
10740 | 981 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
982 if (prpl == NULL) | |
983 { | |
984 gchar *message; | |
6036 | 985 |
10740 | 986 message = g_strdup_printf(_("Missing protocol plugin for %s"), |
987 gaim_account_get_username(account)); | |
10758 | 988 gaim_notify_error(account, _("Connection Error"), message, NULL); |
10740 | 989 g_free(message); |
990 return; | |
991 } | |
5563 | 992 |
10740 | 993 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
994 password = gaim_account_get_password(account); | |
995 if ((password == NULL) && | |
996 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && | |
997 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) | |
998 request_password(account); | |
999 else | |
1000 gaim_connection_new(account, FALSE, password); | |
5563 | 1001 } |
1002 | |
1003 void | |
1004 gaim_account_disconnect(GaimAccount *account) | |
1005 { | |
5926
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
1006 GaimConnection *gc; |
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
1007 |
5563 | 1008 g_return_if_fail(account != NULL); |
11251 | 1009 g_return_if_fail(!gaim_account_is_disconnected(account)); |
5563 | 1010 |
9944 | 1011 gaim_debug_info("account", "Disconnecting account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
1012 |
10384 | 1013 account->disconnecting = TRUE; |
5563 | 1014 |
10742 | 1015 gc = gaim_account_get_connection(account); |
1016 gaim_connection_destroy(gc); | |
11562 | 1017 if (!gaim_account_get_remember_password(account)) |
1018 gaim_account_set_password(account, NULL); | |
10742 | 1019 gaim_account_set_connection(account, NULL); |
10384 | 1020 |
1021 account->disconnecting = FALSE; | |
5563 | 1022 } |
1023 | |
1024 void | |
7166 | 1025 gaim_account_notify_added(GaimAccount *account, const char *id, |
1026 const char *remote_user, const char *alias, | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1027 const char *message) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1028 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1029 GaimAccountUiOps *ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1030 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1031 g_return_if_fail(account != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1032 g_return_if_fail(remote_user != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1033 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1034 ui_ops = gaim_accounts_get_ui_ops(); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1035 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1036 if (ui_ops != NULL && ui_ops->notify_added != NULL) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1037 ui_ops->notify_added(account, remote_user, id, alias, message); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1038 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1039 |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1040 static void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1041 change_password_cb(GaimAccount *account, GaimRequestFields *fields) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1042 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1043 const char *orig_pass, *new_pass_1, *new_pass_2; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1044 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1045 orig_pass = gaim_request_fields_get_string(fields, "password"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1046 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
|
1047 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
|
1048 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1049 if (g_utf8_collate(new_pass_1, new_pass_2)) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1050 { |
10758 | 1051 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1052 _("New passwords do not match."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1053 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1054 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1055 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1056 |
8638 | 1057 if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL || |
1058 *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
|
1059 { |
10758 | 1060 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1061 _("Fill out all fields completely."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1062 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1063 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1064 |
11643 | 1065 gaim_account_change_password(account, orig_pass, new_pass_1); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1066 gaim_account_set_password(account, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1067 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1068 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1069 void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1070 gaim_account_request_change_password(GaimAccount *account) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1071 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1072 GaimRequestFields *fields; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1073 GaimRequestFieldGroup *group; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1074 GaimRequestField *field; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1075 char primary[256]; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1076 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1077 g_return_if_fail(account != NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1078 g_return_if_fail(gaim_account_is_connected(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1079 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1080 fields = gaim_request_fields_new(); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1081 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1082 group = gaim_request_field_group_new(NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1083 gaim_request_fields_add_group(fields, group); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1084 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1085 field = gaim_request_field_string_new("password", _("Original password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1086 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1087 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1088 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1089 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1090 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1091 field = gaim_request_field_string_new("new_password_1", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1092 _("New password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1093 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1094 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1095 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1096 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1097 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1098 field = gaim_request_field_string_new("new_password_2", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1099 _("New password (again)"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1100 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1101 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1102 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1103 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1104 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1105 g_snprintf(primary, sizeof(primary), _("Change password for %s"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1106 gaim_account_get_username(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1107 |
7755 | 1108 /* I'm sticking this somewhere in the code: bologna */ |
1109 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1110 gaim_request_fields(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1111 NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1112 primary, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1113 _("Please enter your current password and your " |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1114 "new password."), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1115 fields, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1116 _("OK"), G_CALLBACK(change_password_cb), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1117 _("Cancel"), NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1118 account); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1119 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1120 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1121 static void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1122 set_user_info_cb(GaimAccount *account, const char *user_info) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1123 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1124 GaimConnection *gc; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1125 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1126 gaim_account_set_user_info(account, user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1127 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1128 gc = gaim_account_get_connection(account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1129 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1130 if (gc != NULL) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1131 serv_set_info(gaim_account_get_connection(account), user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1132 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1133 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1134 void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1135 gaim_account_request_change_user_info(GaimAccount *account) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1136 { |
8697 | 1137 GaimConnection *gc; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1138 char primary[256]; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1139 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1140 g_return_if_fail(account != NULL); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1141 g_return_if_fail(gaim_account_is_connected(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1142 |
8697 | 1143 gc = gaim_account_get_connection(account); |
1144 | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1145 g_snprintf(primary, sizeof(primary), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1146 _("Change user information for %s"), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1147 gaim_account_get_username(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1148 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1149 gaim_request_input(gaim_account_get_connection(account), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1150 NULL, primary, NULL, |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1151 gaim_account_get_user_info(account), |
8697 | 1152 TRUE, FALSE, ((gc != NULL) && |
1153 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL), | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1154 _("Save"), G_CALLBACK(set_user_info_cb), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1155 _("Cancel"), NULL, account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1156 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1157 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1158 void |
5563 | 1159 gaim_account_set_username(GaimAccount *account, const char *username) |
1160 { | |
5711
e33778b9d395
[gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents:
5710
diff
changeset
|
1161 g_return_if_fail(account != NULL); |
5563 | 1162 |
10740 | 1163 g_free(account->username); |
5563 | 1164 account->username = (username == NULL ? NULL : g_strdup(username)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1165 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1166 schedule_accounts_save(); |
5563 | 1167 } |
1168 | |
1169 void | |
1170 gaim_account_set_password(GaimAccount *account, const char *password) | |
1171 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1172 g_return_if_fail(account != NULL); |
5563 | 1173 |
10740 | 1174 g_free(account->password); |
1175 account->password = NULL; | |
5563 | 1176 account->password = (password == NULL ? NULL : g_strdup(password)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1177 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1178 schedule_accounts_save(); |
5563 | 1179 } |
1180 | |
1181 void | |
1182 gaim_account_set_alias(GaimAccount *account, const char *alias) | |
1183 { | |
1184 g_return_if_fail(account != NULL); | |
1185 | |
10740 | 1186 g_free(account->alias); |
5563 | 1187 account->alias = (alias == NULL ? NULL : g_strdup(alias)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1188 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1189 schedule_accounts_save(); |
5563 | 1190 } |
1191 | |
1192 void | |
1193 gaim_account_set_user_info(GaimAccount *account, const char *user_info) | |
1194 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1195 g_return_if_fail(account != NULL); |
5563 | 1196 |
10740 | 1197 g_free(account->user_info); |
5563 | 1198 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
|
1199 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1200 schedule_accounts_save(); |
5563 | 1201 } |
1202 | |
1203 void | |
1204 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) | |
1205 { | |
1206 g_return_if_fail(account != NULL); | |
1207 | |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1208 /* Delete an existing icon from the cache. */ |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1209 if (account->buddy_icon != NULL && (icon == NULL || strcmp(account->buddy_icon, icon))) |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1210 { |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1211 const char *dirname = gaim_buddy_icons_get_cache_dir(); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1212 struct stat st; |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1213 |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1214 if (g_stat(account->buddy_icon, &st) == 0) |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1215 { |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1216 /* The file exists. This is a full path. */ |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1217 |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1218 /* XXX: This is a hack so we only delete the file if it's |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1219 * in the cache dir. Otherwise, people who upgrade (who |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1220 * may have buddy icon filenames set outside of the cache |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1221 * dir) could lose files. */ |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1222 if (!strncmp(dirname, account->buddy_icon, strlen(dirname))) |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1223 g_unlink(account->buddy_icon); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1224 } |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1225 else |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1226 { |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1227 char *filename = g_build_filename(dirname, account->buddy_icon, NULL); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1228 g_unlink(filename); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1229 g_free(filename); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1230 } |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1231 } |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
1232 |
10740 | 1233 g_free(account->buddy_icon); |
5563 | 1234 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); |
10740 | 1235 if (gaim_account_is_connected(account)) |
11320
d3b567926e8f
[gaim-migrate @ 13523]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
1236 { |
d3b567926e8f
[gaim-migrate @ 13523]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
1237 char *filename = gaim_buddy_icons_get_full_path(icon); |
d3b567926e8f
[gaim-migrate @ 13523]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
1238 serv_set_buddyicon(gaim_account_get_connection(account), filename); |
d3b567926e8f
[gaim-migrate @ 13523]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
1239 g_free(filename); |
d3b567926e8f
[gaim-migrate @ 13523]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
1240 } |
10418 | 1241 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1242 schedule_accounts_save(); |
5563 | 1243 } |
1244 | |
1245 void | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1246 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1247 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1248 g_return_if_fail(account != NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1249 g_return_if_fail(protocol_id != NULL); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1250 |
10740 | 1251 g_free(account->protocol_id); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1252 account->protocol_id = g_strdup(protocol_id); |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
1253 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1254 schedule_accounts_save(); |
5563 | 1255 } |
1256 | |
1257 void | |
1258 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc) | |
1259 { | |
1260 g_return_if_fail(account != NULL); | |
1261 | |
1262 account->gc = gc; | |
1263 } | |
1264 | |
1265 void | |
1266 gaim_account_set_remember_password(GaimAccount *account, gboolean value) | |
1267 { | |
1268 g_return_if_fail(account != NULL); | |
1269 | |
1270 account->remember_pass = value; | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1271 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1272 schedule_accounts_save(); |
5563 | 1273 } |
1274 | |
1275 void | |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1276 gaim_account_set_check_mail(GaimAccount *account, gboolean value) |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1277 { |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1278 g_return_if_fail(account != NULL); |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1279 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1280 gaim_account_set_bool(account, "check-mail", value); |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1281 } |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1282 |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1283 void |
10400 | 1284 gaim_account_set_enabled(GaimAccount *account, const char *ui, |
1285 gboolean value) | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1286 { |
11638 | 1287 GaimConnection *gc; |
1288 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1289 g_return_if_fail(account != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1290 g_return_if_fail(ui != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1291 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1292 gaim_account_set_ui_bool(account, ui, "auto-login", value); |
11638 | 1293 gc = gaim_account_get_connection(account); |
1294 | |
1295 if ((gc != NULL) && (gc->wants_to_die == TRUE)) | |
1296 return; | |
1297 | |
11298 | 1298 if (value && gaim_presence_is_online(account->presence)) |
10862 | 1299 gaim_account_connect(account); |
11348 | 1300 else if (!value && !gaim_account_is_disconnected(account)) |
1301 gaim_account_disconnect(account); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1302 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1303 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1304 void |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1305 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1306 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1307 g_return_if_fail(account != NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1308 |
5695
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1309 if (account->proxy_info != NULL) |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1310 gaim_proxy_info_destroy(account->proxy_info); |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1311 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1312 account->proxy_info = info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1313 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1314 schedule_accounts_save(); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1315 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1316 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1317 void |
9944 | 1318 gaim_account_set_status_types(GaimAccount *account, GList *status_types) |
1319 { | |
1320 g_return_if_fail(account != NULL); | |
1321 | |
10005 | 1322 /* Old with the old... */ |
9944 | 1323 if (account->status_types != NULL) |
1324 { | |
1325 GList *l; | |
1326 | |
1327 for (l = account->status_types; l != NULL; l = l->next) | |
1328 gaim_status_type_destroy((GaimStatusType *)l->data); | |
1329 | |
1330 g_list_free(account->status_types); | |
1331 } | |
1332 | |
10005 | 1333 /* In with the new... */ |
9944 | 1334 account->status_types = status_types; |
1335 } | |
1336 | |
1337 void | |
1338 gaim_account_set_status(GaimAccount *account, const char *status_id, | |
1339 gboolean active, ...) | |
1340 { | |
10738 | 1341 va_list args; |
1342 | |
1343 va_start(args, active); | |
1344 gaim_account_set_status_vargs(account, status_id, active, args); | |
1345 va_end(args); | |
1346 } | |
1347 | |
1348 void | |
1349 gaim_account_set_status_vargs(GaimAccount *account, const char *status_id, | |
1350 gboolean active, va_list args) | |
1351 { | |
11249 | 1352 GList *attrs = NULL; |
1353 const gchar *id; | |
1354 gpointer data; | |
1355 | |
1356 if (args != NULL) | |
1357 { | |
1358 while ((id = va_arg(args, const char *)) != NULL) | |
1359 { | |
1360 attrs = g_list_append(attrs, (char *)id); | |
1361 data = va_arg(args, void *); | |
1362 attrs = g_list_append(attrs, data); | |
1363 } | |
1364 } | |
1365 gaim_account_set_status_list(account, status_id, active, attrs); | |
1366 g_list_free(attrs); | |
1367 } | |
1368 | |
1369 void | |
1370 gaim_account_set_status_list(GaimAccount *account, const char *status_id, | |
1371 gboolean active, GList *attrs) | |
1372 { | |
9944 | 1373 GaimStatus *status; |
1374 | |
1375 g_return_if_fail(account != NULL); | |
1376 g_return_if_fail(status_id != NULL); | |
1377 | |
1378 status = gaim_account_get_status(account, status_id); | |
1379 if (status == NULL) | |
1380 { | |
10760 | 1381 gaim_debug_error("account", |
9944 | 1382 "Invalid status ID %s for account %s (%s)\n", |
1383 status_id, gaim_account_get_username(account), | |
1384 gaim_account_get_protocol_id(account)); | |
1385 return; | |
1386 } | |
10720 | 1387 |
10754 | 1388 if (active || gaim_status_is_independent(status)) |
11249 | 1389 gaim_status_set_active_with_attrs_list(status, active, attrs); |
10862 | 1390 |
1391 /* | |
1392 * Our current statuses are saved to accounts.xml (so that when we | |
1393 * reconnect, we go back to the previous status). | |
1394 */ | |
1395 schedule_accounts_save(); | |
9944 | 1396 } |
1397 | |
1398 void | |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1399 gaim_account_clear_settings(GaimAccount *account) |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1400 { |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1401 g_return_if_fail(account != NULL); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1402 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1403 g_hash_table_destroy(account->settings); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1404 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1405 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
|
1406 g_free, delete_setting); |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1407 } |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1408 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1409 void |
5563 | 1410 gaim_account_set_int(GaimAccount *account, const char *name, int value) |
1411 { | |
1412 GaimAccountSetting *setting; | |
1413 | |
1414 g_return_if_fail(account != NULL); | |
1415 g_return_if_fail(name != NULL); | |
1416 | |
1417 setting = g_new0(GaimAccountSetting, 1); | |
1418 | |
1419 setting->type = GAIM_PREF_INT; | |
1420 setting->value.integer = value; | |
1421 | |
1422 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1423 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1424 schedule_accounts_save(); |
5563 | 1425 } |
1426 | |
1427 void | |
1428 gaim_account_set_string(GaimAccount *account, const char *name, | |
1429 const char *value) | |
1430 { | |
1431 GaimAccountSetting *setting; | |
1432 | |
1433 g_return_if_fail(account != NULL); | |
1434 g_return_if_fail(name != NULL); | |
1435 | |
1436 setting = g_new0(GaimAccountSetting, 1); | |
1437 | |
1438 setting->type = GAIM_PREF_STRING; | |
1439 setting->value.string = g_strdup(value); | |
1440 | |
1441 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1442 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1443 schedule_accounts_save(); |
5563 | 1444 } |
1445 | |
1446 void | |
1447 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value) | |
1448 { | |
1449 GaimAccountSetting *setting; | |
1450 | |
1451 g_return_if_fail(account != NULL); | |
1452 g_return_if_fail(name != NULL); | |
1453 | |
1454 setting = g_new0(GaimAccountSetting, 1); | |
1455 | |
1456 setting->type = GAIM_PREF_BOOLEAN; | |
1457 setting->value.bool = value; | |
1458 | |
1459 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1460 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1461 schedule_accounts_save(); |
5563 | 1462 } |
1463 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1464 static GHashTable * |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1465 get_ui_settings_table(GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1466 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1467 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1468 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1469 table = g_hash_table_lookup(account->ui_settings, ui); |
5979
49ae70ffcea5
[gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents:
5977
diff
changeset
|
1470 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1471 if (table == NULL) { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1472 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
|
1473 delete_setting); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1474 g_hash_table_insert(account->ui_settings, g_strdup(ui), table); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1475 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1476 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1477 return table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1478 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1479 |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1480 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1481 gaim_account_set_ui_int(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1482 const char *name, int value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1483 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1484 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1485 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1486 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1487 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1488 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1489 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1490 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1491 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1492 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1493 setting->type = GAIM_PREF_INT; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1494 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1495 setting->value.integer = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1496 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1497 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1498 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1499 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1500 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1501 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1502 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1503 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1504 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1505 gaim_account_set_ui_string(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1506 const char *name, const char *value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1507 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1508 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1509 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1510 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1511 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1512 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1513 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1514 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1515 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1516 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1517 setting->type = GAIM_PREF_STRING; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1518 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1519 setting->value.string = g_strdup(value); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1520 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1521 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1522 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1523 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1524 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1525 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1526 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1527 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1528 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1529 gaim_account_set_ui_bool(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1530 const char *name, gboolean value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1531 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1532 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1533 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1534 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1535 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1536 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1537 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1538 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1539 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1540 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1541 setting->type = GAIM_PREF_BOOLEAN; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1542 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1543 setting->value.bool = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1544 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1545 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1546 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1547 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1548 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1549 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1550 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1551 |
11251 | 1552 static GaimConnectionState |
1553 gaim_account_get_state(const GaimAccount *account) | |
5563 | 1554 { |
9019 | 1555 GaimConnection *gc; |
1556 | |
11251 | 1557 g_return_val_if_fail(account != NULL, GAIM_DISCONNECTED); |
5563 | 1558 |
9019 | 1559 gc = gaim_account_get_connection(account); |
11251 | 1560 if (!gc) |
1561 return GAIM_DISCONNECTED; | |
9019 | 1562 |
11251 | 1563 return gaim_connection_get_state(gc); |
1564 } | |
1565 | |
1566 gboolean | |
1567 gaim_account_is_connected(const GaimAccount *account) | |
1568 { | |
1569 return (gaim_account_get_state(account) == GAIM_CONNECTED); | |
1570 } | |
1571 | |
1572 gboolean | |
1573 gaim_account_is_connecting(const GaimAccount *account) | |
1574 { | |
1575 return (gaim_account_get_state(account) == GAIM_CONNECTING); | |
1576 } | |
1577 | |
1578 gboolean | |
1579 gaim_account_is_disconnected(const GaimAccount *account) | |
1580 { | |
1581 return (gaim_account_get_state(account) == GAIM_DISCONNECTED); | |
5563 | 1582 } |
1583 | |
1584 const char * | |
1585 gaim_account_get_username(const GaimAccount *account) | |
1586 { | |
1587 g_return_val_if_fail(account != NULL, NULL); | |
1588 | |
1589 return account->username; | |
1590 } | |
1591 | |
1592 const char * | |
1593 gaim_account_get_password(const GaimAccount *account) | |
1594 { | |
1595 g_return_val_if_fail(account != NULL, NULL); | |
1596 | |
1597 return account->password; | |
1598 } | |
1599 | |
1600 const char * | |
1601 gaim_account_get_alias(const GaimAccount *account) | |
1602 { | |
1603 g_return_val_if_fail(account != NULL, NULL); | |
1604 | |
1605 return account->alias; | |
1606 } | |
1607 | |
1608 const char * | |
1609 gaim_account_get_user_info(const GaimAccount *account) | |
1610 { | |
1611 g_return_val_if_fail(account != NULL, NULL); | |
1612 | |
1613 return account->user_info; | |
1614 } | |
1615 | |
1616 const char * | |
1617 gaim_account_get_buddy_icon(const GaimAccount *account) | |
1618 { | |
1619 g_return_val_if_fail(account != NULL, NULL); | |
1620 | |
1621 return account->buddy_icon; | |
1622 } | |
1623 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1624 const char * |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1625 gaim_account_get_protocol_id(const GaimAccount *account) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1626 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1627 g_return_val_if_fail(account != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1628 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1629 return account->protocol_id; |
5563 | 1630 } |
1631 | |
9699 | 1632 const char * |
1633 gaim_account_get_protocol_name(const GaimAccount *account) | |
1634 { | |
9720 | 1635 GaimPlugin *p; |
1636 | |
9699 | 1637 g_return_val_if_fail(account != NULL, NULL); |
1638 | |
9989 | 1639 p = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
9988 | 1640 |
1641 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); | |
1642 } | |
1643 | |
5563 | 1644 GaimConnection * |
1645 gaim_account_get_connection(const GaimAccount *account) | |
1646 { | |
1647 g_return_val_if_fail(account != NULL, NULL); | |
1648 | |
1649 return account->gc; | |
1650 } | |
1651 | |
1652 gboolean | |
1653 gaim_account_get_remember_password(const GaimAccount *account) | |
1654 { | |
1655 g_return_val_if_fail(account != NULL, FALSE); | |
1656 | |
1657 return account->remember_pass; | |
1658 } | |
1659 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1660 gboolean |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1661 gaim_account_get_check_mail(const GaimAccount *account) |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1662 { |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1663 g_return_val_if_fail(account != NULL, FALSE); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1664 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1665 return gaim_account_get_bool(account, "check-mail", FALSE); |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1666 } |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1667 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1668 gboolean |
10400 | 1669 gaim_account_get_enabled(const GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1670 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1671 g_return_val_if_fail(account != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1672 g_return_val_if_fail(ui != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1673 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1674 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1675 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1676 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1677 GaimProxyInfo * |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1678 gaim_account_get_proxy_info(const GaimAccount *account) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1679 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1680 g_return_val_if_fail(account != NULL, NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1681 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1682 return account->proxy_info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1683 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1684 |
9944 | 1685 GaimStatus * |
10738 | 1686 gaim_account_get_active_status(const GaimAccount *account) |
1687 { | |
1688 g_return_val_if_fail(account != NULL, NULL); | |
1689 | |
1690 return gaim_presence_get_active_status(account->presence); | |
1691 } | |
1692 | |
1693 GaimStatus * | |
9944 | 1694 gaim_account_get_status(const GaimAccount *account, const char *status_id) |
1695 { | |
1696 g_return_val_if_fail(account != NULL, NULL); | |
1697 g_return_val_if_fail(status_id != NULL, NULL); | |
1698 | |
1699 return gaim_presence_get_status(account->presence, status_id); | |
1700 } | |
1701 | |
1702 GaimStatusType * | |
1703 gaim_account_get_status_type(const GaimAccount *account, const char *id) | |
1704 { | |
1705 const GList *l; | |
1706 | |
1707 g_return_val_if_fail(account != NULL, NULL); | |
1708 g_return_val_if_fail(id != NULL, NULL); | |
1709 | |
1710 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
1711 { | |
1712 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
1713 | |
1714 if (!strcmp(gaim_status_type_get_id(status_type), id)) | |
1715 return status_type; | |
1716 } | |
1717 | |
1718 return NULL; | |
1719 } | |
1720 | |
11739 | 1721 GaimStatusType * |
1722 gaim_account_get_status_type_with_primitive(const GaimAccount *account, GaimStatusPrimitive primitive) | |
1723 { | |
1724 const GList *l; | |
1725 | |
1726 g_return_val_if_fail(account != NULL, NULL); | |
1727 | |
1728 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
1729 { | |
1730 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
1731 | |
1732 if (gaim_status_type_get_primitive(status_type) == primitive) | |
1733 return status_type; | |
1734 } | |
1735 | |
1736 return NULL; | |
1737 } | |
1738 | |
9944 | 1739 GaimPresence * |
1740 gaim_account_get_presence(const GaimAccount *account) | |
1741 { | |
1742 g_return_val_if_fail(account != NULL, NULL); | |
1743 | |
1744 return account->presence; | |
1745 } | |
1746 | |
1747 gboolean | |
1748 gaim_account_is_status_active(const GaimAccount *account, | |
1749 const char *status_id) | |
1750 { | |
1751 g_return_val_if_fail(account != NULL, FALSE); | |
1752 g_return_val_if_fail(status_id != NULL, FALSE); | |
1753 | |
1754 return gaim_presence_is_status_active(account->presence, status_id); | |
1755 } | |
1756 | |
1757 const GList * | |
1758 gaim_account_get_status_types(const GaimAccount *account) | |
1759 { | |
1760 g_return_val_if_fail(account != NULL, NULL); | |
1761 | |
1762 return account->status_types; | |
1763 } | |
1764 | |
5563 | 1765 int |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1766 gaim_account_get_int(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1767 int default_value) |
5563 | 1768 { |
1769 GaimAccountSetting *setting; | |
1770 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1771 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1772 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1773 |
1774 setting = g_hash_table_lookup(account->settings, name); | |
1775 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1776 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1777 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1778 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1779 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
5563 | 1780 |
1781 return setting->value.integer; | |
1782 } | |
1783 | |
1784 const char * | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1785 gaim_account_get_string(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1786 const char *default_value) |
5563 | 1787 { |
1788 GaimAccountSetting *setting; | |
1789 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1790 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1791 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1792 |
1793 setting = g_hash_table_lookup(account->settings, name); | |
1794 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1795 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1796 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1797 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1798 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
5563 | 1799 |
1800 return setting->value.string; | |
1801 } | |
1802 | |
1803 gboolean | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1804 gaim_account_get_bool(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1805 gboolean default_value) |
5563 | 1806 { |
1807 GaimAccountSetting *setting; | |
1808 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1809 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1810 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1811 |
1812 setting = g_hash_table_lookup(account->settings, name); | |
1813 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1814 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1815 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1816 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1817 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
5563 | 1818 |
1819 return setting->value.bool; | |
1820 } | |
1821 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1822 int |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1823 gaim_account_get_ui_int(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1824 const char *name, int default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1825 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1826 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1827 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1828 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1829 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1830 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1831 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1832 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1833 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1834 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1835 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1836 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1837 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1838 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1839 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
|
1840 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1841 return setting->value.integer; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1842 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1843 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1844 const char * |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1845 gaim_account_get_ui_string(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1846 const char *name, const char *default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1847 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1848 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1849 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1850 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1851 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1852 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1853 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1854 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1855 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1856 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1857 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1858 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1859 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1860 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1861 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
|
1862 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1863 return setting->value.string; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1864 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1865 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1866 gboolean |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1867 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1868 const char *name, gboolean default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1869 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1870 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1871 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1872 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1873 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1874 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1875 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1876 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1877 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1878 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1879 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1880 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1881 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1882 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1883 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
|
1884 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1885 return setting->value.bool; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1886 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1887 |
8573 | 1888 GaimLog * |
1889 gaim_account_get_log(GaimAccount *account) | |
1890 { | |
1891 g_return_val_if_fail(account != NULL, NULL); | |
1892 | |
1893 if(!account->system_log){ | |
8658 | 1894 GaimConnection *gc; |
1895 | |
1896 gc = gaim_account_get_connection(account); | |
1897 | |
8635 | 1898 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, |
11292
ef9280fdc511
[gaim-migrate @ 13492]
Richard Laager <rlaager@wiktel.com>
parents:
11284
diff
changeset
|
1899 gaim_account_get_username(account), account, NULL, |
11014 | 1900 (gc != NULL && gc->login_time != 0) ? gc->login_time : time(NULL)); |
8573 | 1901 } |
1902 | |
1903 return account->system_log; | |
1904 } | |
1905 | |
1906 void | |
1907 gaim_account_destroy_log(GaimAccount *account) | |
1908 { | |
1909 g_return_if_fail(account != NULL); | |
1910 | |
1911 if(account->system_log){ | |
1912 gaim_log_free(account->system_log); | |
1913 account->system_log = NULL; | |
1914 } | |
1915 } | |
1916 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1917 void |
11643 | 1918 gaim_account_add_buddy(GaimAccount *account, GaimBuddy *buddy) |
1919 { | |
1920 GaimPluginProtocolInfo *prpl_info = NULL; | |
1921 GaimConnection *gc = gaim_account_get_connection(account); | |
1922 | |
1923 if (gc != NULL && gc->prpl != NULL) | |
1924 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1925 | |
1926 if (prpl_info != NULL && g_list_find(gaim_connections_get_all(), gc) && | |
1927 prpl_info->add_buddy != NULL) | |
1928 prpl_info->add_buddy(gc, buddy, gaim_find_buddys_group(buddy)); | |
1929 } | |
1930 | |
1931 void | |
1932 gaim_account_add_buddies(GaimAccount *account, GList *buddies) | |
1933 { | |
1934 GaimPluginProtocolInfo *prpl_info = NULL; | |
1935 GaimConnection *gc = gaim_account_get_connection(account); | |
1936 | |
1937 if (gc != NULL && gc->prpl != NULL) | |
1938 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1939 | |
1940 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) { | |
1941 GList *cur, *groups = NULL; | |
1942 | |
1943 /* Make a list of what group each buddy is in */ | |
1944 for (cur = buddies; cur != NULL; cur = cur->next) { | |
1945 GaimBlistNode *node = cur->data; | |
1946 groups = g_list_append(groups, node->parent->parent); | |
1947 } | |
1948 | |
1949 if (prpl_info->add_buddies != NULL) | |
1950 prpl_info->add_buddies(gc, buddies, groups); | |
1951 else if (prpl_info->add_buddy != NULL) { | |
1952 GList *curb = buddies, *curg = groups; | |
1953 | |
1954 while ((curb != NULL) && (curg != NULL)) { | |
1955 prpl_info->add_buddy(gc, curb->data, curg->data); | |
1956 curb = curb->next; | |
1957 curg = curg->next; | |
1958 } | |
1959 } | |
1960 | |
1961 g_list_free(groups); | |
1962 } | |
1963 } | |
1964 | |
1965 void | |
1966 gaim_account_remove_buddy(GaimAccount *account, GaimBuddy *buddy, | |
1967 GaimGroup *group) | |
1968 { | |
1969 GaimPluginProtocolInfo *prpl_info = NULL; | |
1970 GaimConnection *gc = gaim_account_get_connection(account); | |
1971 | |
1972 if (gc != NULL && gc->prpl != NULL) | |
1973 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1974 | |
1975 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_buddy) | |
1976 prpl_info->remove_buddy(gc, buddy, group); | |
1977 } | |
1978 | |
1979 void | |
1980 gaim_account_remove_buddies(GaimAccount *account, GList *buddies, GList *groups) | |
1981 { | |
1982 GaimPluginProtocolInfo *prpl_info = NULL; | |
1983 GaimConnection *gc = gaim_account_get_connection(account); | |
1984 | |
1985 if (!g_list_find(gaim_connections_get_all(), gc)) | |
1986 return; | |
1987 | |
1988 if (gc != NULL && gc->prpl != NULL) | |
1989 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1990 | |
1991 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) { | |
1992 if (prpl_info->remove_buddies) | |
1993 prpl_info->remove_buddies(gc, buddies, groups); | |
1994 else { | |
1995 GList *curb = buddies; | |
1996 GList *curg = groups; | |
1997 while ((curb != NULL) && (curg != NULL)) { | |
1998 gaim_account_remove_buddy(account, curb->data, curg->data); | |
1999 curb = curb->next; | |
2000 curg = curg->next; | |
2001 } | |
2002 } | |
2003 } | |
2004 } | |
2005 | |
2006 void | |
2007 gaim_account_remove_group(GaimAccount *account, GaimGroup *group) | |
2008 { | |
2009 GaimPluginProtocolInfo *prpl_info = NULL; | |
2010 GaimConnection *gc = gaim_account_get_connection(account); | |
2011 | |
2012 if (gc != NULL && gc->prpl != NULL) | |
2013 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
2014 | |
2015 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_group) | |
2016 prpl_info->remove_group(gc, group); | |
2017 } | |
2018 | |
2019 void | |
2020 gaim_account_change_password(GaimAccount *account, const char *orig_pw, | |
2021 const char *new_pw) | |
2022 { | |
2023 GaimPluginProtocolInfo *prpl_info = NULL; | |
2024 GaimConnection *gc = gaim_account_get_connection(account); | |
2025 | |
2026 if (gc != NULL && gc->prpl != NULL) | |
2027 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
2028 | |
2029 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->change_passwd) | |
2030 prpl_info->change_passwd(gc, orig_pw, new_pw); | |
2031 } | |
2032 | |
2033 void | |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2034 gaim_accounts_add(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2035 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2036 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2037 |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
2038 if (g_list_find(accounts, account) != NULL) |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
2039 return; |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
2040 |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2041 accounts = g_list_append(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2042 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2043 schedule_accounts_save(); |
8134 | 2044 |
2045 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account); | |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2046 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2047 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2048 void |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2049 gaim_accounts_remove(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2050 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2051 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2052 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2053 accounts = g_list_remove(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2054 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2055 schedule_accounts_save(); |
8134 | 2056 |
2057 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2058 } |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2059 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2060 void |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2061 gaim_accounts_delete(GaimAccount *account) |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2062 { |
6695 | 2063 GaimBlistNode *gnode, *cnode, *bnode; |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2064 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2065 g_return_if_fail(account != NULL); |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2066 |
10758 | 2067 gaim_notify_close_with_handle(account); |
2068 gaim_request_close_with_handle(account); | |
2069 | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2070 gaim_accounts_remove(account); |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2071 |
8235 | 2072 /* Remove this account's buddies */ |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2073 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) { |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2074 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2075 continue; |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2076 |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2077 cnode = gnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2078 while (cnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2079 GaimBlistNode *cnode_next = cnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2080 |
6695 | 2081 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2082 bnode = cnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2083 while (bnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2084 GaimBlistNode *bnode_next = bnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2085 |
6695 | 2086 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
2087 GaimBuddy *b = (GaimBuddy *)bnode; | |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2088 |
6695 | 2089 if (b->account == account) |
2090 gaim_blist_remove_buddy(b); | |
2091 } | |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2092 bnode = bnode_next; |
6695 | 2093 } |
2094 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
2095 GaimChat *c = (GaimChat *)cnode; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2096 |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2097 if (c->account == account) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2098 gaim_blist_remove_chat(c); |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2099 } |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
2100 cnode = cnode_next; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2101 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2102 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
2103 |
8235 | 2104 /* Remove this account's pounces */ |
2105 gaim_pounce_destroy_all_by_account(account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2106 |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
2107 /* This will cause the deletion of an old buddy icon. */ |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
2108 gaim_account_set_buddy_icon(account, NULL); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11298
diff
changeset
|
2109 |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
2110 gaim_account_destroy(account); |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2111 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2112 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
2113 void |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2114 gaim_accounts_reorder(GaimAccount *account, size_t new_index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2115 { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2116 size_t index; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2117 GList *l; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2118 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2119 g_return_if_fail(account != NULL); |
5620
c9724982ce45
[gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents:
5610
diff
changeset
|
2120 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
|
2121 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2122 index = g_list_index(accounts, account); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2123 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2124 if (index == -1) { |
10760 | 2125 gaim_debug_error("account", |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2126 "Unregistered account (%s) discovered during reorder!\n", |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2127 gaim_account_get_username(account)); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2128 return; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2129 } |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2130 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2131 l = g_list_nth(accounts, index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2132 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2133 if (new_index > index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2134 new_index--; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2135 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2136 /* Remove the old one. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2137 accounts = g_list_delete_link(accounts, l); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2138 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2139 /* Insert it where it should go. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2140 accounts = g_list_insert(accounts, account, new_index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2141 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2142 schedule_accounts_save(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
2143 } |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
2144 |
5563 | 2145 GList * |
2146 gaim_accounts_get_all(void) | |
2147 { | |
2148 return accounts; | |
2149 } | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2150 |
11053
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2151 GList * |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2152 gaim_accounts_get_all_active(void) |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2153 { |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2154 GList *list = NULL; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2155 GList *all = gaim_accounts_get_all(); |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2156 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2157 while (all != NULL) { |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2158 GaimAccount *account = all->data; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2159 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2160 if (gaim_account_get_enabled(account, gaim_core_get_ui())) |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2161 list = g_list_append(list, account); |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2162 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2163 all = all->next; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2164 } |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2165 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2166 return list; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2167 } |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
2168 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2169 GaimAccount * |
7132 | 2170 gaim_accounts_find(const char *name, const char *protocol_id) |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2171 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2172 GaimAccount *account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2173 GList *l; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2174 char *who; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2175 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2176 g_return_val_if_fail(name != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2177 |
7261 | 2178 who = g_strdup(gaim_normalize(NULL, name)); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2179 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2180 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2181 account = (GaimAccount *)l->data; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2182 |
7261 | 2183 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && |
7132 | 2184 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2185 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2186 break; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2187 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2188 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2189 account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2190 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2191 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2192 g_free(who); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2193 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2194 return account; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2195 } |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2196 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2197 void |
11348 | 2198 gaim_accounts_restore_previous_statuses() |
2199 { | |
2200 GList *l; | |
2201 GaimAccount *account; | |
2202 | |
2203 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) | |
2204 { | |
2205 account = (GaimAccount *)l->data; | |
2206 if (gaim_account_get_enabled(account, gaim_core_get_ui()) && | |
2207 (gaim_presence_is_online(account->presence))) | |
2208 { | |
2209 gaim_account_connect(account); | |
2210 } | |
2211 } | |
2212 } | |
2213 | |
2214 void | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2215 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2216 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2217 account_ui_ops = ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2218 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2219 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2220 GaimAccountUiOps * |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2221 gaim_accounts_get_ui_ops(void) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2222 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2223 return account_ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2224 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2225 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2226 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2227 gaim_accounts_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2228 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2229 static int handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2230 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2231 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2232 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2233 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2234 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2235 gaim_accounts_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2236 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2237 void *handle = gaim_accounts_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2238 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2239 gaim_signal_register(handle, "account-connecting", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2240 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2241 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2242 GAIM_SUBTYPE_ACCOUNT)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2243 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2244 gaim_signal_register(handle, "account-setting-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2245 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2246 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2247 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2248 gaim_value_new(GAIM_TYPE_STRING)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2249 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2250 gaim_signal_register(handle, "account-set-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2251 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2252 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2253 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2254 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2255 |
8134 | 2256 gaim_signal_register(handle, "account-added", |
10447 | 2257 gaim_marshal_VOID__POINTER, NULL, 1, |
2258 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
8134 | 2259 |
2260 gaim_signal_register(handle, "account-removed", | |
10447 | 2261 gaim_marshal_VOID__POINTER, NULL, 1, |
2262 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
10490 | 2263 |
11628 | 2264 gaim_signal_register(handle, "account-status-changed", |
2265 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, | |
2266 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
2267 GAIM_SUBTYPE_ACCOUNT), | |
2268 gaim_value_new(GAIM_TYPE_POINTER), | |
2269 gaim_value_new(GAIM_TYPE_POINTER)); | |
2270 | |
10490 | 2271 load_accounts(); |
2272 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2273 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2274 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2275 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2276 gaim_accounts_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2277 { |
10428 | 2278 if (save_timer != 0) |
10427 | 2279 { |
10428 | 2280 gaim_timeout_remove(save_timer); |
2281 save_timer = 0; | |
10427 | 2282 sync_accounts(); |
8235 | 2283 } |
2284 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2285 gaim_signals_unregister_by_instance(gaim_accounts_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2286 } |