annotate src/account.c @ 10711:00483ba950bf

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