annotate src/account.c @ 12232:375f1f3817a8

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