annotate src/account.c @ 10429:e41f0668a648

[gaim-migrate @ 11681] blist.xml is now written using the util function and xmlnodes. Let no one ever ever complain about losing their blist because their hard drive was full. prefs and pounces are the only two xml files not use the util functions and xmlnodes. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 27 Dec 2004 06:24:22 +0000
parents 04c663ccbcb1
children b6ca0e1b19d0
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 {
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
260 gaim_debug_error("accounts", "Attempted to save accounts before they "
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
261 "were read!\n");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
262 }
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 node = accounts_to_xmlnode();
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
265 data = xmlnode_to_formatted_str(node, NULL);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
266 gaim_util_write_data_to_file("accounts.xml", data, -1);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
267 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
268 xmlnode_free(node);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
269 }
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 static gboolean
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
272 save_cb(gpointer data)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
273 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
274 sync_accounts();
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
275 save_timer = 0;
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
276 return FALSE;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
277 }
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 static void
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
280 schedule_accounts_save()
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
281 {
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
282 if (save_timer == 0)
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
283 save_timer = gaim_timeout_add(5000, save_cb, NULL);
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
284 }
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
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
287 /*********************************************************************
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
288 * Reading from disk *
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
289 *********************************************************************/
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
290
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
291 static void
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
292 parse_settings(xmlnode *node, GaimAccount *account)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
293 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
294 const char *ui;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
295 xmlnode *child;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
296
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
297 /* Get the UI string, if these are UI settings */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
298 ui = xmlnode_get_attrib(node, "ui");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
299
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
300 /* Read settings, one by one */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
301 for (child = xmlnode_get_child(node, "setting"); child != NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
302 child = xmlnode_get_next_twin(child))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
303 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
304 const char *name, *str_type;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
305 GaimPrefType type;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
306 char *data;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
307
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
308 name = xmlnode_get_attrib(child, "name");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
309 if (name == NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
310 /* Ignore this setting */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
311 continue;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
312
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
313 str_type = xmlnode_get_attrib(child, "type");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
314 if (!strcmp(str_type, "string"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
315 type = GAIM_PREF_STRING;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
316 else if (!strcmp(str_type, "int"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
317 type = GAIM_PREF_INT;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
318 else if (!strcmp(str_type, "bool"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
319 type = GAIM_PREF_BOOLEAN;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
320 else
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
321 /* Ignore this setting */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
322 continue;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
323
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
324 data = xmlnode_get_data(child);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
325 if (data == NULL)
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 if (ui == NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
330 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
331 if (type == GAIM_PREF_STRING)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
332 gaim_account_set_string(account, name, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
333 else if (type == GAIM_PREF_INT)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
334 gaim_account_set_int(account, name, atoi(data));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
335 else if (type == GAIM_PREF_BOOLEAN)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
336 gaim_account_set_bool(account, name,
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
337 (*data == '0' ? FALSE : TRUE));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
338 } else {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
339 if (type == GAIM_PREF_STRING)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
340 gaim_account_set_ui_string(account, ui, name, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
341 else if (type == GAIM_PREF_INT)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
342 gaim_account_set_ui_int(account, ui, name, atoi(data));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
343 else if (type == GAIM_PREF_BOOLEAN)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
344 gaim_account_set_ui_bool(account, ui, name,
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
345 (*data == '0' ? FALSE : TRUE));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
346 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
347
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
348 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
349 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
350 }
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 static void
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
353 parse_proxy_info(xmlnode *node, GaimAccount *account)
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 GaimProxyInfo *proxy_info;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
356 xmlnode *child;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
357 char *data;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
358
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
359 proxy_info = gaim_proxy_info_new();
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
360
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
361 /* Use the global proxy settings, by default */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
362 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL);
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 /* Read proxy type */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
365 child = xmlnode_get_child(node, "type");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
366 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
367 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
368 if (!strcmp(data, "global"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
369 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_GLOBAL);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
370 else if (!strcmp(data, "none"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
371 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_NONE);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
372 else if (!strcmp(data, "http"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
373 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_HTTP);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
374 else if (!strcmp(data, "socks4"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
375 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS4);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
376 else if (!strcmp(data, "socks5"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
377 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_SOCKS5);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
378 else if (!strcmp(data, "envvar"))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
379 gaim_proxy_info_set_type(proxy_info, GAIM_PROXY_USE_ENVVAR);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
380 else
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
381 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
382 gaim_debug_error("account", "Invalid proxy type found when "
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
383 "loading account information for %s\n",
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
384 gaim_account_get_username(account));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
385 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
386 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
387 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
388
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
389 /* Read proxy host */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
390 child = xmlnode_get_child(node, "host");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
391 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_proxy_info_set_host(proxy_info, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
394 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
395 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
396
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
397 /* Read proxy port */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
398 child = xmlnode_get_child(node, "port");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
399 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_proxy_info_set_port(proxy_info, atoi(data));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
402 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
403 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
404
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
405 /* Read proxy username */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
406 child = xmlnode_get_child(node, "username");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
407 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_proxy_info_set_username(proxy_info, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
410 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
411 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
412
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
413 /* Read proxy password */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
414 child = xmlnode_get_child(node, "password");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
415 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_proxy_info_set_password(proxy_info, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
418 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
419 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
420
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
421 /* If there are no values set then proxy_infourn NULL */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
422 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
423 (gaim_proxy_info_get_host(proxy_info) == NULL) &&
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
424 (gaim_proxy_info_get_port(proxy_info) == 0) &&
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
425 (gaim_proxy_info_get_username(proxy_info) == NULL) &&
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
426 (gaim_proxy_info_get_password(proxy_info) == NULL))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
427 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
428 gaim_proxy_info_destroy(proxy_info);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
429 return;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
430 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
431
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
432 gaim_account_set_proxy_info(account, proxy_info);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
433 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
434
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
435 static GaimAccount *
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
436 parse_account(xmlnode *node)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
437 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
438 GaimAccount *ret;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
439 xmlnode *child;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
440 char *protocol_id = NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
441 char *name = NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
442 char *data;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
443
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
444 child = xmlnode_get_child(node, "protocol");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
445 if (child != NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
446 protocol_id = xmlnode_get_data(child);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
447
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
448 child = xmlnode_get_child(node, "name");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
449 if (child != NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
450 name = xmlnode_get_data(child);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
451 if (name == NULL)
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 /* Do we really need to do this? */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
454 child = xmlnode_get_child(node, "username");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
455 if (child != NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
456 name = xmlnode_get_data(child);
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
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
459 if ((protocol_id == NULL) || (name == NULL))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
460 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
461 free(protocol_id);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
462 free(name);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
463 return NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
464 }
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 ret = gaim_account_new(name, 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 free(protocol_id);
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 /* Read the password */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
471 child = xmlnode_get_child(node, "password");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
472 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
473 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
474 gaim_account_set_password(ret, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
475 gaim_account_set_remember_password(ret, TRUE);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
476 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
477 }
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 /* Read the alias */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
480 child = xmlnode_get_child(node, "alias");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
481 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_account_set_alias(ret, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
484 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
485 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
486
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
487 /* Read the userinfo */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
488 child = xmlnode_get_child(node, "userinfo");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
489 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_account_set_user_info(ret, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
492 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
493 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
494
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
495 /* Read the buddyicon */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
496 child = xmlnode_get_child(node, "buddyicon");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
497 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
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 gaim_account_set_buddy_icon(ret, data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
500 g_free(data);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
501 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
502
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
503 /* Read settings (both core and UI) */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
504 for (child = xmlnode_get_child(node, "settings"); child != NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
505 child = xmlnode_get_next_twin(child))
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 parse_settings(child, ret);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
508 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
509
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
510 /* Read proxy */
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
511 child = xmlnode_get_child(node, "proxy");
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
512 if (child != NULL)
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 parse_proxy_info(child, ret);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
515 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
516
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
517 return ret;
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
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
520 static void
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
521 load_accounts(void)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
522 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
523 xmlnode *node, *child;
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 accounts_loaded = TRUE;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
526
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
527 node = gaim_util_read_xml_from_file("accounts.xml", _("accounts"));
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
528
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
529 if (node == NULL)
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
530 return;
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 for (child = xmlnode_get_child(node, "account"); child != NULL;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
533 child = xmlnode_get_next_twin(child))
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
534 {
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
535 GaimAccount *new;
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
536 new = parse_account(child);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
537 gaim_accounts_add(new);
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
538 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
539 }
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
540
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
541
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
543 delete_setting(void *data)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
544 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 GaimAccountSetting *setting = (GaimAccountSetting *)data;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
546
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
547 if (setting->ui != NULL)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
548 g_free(setting->ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
549
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
550 if (setting->type == GAIM_PREF_STRING)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 g_free(setting->value.string);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553 g_free(setting);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
554 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
556 GaimAccount *
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
557 gaim_account_new(const char *username, const char *protocol_id)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 {
6067
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
559 GaimAccount *account = NULL;
10012
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
560 GaimPlugin *prpl = NULL;
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
561 GaimPluginProtocolInfo *prpl_info = NULL;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
563 g_return_val_if_fail(username != NULL, NULL);
9971
ab5db2c5da79 [gaim-migrate @ 10882]
Mark Doliner <mark@kingant.net>
parents: 9944
diff changeset
564 g_return_val_if_fail(protocol_id != NULL, NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565
9971
ab5db2c5da79 [gaim-migrate @ 10882]
Mark Doliner <mark@kingant.net>
parents: 9944
diff changeset
566 account = gaim_accounts_find(username, protocol_id);
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
567
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
568 if (account != NULL)
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
569 return account;
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
570
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571 account = g_new0(GaimAccount, 1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572
6067
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
573 gaim_account_set_username(account, username);
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
574
9971
ab5db2c5da79 [gaim-migrate @ 10882]
Mark Doliner <mark@kingant.net>
parents: 9944
diff changeset
575 gaim_account_set_protocol_id(account, protocol_id);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577 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
578 g_free, delete_setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
579 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
580 g_free, (GDestroyNotify)g_hash_table_destroy);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
581 account->system_log = NULL;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
582
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
583 account->presence = gaim_presence_new_for_account(account);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
584
10012
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
585 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
10052
eaec201b2688 [gaim-migrate @ 11013]
Mark Doliner <mark@kingant.net>
parents: 10012
diff changeset
586
10012
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
587 if (prpl == NULL)
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
588 return account;
10052
eaec201b2688 [gaim-migrate @ 11013]
Mark Doliner <mark@kingant.net>
parents: 10012
diff changeset
589
10012
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
590 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
591 if ( prpl_info != NULL && prpl_info->status_types != NULL )
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
592 gaim_account_set_status_types(account, prpl_info->status_types(account));
a38881ec9c0f [gaim-migrate @ 10929]
Nathan Walp <nwalp@pidgin.im>
parents: 10005
diff changeset
593
10052
eaec201b2688 [gaim-migrate @ 11013]
Mark Doliner <mark@kingant.net>
parents: 10012
diff changeset
594 gaim_presence_set_status_active(account->presence, "offline", TRUE);
eaec201b2688 [gaim-migrate @ 11013]
Mark Doliner <mark@kingant.net>
parents: 10012
diff changeset
595
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 return account;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
600 gaim_account_destroy(GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
601 {
7324
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
602 GList *l;
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
603
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
606 gaim_debug_info("account", "Destroying account %p\n", account);
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
607
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608 if (account->gc != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
609 gaim_connection_destroy(account->gc);
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", "Continuing to destroy account %p\n", account);
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
612
7324
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
613 for (l = gaim_get_conversations(); l != NULL; l = l->next)
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
614 {
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
615 GaimConversation *conv = (GaimConversation *)l->data;
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
616
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
617 if (gaim_conversation_get_account(conv) == account)
4963abdebd29 [gaim-migrate @ 7910]
Christian Hammond <chipx86@chipx86.com>
parents: 7263
diff changeset
618 gaim_conversation_set_account(conv, NULL);
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
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
621 if (account->username != NULL) g_free(account->username);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
622 if (account->alias != NULL) g_free(account->alias);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
623 if (account->password != NULL) g_free(account->password);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
624 if (account->user_info != NULL) g_free(account->user_info);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
625 if (account->protocol_id != NULL) g_free(account->protocol_id);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
626
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627 g_hash_table_destroy(account->settings);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
628 g_hash_table_destroy(account->ui_settings);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
629
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
630 gaim_account_set_status_types(account, NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
631
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
632 gaim_presence_destroy(account->presence);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
633
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
634 if(account->system_log)
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
635 gaim_log_free(account->system_log);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
636
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
637 g_free(account);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
639
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
640 GaimConnection *
6581
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
641 gaim_account_register(GaimAccount *account)
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
642 {
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
643 GaimConnection *gc;
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
644
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
645 g_return_val_if_fail(account != NULL, NULL);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
646
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
647 if (gaim_account_get_connection(account) != NULL)
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
648 return NULL;
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 gc = gaim_connection_new(account);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
651
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
652 gaim_debug_info("account", "Registering account %p. gc = %p\n",
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
653 account, gc);
6581
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 gaim_connection_register(gc);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
656
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
657 return gc;
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
658 }
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 GaimConnection *
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
661 gaim_account_connect(GaimAccount *account, GaimStatus *status)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
662 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
663 GaimConnection *gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
664
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
666
6109
0922bb7a7bbc [gaim-migrate @ 6571]
Mark Doliner <mark@kingant.net>
parents: 6067
diff changeset
667 if (gaim_account_get_connection(account) != NULL)
0922bb7a7bbc [gaim-migrate @ 6571]
Mark Doliner <mark@kingant.net>
parents: 6067
diff changeset
668 return NULL;
6036
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 5979
diff changeset
669
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670 gc = gaim_connection_new(account);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
672 gaim_debug_info("account", "Connecting to account %p. gc = %p\n",
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
673 account, gc);
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
674
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
675 gaim_connection_connect(gc, status);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
676
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
677 return gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
679
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
680 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681 gaim_account_disconnect(GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682 {
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
683 GaimConnection *gc;
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
684
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
686 g_return_if_fail(gaim_account_is_connected(account));
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
687
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
688 gaim_debug_info("account", "Disconnecting account %p\n", account);
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
689
10384
b234ad7e0dfe [gaim-migrate @ 11610]
Tim Ringenbach <marv@pidgin.im>
parents: 10309
diff changeset
690 account->disconnecting = TRUE;
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
691 gc = gaim_account_get_connection(account);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692
10384
b234ad7e0dfe [gaim-migrate @ 11610]
Tim Ringenbach <marv@pidgin.im>
parents: 10309
diff changeset
693 gaim_connection_disconnect(gc);
b234ad7e0dfe [gaim-migrate @ 11610]
Tim Ringenbach <marv@pidgin.im>
parents: 10309
diff changeset
694
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
695 gaim_account_set_connection(account, NULL);
10384
b234ad7e0dfe [gaim-migrate @ 11610]
Tim Ringenbach <marv@pidgin.im>
parents: 10309
diff changeset
696 account->disconnecting = FALSE;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
698
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699 void
7166
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 7132
diff changeset
700 gaim_account_notify_added(GaimAccount *account, const char *id,
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 7132
diff changeset
701 const char *remote_user, const char *alias,
7015
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
702 const char *message)
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
703 {
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
704 GaimAccountUiOps *ui_ops;
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
705
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
706 g_return_if_fail(account != NULL);
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
707 g_return_if_fail(remote_user != NULL);
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 ui_ops = gaim_accounts_get_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 if (ui_ops != NULL && ui_ops->notify_added != NULL)
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
712 ui_ops->notify_added(account, remote_user, id, alias, message);
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
7063
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
715 static void
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
716 change_password_cb(GaimAccount *account, GaimRequestFields *fields)
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
717 {
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
718 const char *orig_pass, *new_pass_1, *new_pass_2;
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
719
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
720 orig_pass = gaim_request_fields_get_string(fields, "password");
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
721 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
722 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
723
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
724 if (g_utf8_collate(new_pass_1, new_pass_2))
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
725 {
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
726 gaim_notify_error(NULL, NULL,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
727 _("New passwords do not match."), NULL);
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 return;
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
8638
0706d86ecec2 [gaim-migrate @ 9390]
Mark Doliner <mark@kingant.net>
parents: 8635
diff changeset
732 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
733 *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
734 {
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
735 gaim_notify_error(NULL, NULL,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
736 _("Fill out all fields completely."), NULL);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
737 return;
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
738 }
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 serv_change_passwd(gaim_account_get_connection(account),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
741 orig_pass, new_pass_1);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
742 gaim_account_set_password(account, new_pass_1);
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 void
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
746 gaim_account_request_change_password(GaimAccount *account)
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
747 {
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
748 GaimRequestFields *fields;
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
749 GaimRequestFieldGroup *group;
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
750 GaimRequestField *field;
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
751 char primary[256];
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 g_return_if_fail(account != NULL);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
754 g_return_if_fail(gaim_account_is_connected(account));
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
755
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
756 fields = gaim_request_fields_new();
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 group = gaim_request_field_group_new(NULL);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
759 gaim_request_fields_add_group(fields, group);
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 field = gaim_request_field_string_new("password", _("Original password"),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
762 NULL, FALSE);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
763 gaim_request_field_string_set_masked(field, TRUE);
8638
0706d86ecec2 [gaim-migrate @ 9390]
Mark Doliner <mark@kingant.net>
parents: 8635
diff changeset
764 gaim_request_field_set_required(field, TRUE);
7063
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
765 gaim_request_field_group_add_field(group, field);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
766
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
767 field = gaim_request_field_string_new("new_password_1",
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
768 _("New password"),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
769 NULL, FALSE);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
770 gaim_request_field_string_set_masked(field, TRUE);
8638
0706d86ecec2 [gaim-migrate @ 9390]
Mark Doliner <mark@kingant.net>
parents: 8635
diff changeset
771 gaim_request_field_set_required(field, TRUE);
7063
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
772 gaim_request_field_group_add_field(group, field);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
773
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
774 field = gaim_request_field_string_new("new_password_2",
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
775 _("New password (again)"),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
776 NULL, FALSE);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
777 gaim_request_field_string_set_masked(field, TRUE);
8638
0706d86ecec2 [gaim-migrate @ 9390]
Mark Doliner <mark@kingant.net>
parents: 8635
diff changeset
778 gaim_request_field_set_required(field, TRUE);
7063
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
779 gaim_request_field_group_add_field(group, field);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
780
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
781 g_snprintf(primary, sizeof(primary), _("Change password for %s"),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
782 gaim_account_get_username(account));
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
783
7755
8ebd9038ef62 [gaim-migrate @ 8400]
Mark Doliner <mark@kingant.net>
parents: 7654
diff changeset
784 /* I'm sticking this somewhere in the code: bologna */
8ebd9038ef62 [gaim-migrate @ 8400]
Mark Doliner <mark@kingant.net>
parents: 7654
diff changeset
785
7063
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
786 gaim_request_fields(gaim_account_get_connection(account),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
787 NULL,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
788 primary,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
789 _("Please enter your current password and your "
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
790 "new password."),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
791 fields,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
792 _("OK"), G_CALLBACK(change_password_cb),
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
793 _("Cancel"), NULL,
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
794 account);
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
795 }
7fdac700deb1 [gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents: 7015
diff changeset
796
7067
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
797 static void
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
798 set_user_info_cb(GaimAccount *account, const char *user_info)
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
799 {
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
800 GaimConnection *gc;
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
801
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
802 gaim_account_set_user_info(account, user_info);
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
803
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
804 gc = gaim_account_get_connection(account);
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
805
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
806 if (gc != NULL)
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
807 serv_set_info(gaim_account_get_connection(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
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
810 void
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
811 gaim_account_request_change_user_info(GaimAccount *account)
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
812 {
8697
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8658
diff changeset
813 GaimConnection *gc;
7067
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
814 char primary[256];
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
815
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
816 g_return_if_fail(account != NULL);
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
817 g_return_if_fail(gaim_account_is_connected(account));
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
818
8697
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8658
diff changeset
819 gc = gaim_account_get_connection(account);
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8658
diff changeset
820
7067
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
821 g_snprintf(primary, sizeof(primary),
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
822 _("Change user information for %s"),
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
823 gaim_account_get_username(account));
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
824
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
825 gaim_request_input(gaim_account_get_connection(account),
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
826 NULL, primary, NULL,
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
827 gaim_account_get_user_info(account),
8697
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8658
diff changeset
828 TRUE, FALSE, ((gc != NULL) &&
725413cc9fb9 [gaim-migrate @ 9450]
Mark Doliner <mark@kingant.net>
parents: 8658
diff changeset
829 (gc->flags & GAIM_CONNECTION_HTML) ? "html" : NULL),
7067
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
830 _("Save"), G_CALLBACK(set_user_info_cb),
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
831 _("Cancel"), NULL, account);
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
832 }
71e0da45abe6 [gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents: 7063
diff changeset
833
7015
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
834 void
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
835 gaim_account_set_username(GaimAccount *account, const char *username)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
836 {
5711
e33778b9d395 [gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents: 5710
diff changeset
837 g_return_if_fail(account != NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
838
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
839 if (account->username != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
840 g_free(account->username);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
841
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
842 account->username = (username == NULL ? NULL : g_strdup(username));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
843
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
844 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
845 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
848 gaim_account_set_password(GaimAccount *account, const char *password)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
849 {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
850 g_return_if_fail(account != NULL);
5563
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 if (account->password != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
853 g_free(account->password);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
854
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
855 account->password = (password == NULL ? NULL : g_strdup(password));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
856
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
857 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
858 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
861 gaim_account_set_alias(GaimAccount *account, const char *alias)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
862 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
863 g_return_if_fail(account != NULL);
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 if (account->alias != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
866 g_free(account->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 account->alias = (alias == NULL ? NULL : g_strdup(alias));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
869
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
870 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
871 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
874 gaim_account_set_user_info(GaimAccount *account, const char *user_info)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
875 {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
876 g_return_if_fail(account != NULL);
5563
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 if (account->user_info != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
879 g_free(account->user_info);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
880
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
881 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
882
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
883 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
884 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
887 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
888 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
889 g_return_if_fail(account != NULL);
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 if (account->buddy_icon != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
892 g_free(account->buddy_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 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon));
5842
dbed8c87f750 [gaim-migrate @ 6273]
Sean Egan <seanegan@gmail.com>
parents: 5794
diff changeset
895 if (account->gc)
dbed8c87f750 [gaim-migrate @ 6273]
Sean Egan <seanegan@gmail.com>
parents: 5794
diff changeset
896 serv_set_buddyicon(account->gc, icon);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents: 10404
diff changeset
897
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
898 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
899 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
900
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
901 void
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
902 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
903 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
904 g_return_if_fail(account != NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
905 g_return_if_fail(protocol_id != NULL);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
906
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
907 if (account->protocol_id != NULL)
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
908 g_free(account->protocol_id);
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
909
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
910 account->protocol_id = g_strdup(protocol_id);
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
911
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
912 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
913 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
914
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
915 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
916 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
917 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
918 g_return_if_fail(account != NULL);
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 account->gc = gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
921 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
924 gaim_account_set_remember_password(GaimAccount *account, gboolean value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
925 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
926 g_return_if_fail(account != NULL);
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 account->remember_pass = value;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
929
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
930 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
931 }
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 void
5659
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
934 gaim_account_set_check_mail(GaimAccount *account, gboolean value)
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
935 {
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
936 g_return_if_fail(account != NULL);
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
937
5977
2d34c02d2031 [gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents: 5953
diff changeset
938 gaim_account_set_bool(account, "check-mail", value);
5659
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
939 }
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 void
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
942 gaim_account_set_enabled(GaimAccount *account, const char *ui,
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
943 gboolean value)
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
944 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
945 g_return_if_fail(account != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
946 g_return_if_fail(ui != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
947
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
948 gaim_account_set_ui_bool(account, ui, "auto-login", value);
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
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
951 void
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
952 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info)
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
953 {
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
954 g_return_if_fail(account != NULL);
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
955
5695
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
956 if (account->proxy_info != NULL)
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
957 gaim_proxy_info_destroy(account->proxy_info);
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
958
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
959 account->proxy_info = info;
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
960
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
961 schedule_accounts_save();
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
962 }
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
963
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
964 void
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
965 gaim_account_set_status_types(GaimAccount *account, GList *status_types)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
966 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
967 g_return_if_fail(account != NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
968
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 9989
diff changeset
969 /* Old with the old... */
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
970 if (account->status_types != NULL)
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 GList *l;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
973
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
974 for (l = account->status_types; l != NULL; l = l->next)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
975 gaim_status_type_destroy((GaimStatusType *)l->data);
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 g_list_free(account->status_types);
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
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 9989
diff changeset
980 /* In with the new... */
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
981 account->status_types = status_types;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
982 }
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 void
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
985 gaim_account_set_status(GaimAccount *account, const char *status_id,
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
986 gboolean active, ...)
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 GaimStatus *status;
10196
760e690a5f30 [gaim-migrate @ 11313]
Mark Doliner <mark@kingant.net>
parents: 10106
diff changeset
989 va_list args;
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
990
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
991 g_return_if_fail(account != NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
992 g_return_if_fail(status_id != NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
993
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
994 status = gaim_account_get_status(account, status_id);
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 if (status == NULL)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
997 {
10309
19974fd2d61d [gaim-migrate @ 11501]
Mark Doliner <mark@kingant.net>
parents: 10301
diff changeset
998 gaim_debug_error("accounts",
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
999 "Invalid status ID %s for account %s (%s)\n",
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1000 status_id, gaim_account_get_username(account),
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1001 gaim_account_get_protocol_id(account));
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1002 return;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1003 }
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1004
10196
760e690a5f30 [gaim-migrate @ 11313]
Mark Doliner <mark@kingant.net>
parents: 10106
diff changeset
1005 va_start(args, active);
10204
393f85d9f8dd [gaim-migrate @ 11325]
Mark Doliner <mark@kingant.net>
parents: 10196
diff changeset
1006 gaim_status_set_active_with_attrs(status, active, args);
10196
760e690a5f30 [gaim-migrate @ 11313]
Mark Doliner <mark@kingant.net>
parents: 10106
diff changeset
1007 va_end(args);
9944
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
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1010 void
5694
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1011 gaim_account_clear_settings(GaimAccount *account)
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1012 {
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1013 g_return_if_fail(account != NULL);
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1014
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1015 g_hash_table_destroy(account->settings);
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1016
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1017 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
1018 g_free, delete_setting);
5694
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
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1021 void
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1022 gaim_account_set_int(GaimAccount *account, const char *name, int value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1023 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1024 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1025
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1026 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1027 g_return_if_fail(name != NULL);
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 setting = g_new0(GaimAccountSetting, 1);
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 setting->type = GAIM_PREF_INT;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1032 setting->value.integer = value;
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 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1035
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1036 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1037 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1040 gaim_account_set_string(GaimAccount *account, const char *name,
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041 const char *value)
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 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1046 g_return_if_fail(name != NULL);
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 setting = g_new0(GaimAccountSetting, 1);
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 setting->type = GAIM_PREF_STRING;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051 setting->value.string = g_strdup(value);
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 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1054
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1055 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1056 }
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 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1059 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1060 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061 GaimAccountSetting *setting;
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 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1064 g_return_if_fail(name != NULL);
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 setting = g_new0(GaimAccountSetting, 1);
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 setting->type = GAIM_PREF_BOOLEAN;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1069 setting->value.bool = value;
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 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1072
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1073 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1076 static GHashTable *
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1077 get_ui_settings_table(GaimAccount *account, const char *ui)
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1078 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1079 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1080
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1081 table = g_hash_table_lookup(account->ui_settings, ui);
5979
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
1082
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1083 if (table == NULL) {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1084 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
1085 delete_setting);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1086 g_hash_table_insert(account->ui_settings, g_strdup(ui), table);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1087 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1088
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1089 return table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1090 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1091
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1092 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1093 gaim_account_set_ui_int(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1094 const char *name, int value)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1095 {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1096 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1097 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1098
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1099 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1100 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1101 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1102
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1103 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1104
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1105 setting->type = GAIM_PREF_INT;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1106 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1107 setting->value.integer = value;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1108
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1109 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1110
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1111 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1112
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1113 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1114 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1115
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1116 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1117 gaim_account_set_ui_string(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1118 const char *name, const char *value)
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 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1121 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1122
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1123 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1124 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1125 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1126
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1127 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1128
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1129 setting->type = GAIM_PREF_STRING;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1130 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1131 setting->value.string = g_strdup(value);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1132
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1133 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1134
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1135 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1136
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1137 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1138 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1139
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1140 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1141 gaim_account_set_ui_bool(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1142 const char *name, gboolean value)
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 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1145 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1146
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1147 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1148 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1149 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1150
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1151 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1152
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1153 setting->type = GAIM_PREF_BOOLEAN;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1154 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1155 setting->value.bool = value;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1156
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1157 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1158
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1159 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1160
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1161 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1162 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1163
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1164 gboolean
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 gaim_account_is_connected(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166 {
9019
db1dc2d02020 [gaim-migrate @ 9795]
Mark Doliner <mark@kingant.net>
parents: 8834
diff changeset
1167 GaimConnection *gc;
db1dc2d02020 [gaim-migrate @ 9795]
Mark Doliner <mark@kingant.net>
parents: 8834
diff changeset
1168
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1169 g_return_val_if_fail(account != NULL, FALSE);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170
9019
db1dc2d02020 [gaim-migrate @ 9795]
Mark Doliner <mark@kingant.net>
parents: 8834
diff changeset
1171 gc = gaim_account_get_connection(account);
db1dc2d02020 [gaim-migrate @ 9795]
Mark Doliner <mark@kingant.net>
parents: 8834
diff changeset
1172
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
1173 /* 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
1174 /* return ((gc != NULL) && GAIM_CONNECTION_IS_CONNECTED(gc)); */
3d30ed8dc7b0 [gaim-migrate @ 9797]
Mark Doliner <mark@kingant.net>
parents: 9019
diff changeset
1175 return ((gc != NULL) && gaim_connection_get_state(gc) != GAIM_DISCONNECTED);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1176 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1177
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1178 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1179 gaim_account_get_username(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1180 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1181 g_return_val_if_fail(account != NULL, NULL);
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 return account->username;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1184 }
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 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1187 gaim_account_get_password(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1188 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1189 g_return_val_if_fail(account != NULL, NULL);
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 return account->password;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1192 }
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 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1195 gaim_account_get_alias(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1196 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1197 g_return_val_if_fail(account != NULL, NULL);
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 return account->alias;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1200 }
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 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1203 gaim_account_get_user_info(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 g_return_val_if_fail(account != NULL, NULL);
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 return account->user_info;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1208 }
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 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1211 gaim_account_get_buddy_icon(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1212 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1213 g_return_val_if_fail(account != NULL, NULL);
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 return account->buddy_icon;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1216 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1217
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1218 const char *
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1219 gaim_account_get_protocol_id(const GaimAccount *account)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1220 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1221 g_return_val_if_fail(account != NULL, NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1222
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1223 return account->protocol_id;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1224 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1225
9699
267eab8f3fa4 [gaim-migrate @ 10558]
Mark Doliner <mark@kingant.net>
parents: 9619
diff changeset
1226 const char *
267eab8f3fa4 [gaim-migrate @ 10558]
Mark Doliner <mark@kingant.net>
parents: 9619
diff changeset
1227 gaim_account_get_protocol_name(const GaimAccount *account)
267eab8f3fa4 [gaim-migrate @ 10558]
Mark Doliner <mark@kingant.net>
parents: 9619
diff changeset
1228 {
9720
78da12f2982d [gaim-migrate @ 10581]
Mark Doliner <mark@kingant.net>
parents: 9699
diff changeset
1229 GaimPlugin *p;
78da12f2982d [gaim-migrate @ 10581]
Mark Doliner <mark@kingant.net>
parents: 9699
diff changeset
1230
9699
267eab8f3fa4 [gaim-migrate @ 10558]
Mark Doliner <mark@kingant.net>
parents: 9619
diff changeset
1231 g_return_val_if_fail(account != NULL, NULL);
267eab8f3fa4 [gaim-migrate @ 10558]
Mark Doliner <mark@kingant.net>
parents: 9619
diff changeset
1232
9989
e4d971338093 [gaim-migrate @ 10902]
Luke Schierer <lschiere@pidgin.im>
parents: 9988
diff changeset
1233 p = gaim_find_prpl(gaim_account_get_protocol_id(account));
9988
d770673338f4 [gaim-migrate @ 10901]
Luke Schierer <lschiere@pidgin.im>
parents: 9971
diff changeset
1234
d770673338f4 [gaim-migrate @ 10901]
Luke Schierer <lschiere@pidgin.im>
parents: 9971
diff changeset
1235 return ((p && p->info->name) ? _(p->info->name) : _("Unknown"));
d770673338f4 [gaim-migrate @ 10901]
Luke Schierer <lschiere@pidgin.im>
parents: 9971
diff changeset
1236 }
d770673338f4 [gaim-migrate @ 10901]
Luke Schierer <lschiere@pidgin.im>
parents: 9971
diff changeset
1237
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1238 GaimConnection *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1239 gaim_account_get_connection(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1240 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1241 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1242
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1243 return account->gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1244 }
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 gboolean
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1247 gaim_account_get_remember_password(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1248 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1249 g_return_val_if_fail(account != NULL, FALSE);
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 return account->remember_pass;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1252 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1253
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1254 gboolean
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1255 gaim_account_get_check_mail(const GaimAccount *account)
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1256 {
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1257 g_return_val_if_fail(account != NULL, FALSE);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1258
5977
2d34c02d2031 [gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents: 5953
diff changeset
1259 return gaim_account_get_bool(account, "check-mail", FALSE);
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1260 }
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1261
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1262 gboolean
10400
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
1263 gaim_account_get_enabled(const GaimAccount *account, const char *ui)
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1264 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1265 g_return_val_if_fail(account != NULL, FALSE);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1266 g_return_val_if_fail(ui != NULL, FALSE);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1267
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1268 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE);
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
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1271 GaimProxyInfo *
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1272 gaim_account_get_proxy_info(const GaimAccount *account)
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1273 {
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1274 g_return_val_if_fail(account != NULL, NULL);
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1275
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1276 return account->proxy_info;
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1277 }
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
1278
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1279 GaimStatus *
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1280 gaim_account_get_status(const GaimAccount *account, const char *status_id)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1281 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1282 g_return_val_if_fail(account != NULL, NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1283 g_return_val_if_fail(status_id != NULL, NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1284
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1285 return gaim_presence_get_status(account->presence, 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
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1288 GaimStatusType *
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1289 gaim_account_get_status_type(const GaimAccount *account, const char *id)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1290 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1291 const GList *l;
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 g_return_val_if_fail(account != NULL, NULL);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1294 g_return_val_if_fail(id != NULL, NULL);
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 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
1297 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1298 GaimStatusType *status_type = (GaimStatusType *)l->data;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1299
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1300 if (!strcmp(gaim_status_type_get_id(status_type), id))
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1301 return status_type;
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
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1304 return NULL;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1305 }
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1306
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1307 GaimPresence *
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1308 gaim_account_get_presence(const GaimAccount *account)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1309 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1310 g_return_val_if_fail(account != NULL, NULL);
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 return account->presence;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1313 }
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 gboolean
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1316 gaim_account_is_status_active(const GaimAccount *account,
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1317 const char *status_id)
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 g_return_val_if_fail(account != NULL, FALSE);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1320 g_return_val_if_fail(status_id != NULL, FALSE);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1321
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1322 return gaim_presence_is_status_active(account->presence, 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
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1325 const GList *
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1326 gaim_account_get_status_types(const GaimAccount *account)
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1327 {
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1328 g_return_val_if_fail(account != NULL, NULL);
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 return account->status_types;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1331 }
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9720
diff changeset
1332
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1333 int
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1334 gaim_account_get_int(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1335 int default_value)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1336 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1337 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1338
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1339 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1340 g_return_val_if_fail(name != NULL, 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 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1343
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1344 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1345 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1346
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1347 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
1348
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1349 return setting->value.integer;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1350 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1351
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1352 const char *
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1353 gaim_account_get_string(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1354 const char *default_value)
5563
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 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1357
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1358 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1359 g_return_val_if_fail(name != NULL, 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 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1362
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1363 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1364 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1365
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1366 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
1367
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1368 return setting->value.string;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1369 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1370
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1371 gboolean
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1372 gaim_account_get_bool(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1373 gboolean default_value)
5563
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 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1376
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1377 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1378 g_return_val_if_fail(name != NULL, 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 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1381
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1382 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1383 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
1384
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
1385 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
1386
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1387 return setting->value.bool;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1388 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1389
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1390 int
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1391 gaim_account_get_ui_int(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1392 const char *name, int default_value)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1393 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1394 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1395 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1396
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1397 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1398 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1399 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1400
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1401 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1402 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1403
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1404 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1405 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1406
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1407 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
1408
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1409 return setting->value.integer;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1410 }
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 const char *
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1413 gaim_account_get_ui_string(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1414 const char *name, const char *default_value)
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 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1417 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1418
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1419 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1420 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1421 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1422
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1423 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1424 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1425
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1426 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1427 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1428
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1429 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
1430
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1431 return setting->value.string;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1432 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1433
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1434 gboolean
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1435 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1436 const char *name, gboolean default_value)
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 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1439 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1440
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1441 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1442 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1443 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1444
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1445 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1446 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1447
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1448 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1449 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1450
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1451 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
1452
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1453 return setting->value.bool;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1454 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1455
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1456 GaimLog *
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1457 gaim_account_get_log(GaimAccount *account)
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1458 {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1459 g_return_val_if_fail(account != NULL, NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1460
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1461 if(!account->system_log){
8658
4133c85d76f7 [gaim-migrate @ 9410]
Mark Doliner <mark@kingant.net>
parents: 8638
diff changeset
1462 GaimConnection *gc;
4133c85d76f7 [gaim-migrate @ 9410]
Mark Doliner <mark@kingant.net>
parents: 8638
diff changeset
1463
4133c85d76f7 [gaim-migrate @ 9410]
Mark Doliner <mark@kingant.net>
parents: 8638
diff changeset
1464 gc = gaim_account_get_connection(account);
4133c85d76f7 [gaim-migrate @ 9410]
Mark Doliner <mark@kingant.net>
parents: 8638
diff changeset
1465
8635
4aee5a47937d [gaim-migrate @ 9387]
Nathan Walp <nwalp@pidgin.im>
parents: 8619
diff changeset
1466 account->system_log = gaim_log_new(GAIM_LOG_SYSTEM,
4aee5a47937d [gaim-migrate @ 9387]
Nathan Walp <nwalp@pidgin.im>
parents: 8619
diff changeset
1467 gaim_account_get_username(account), account,
8658
4133c85d76f7 [gaim-migrate @ 9410]
Mark Doliner <mark@kingant.net>
parents: 8638
diff changeset
1468 gc != NULL ? gc->login_time : time(NULL));
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1469 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1470
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1471 return account->system_log;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1472 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1473
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1474 void
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1475 gaim_account_destroy_log(GaimAccount *account)
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1476 {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1477 g_return_if_fail(account != NULL);
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 if(account->system_log){
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1480 gaim_log_free(account->system_log);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1481 account->system_log = NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8549
diff changeset
1482 }
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
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1485 void
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1486 gaim_accounts_add(GaimAccount *account)
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1487 {
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1488 g_return_if_fail(account != NULL);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1489
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1490 if (g_list_find(accounts, account) != NULL)
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1491 return;
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1492
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1493 accounts = g_list_append(accounts, account);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1494
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1495 schedule_accounts_save();
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1496
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1497 gaim_signal_emit(gaim_accounts_get_handle(), "account-added", account);
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1498 }
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 void
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1501 gaim_accounts_remove(GaimAccount *account)
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1502 {
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1503 g_return_if_fail(account != NULL);
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 accounts = g_list_remove(accounts, account);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1506
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1507 schedule_accounts_save();
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1508
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1509 gaim_signal_emit(gaim_accounts_get_handle(), "account-removed", account);
6368
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1510 }
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1511
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1512 void
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1513 gaim_accounts_delete(GaimAccount *account)
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1514 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1515 GaimBlistNode *gnode, *cnode, *bnode;
6368
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 g_return_if_fail(account != NULL);
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1518
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1519 gaim_accounts_remove(account);
6367
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1520
8235
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1521 /* Remove this account's buddies */
6367
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1522 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) {
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1523 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1524 continue;
10106
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1525
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1526 cnode = gnode->child;
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1527 while (cnode) {
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1528 GaimBlistNode *cnode_next = cnode->next;
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1529
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1530 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) {
10106
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1531 bnode = cnode->child;
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1532 while (bnode) {
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1533 GaimBlistNode *bnode_next = bnode->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_BUDDY(bnode)) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1536 GaimBuddy *b = (GaimBuddy *)bnode;
6367
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1537
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1538 if (b->account == account)
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1539 gaim_blist_remove_buddy(b);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1540 }
10106
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1541 bnode = bnode_next;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1542 }
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6621
diff changeset
1543 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) {
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
1544 GaimChat *c = (GaimChat *)cnode;
6367
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1545
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1546 if (c->account == account)
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1547 gaim_blist_remove_chat(c);
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1548 }
10106
131f70fc53c1 [gaim-migrate @ 11138]
Luke Schierer <lschiere@pidgin.im>
parents: 10067
diff changeset
1549 cnode = cnode_next;
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 }
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1552
8235
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1553 /* Remove this account's pounces */
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1554 gaim_pounce_destroy_all_by_account(account);
6368
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1555
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1556 gaim_account_destroy(account);
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1557 }
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1558
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1559 void
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1560 gaim_accounts_auto_login(const char *ui)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1561 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1562 GaimAccount *account;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1563 GList *l;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1564
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1565 g_return_if_fail(ui != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1566
5780
a9029bed0479 [gaim-migrate @ 6205]
Christian Hammond <chipx86@chipx86.com>
parents: 5779
diff changeset
1567 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
1568 account = l->data;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1569
10404
ce098e226486 [gaim-migrate @ 11649]
Mark Doliner <mark@kingant.net>
parents: 10400
diff changeset
1570 /* 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
1571 if (gaim_account_get_enabled(account, ui))
6a043ae92db6 [gaim-migrate @ 11631]
Sean Egan <seanegan@gmail.com>
parents: 10399
diff changeset
1572 gaim_account_connect(account, gaim_account_get_status(account, "online"));
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1573 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1574 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1575
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1576 void
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1577 gaim_accounts_reorder(GaimAccount *account, size_t new_index)
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1578 {
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1579 size_t index;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1580 GList *l;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1581
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1582 g_return_if_fail(account != NULL);
5620
c9724982ce45 [gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents: 5610
diff changeset
1583 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
1584
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1585 index = g_list_index(accounts, account);
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 if (index == -1) {
10309
19974fd2d61d [gaim-migrate @ 11501]
Mark Doliner <mark@kingant.net>
parents: 10301
diff changeset
1588 gaim_debug_error("accounts",
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1589 "Unregistered account (%s) discovered during reorder!\n",
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1590 gaim_account_get_username(account));
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1591 return;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1592 }
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1593
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1594 l = g_list_nth(accounts, index);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1595
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1596 if (new_index > index)
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1597 new_index--;
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 /* Remove the old one. */
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1600 accounts = g_list_delete_link(accounts, l);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1601
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1602 /* Insert it where it should go. */
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1603 accounts = g_list_insert(accounts, account, new_index);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1604
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1605 schedule_accounts_save();
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1606 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1607
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1608 GList *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1609 gaim_accounts_get_all(void)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1610 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1611 return accounts;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1612 }
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1613
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1614 GaimAccount *
7132
d17a587efeb3 [gaim-migrate @ 7699]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
1615 gaim_accounts_find(const char *name, const char *protocol_id)
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1616 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1617 GaimAccount *account = NULL;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1618 GList *l;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1619 char *who;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1620
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1621 g_return_val_if_fail(name != NULL, NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1622
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7166
diff changeset
1623 who = g_strdup(gaim_normalize(NULL, name));
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1624
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1625 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1626 account = (GaimAccount *)l->data;
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 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
1629 (!protocol_id || !strcmp(account->protocol_id, protocol_id))) {
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1630
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1631 break;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1632 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1633
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1634 account = NULL;
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
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1637 g_free(who);
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 return account;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1640 }
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1641
7015
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1642 void
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1643 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops)
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1644 {
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1645 account_ui_ops = ops;
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1646 }
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1647
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1648 GaimAccountUiOps *
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1649 gaim_accounts_get_ui_ops(void)
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1650 {
dece74f05509 [gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
1651 return account_ui_ops;
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
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1654 void *
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1655 gaim_accounts_get_handle(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1656 {
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1657 static int handle;
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1658
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1659 return &handle;
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1660 }
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 void
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1663 gaim_accounts_init(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1664 {
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1665 void *handle = gaim_accounts_get_handle();
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1666
10425
9903182f2aac [gaim-migrate @ 11677]
Mark Doliner <mark@kingant.net>
parents: 10424
diff changeset
1667 load_accounts();
9903182f2aac [gaim-migrate @ 11677]
Mark Doliner <mark@kingant.net>
parents: 10424
diff changeset
1668
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1669 gaim_signal_register(handle, "account-connecting",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1670 gaim_marshal_VOID__POINTER, NULL, 1,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1671 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1672 GAIM_SUBTYPE_ACCOUNT));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1673
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1674 gaim_signal_register(handle, "account-away",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1675 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1676 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1677 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1678 gaim_value_new(GAIM_TYPE_STRING),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1679 gaim_value_new(GAIM_TYPE_STRING));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1680
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1681 gaim_signal_register(handle, "account-setting-info",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1682 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1683 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1684 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1685 gaim_value_new(GAIM_TYPE_STRING));
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1686
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1687 gaim_signal_register(handle, "account-set-info",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1688 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1689 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1690 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1691 gaim_value_new(GAIM_TYPE_STRING));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1692
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1693 gaim_signal_register(handle, "account-warned",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1694 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1695 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1696 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1697 gaim_value_new(GAIM_TYPE_STRING),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1698 gaim_value_new(GAIM_TYPE_UINT));
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1699
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1700 gaim_signal_register(handle, "account-added",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1701 gaim_marshal_VOID__POINTER, NULL, 1,
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1702 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT));
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1703
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1704 gaim_signal_register(handle, "account-removed",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1705 gaim_marshal_VOID__POINTER, NULL, 1,
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8046
diff changeset
1706 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1707 }
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1708
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1709 void
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1710 gaim_accounts_uninit(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1711 {
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
1712 if (save_timer != 0)
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
1713 {
10428
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
1714 gaim_timeout_remove(save_timer);
04c663ccbcb1 [gaim-migrate @ 11680]
Mark Doliner <mark@kingant.net>
parents: 10427
diff changeset
1715 save_timer = 0;
10427
16d63d8c26d8 [gaim-migrate @ 11679]
Mark Doliner <mark@kingant.net>
parents: 10426
diff changeset
1716 sync_accounts();
8235
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1717 }
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1718
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1719 gaim_signals_unregister_by_instance(gaim_accounts_get_handle());
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1720 }