annotate src/account.c @ 6681:c1bbb8358959

[gaim-migrate @ 7206] Rob, you should release. I know you want to, I can see it in your eyes. I mean, uh, I _could_ see it in your eyes if I was, say, looking at you through a powerful telescope... ...which I'm not. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 01 Sep 2003 23:07:34 +0000
parents 42fdf16f1dad
children 0c5637b5462e
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 *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
8 *
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * 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
11 * the Free Software Foundation; either version 2 of the License, or
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5870
diff changeset
23 #include "internal.h"
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "account.h"
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5711
diff changeset
25 #include "debug.h"
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "prefs.h"
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
27 #include "prpl.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
28 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5870
diff changeset
29 #include "server.h"
5717
1d140b31d4b3 [gaim-migrate @ 6138]
Nathan Walp <nwalp@pidgin.im>
parents: 5711
diff changeset
30 #include "util.h"
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
32 typedef enum
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
33 {
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
34 TAG_NONE = 0,
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
35 TAG_PROTOCOL,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
36 TAG_NAME,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
37 TAG_PASSWORD,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
38 TAG_ALIAS,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
39 TAG_USERINFO,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
40 TAG_BUDDYICON,
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
41 TAG_PUBLIC_IP,
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
42 TAG_SETTING,
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
43 TAG_TYPE,
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
44 TAG_HOST,
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
45 TAG_PORT
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
46
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
47 } AccountParserTag;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
48
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 typedef struct
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 GaimPrefType type;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
53 char *ui;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
54
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 union
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 int integer;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 char *string;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 gboolean bool;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 } value;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 } GaimAccountSetting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
65 typedef struct
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
66 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
67 AccountParserTag tag;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
68
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
69 GaimAccount *account;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
70 GaimProtocol protocol;
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
71 GaimProxyInfo *proxy_info;
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
72 char *protocol_id;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
73
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
74 GString *buffer;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
75
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
76 GaimPrefType setting_type;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
77 char *setting_ui;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
78 char *setting_name;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
79
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
80 gboolean in_proxy;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
81
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
82 } AccountParserData;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
83
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
84 static GList *accounts = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
85 static guint accounts_save_timer = 0;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
86 static gboolean accounts_loaded = FALSE;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
89 delete_setting(void *data)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 GaimAccountSetting *setting = (GaimAccountSetting *)data;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
93 if (setting->ui != NULL)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
94 g_free(setting->ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
95
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 if (setting->type == GAIM_PREF_STRING)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 g_free(setting->value.string);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 g_free(setting);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
102 static gboolean
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
103 accounts_save_cb(gpointer unused)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
104 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
105 gaim_accounts_sync();
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
106 accounts_save_timer = 0;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
107
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
108 return FALSE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
109 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
110
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
111 static void
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
112 schedule_accounts_save()
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
113 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
114 if (!accounts_save_timer)
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
115 accounts_save_timer = g_timeout_add(5000, accounts_save_cb, NULL);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
116 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
117
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 GaimAccount *
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
119 gaim_account_new(const char *username, const char *protocol_id)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 {
6067
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
121 GaimAccount *account = NULL;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
123 g_return_val_if_fail(username != NULL, NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124
6067
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
125 if(protocol_id)
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
126 account = gaim_accounts_find_with_prpl_id(username, protocol_id);
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
127
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
128 if (account != NULL)
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
129 return account;
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
130
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 account = g_new0(GaimAccount, 1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
6067
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
133 gaim_account_set_username(account, username);
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
134
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
135 if(protocol_id)
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
136 gaim_account_set_protocol_id(account, protocol_id);
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
137 else
6a3b676eb36a [gaim-migrate @ 6517]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
138 gaim_account_set_protocol(account, GAIM_PROTO_DEFAULT);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 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
141 g_free, delete_setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
142 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
143 g_free, (GDestroyNotify)g_hash_table_destroy);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
144
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 return account;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 gaim_account_destroy(GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
153 gaim_debug(GAIM_DEBUG_INFO, "account",
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
154 "Destroying account %p\n", account);
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
155
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 if (account->gc != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 gaim_connection_destroy(account->gc);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
159 gaim_debug(GAIM_DEBUG_INFO, "account",
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
160 "Continuing to destroy account %p\n", account);
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
161
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
162 if (account->username != NULL) g_free(account->username);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
163 if (account->alias != NULL) g_free(account->alias);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
164 if (account->password != NULL) g_free(account->password);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
165 if (account->user_info != NULL) g_free(account->user_info);
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
166 if (account->protocol_id != NULL) g_free(account->protocol_id);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 g_hash_table_destroy(account->settings);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
169 g_hash_table_destroy(account->ui_settings);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 g_free(account);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 GaimConnection *
6581
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
175 gaim_account_register(GaimAccount *account)
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
176 {
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
177 GaimConnection *gc;
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
178
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
179 g_return_val_if_fail(account != NULL, NULL);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
180
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
181 if (gaim_account_get_connection(account) != NULL)
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
182 return NULL;
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
183
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
184 gc = gaim_connection_new(account);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
185
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
186 gaim_debug(GAIM_DEBUG_INFO, "account",
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
187 "Registering account %p. gc = %p\n", account, gc);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
188
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
189 gaim_connection_register(gc);
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
190
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
191 return gc;
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
192 }
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
193
0473a28ce807 [gaim-migrate @ 7103]
Nathan Walp <nwalp@pidgin.im>
parents: 6564
diff changeset
194 GaimConnection *
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 gaim_account_connect(GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 GaimConnection *gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
6109
0922bb7a7bbc [gaim-migrate @ 6571]
Mark Doliner <mark@kingant.net>
parents: 6067
diff changeset
201 if (gaim_account_get_connection(account) != NULL)
0922bb7a7bbc [gaim-migrate @ 6571]
Mark Doliner <mark@kingant.net>
parents: 6067
diff changeset
202 return NULL;
6036
547ba881bc7e [gaim-migrate @ 6486]
Mark Doliner <mark@kingant.net>
parents: 5979
diff changeset
203
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 gc = gaim_connection_new(account);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
206 gaim_debug(GAIM_DEBUG_INFO, "account",
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
207 "Connecting to account %p. gc = %p\n", account, gc);
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
208
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 gaim_connection_connect(gc);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 return gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 gaim_account_disconnect(GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 {
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
217 GaimConnection *gc;
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
218
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 g_return_if_fail(gaim_account_is_connected(account));
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
222 gaim_debug(GAIM_DEBUG_INFO, "account",
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
223 "Disconnecting account %p\n", account);
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
224
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
225 gc = gaim_account_get_connection(account);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
5926
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
227 gaim_account_set_connection(account, NULL);
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
228
6c22d37c6a3c [gaim-migrate @ 6366]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
229 gaim_connection_disconnect(gc);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 gaim_account_set_username(GaimAccount *account, const char *username)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 {
5711
e33778b9d395 [gaim-migrate @ 6132]
Christian Hammond <chipx86@chipx86.com>
parents: 5710
diff changeset
235 g_return_if_fail(account != NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 if (account->username != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 g_free(account->username);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 account->username = (username == NULL ? NULL : g_strdup(username));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
241
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
242 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 gaim_account_set_password(GaimAccount *account, const char *password)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
248 g_return_if_fail(account != NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 if (account->password != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 g_free(account->password);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 account->password = (password == NULL ? NULL : g_strdup(password));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
254
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
255 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 gaim_account_set_alias(GaimAccount *account, const char *alias)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 if (account->alias != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 g_free(account->alias);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 account->alias = (alias == NULL ? NULL : g_strdup(alias));
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
267
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
268 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 gaim_account_set_user_info(GaimAccount *account, const char *user_info)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
274 g_return_if_fail(account != NULL);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 if (account->user_info != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 g_free(account->user_info);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 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
280
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
281 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 if (account->buddy_icon != NULL)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 g_free(account->buddy_icon);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon));
5842
dbed8c87f750 [gaim-migrate @ 6273]
Sean Egan <seanegan@gmail.com>
parents: 5794
diff changeset
293 if (account->gc)
dbed8c87f750 [gaim-migrate @ 6273]
Sean Egan <seanegan@gmail.com>
parents: 5794
diff changeset
294 serv_set_buddyicon(account->gc, icon);
dbed8c87f750 [gaim-migrate @ 6273]
Sean Egan <seanegan@gmail.com>
parents: 5794
diff changeset
295
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
296 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 gaim_account_set_protocol(GaimAccount *account, GaimProtocol protocol)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
304 gaim_account_set_protocol_id(account, gaim_prpl_num_to_id(protocol));
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
305 }
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
306
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
307 void
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
308 gaim_account_set_protocol_id(GaimAccount *account, const char *protocol_id)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
309 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
310 g_return_if_fail(account != NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
311 g_return_if_fail(protocol_id != NULL);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
312
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
313 if (account->protocol_id != NULL)
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
314 g_free(account->protocol_id);
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
315
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
316 account->protocol_id = g_strdup(protocol_id);
5665
132a30783c3d [gaim-migrate @ 6081]
Christian Hammond <chipx86@chipx86.com>
parents: 5659
diff changeset
317
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
318 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 gaim_account_set_connection(GaimAccount *account, GaimConnection *gc)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 account->gc = gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 gaim_account_set_remember_password(GaimAccount *account, gboolean value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 account->remember_pass = value;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
335
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
336 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 void
5659
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
340 gaim_account_set_check_mail(GaimAccount *account, gboolean value)
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
341 {
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
342 g_return_if_fail(account != NULL);
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
343
5977
2d34c02d2031 [gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents: 5953
diff changeset
344 gaim_account_set_bool(account, "check-mail", value);
5659
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
345 }
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
346
6b3214ab8632 [gaim-migrate @ 6073]
Christian Hammond <chipx86@chipx86.com>
parents: 5643
diff changeset
347 void
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
348 gaim_account_set_auto_login(GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
349 gboolean value)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
350 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
351 g_return_if_fail(account != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
352 g_return_if_fail(ui != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
353
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
354 gaim_account_set_ui_bool(account, ui, "auto-login", value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
355 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
356
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
357 void
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
358 gaim_account_set_public_ip(GaimAccount *account, const char *ip)
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
359 {
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
360 g_return_if_fail(account != NULL);
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
361
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
362 if (account->ip != NULL)
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
363 g_free(account->ip);
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
364
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
365 account->ip = (ip == NULL ? NULL : g_strdup(ip));
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
366
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
367 schedule_accounts_save();
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
368 }
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
369
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
370 void
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
371 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info)
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
372 {
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
373 g_return_if_fail(account != NULL);
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
374
5695
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
375 if (account->proxy_info != NULL)
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
376 gaim_proxy_info_destroy(account->proxy_info);
e42535701e25 [gaim-migrate @ 6116]
Christian Hammond <chipx86@chipx86.com>
parents: 5694
diff changeset
377
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
378 account->proxy_info = info;
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
379
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
380 schedule_accounts_save();
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
381 }
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
382
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
383 void
5694
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
384 gaim_account_clear_settings(GaimAccount *account)
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
385 {
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
386 g_return_if_fail(account != NULL);
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
387
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
388 g_hash_table_destroy(account->settings);
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
389
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
390 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
391 g_free, delete_setting);
5694
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
392 }
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
393
2d0d96c5a7a7 [gaim-migrate @ 6115]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
394 void
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 gaim_account_set_int(GaimAccount *account, const char *name, int value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 g_return_if_fail(name != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 setting = g_new0(GaimAccountSetting, 1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 setting->type = GAIM_PREF_INT;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 setting->value.integer = value;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
408
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
409 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 gaim_account_set_string(GaimAccount *account, const char *name,
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 const char *value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 g_return_if_fail(name != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 setting = g_new0(GaimAccountSetting, 1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 setting->type = GAIM_PREF_STRING;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 setting->value.string = g_strdup(value);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
427
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
428 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 void
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 gaim_account_set_bool(GaimAccount *account, const char *name, gboolean value)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 g_return_if_fail(account != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 g_return_if_fail(name != NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438
5979
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
439 gaim_debug(GAIM_DEBUG_INFO, "account", "Setting bool: %s, %d\n",
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
440 name, value);
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
441
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 setting = g_new0(GaimAccountSetting, 1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 setting->type = GAIM_PREF_BOOLEAN;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 setting->value.bool = value;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 g_hash_table_insert(account->settings, g_strdup(name), setting);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
448
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
449 schedule_accounts_save();
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
452 static GHashTable *
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
453 get_ui_settings_table(GaimAccount *account, const char *ui)
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
454 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
455 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
456
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
457 table = g_hash_table_lookup(account->ui_settings, ui);
5979
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
458
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
459 if (table == NULL) {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
460 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
461 delete_setting);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
462 g_hash_table_insert(account->ui_settings, g_strdup(ui), table);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
463 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
464
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
465 return table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
466 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
467
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
468 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
469 gaim_account_set_ui_int(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
470 const char *name, int value)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
471 {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
472 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
473 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
474
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
475 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
476 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
477 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
478
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
479 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
480
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
481 setting->type = GAIM_PREF_INT;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
482 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
483 setting->value.integer = value;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
484
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
485 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
486
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
487 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
488
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
489 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
490 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
491
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
492 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
493 gaim_account_set_ui_string(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
494 const char *name, const char *value)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
495 {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
496 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
497 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
498
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
499 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
500 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
501 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
502
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
503 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
504
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
505 setting->type = GAIM_PREF_STRING;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
506 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
507 setting->value.string = g_strdup(value);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
508
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
509 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
510
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
511 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
512
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
513 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
514 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
515
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
516 void
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
517 gaim_account_set_ui_bool(GaimAccount *account, const char *ui,
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
518 const char *name, gboolean value)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
519 {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
520 GaimAccountSetting *setting;
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
521 GHashTable *table;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
522
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
523 g_return_if_fail(account != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
524 g_return_if_fail(ui != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
525 g_return_if_fail(name != NULL);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
526
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
527 setting = g_new0(GaimAccountSetting, 1);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
528
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
529 setting->type = GAIM_PREF_BOOLEAN;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
530 setting->ui = g_strdup(ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
531 setting->value.bool = value;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
532
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
533 table = get_ui_settings_table(account, ui);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
534
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
535 g_hash_table_insert(table, g_strdup(name), setting);
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
536
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
537 schedule_accounts_save();
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
538 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
539
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540 gboolean
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
541 gaim_account_is_connected(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
543 g_return_val_if_fail(account != NULL, FALSE);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
544
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 return (account->gc != NULL &&
5930
03f1d6cd784c [gaim-migrate @ 6370]
Christian Hammond <chipx86@chipx86.com>
parents: 5926
diff changeset
546 gaim_connection_get_state(account->gc) != GAIM_DISCONNECTED);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
547 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
550 gaim_account_get_username(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
554 return account->username;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
556
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 gaim_account_get_password(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
561
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562 return account->password;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
564
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
566 gaim_account_get_alias(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
568 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
570 return account->alias;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
573 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574 gaim_account_get_user_info(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
578 return account->user_info;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
579 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
581 const char *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
582 gaim_account_get_buddy_icon(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
583 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
584 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
585
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 return account->buddy_icon;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 GaimProtocol
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 gaim_account_get_protocol(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 g_return_val_if_fail(account != NULL, -1);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
594 return gaim_prpl_id_to_num(gaim_account_get_protocol_id(account));
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
595 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
596
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
597 const char *
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
598 gaim_account_get_protocol_id(const GaimAccount *account)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
599 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
600 g_return_val_if_fail(account != NULL, NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
601
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
602 return account->protocol_id;
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605 GaimConnection *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606 gaim_account_get_connection(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
607 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608 g_return_val_if_fail(account != NULL, NULL);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
609
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
610 return account->gc;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
611 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 gboolean
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
614 gaim_account_get_remember_password(const GaimAccount *account)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
615 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616 g_return_val_if_fail(account != NULL, FALSE);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
617
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618 return account->remember_pass;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
621 gboolean
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
622 gaim_account_get_check_mail(const GaimAccount *account)
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
623 {
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
624 g_return_val_if_fail(account != NULL, FALSE);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
625
5977
2d34c02d2031 [gaim-migrate @ 6424]
Christian Hammond <chipx86@chipx86.com>
parents: 5953
diff changeset
626 return gaim_account_get_bool(account, "check-mail", FALSE);
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
627 }
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
628
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
629 gboolean
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
630 gaim_account_get_auto_login(const GaimAccount *account, const char *ui)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
631 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
632 g_return_val_if_fail(account != NULL, FALSE);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
633 g_return_val_if_fail(ui != NULL, FALSE);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
634
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
635 return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
636 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
637
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
638 const char *
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
639 gaim_account_get_public_ip(const GaimAccount *account)
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
640 {
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
641 g_return_val_if_fail(account != NULL, NULL);
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
642
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
643 return account->ip;
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
644 }
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
645
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
646 GaimProxyInfo *
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
647 gaim_account_get_proxy_info(const GaimAccount *account)
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
648 {
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
649 g_return_val_if_fail(account != NULL, NULL);
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
650
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
651 return account->proxy_info;
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
652 }
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5666
diff changeset
653
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
654 int
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
655 gaim_account_get_int(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
656 int default_value)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
657 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
658 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
659
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
660 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
661 g_return_val_if_fail(name != NULL, default_value);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
662
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
663 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
664
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
665 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
666 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
667
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
668 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
669
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670 return setting->value.integer;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
672
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
673 const char *
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
674 gaim_account_get_string(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
675 const char *default_value)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
676 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
677 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
679 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
680 g_return_val_if_fail(name != NULL, default_value);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
683
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
684 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
685 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
686
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
687 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
688
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689 return setting->value.string;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692 gboolean
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
693 gaim_account_get_bool(const GaimAccount *account, const char *name,
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
694 gboolean default_value)
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
695 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
696 GaimAccountSetting *setting;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
698 g_return_val_if_fail(account != NULL, default_value);
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
699 g_return_val_if_fail(name != NULL, default_value);
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700
5979
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
701 gaim_debug(GAIM_DEBUG_INFO, "account", "looking for bool setting: %s\n",
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
702 name);
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
703
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
704 setting = g_hash_table_lookup(account->settings, name);
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
705
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
706 if (setting == NULL)
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
707 return default_value;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
708
5979
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
709 gaim_debug(GAIM_DEBUG_INFO, "account", "bool setting found: %s, %d\n",
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
710 name, setting->value.bool);
49ae70ffcea5 [gaim-migrate @ 6426]
Christian Hammond <chipx86@chipx86.com>
parents: 5977
diff changeset
711
5565
c3c4aaf69f65 [gaim-migrate @ 5967]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
712 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
713
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
714 return setting->value.bool;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715 }
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
716
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
717 int
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
718 gaim_account_get_ui_int(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
719 const char *name, int default_value)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
720 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
721 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
722 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
723
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
724 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
725 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
726 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
727
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
728 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
729 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
730
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
731 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
732 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
733
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
734 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
735
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
736 return setting->value.integer;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
737 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
738
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
739 const char *
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
740 gaim_account_get_ui_string(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
741 const char *name, const char *default_value)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
742 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
743 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
744 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
745
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
746 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
747 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
748 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
749
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
750 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
751 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
752
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
753 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
754 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
755
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
756 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
757
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
758 return setting->value.string;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
759 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
760
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
761 gboolean
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
762 gaim_account_get_ui_bool(const GaimAccount *account, const char *ui,
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
763 const char *name, gboolean default_value)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
764 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
765 GaimAccountSetting *setting;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
766 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
767
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
768 g_return_val_if_fail(account != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
769 g_return_val_if_fail(ui != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
770 g_return_val_if_fail(name != NULL, default_value);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
771
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
772 if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
773 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
774
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
775 if ((setting = g_hash_table_lookup(table, name)) == NULL)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
776 return default_value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
777
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
778 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
779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
780 return setting->value.bool;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
781 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
782
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
783 /* XML Stuff */
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
784 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
785 free_parser_data(gpointer user_data)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
786 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
787 AccountParserData *data = user_data;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
788
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
789 if (data->buffer != NULL)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5874
diff changeset
790 g_string_free(data->buffer, TRUE);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
791
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
792 if (data->setting_name != NULL)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
793 g_free(data->setting_name);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
794
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
795 g_free(data);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
796 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
797
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
798 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
799 start_element_handler(GMarkupParseContext *context,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
800 const gchar *element_name,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
801 const gchar **attribute_names,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
802 const gchar **attribute_values,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
803 gpointer user_data, GError **error)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
804 {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
805 const char *value;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
806 AccountParserData *data = user_data;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
807 GHashTable *atts;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
808 int i;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
809
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
810 atts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
811
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
812 for (i = 0; attribute_names[i] != NULL; i++) {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
813 g_hash_table_insert(atts, g_strdup(attribute_names[i]),
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
814 g_strdup(attribute_values[i]));
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
815 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
816
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
817 if (data->buffer != NULL) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
818 g_string_free(data->buffer, TRUE);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
819 data->buffer = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
820 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
821
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
822 if (!strcmp(element_name, "protocol"))
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
823 data->tag = TAG_PROTOCOL;
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
824 else if (!strcmp(element_name, "name") || !strcmp(element_name, "username"))
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
825 data->tag = TAG_NAME;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
826 else if (!strcmp(element_name, "password"))
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
827 data->tag = TAG_PASSWORD;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
828 else if (!strcmp(element_name, "alias"))
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
829 data->tag = TAG_ALIAS;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
830 else if (!strcmp(element_name, "userinfo"))
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
831 data->tag = TAG_USERINFO;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
832 else if (!strcmp(element_name, "buddyicon"))
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
833 data->tag = TAG_BUDDYICON;
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
834 else if (!strcmp(element_name, "public-ip"))
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
835 data->tag = TAG_PUBLIC_IP;
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
836 else if (!strcmp(element_name, "proxy")) {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
837 data->in_proxy = TRUE;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
838
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
839 data->proxy_info = gaim_proxy_info_new();
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
840 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
841 else if (!strcmp(element_name, "type"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
842 data->tag = TAG_TYPE;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
843 else if (!strcmp(element_name, "host"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
844 data->tag = TAG_HOST;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
845 else if (!strcmp(element_name, "port"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
846 data->tag = TAG_PORT;
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
847 else if (!strcmp(element_name, "settings")) {
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
848 if ((value = g_hash_table_lookup(atts, "ui")) != NULL) {
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
849 data->setting_ui = g_strdup(value);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
850 }
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
851 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
852 else if (!strcmp(element_name, "setting")) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
853 data->tag = TAG_SETTING;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
854
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
855 if ((value = g_hash_table_lookup(atts, "name")) != NULL)
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
856 data->setting_name = g_strdup(value);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
857
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
858 if ((value = g_hash_table_lookup(atts, "type")) != NULL) {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
859 if (!strcmp(value, "string"))
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
860 data->setting_type = GAIM_PREF_STRING;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
861 else if (!strcmp(value, "int"))
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
862 data->setting_type = GAIM_PREF_INT;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
863 else if (!strcmp(value, "bool"))
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
864 data->setting_type = GAIM_PREF_BOOLEAN;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
865 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
866 }
5870
44d381ad19a9 [gaim-migrate @ 6302]
Mark Doliner <mark@kingant.net>
parents: 5868
diff changeset
867
44d381ad19a9 [gaim-migrate @ 6302]
Mark Doliner <mark@kingant.net>
parents: 5868
diff changeset
868 g_hash_table_destroy(atts);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
869 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
870
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
871 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
872 end_element_handler(GMarkupParseContext *context, const gchar *element_name,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
873 gpointer user_data, GError **error)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
874 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
875 AccountParserData *data = user_data;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
876 gchar *buffer;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
877
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
878 if (data->buffer == NULL)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
879 return;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
880
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
881 buffer = g_string_free(data->buffer, FALSE);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
882 data->buffer = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
883
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
884 if (data->tag == TAG_PROTOCOL) {
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
885 data->protocol_id = g_strdup(buffer);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
886 }
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
887 else if (data->tag == TAG_NAME) {
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
888 if (data->in_proxy) {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
889 gaim_proxy_info_set_username(data->proxy_info, buffer);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
890 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
891 else {
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
892 data->account = gaim_account_new(buffer, data->protocol_id);
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
893
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
894 gaim_accounts_add(data->account);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
895
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
896 g_free(data->protocol_id);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
897
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
898 data->protocol_id = NULL;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
899 }
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
900 }
5581
3a9b54f260e3 [gaim-migrate @ 5985]
Christian Hammond <chipx86@chipx86.com>
parents: 5580
diff changeset
901 else if (data->tag == TAG_PASSWORD) {
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
902 if (*buffer != '\0') {
5792
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
903 if (data->in_proxy) {
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
904 gaim_proxy_info_set_password(data->proxy_info, buffer);
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
905 }
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
906 else {
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
907 gaim_account_set_password(data->account, buffer);
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
908 gaim_account_set_remember_password(data->account, TRUE);
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
909 }
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
910 }
5581
3a9b54f260e3 [gaim-migrate @ 5985]
Christian Hammond <chipx86@chipx86.com>
parents: 5580
diff changeset
911 }
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
912 else if (data->tag == TAG_ALIAS) {
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
913 if (*buffer != '\0')
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
914 gaim_account_set_alias(data->account, buffer);
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
915 }
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
916 else if (data->tag == TAG_USERINFO) {
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
917 if (*buffer != '\0')
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
918 gaim_account_set_user_info(data->account, buffer);
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
919 }
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
920 else if (data->tag == TAG_BUDDYICON) {
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
921 if (*buffer != '\0')
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
922 gaim_account_set_buddy_icon(data->account, buffer);
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
923 }
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
924 else if (data->tag == TAG_PUBLIC_IP) {
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
925 if (*buffer != '\0')
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
926 gaim_account_set_public_ip(data->account, buffer);
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
927 }
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
928 else if (data->tag == TAG_TYPE) {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
929 if (data->in_proxy) {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
930 if (!strcmp(buffer, "global"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
931 gaim_proxy_info_set_type(data->proxy_info,
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
932 GAIM_PROXY_USE_GLOBAL);
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
933 else if (!strcmp(buffer, "none"))
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
934 gaim_proxy_info_set_type(data->proxy_info, GAIM_PROXY_NONE);
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
935 else if (!strcmp(buffer, "http"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
936 gaim_proxy_info_set_type(data->proxy_info, GAIM_PROXY_HTTP);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
937 else if (!strcmp(buffer, "socks4"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
938 gaim_proxy_info_set_type(data->proxy_info, GAIM_PROXY_SOCKS4);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
939 else if (!strcmp(buffer, "socks5"))
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
940 gaim_proxy_info_set_type(data->proxy_info, GAIM_PROXY_SOCKS5);
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
941 else if (!strcmp(buffer, "envvar"))
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
942 gaim_proxy_info_set_type(data->proxy_info, GAIM_PROXY_USE_ENVVAR);
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
943 else
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
944 gaim_debug(GAIM_DEBUG_ERROR, "account",
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
945 "Invalid proxy type found when loading account "
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
946 "information for %s\n",
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
947 gaim_account_get_username(data->account));
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
948 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
949 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
950 else if (data->tag == TAG_HOST) {
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
951 if (data->in_proxy && *buffer != '\0')
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
952 gaim_proxy_info_set_host(data->proxy_info, buffer);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
953 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
954 else if (data->tag == TAG_PORT) {
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
955 if (data->in_proxy && *buffer != '\0')
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
956 gaim_proxy_info_set_port(data->proxy_info, atoi(buffer));
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
957 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
958 else if (data->tag == TAG_SETTING) {
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
959 if (*buffer != '\0') {
5792
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
960 if (data->setting_ui != NULL) {
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
961 if (data->setting_type == GAIM_PREF_STRING)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
962 gaim_account_set_ui_string(data->account, data->setting_ui,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
963 data->setting_name, buffer);
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
964 else if (data->setting_type == GAIM_PREF_INT)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
965 gaim_account_set_ui_int(data->account, data->setting_ui,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
966 data->setting_name, atoi(buffer));
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
967 else if (data->setting_type == GAIM_PREF_BOOLEAN)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
968 gaim_account_set_ui_bool(data->account, data->setting_ui,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
969 data->setting_name,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
970 (*buffer == '0' ? FALSE : TRUE));
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
971 }
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
972 else {
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
973 if (data->setting_type == GAIM_PREF_STRING)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
974 gaim_account_set_string(data->account, data->setting_name,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
975 buffer);
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
976 else if (data->setting_type == GAIM_PREF_INT)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
977 gaim_account_set_int(data->account, data->setting_name,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
978 atoi(buffer));
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
979 else if (data->setting_type == GAIM_PREF_BOOLEAN)
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
980 gaim_account_set_bool(data->account, data->setting_name,
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
981 (*buffer == '0' ? FALSE : TRUE));
d89cadcafbec [gaim-migrate @ 6217]
Christian Hammond <chipx86@chipx86.com>
parents: 5780
diff changeset
982 }
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
983 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
984
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
985 g_free(data->setting_name);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
986 data->setting_name = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
987 }
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
988 else if (!strcmp(element_name, "proxy")) {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
989 data->in_proxy = FALSE;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
990
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
991 if (gaim_proxy_info_get_type(data->proxy_info) == GAIM_PROXY_USE_GLOBAL) {
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
992 gaim_proxy_info_destroy(data->proxy_info);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
993 data->proxy_info = NULL;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
994 }
5953
bc71bd31c223 [gaim-migrate @ 6397]
Christian Hammond <chipx86@chipx86.com>
parents: 5943
diff changeset
995 else if (*buffer != '\0') {
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
996 gaim_account_set_proxy_info(data->account, data->proxy_info);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
997 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
998 }
5777
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
999 else if (!strcmp(element_name, "settings")) {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1000 if (data->setting_ui != NULL) {
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1001 g_free(data->setting_ui);
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1002 data->setting_ui = NULL;
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1003 }
1f786fb43ee6 [gaim-migrate @ 6202]
Christian Hammond <chipx86@chipx86.com>
parents: 5742
diff changeset
1004 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1005
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1006 data->tag = TAG_NONE;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1007
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1008 g_free(buffer);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1009 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1010
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1011 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1012 text_handler(GMarkupParseContext *context, const gchar *text,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1013 gsize text_len, gpointer user_data, GError **error)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1014 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1015 AccountParserData *data = user_data;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1016
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1017 if (data->buffer == NULL)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1018 data->buffer = g_string_new_len(text, text_len);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1019 else
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1020 g_string_append_len(data->buffer, text, text_len);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1021 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1022
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1023 static GMarkupParser accounts_parser =
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1024 {
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1025 start_element_handler,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1026 end_element_handler,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1027 text_handler,
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1028 NULL,
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1029 NULL
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1030 };
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1031
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1032 gboolean
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1033 gaim_accounts_load()
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1034 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1035 gchar *filename = g_build_filename(gaim_user_dir(), "accounts.xml", NULL);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1036 gchar *contents = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1037 gsize length;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1038 GMarkupParseContext *context;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1039 GError *error = NULL;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1040 AccountParserData *parser_data;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1041
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1042 if (filename == NULL) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1043 accounts_loaded = TRUE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1044 return FALSE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1045 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1046
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1047 if (!g_file_get_contents(filename, &contents, &length, &error)) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1048 gaim_debug(GAIM_DEBUG_ERROR, "accounts",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1049 "Error reading accounts: %s\n", error->message);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1050 g_error_free(error);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
1051 g_free(filename);
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
1052 accounts_loaded = TRUE;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1053
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1054 return FALSE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1055 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1056
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1057 parser_data = g_new0(AccountParserData, 1);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1058
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1059 context = g_markup_parse_context_new(&accounts_parser, 0,
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1060 parser_data, free_parser_data);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1061
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1062 if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1063 g_markup_parse_context_free(context);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1064 g_free(contents);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
1065 g_free(filename);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1066 accounts_loaded = TRUE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1067
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1068 return FALSE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1069 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1070
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1071 if (!g_markup_parse_context_end_parse(context, NULL)) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1072 gaim_debug(GAIM_DEBUG_ERROR, "accounts", "Error parsing %s\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1073 filename);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1074 g_markup_parse_context_free(context);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1075 g_free(contents);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 6036
diff changeset
1076 g_free(filename);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1077 accounts_loaded = TRUE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1078
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1079 return FALSE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1080 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1081
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1082 g_markup_parse_context_free(context);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1083 g_free(contents);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1084 g_free(filename);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1085 accounts_loaded = TRUE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1086
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1087 return TRUE;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1088 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1089
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1090 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1091 write_setting(gpointer key, gpointer value, gpointer user_data)
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1092 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1093 GaimAccountSetting *setting;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1094 const char *name;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1095 FILE *fp;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1096
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1097 setting = (GaimAccountSetting *)value;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1098 name = (const char *)key;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1099 fp = (FILE *)user_data;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1100
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1101 if (setting->type == GAIM_PREF_INT) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1102 fprintf(fp, " <setting name='%s' type='int'>%d</setting>\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1103 name, setting->value.integer);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1104 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1105 else if (setting->type == GAIM_PREF_STRING) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1106 fprintf(fp, " <setting name='%s' type='string'>%s</setting>\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1107 name, setting->value.string);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1108 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1109 else if (setting->type == GAIM_PREF_BOOLEAN) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1110 fprintf(fp, " <setting name='%s' type='bool'>%d</setting>\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1111 name, setting->value.bool);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1112 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1113 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1114
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1115 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1116 write_ui_setting_list(gpointer key, gpointer value, gpointer user_data)
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1117 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1118 GHashTable *table;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1119 const char *ui;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1120 FILE *fp;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1121
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1122 table = (GHashTable *)value;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1123 ui = (const char *)key;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1124 fp = (FILE *)user_data;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1125
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1126 fprintf(fp, " <settings ui='%s'>\n", ui);
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1127 g_hash_table_foreach(table, write_setting, fp);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1128 fprintf(fp, " </settings>\n");
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1129 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1130
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1131 static void
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1132 gaim_accounts_write(FILE *fp, GaimAccount *account)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1133 {
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1134 GaimProxyInfo *proxy_info;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1135 GaimProxyType proxy_type;
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
1136 const char *password, *alias, *user_info, *buddy_icon, *ip;
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1137 char *esc;
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1138
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1139 fprintf(fp, " <account>\n");
5643
eb685809108b [gaim-migrate @ 6057]
Christian Hammond <chipx86@chipx86.com>
parents: 5620
diff changeset
1140 fprintf(fp, " <protocol>%s</protocol>\n", account->protocol_id);
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1141 esc = g_markup_escape_text(gaim_account_get_username(account), -1);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1142 fprintf(fp, " <name>%s</name>\n", esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1143 g_free(esc);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1144
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1145 if (gaim_account_get_remember_password(account) &&
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1146 (password = gaim_account_get_password(account)) != NULL) {
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1147 esc = g_markup_escape_text(password, -1);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1148 fprintf(fp, " <password>%s</password>\n", esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1149 g_free(esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1150 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1151
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1152 if ((alias = gaim_account_get_alias(account)) != NULL) {
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1153 esc = g_markup_escape_text(alias, -1);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1154 fprintf(fp, " <alias>%s</alias>\n", esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1155 g_free(esc);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1156 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1157
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1158 if ((user_info = gaim_account_get_user_info(account)) != NULL) {
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1159 esc = g_markup_escape_text(user_info, -1);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1160 fprintf(fp, " <userinfo>%s</userinfo>\n", esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1161 g_free(esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1162 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1163
5610
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1164 if ((buddy_icon = gaim_account_get_buddy_icon(account)) != NULL) {
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1165 esc = g_markup_escape_text(buddy_icon, -1);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1166 fprintf(fp, " <buddyicon>%s</buddyicon>\n", esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1167 g_free(esc);
4a1f97312412 [gaim-migrate @ 6016]
Nathan Walp <nwalp@pidgin.im>
parents: 5581
diff changeset
1168 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1169
6239
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
1170 if ((ip = gaim_account_get_public_ip(account)) != NULL) {
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
1171 fprintf(fp, " <public-ip>%s</public-ip>\n", ip);
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
1172 }
8d10cdfe1bb1 [gaim-migrate @ 6733]
Christian Hammond <chipx86@chipx86.com>
parents: 6122
diff changeset
1173
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1174 fprintf(fp, " <settings>\n");
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1175 g_hash_table_foreach(account->settings, write_setting, fp);
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1176 fprintf(fp, " </settings>\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1177
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5792
diff changeset
1178 g_hash_table_foreach(account->ui_settings, write_ui_setting_list, fp);
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1179
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1180 if ((proxy_info = gaim_account_get_proxy_info(account)) != NULL)
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1181 {
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1182 const char *value;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1183 int int_value;
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1184
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1185 proxy_type = gaim_proxy_info_get_type(proxy_info);
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1186
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1187 fprintf(fp, " <proxy>\n");
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1188 fprintf(fp, " <type>%s</type>\n",
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1189 (proxy_type == GAIM_PROXY_USE_GLOBAL ? "global" :
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1190 proxy_type == GAIM_PROXY_NONE ? "none" :
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1191 proxy_type == GAIM_PROXY_HTTP ? "http" :
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1192 proxy_type == GAIM_PROXY_SOCKS4 ? "socks4" :
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1193 proxy_type == GAIM_PROXY_SOCKS5 ? "socks5" :
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1194 proxy_type == GAIM_PROXY_USE_ENVVAR ? "envvar" : "unknown"));
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1195
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1196 if (proxy_type != GAIM_PROXY_USE_GLOBAL &&
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1197 proxy_type != GAIM_PROXY_NONE &&
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6581
diff changeset
1198 proxy_type != GAIM_PROXY_USE_ENVVAR) {
5707
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1199 if ((value = gaim_proxy_info_get_host(proxy_info)) != NULL)
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1200 fprintf(fp, " <host>%s</host>\n", value);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1201
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1202 if ((int_value = gaim_proxy_info_get_port(proxy_info)) != 0)
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1203 fprintf(fp, " <port>%d</port>\n", int_value);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1204
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1205 if ((value = gaim_proxy_info_get_username(proxy_info)) != NULL)
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1206 fprintf(fp, " <username>%s</username>\n", value);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1207
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1208 if ((value = gaim_proxy_info_get_password(proxy_info)) != NULL)
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1209 fprintf(fp, " <password>%s</password>\n", value);
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1210 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1211
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1212 fprintf(fp, " </proxy>\n");
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1213 }
b69400aa008e [gaim-migrate @ 6128]
Christian Hammond <chipx86@chipx86.com>
parents: 5703
diff changeset
1214
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1215 fprintf(fp, " </account>\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1216 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1217
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1218 void
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1219 gaim_accounts_sync(void)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1220 {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1221 FILE *fp;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1222 const char *user_dir = gaim_user_dir();
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1223 char *filename;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1224 char *filename_real;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1225
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1226 if (!accounts_loaded) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1227 gaim_debug(GAIM_DEBUG_WARNING, "accounts",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1228 "Writing accounts to disk.\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1229 schedule_accounts_save();
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1230 return;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1231 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1232
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1233 if (user_dir == NULL)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1234 return;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1235
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1236 gaim_debug(GAIM_DEBUG_INFO, "accounts", "Writing accounts to disk.\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1237
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1238 fp = fopen(user_dir, "r");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1239
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1240 if (fp == NULL)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1241 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1242 else
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1243 fclose(fp);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1244
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1245 filename = g_build_filename(user_dir, "accounts.xml.save", NULL);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1246
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1247 if ((fp = fopen(filename, "w")) != NULL) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1248 GList *l;
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1249
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1250 fprintf(fp, "<?xml version='1.0' encoding='UTF-8' ?>\n\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1251 fprintf(fp, "<accounts>\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1252
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1253 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1254 gaim_accounts_write(fp, l->data);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1255
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1256 fprintf(fp, "</accounts>\n");
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1257
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1258 fclose(fp);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1259 chmod(filename, S_IRUSR | S_IWUSR);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1260 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1261 else {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1262 gaim_debug(GAIM_DEBUG_ERROR, "accounts", "Unable to write %s\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1263 filename);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1264 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1265
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1266 filename_real = g_build_filename(user_dir, "accounts.xml", NULL);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1267
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1268 if (rename(filename, filename_real) < 0) {
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1269 gaim_debug(GAIM_DEBUG_ERROR, "accounts", "Error renaming %s to %s\n",
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1270 filename, filename_real);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1271 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1272
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1273 g_free(filename);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1274 g_free(filename_real);
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1275 }
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1276
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1277 void
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1278 gaim_accounts_add(GaimAccount *account)
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1279 {
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1280 g_return_if_fail(account != NULL);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1281
5867
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1282 if (g_list_find(accounts, account) != NULL)
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1283 return;
db4df0be06fd [gaim-migrate @ 6298]
Christian Hammond <chipx86@chipx86.com>
parents: 5865
diff changeset
1284
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1285 accounts = g_list_append(accounts, account);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1286
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1287 schedule_accounts_save();
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1288 }
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1289
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1290 void
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1291 gaim_accounts_remove(GaimAccount *account)
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1292 {
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1293 g_return_if_fail(account != NULL);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1294
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1295 accounts = g_list_remove(accounts, account);
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1296
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1297 schedule_accounts_save();
6368
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1298 }
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1299
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1300 void
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1301 gaim_accounts_delete(GaimAccount *account)
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1302 {
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1303 GaimBlistNode *gnode, *bnode;
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1304
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1305 g_return_if_fail(account != NULL);
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1306
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1307 gaim_accounts_remove(account);
6367
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1308
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1309 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) {
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1310 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1311 continue;
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1312
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1313 for (bnode = gnode->child; bnode != NULL; bnode = bnode->next) {
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1314 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1315 struct buddy *b = (struct buddy *)bnode;
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1316
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1317 if (b->account == account)
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1318 gaim_blist_remove_buddy(b);
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1319 }
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1320 else if (GAIM_BLIST_NODE_IS_CHAT(bnode)) {
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1321 struct chat *c = (struct chat *)bnode;
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1322
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1323 if (c->account == account)
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1324 gaim_blist_remove_chat(c);
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1325 }
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1326 }
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1327 }
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1328
9fd154ca6a94 [gaim-migrate @ 6872]
Christian Hammond <chipx86@chipx86.com>
parents: 6366
diff changeset
1329 gaim_blist_save();
6368
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1330
41e6d15f4687 [gaim-migrate @ 6873]
Christian Hammond <chipx86@chipx86.com>
parents: 6367
diff changeset
1331 gaim_account_destroy(account);
5710
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1332 }
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1333
dbac958d8937 [gaim-migrate @ 6131]
Christian Hammond <chipx86@chipx86.com>
parents: 5707
diff changeset
1334 void
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1335 gaim_accounts_auto_login(const char *ui)
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1336 {
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1337 GaimAccount *account;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1338 GList *l;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1339
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1340 g_return_if_fail(ui != NULL);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1341
5780
a9029bed0479 [gaim-migrate @ 6205]
Christian Hammond <chipx86@chipx86.com>
parents: 5779
diff changeset
1342 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1343 account = l->data;
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1344
6122
914f2d5da21c [gaim-migrate @ 6596]
Mark Doliner <mark@kingant.net>
parents: 6110
diff changeset
1345 if (gaim_account_get_auto_login(account, ui))
5779
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1346 gaim_account_connect(account);
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1347 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1348 }
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1349
758fa27534b3 [gaim-migrate @ 6204]
Christian Hammond <chipx86@chipx86.com>
parents: 5777
diff changeset
1350 void
5580
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1351 gaim_accounts_reorder(GaimAccount *account, size_t new_index)
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1352 {
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1353 size_t index;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1354 GList *l;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1355
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1356 g_return_if_fail(account != NULL);
5620
c9724982ce45 [gaim-migrate @ 6027]
Christian Hammond <chipx86@chipx86.com>
parents: 5610
diff changeset
1357 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
1358
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1359 index = g_list_index(accounts, account);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1360
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1361 if (index == -1) {
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1362 gaim_debug(GAIM_DEBUG_ERROR, "accounts",
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1363 "Unregistered account (%s) discovered during reorder!\n",
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1364 gaim_account_get_username(account));
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1365 return;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1366 }
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1367
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1368 l = g_list_nth(accounts, index);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1369
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1370 if (new_index > index)
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1371 new_index--;
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1372
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1373 /* Remove the old one. */
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1374 accounts = g_list_delete_link(accounts, l);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1375
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1376 /* Insert it where it should go. */
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1377 accounts = g_list_insert(accounts, account, new_index);
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1378
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1379 schedule_accounts_save();
86456ec3ca25 [gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents: 5574
diff changeset
1380 }
5573
5e7de337a053 [gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents: 5565
diff changeset
1381
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1382 GList *
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1383 gaim_accounts_get_all(void)
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1384 {
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1385 return accounts;
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1386 }
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1387
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1388 GaimAccount *
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1389 gaim_accounts_find(const char *name, GaimProtocol protocol)
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1390 {
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1391 GaimAccount *account = NULL;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1392 GList *l;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1393 char *who;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1394
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1395 g_return_val_if_fail(name != NULL, NULL);
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1396
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1397 who = g_strdup(normalize(name));
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1398
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1399 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1400 account = (GaimAccount *)l->data;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1401
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1402 if (!strcmp(normalize(gaim_account_get_username(account)), who)) {
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1403 if (protocol != -1) {
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1404 if (gaim_account_get_protocol(account) == protocol)
5874
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1405 break;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1406 }
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1407 else
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1408 break;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1409 }
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1410
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1411 account = NULL;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1412 }
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1413
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1414 g_free(who);
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1415
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1416 return account;
964e4f94fc56 [gaim-migrate @ 6306]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1417 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1418
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1419 GaimAccount *
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1420 gaim_accounts_find_with_prpl_id(const char *name, const char *protocol_id)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1421 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1422 GaimAccount *account = NULL;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1423 GList *l;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1424 char *who;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1425
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1426 g_return_val_if_fail(name != NULL, NULL);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1427
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1428 who = g_strdup(normalize(name));
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1429
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1430 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1431 account = (GaimAccount *)l->data;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1432
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1433 if (!strcmp(normalize(gaim_account_get_username(account)), who) &&
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1434 !strcmp(account->protocol_id, protocol_id)) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1435
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1436 break;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1437 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1438
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1439 account = NULL;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1440 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1441
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1442 g_free(who);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1443
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1444 return account;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5942
diff changeset
1445 }
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1446
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1447 void *
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1448 gaim_accounts_get_handle(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1449 {
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1450 static int handle;
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1451
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1452 return &handle;
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1453 }
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1454
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1455 void
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1456 gaim_accounts_init(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1457 {
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1458 void *handle = gaim_accounts_get_handle();
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1459
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1460 gaim_signal_register(handle, "account-connecting",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1461 gaim_marshal_VOID__POINTER, NULL, 1,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1462 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1463 GAIM_SUBTYPE_ACCOUNT));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1464
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1465 gaim_signal_register(handle, "account-away",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1466 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1467 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1468 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1469 gaim_value_new(GAIM_TYPE_STRING),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1470 gaim_value_new(GAIM_TYPE_STRING));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1471
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1472 gaim_signal_register(handle, "account-setting-info",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1473 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1474 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1475 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1476 gaim_value_new(GAIM_TYPE_STRING));
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1477
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1478 gaim_signal_register(handle, "account-set-info",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1479 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1480 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1481 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1482 gaim_value_new(GAIM_TYPE_STRING));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1483
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1484 gaim_signal_register(handle, "account-warned",
6564
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1485 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1486 gaim_value_new(GAIM_TYPE_SUBTYPE,
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1487 GAIM_SUBTYPE_ACCOUNT),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1488 gaim_value_new(GAIM_TYPE_STRING),
800ef4a51096 [gaim-migrate @ 7086]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
1489 gaim_value_new(GAIM_TYPE_UINT));
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1490 }
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1491
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1492 void
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1493 gaim_accounts_uninit(void)
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1494 {
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1495 gaim_signals_unregister_by_instance(gaim_accounts_get_handle());
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6368
diff changeset
1496 }