Mercurial > pidgin
annotate src/account.c @ 11279:ed5302df41b0
[gaim-migrate @ 13474]
Patch by Sadrul Habib Chowdhury to fix tab dragging. Many thanks also to
Cae for helping to track down the exact behavior, and for helping to test
this patch so that Sadrul could provide a version that actually fixes the
bug. :-)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 16 Aug 2005 18:54:40 +0000 |
parents | bb0d7b719af2 |
children | f24541048a64 |
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 { | |
341 /* TODO: Do we need to call gaim_str_strip_cr(tmp) here? */ | |
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 } |
785 } | |
786 | |
787 | |
5563 | 788 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
789 delete_setting(void *data) |
5563 | 790 { |
791 GaimAccountSetting *setting = (GaimAccountSetting *)data; | |
792 | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
793 if (setting->ui != NULL) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
794 g_free(setting->ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
795 |
5563 | 796 if (setting->type == GAIM_PREF_STRING) |
797 g_free(setting->value.string); | |
798 | |
799 g_free(setting); | |
800 } | |
801 | |
802 GaimAccount * | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
803 gaim_account_new(const char *username, const char *protocol_id) |
5563 | 804 { |
6067 | 805 GaimAccount *account = NULL; |
10012 | 806 GaimPlugin *prpl = NULL; |
807 GaimPluginProtocolInfo *prpl_info = NULL; | |
5563 | 808 |
9944 | 809 g_return_val_if_fail(username != NULL, NULL); |
9971 | 810 g_return_val_if_fail(protocol_id != NULL, NULL); |
5563 | 811 |
9971 | 812 account = gaim_accounts_find(username, protocol_id); |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
813 |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
814 if (account != NULL) |
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
815 return account; |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
816 |
5563 | 817 account = g_new0(GaimAccount, 1); |
11146 | 818 GAIM_DBUS_REGISTER_POINTER(account, GaimAccount); |
5563 | 819 |
6067 | 820 gaim_account_set_username(account, username); |
821 | |
9971 | 822 gaim_account_set_protocol_id(account, protocol_id); |
5563 | 823 |
824 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
|
825 g_free, delete_setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
826 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
|
827 g_free, (GDestroyNotify)g_hash_table_destroy); |
8573 | 828 account->system_log = NULL; |
10944 | 829 /* 0 is not a valid privacy setting */ |
10945 | 830 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; |
10720 | 831 |
9944 | 832 account->presence = gaim_presence_new_for_account(account); |
833 | |
10447 | 834 prpl = gaim_find_prpl(protocol_id); |
10052 | 835 |
10012 | 836 if (prpl == NULL) |
837 return account; | |
10052 | 838 |
10738 | 839 /* TODO: Should maybe use gaim_prpl_get_statuses()? */ |
10012 | 840 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
10738 | 841 if (prpl_info != NULL && prpl_info->status_types != NULL) |
10012 | 842 gaim_account_set_status_types(account, prpl_info->status_types(account)); |
843 | |
10052 | 844 gaim_presence_set_status_active(account->presence, "offline", TRUE); |
845 | |
5563 | 846 return account; |
847 } | |
848 | |
849 void | |
850 gaim_account_destroy(GaimAccount *account) | |
851 { | |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
852 GList *l; |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
853 |
5563 | 854 g_return_if_fail(account != NULL); |
855 | |
9944 | 856 gaim_debug_info("account", "Destroying account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
857 |
10742 | 858 if (gaim_account_is_connected(account)) |
859 gaim_account_disconnect(account); | |
5563 | 860 |
9944 | 861 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
|
862 |
7324
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
863 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
864 { |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
865 GaimConversation *conv = (GaimConversation *)l->data; |
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 if (gaim_conversation_get_account(conv) == account) |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
868 gaim_conversation_set_account(conv, NULL); |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
869 } |
4963abdebd29
[gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents:
7263
diff
changeset
|
870 |
5643
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
871 if (account->username != NULL) g_free(account->username); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
872 if (account->alias != NULL) g_free(account->alias); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
873 if (account->password != NULL) g_free(account->password); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
874 if (account->user_info != NULL) g_free(account->user_info); |
eb685809108b
[gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents:
5620
diff
changeset
|
875 if (account->protocol_id != NULL) g_free(account->protocol_id); |
5563 | 876 |
877 g_hash_table_destroy(account->settings); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
878 g_hash_table_destroy(account->ui_settings); |
5563 | 879 |
9944 | 880 gaim_account_set_status_types(account, NULL); |
881 | |
882 gaim_presence_destroy(account->presence); | |
883 | |
8573 | 884 if(account->system_log) |
885 gaim_log_free(account->system_log); | |
886 | |
11067 | 887 GAIM_DBUS_UNREGISTER_POINTER(account); |
5563 | 888 g_free(account); |
889 } | |
890 | |
10740 | 891 void |
6581 | 892 gaim_account_register(GaimAccount *account) |
893 { | |
10740 | 894 g_return_if_fail(account != NULL); |
6581 | 895 |
10740 | 896 gaim_debug_info("account", "Registering account %s\n", |
897 gaim_account_get_username(account)); | |
6581 | 898 |
10740 | 899 gaim_connection_new(account, TRUE, NULL); |
900 } | |
6581 | 901 |
10740 | 902 static void |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
903 request_password_ok_cb(GaimAccount *account, GaimRequestFields *fields) |
10740 | 904 { |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
905 const char *entry; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
906 gboolean remember; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
907 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
908 entry = gaim_request_fields_get_string(fields, "password"); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
909 remember = gaim_request_fields_get_bool(fields, "remember"); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
910 |
10740 | 911 if (!entry || !*entry) |
912 { | |
913 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL); | |
914 return; | |
915 } | |
6581 | 916 |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
917 if(remember) |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
918 gaim_account_set_remember_password(account, TRUE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
919 |
10740 | 920 if (gaim_account_get_remember_password(account)) |
921 gaim_account_set_password(account, entry); | |
6581 | 922 |
10740 | 923 gaim_connection_new(account, FALSE, entry); |
6581 | 924 } |
925 | |
10740 | 926 static void |
927 request_password(GaimAccount *account) | |
928 { | |
929 gchar *primary; | |
930 const gchar *username; | |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
931 GaimRequestFieldGroup *group; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
932 GaimRequestField *field; |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
933 GaimRequestFields *fields; |
10740 | 934 |
10758 | 935 /* Close any previous password request windows */ |
936 gaim_request_close_with_handle(account); | |
937 | |
10740 | 938 username = gaim_account_get_username(account); |
10774 | 939 primary = g_strdup_printf(_("Enter password for %s (%s)"), username, |
10740 | 940 gaim_account_get_protocol_name(account)); |
11042
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
941 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
942 fields = gaim_request_fields_new(); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
943 group = gaim_request_field_group_new(NULL); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
944 gaim_request_fields_add_group(fields, group); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
945 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
946 field = gaim_request_field_string_new("password", _("Enter Password"), NULL, FALSE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
947 gaim_request_field_string_set_masked(field, TRUE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
948 gaim_request_field_set_required(field, TRUE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
949 gaim_request_field_group_add_field(group, field); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
950 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
951 field = gaim_request_field_bool_new("remember", _("Save password"), FALSE); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
952 gaim_request_field_group_add_field(group, field); |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
953 |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
954 gaim_request_fields(account, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
955 NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
956 primary, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
957 NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
958 fields, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
959 _("OK"), G_CALLBACK(request_password_ok_cb), |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
960 _("Cancel"), NULL, |
a5c31b83063f
[gaim-migrate @ 12954]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
961 account); |
10740 | 962 g_free(primary); |
963 } | |
964 | |
965 void | |
10738 | 966 gaim_account_connect(GaimAccount *account) |
5563 | 967 { |
10740 | 968 GaimPlugin *prpl; |
969 GaimPluginProtocolInfo *prpl_info; | |
970 const char *password; | |
971 | |
972 g_return_if_fail(account != NULL); | |
5563 | 973 |
10740 | 974 gaim_debug_info("account", "Connecting to account %s\n", |
975 gaim_account_get_username(account)); | |
5563 | 976 |
10740 | 977 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
978 if (prpl == NULL) | |
979 { | |
980 gchar *message; | |
6036 | 981 |
10740 | 982 message = g_strdup_printf(_("Missing protocol plugin for %s"), |
983 gaim_account_get_username(account)); | |
10758 | 984 gaim_notify_error(account, _("Connection Error"), message, NULL); |
10740 | 985 g_free(message); |
986 return; | |
987 } | |
5563 | 988 |
10740 | 989 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
990 password = gaim_account_get_password(account); | |
991 if ((password == NULL) && | |
992 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && | |
993 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) | |
994 request_password(account); | |
995 else | |
996 gaim_connection_new(account, FALSE, password); | |
5563 | 997 } |
998 | |
999 void | |
1000 gaim_account_disconnect(GaimAccount *account) | |
1001 { | |
5926
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
1002 GaimConnection *gc; |
6c22d37c6a3c
[gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
1003 |
5563 | 1004 g_return_if_fail(account != NULL); |
11251 | 1005 g_return_if_fail(!gaim_account_is_disconnected(account)); |
5563 | 1006 |
9944 | 1007 gaim_debug_info("account", "Disconnecting account %p\n", account); |
5930
03f1d6cd784c
[gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents:
5926
diff
changeset
|
1008 |
10384 | 1009 account->disconnecting = TRUE; |
5563 | 1010 |
10742 | 1011 gc = gaim_account_get_connection(account); |
1012 gaim_connection_destroy(gc); | |
1013 gaim_account_set_connection(account, NULL); | |
10384 | 1014 |
1015 account->disconnecting = FALSE; | |
5563 | 1016 } |
1017 | |
1018 void | |
7166 | 1019 gaim_account_notify_added(GaimAccount *account, const char *id, |
1020 const char *remote_user, const char *alias, | |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1021 const char *message) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1022 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1023 GaimAccountUiOps *ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1024 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1025 g_return_if_fail(account != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1026 g_return_if_fail(remote_user != NULL); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1027 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1028 ui_ops = gaim_accounts_get_ui_ops(); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1029 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1030 if (ui_ops != NULL && ui_ops->notify_added != NULL) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1031 ui_ops->notify_added(account, remote_user, id, alias, message); |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1032 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1033 |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1034 static void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1035 change_password_cb(GaimAccount *account, GaimRequestFields *fields) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1036 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1037 const char *orig_pass, *new_pass_1, *new_pass_2; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1038 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1039 orig_pass = gaim_request_fields_get_string(fields, "password"); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1040 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
|
1041 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
|
1042 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1043 if (g_utf8_collate(new_pass_1, new_pass_2)) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1044 { |
10758 | 1045 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1046 _("New passwords do not match."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1047 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1048 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1049 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1050 |
8638 | 1051 if (orig_pass == NULL || new_pass_1 == NULL || new_pass_2 == NULL || |
1052 *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
|
1053 { |
10758 | 1054 gaim_notify_error(account, NULL, |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1055 _("Fill out all fields completely."), NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1056 return; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1057 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1058 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1059 serv_change_passwd(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1060 orig_pass, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1061 gaim_account_set_password(account, new_pass_1); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1062 } |
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 void |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1065 gaim_account_request_change_password(GaimAccount *account) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1066 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1067 GaimRequestFields *fields; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1068 GaimRequestFieldGroup *group; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1069 GaimRequestField *field; |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1070 char primary[256]; |
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 g_return_if_fail(account != NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1073 g_return_if_fail(gaim_account_is_connected(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1074 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1075 fields = gaim_request_fields_new(); |
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 group = gaim_request_field_group_new(NULL); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1078 gaim_request_fields_add_group(fields, group); |
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 field = gaim_request_field_string_new("password", _("Original password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1081 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1082 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1083 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1084 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1085 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1086 field = gaim_request_field_string_new("new_password_1", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1087 _("New password"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1088 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1089 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1090 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1091 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1092 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1093 field = gaim_request_field_string_new("new_password_2", |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1094 _("New password (again)"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1095 NULL, FALSE); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1096 gaim_request_field_string_set_masked(field, TRUE); |
8638 | 1097 gaim_request_field_set_required(field, TRUE); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1098 gaim_request_field_group_add_field(group, field); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1099 |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1100 g_snprintf(primary, sizeof(primary), _("Change password for %s"), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1101 gaim_account_get_username(account)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1102 |
7755 | 1103 /* I'm sticking this somewhere in the code: bologna */ |
1104 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1105 gaim_request_fields(gaim_account_get_connection(account), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1106 NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1107 primary, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1108 _("Please enter your current password and your " |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1109 "new password."), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1110 fields, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1111 _("OK"), G_CALLBACK(change_password_cb), |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1112 _("Cancel"), NULL, |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1113 account); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1114 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7015
diff
changeset
|
1115 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1116 static void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1117 set_user_info_cb(GaimAccount *account, const char *user_info) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1118 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1119 GaimConnection *gc; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1120 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1121 gaim_account_set_user_info(account, user_info); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1122 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1123 gc = gaim_account_get_connection(account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1124 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1125 if (gc != NULL) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1126 serv_set_info(gaim_account_get_connection(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 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1129 void |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1130 gaim_account_request_change_user_info(GaimAccount *account) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1131 { |
8697 | 1132 GaimConnection *gc; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1133 char primary[256]; |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1134 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1135 g_return_if_fail(account != NULL); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1136 g_return_if_fail(gaim_account_is_connected(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1137 |
8697 | 1138 gc = gaim_account_get_connection(account); |
1139 | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1140 g_snprintf(primary, sizeof(primary), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1141 _("Change user information for %s"), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1142 gaim_account_get_username(account)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1143 |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1144 gaim_request_input(gaim_account_get_connection(account), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1145 NULL, primary, NULL, |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1146 gaim_account_get_user_info(account), |
8697 | 1147 TRUE, FALSE, ((gc != NULL) && |
1148 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL), | |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1149 _("Save"), G_CALLBACK(set_user_info_cb), |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1150 _("Cancel"), NULL, account); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1151 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1152 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1153 void |
5563 | 1154 gaim_account_set_username(GaimAccount *account, const char *username) |
1155 { | |
5711
e33778b9d395
[gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents:
5710
diff
changeset
|
1156 g_return_if_fail(account != NULL); |
5563 | 1157 |
10740 | 1158 g_free(account->username); |
5563 | 1159 account->username = (username == NULL ? NULL : g_strdup(username)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1160 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1161 schedule_accounts_save(); |
5563 | 1162 } |
1163 | |
1164 void | |
1165 gaim_account_set_password(GaimAccount *account, const char *password) | |
1166 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1167 g_return_if_fail(account != NULL); |
5563 | 1168 |
10740 | 1169 g_free(account->password); |
1170 account->password = NULL; | |
1171 | |
1172 if (!gaim_account_get_remember_password(account)) | |
1173 return; | |
5563 | 1174 |
1175 account->password = (password == NULL ? NULL : g_strdup(password)); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1176 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1177 schedule_accounts_save(); |
5563 | 1178 } |
1179 | |
1180 void | |
1181 gaim_account_set_alias(GaimAccount *account, const char *alias) | |
1182 { | |
1183 g_return_if_fail(account != NULL); | |
1184 | |
10740 | 1185 g_free(account->alias); |
5563 | 1186 account->alias = (alias == NULL ? NULL : g_strdup(alias)); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1187 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1188 schedule_accounts_save(); |
5563 | 1189 } |
1190 | |
1191 void | |
1192 gaim_account_set_user_info(GaimAccount *account, const char *user_info) | |
1193 { | |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1194 g_return_if_fail(account != NULL); |
5563 | 1195 |
10740 | 1196 g_free(account->user_info); |
5563 | 1197 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
|
1198 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1199 schedule_accounts_save(); |
5563 | 1200 } |
1201 | |
1202 void | |
1203 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) | |
1204 { | |
1205 g_return_if_fail(account != NULL); | |
1206 | |
10740 | 1207 g_free(account->buddy_icon); |
5563 | 1208 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); |
10740 | 1209 if (gaim_account_is_connected(account)) |
10742 | 1210 serv_set_buddyicon(gaim_account_get_connection(account), icon); |
10418 | 1211 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1212 schedule_accounts_save(); |
5563 | 1213 } |
1214 | |
1215 void | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1216 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1217 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1218 g_return_if_fail(account != NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1219 g_return_if_fail(protocol_id != NULL); |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1220 |
10740 | 1221 g_free(account->protocol_id); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1222 account->protocol_id = g_strdup(protocol_id); |
5665
132a30783c3d
[gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents:
5659
diff
changeset
|
1223 |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1224 schedule_accounts_save(); |
5563 | 1225 } |
1226 | |
1227 void | |
1228 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc) | |
1229 { | |
1230 g_return_if_fail(account != NULL); | |
1231 | |
1232 account->gc = gc; | |
1233 } | |
1234 | |
1235 void | |
1236 gaim_account_set_remember_password(GaimAccount *account, gboolean value) | |
1237 { | |
1238 g_return_if_fail(account != NULL); | |
1239 | |
1240 account->remember_pass = value; | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1241 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1242 schedule_accounts_save(); |
5563 | 1243 } |
1244 | |
1245 void | |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1246 gaim_account_set_check_mail(GaimAccount *account, gboolean value) |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1247 { |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1248 g_return_if_fail(account != NULL); |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1249 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1250 gaim_account_set_bool(account, "check-mail", value); |
5659
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1251 } |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1252 |
6b3214ab8632
[gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents:
5643
diff
changeset
|
1253 void |
10400 | 1254 gaim_account_set_enabled(GaimAccount *account, const char *ui, |
1255 gboolean value) | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1256 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1257 g_return_if_fail(account != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1258 g_return_if_fail(ui != NULL); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1259 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1260 gaim_account_set_ui_bool(account, ui, "auto-login", value); |
10862 | 1261 if (gaim_presence_is_online(account->presence)) |
1262 gaim_account_connect(account); | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1263 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1264 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1265 void |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1266 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1267 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1268 g_return_if_fail(account != NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1269 |
5695
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1270 if (account->proxy_info != NULL) |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1271 gaim_proxy_info_destroy(account->proxy_info); |
e42535701e25
[gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents:
5694
diff
changeset
|
1272 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1273 account->proxy_info = info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1274 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1275 schedule_accounts_save(); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1276 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1277 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1278 void |
9944 | 1279 gaim_account_set_status_types(GaimAccount *account, GList *status_types) |
1280 { | |
1281 g_return_if_fail(account != NULL); | |
1282 | |
10005 | 1283 /* Old with the old... */ |
9944 | 1284 if (account->status_types != NULL) |
1285 { | |
1286 GList *l; | |
1287 | |
1288 for (l = account->status_types; l != NULL; l = l->next) | |
1289 gaim_status_type_destroy((GaimStatusType *)l->data); | |
1290 | |
1291 g_list_free(account->status_types); | |
1292 } | |
1293 | |
10005 | 1294 /* In with the new... */ |
9944 | 1295 account->status_types = status_types; |
1296 } | |
1297 | |
1298 void | |
1299 gaim_account_set_status(GaimAccount *account, const char *status_id, | |
1300 gboolean active, ...) | |
1301 { | |
10738 | 1302 va_list args; |
1303 | |
1304 va_start(args, active); | |
1305 gaim_account_set_status_vargs(account, status_id, active, args); | |
1306 va_end(args); | |
1307 } | |
1308 | |
1309 void | |
1310 gaim_account_set_status_vargs(GaimAccount *account, const char *status_id, | |
1311 gboolean active, va_list args) | |
1312 { | |
11249 | 1313 GList *attrs = NULL; |
1314 const gchar *id; | |
1315 gpointer data; | |
1316 | |
1317 if (args != NULL) | |
1318 { | |
1319 while ((id = va_arg(args, const char *)) != NULL) | |
1320 { | |
1321 attrs = g_list_append(attrs, (char *)id); | |
1322 data = va_arg(args, void *); | |
1323 attrs = g_list_append(attrs, data); | |
1324 } | |
1325 } | |
1326 gaim_account_set_status_list(account, status_id, active, attrs); | |
1327 g_list_free(attrs); | |
1328 } | |
1329 | |
1330 void | |
1331 gaim_account_set_status_list(GaimAccount *account, const char *status_id, | |
1332 gboolean active, GList *attrs) | |
1333 { | |
9944 | 1334 GaimStatus *status; |
1335 | |
1336 g_return_if_fail(account != NULL); | |
1337 g_return_if_fail(status_id != NULL); | |
1338 | |
10760 | 1339 gaim_debug_info("account", "Changing status for %s, setting %s to %d\n", |
1340 gaim_account_get_username(account), status_id, active); | |
1341 | |
9944 | 1342 status = gaim_account_get_status(account, status_id); |
1343 if (status == NULL) | |
1344 { | |
10760 | 1345 gaim_debug_error("account", |
9944 | 1346 "Invalid status ID %s for account %s (%s)\n", |
1347 status_id, gaim_account_get_username(account), | |
1348 gaim_account_get_protocol_id(account)); | |
1349 return; | |
1350 } | |
10720 | 1351 |
10754 | 1352 if (active || gaim_status_is_independent(status)) |
11249 | 1353 gaim_status_set_active_with_attrs_list(status, active, attrs); |
10862 | 1354 |
1355 /* | |
1356 * Our current statuses are saved to accounts.xml (so that when we | |
1357 * reconnect, we go back to the previous status). | |
1358 */ | |
1359 schedule_accounts_save(); | |
9944 | 1360 } |
1361 | |
1362 void | |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1363 gaim_account_clear_settings(GaimAccount *account) |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1364 { |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1365 g_return_if_fail(account != NULL); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1366 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1367 g_hash_table_destroy(account->settings); |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1368 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1369 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
|
1370 g_free, delete_setting); |
5694
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1371 } |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1372 |
2d0d96c5a7a7
[gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1373 void |
5563 | 1374 gaim_account_set_int(GaimAccount *account, const char *name, int value) |
1375 { | |
1376 GaimAccountSetting *setting; | |
1377 | |
1378 g_return_if_fail(account != NULL); | |
1379 g_return_if_fail(name != NULL); | |
1380 | |
1381 setting = g_new0(GaimAccountSetting, 1); | |
1382 | |
1383 setting->type = GAIM_PREF_INT; | |
1384 setting->value.integer = value; | |
1385 | |
1386 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1387 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1388 schedule_accounts_save(); |
5563 | 1389 } |
1390 | |
1391 void | |
1392 gaim_account_set_string(GaimAccount *account, const char *name, | |
1393 const char *value) | |
1394 { | |
1395 GaimAccountSetting *setting; | |
1396 | |
1397 g_return_if_fail(account != NULL); | |
1398 g_return_if_fail(name != NULL); | |
1399 | |
1400 setting = g_new0(GaimAccountSetting, 1); | |
1401 | |
1402 setting->type = GAIM_PREF_STRING; | |
1403 setting->value.string = g_strdup(value); | |
1404 | |
1405 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1406 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1407 schedule_accounts_save(); |
5563 | 1408 } |
1409 | |
1410 void | |
1411 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value) | |
1412 { | |
1413 GaimAccountSetting *setting; | |
1414 | |
1415 g_return_if_fail(account != NULL); | |
1416 g_return_if_fail(name != NULL); | |
1417 | |
1418 setting = g_new0(GaimAccountSetting, 1); | |
1419 | |
1420 setting->type = GAIM_PREF_BOOLEAN; | |
1421 setting->value.bool = value; | |
1422 | |
1423 g_hash_table_insert(account->settings, g_strdup(name), setting); | |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1424 |
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1425 schedule_accounts_save(); |
5563 | 1426 } |
1427 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1428 static GHashTable * |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1429 get_ui_settings_table(GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1430 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1431 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1432 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1433 table = g_hash_table_lookup(account->ui_settings, ui); |
5979
49ae70ffcea5
[gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents:
5977
diff
changeset
|
1434 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1435 if (table == NULL) { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1436 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
|
1437 delete_setting); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1438 g_hash_table_insert(account->ui_settings, g_strdup(ui), table); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1439 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1440 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1441 return table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1442 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1443 |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1444 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1445 gaim_account_set_ui_int(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1446 const char *name, int value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1447 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1448 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1449 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1450 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1451 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1452 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1453 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1454 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1455 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1456 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1457 setting->type = GAIM_PREF_INT; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1458 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1459 setting->value.integer = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1460 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1461 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1462 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1463 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1464 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1465 schedule_accounts_save(); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1466 } |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1467 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1468 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1469 gaim_account_set_ui_string(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1470 const char *name, const char *value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1471 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1472 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1473 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1474 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1475 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1476 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1477 g_return_if_fail(name != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1478 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1479 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1480 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1481 setting->type = GAIM_PREF_STRING; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1482 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1483 setting->value.string = g_strdup(value); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1484 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1485 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1486 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1487 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1488 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1489 schedule_accounts_save(); |
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 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1492 void |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1493 gaim_account_set_ui_bool(GaimAccount *account, const char *ui, |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1494 const char *name, gboolean value) |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1495 { |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1496 GaimAccountSetting *setting; |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1497 GHashTable *table; |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1498 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1499 g_return_if_fail(account != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1500 g_return_if_fail(ui != NULL); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1501 g_return_if_fail(name != NULL); |
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 setting = g_new0(GaimAccountSetting, 1); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1504 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1505 setting->type = GAIM_PREF_BOOLEAN; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1506 setting->ui = g_strdup(ui); |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1507 setting->value.bool = value; |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1508 |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5792
diff
changeset
|
1509 table = get_ui_settings_table(account, ui); |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1510 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1511 g_hash_table_insert(table, g_strdup(name), setting); |
5777
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1512 |
1f786fb43ee6
[gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents:
5742
diff
changeset
|
1513 schedule_accounts_save(); |
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 |
11251 | 1516 static GaimConnectionState |
1517 gaim_account_get_state(const GaimAccount *account) | |
5563 | 1518 { |
9019 | 1519 GaimConnection *gc; |
1520 | |
11251 | 1521 g_return_val_if_fail(account != NULL, GAIM_DISCONNECTED); |
5563 | 1522 |
9019 | 1523 gc = gaim_account_get_connection(account); |
11251 | 1524 if (!gc) |
1525 return GAIM_DISCONNECTED; | |
9019 | 1526 |
11251 | 1527 return gaim_connection_get_state(gc); |
1528 } | |
1529 | |
1530 gboolean | |
1531 gaim_account_is_connected(const GaimAccount *account) | |
1532 { | |
1533 return (gaim_account_get_state(account) == GAIM_CONNECTED); | |
1534 } | |
1535 | |
1536 gboolean | |
1537 gaim_account_is_connecting(const GaimAccount *account) | |
1538 { | |
1539 return (gaim_account_get_state(account) == GAIM_CONNECTING); | |
1540 } | |
1541 | |
1542 gboolean | |
1543 gaim_account_is_disconnected(const GaimAccount *account) | |
1544 { | |
1545 return (gaim_account_get_state(account) == GAIM_DISCONNECTED); | |
5563 | 1546 } |
1547 | |
1548 const char * | |
1549 gaim_account_get_username(const GaimAccount *account) | |
1550 { | |
1551 g_return_val_if_fail(account != NULL, NULL); | |
1552 | |
1553 return account->username; | |
1554 } | |
1555 | |
1556 const char * | |
1557 gaim_account_get_password(const GaimAccount *account) | |
1558 { | |
1559 g_return_val_if_fail(account != NULL, NULL); | |
1560 | |
1561 return account->password; | |
1562 } | |
1563 | |
1564 const char * | |
1565 gaim_account_get_alias(const GaimAccount *account) | |
1566 { | |
1567 g_return_val_if_fail(account != NULL, NULL); | |
1568 | |
1569 return account->alias; | |
1570 } | |
1571 | |
1572 const char * | |
1573 gaim_account_get_user_info(const GaimAccount *account) | |
1574 { | |
1575 g_return_val_if_fail(account != NULL, NULL); | |
1576 | |
1577 return account->user_info; | |
1578 } | |
1579 | |
1580 const char * | |
1581 gaim_account_get_buddy_icon(const GaimAccount *account) | |
1582 { | |
1583 g_return_val_if_fail(account != NULL, NULL); | |
1584 | |
1585 return account->buddy_icon; | |
1586 } | |
1587 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1588 const char * |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1589 gaim_account_get_protocol_id(const GaimAccount *account) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1590 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1591 g_return_val_if_fail(account != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1592 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1593 return account->protocol_id; |
5563 | 1594 } |
1595 | |
9699 | 1596 const char * |
1597 gaim_account_get_protocol_name(const GaimAccount *account) | |
1598 { | |
9720 | 1599 GaimPlugin *p; |
1600 | |
9699 | 1601 g_return_val_if_fail(account != NULL, NULL); |
1602 | |
9989 | 1603 p = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
9988 | 1604 |
1605 return ((p && p->info->name) ? _(p->info->name) : _("Unknown")); | |
1606 } | |
1607 | |
5563 | 1608 GaimConnection * |
1609 gaim_account_get_connection(const GaimAccount *account) | |
1610 { | |
1611 g_return_val_if_fail(account != NULL, NULL); | |
1612 | |
1613 return account->gc; | |
1614 } | |
1615 | |
1616 gboolean | |
1617 gaim_account_get_remember_password(const GaimAccount *account) | |
1618 { | |
1619 g_return_val_if_fail(account != NULL, FALSE); | |
1620 | |
1621 return account->remember_pass; | |
1622 } | |
1623 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1624 gboolean |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1625 gaim_account_get_check_mail(const GaimAccount *account) |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1626 { |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1627 g_return_val_if_fail(account != NULL, FALSE); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1628 |
5977
2d34c02d2031
[gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents:
5953
diff
changeset
|
1629 return gaim_account_get_bool(account, "check-mail", FALSE); |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1630 } |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1631 |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1632 gboolean |
10400 | 1633 gaim_account_get_enabled(const GaimAccount *account, const char *ui) |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1634 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1635 g_return_val_if_fail(account != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1636 g_return_val_if_fail(ui != NULL, FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1637 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1638 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1639 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1640 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1641 GaimProxyInfo * |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1642 gaim_account_get_proxy_info(const GaimAccount *account) |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1643 { |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1644 g_return_val_if_fail(account != NULL, NULL); |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1645 |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1646 return account->proxy_info; |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1647 } |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5666
diff
changeset
|
1648 |
9944 | 1649 GaimStatus * |
10738 | 1650 gaim_account_get_active_status(const GaimAccount *account) |
1651 { | |
1652 g_return_val_if_fail(account != NULL, NULL); | |
1653 | |
1654 return gaim_presence_get_active_status(account->presence); | |
1655 } | |
1656 | |
1657 GaimStatus * | |
9944 | 1658 gaim_account_get_status(const GaimAccount *account, const char *status_id) |
1659 { | |
1660 g_return_val_if_fail(account != NULL, NULL); | |
1661 g_return_val_if_fail(status_id != NULL, NULL); | |
1662 | |
1663 return gaim_presence_get_status(account->presence, status_id); | |
1664 } | |
1665 | |
1666 GaimStatusType * | |
1667 gaim_account_get_status_type(const GaimAccount *account, const char *id) | |
1668 { | |
1669 const GList *l; | |
1670 | |
1671 g_return_val_if_fail(account != NULL, NULL); | |
1672 g_return_val_if_fail(id != NULL, NULL); | |
1673 | |
1674 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next) | |
1675 { | |
1676 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
1677 | |
1678 if (!strcmp(gaim_status_type_get_id(status_type), id)) | |
1679 return status_type; | |
1680 } | |
1681 | |
1682 return NULL; | |
1683 } | |
1684 | |
1685 GaimPresence * | |
1686 gaim_account_get_presence(const GaimAccount *account) | |
1687 { | |
1688 g_return_val_if_fail(account != NULL, NULL); | |
1689 | |
1690 return account->presence; | |
1691 } | |
1692 | |
1693 gboolean | |
1694 gaim_account_is_status_active(const GaimAccount *account, | |
1695 const char *status_id) | |
1696 { | |
1697 g_return_val_if_fail(account != NULL, FALSE); | |
1698 g_return_val_if_fail(status_id != NULL, FALSE); | |
1699 | |
1700 return gaim_presence_is_status_active(account->presence, status_id); | |
1701 } | |
1702 | |
1703 const GList * | |
1704 gaim_account_get_status_types(const GaimAccount *account) | |
1705 { | |
1706 g_return_val_if_fail(account != NULL, NULL); | |
1707 | |
1708 return account->status_types; | |
1709 } | |
1710 | |
5563 | 1711 int |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1712 gaim_account_get_int(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1713 int default_value) |
5563 | 1714 { |
1715 GaimAccountSetting *setting; | |
1716 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1717 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1718 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1719 |
1720 setting = g_hash_table_lookup(account->settings, name); | |
1721 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1722 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1723 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1724 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1725 g_return_val_if_fail(setting->type == GAIM_PREF_INT, default_value); |
5563 | 1726 |
1727 return setting->value.integer; | |
1728 } | |
1729 | |
1730 const char * | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1731 gaim_account_get_string(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1732 const char *default_value) |
5563 | 1733 { |
1734 GaimAccountSetting *setting; | |
1735 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1736 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1737 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1738 |
1739 setting = g_hash_table_lookup(account->settings, name); | |
1740 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1741 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1742 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1743 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1744 g_return_val_if_fail(setting->type == GAIM_PREF_STRING, default_value); |
5563 | 1745 |
1746 return setting->value.string; | |
1747 } | |
1748 | |
1749 gboolean | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1750 gaim_account_get_bool(const GaimAccount *account, const char *name, |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1751 gboolean default_value) |
5563 | 1752 { |
1753 GaimAccountSetting *setting; | |
1754 | |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1755 g_return_val_if_fail(account != NULL, default_value); |
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1756 g_return_val_if_fail(name != NULL, default_value); |
5563 | 1757 |
1758 setting = g_hash_table_lookup(account->settings, name); | |
1759 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1760 if (setting == NULL) |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1761 return default_value; |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
1762 |
5565
c3c4aaf69f65
[gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
1763 g_return_val_if_fail(setting->type == GAIM_PREF_BOOLEAN, default_value); |
5563 | 1764 |
1765 return setting->value.bool; | |
1766 } | |
1767 | |
5779
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1768 int |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1769 gaim_account_get_ui_int(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1770 const char *name, int default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1771 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1772 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1773 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1774 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1775 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1776 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1777 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1778 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1779 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1780 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1781 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1782 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1783 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1784 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1785 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
|
1786 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1787 return setting->value.integer; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1788 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1789 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1790 const char * |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1791 gaim_account_get_ui_string(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1792 const char *name, const char *default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1793 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1794 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1795 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1796 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1797 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1798 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1799 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1800 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1801 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1802 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1803 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1804 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1805 return default_value; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1806 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1807 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
|
1808 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1809 return setting->value.string; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1810 } |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1811 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1812 gboolean |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1813 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui, |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1814 const char *name, gboolean default_value) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1815 { |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1816 GaimAccountSetting *setting; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1817 GHashTable *table; |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1818 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1819 g_return_val_if_fail(account != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1820 g_return_val_if_fail(ui != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1821 g_return_val_if_fail(name != NULL, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1822 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1823 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1824 return 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 if ((setting = g_hash_table_lookup(table, name)) == NULL) |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1827 return default_value; |
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(setting->type == GAIM_PREF_BOOLEAN, default_value); |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1830 |
758fa27534b3
[gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents:
5777
diff
changeset
|
1831 return setting->value.bool; |
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 |
8573 | 1834 GaimLog * |
1835 gaim_account_get_log(GaimAccount *account) | |
1836 { | |
1837 g_return_val_if_fail(account != NULL, NULL); | |
1838 | |
1839 if(!account->system_log){ | |
8658 | 1840 GaimConnection *gc; |
1841 | |
1842 gc = gaim_account_get_connection(account); | |
1843 | |
8635 | 1844 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM, |
1845 gaim_account_get_username(account), account, | |
11014 | 1846 (gc != NULL && gc->login_time != 0) ? gc->login_time : time(NULL)); |
8573 | 1847 } |
1848 | |
1849 return account->system_log; | |
1850 } | |
1851 | |
1852 void | |
1853 gaim_account_destroy_log(GaimAccount *account) | |
1854 { | |
1855 g_return_if_fail(account != NULL); | |
1856 | |
1857 if(account->system_log){ | |
1858 gaim_log_free(account->system_log); | |
1859 account->system_log = NULL; | |
1860 } | |
1861 } | |
1862 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1863 void |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1864 gaim_accounts_add(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1865 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1866 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1867 |
5867
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1868 if (g_list_find(accounts, account) != NULL) |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1869 return; |
db4df0be06fd
[gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents:
5865
diff
changeset
|
1870 |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1871 accounts = g_list_append(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1872 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1873 schedule_accounts_save(); |
8134 | 1874 |
1875 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account); | |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1876 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1877 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1878 void |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1879 gaim_accounts_remove(GaimAccount *account) |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1880 { |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1881 g_return_if_fail(account != NULL); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1882 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1883 accounts = g_list_remove(accounts, account); |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1884 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1885 schedule_accounts_save(); |
8134 | 1886 |
1887 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1888 } |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1889 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1890 void |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1891 gaim_accounts_delete(GaimAccount *account) |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1892 { |
6695 | 1893 GaimBlistNode *gnode, *cnode, *bnode; |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1894 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1895 g_return_if_fail(account != NULL); |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1896 |
10758 | 1897 gaim_notify_close_with_handle(account); |
1898 gaim_request_close_with_handle(account); | |
1899 | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1900 gaim_accounts_remove(account); |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1901 |
8235 | 1902 /* Remove this account's buddies */ |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1903 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) { |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1904 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1905 continue; |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1906 |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1907 cnode = gnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1908 while (cnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1909 GaimBlistNode *cnode_next = cnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1910 |
6695 | 1911 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1912 bnode = cnode->child; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1913 while (bnode) { |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1914 GaimBlistNode *bnode_next = bnode->next; |
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1915 |
6695 | 1916 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { |
1917 GaimBuddy *b = (GaimBuddy *)bnode; | |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1918 |
6695 | 1919 if (b->account == account) |
1920 gaim_blist_remove_buddy(b); | |
1921 } | |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1922 bnode = bnode_next; |
6695 | 1923 } |
1924 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
1925 GaimChat *c = (GaimChat *)cnode; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1926 |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1927 if (c->account == account) |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1928 gaim_blist_remove_chat(c); |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1929 } |
10106
131f70fc53c1
[gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents:
10067
diff
changeset
|
1930 cnode = cnode_next; |
6367
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1931 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1932 } |
9fd154ca6a94
[gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents:
6366
diff
changeset
|
1933 |
8235 | 1934 /* Remove this account's pounces */ |
1935 gaim_pounce_destroy_all_by_account(account); | |
6368
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1936 |
41e6d15f4687
[gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents:
6367
diff
changeset
|
1937 gaim_account_destroy(account); |
5710
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1938 } |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1939 |
dbac958d8937
[gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents:
5707
diff
changeset
|
1940 void |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1941 gaim_accounts_reorder(GaimAccount *account, size_t new_index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1942 { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1943 size_t index; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1944 GList *l; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1945 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1946 g_return_if_fail(account != NULL); |
5620
c9724982ce45
[gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents:
5610
diff
changeset
|
1947 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
|
1948 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1949 index = g_list_index(accounts, account); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1950 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1951 if (index == -1) { |
10760 | 1952 gaim_debug_error("account", |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1953 "Unregistered account (%s) discovered during reorder!\n", |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1954 gaim_account_get_username(account)); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1955 return; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1956 } |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1957 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1958 l = g_list_nth(accounts, index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1959 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1960 if (new_index > index) |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1961 new_index--; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1962 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1963 /* Remove the old one. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1964 accounts = g_list_delete_link(accounts, l); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1965 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1966 /* Insert it where it should go. */ |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1967 accounts = g_list_insert(accounts, account, new_index); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1968 |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1969 schedule_accounts_save(); |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5574
diff
changeset
|
1970 } |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5565
diff
changeset
|
1971 |
5563 | 1972 GList * |
1973 gaim_accounts_get_all(void) | |
1974 { | |
1975 return accounts; | |
1976 } | |
5874
964e4f94fc56
[gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1977 |
11053
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1978 GList * |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1979 gaim_accounts_get_all_active(void) |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1980 { |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1981 GList *list = NULL; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1982 GList *all = gaim_accounts_get_all(); |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1983 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1984 while (all != NULL) { |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1985 GaimAccount *account = all->data; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1986 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1987 if (gaim_account_get_enabled(account, gaim_core_get_ui())) |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1988 list = g_list_append(list, account); |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1989 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1990 all = all->next; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1991 } |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1992 |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1993 return list; |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1994 } |
da05145441ca
[gaim-migrate @ 12991]
Richard Laager <rlaager@wiktel.com>
parents:
11042
diff
changeset
|
1995 |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1996 GaimAccount * |
7132 | 1997 gaim_accounts_find(const char *name, const char *protocol_id) |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1998 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
1999 GaimAccount *account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2000 GList *l; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2001 char *who; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2002 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2003 g_return_val_if_fail(name != NULL, NULL); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2004 |
7261 | 2005 who = g_strdup(gaim_normalize(NULL, name)); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2006 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2007 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2008 account = (GaimAccount *)l->data; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2009 |
7261 | 2010 if (!strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who) && |
7132 | 2011 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) { |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2012 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2013 break; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2014 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2015 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2016 account = NULL; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2017 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2018 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2019 g_free(who); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2020 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2021 return account; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5942
diff
changeset
|
2022 } |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2023 |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2024 void |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2025 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2026 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2027 account_ui_ops = ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2028 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2029 |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2030 GaimAccountUiOps * |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2031 gaim_accounts_get_ui_ops(void) |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2032 { |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2033 return account_ui_ops; |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2034 } |
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2035 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2036 void * |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2037 gaim_accounts_get_handle(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2038 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2039 static int handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2040 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2041 return &handle; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2042 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2043 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2044 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2045 gaim_accounts_init(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2046 { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2047 void *handle = gaim_accounts_get_handle(); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2048 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2049 gaim_signal_register(handle, "account-connecting", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2050 gaim_marshal_VOID__POINTER, NULL, 1, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2051 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2052 GAIM_SUBTYPE_ACCOUNT)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2053 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2054 gaim_signal_register(handle, "account-away", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2055 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2056 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2057 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2058 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2059 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2060 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2061 gaim_signal_register(handle, "account-setting-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2062 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2063 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2064 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2065 gaim_value_new(GAIM_TYPE_STRING)); |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2066 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2067 gaim_signal_register(handle, "account-set-info", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2068 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2069 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2070 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2071 gaim_value_new(GAIM_TYPE_STRING)); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2072 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2073 gaim_signal_register(handle, "account-warned", |
6564
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2074 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2075 gaim_value_new(GAIM_TYPE_SUBTYPE, |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2076 GAIM_SUBTYPE_ACCOUNT), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2077 gaim_value_new(GAIM_TYPE_STRING), |
800ef4a51096
[gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2078 gaim_value_new(GAIM_TYPE_UINT)); |
8134 | 2079 |
2080 gaim_signal_register(handle, "account-added", | |
10447 | 2081 gaim_marshal_VOID__POINTER, NULL, 1, |
2082 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
8134 | 2083 |
2084 gaim_signal_register(handle, "account-removed", | |
10447 | 2085 gaim_marshal_VOID__POINTER, NULL, 1, |
2086 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); | |
10490 | 2087 |
2088 load_accounts(); | |
2089 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2090 } |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2091 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2092 void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2093 gaim_accounts_uninit(void) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2094 { |
10428 | 2095 if (save_timer != 0) |
10427 | 2096 { |
10428 | 2097 gaim_timeout_remove(save_timer); |
2098 save_timer = 0; | |
10427 | 2099 sync_accounts(); |
8235 | 2100 } |
2101 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2102 gaim_signals_unregister_by_instance(gaim_accounts_get_handle()); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6368
diff
changeset
|
2103 } |