libpurple/accounts.c

Wed, 19 Jun 2013 01:40:28 +0530

author
Ankit Vani <a@nevitus.org>
date
Wed, 19 Jun 2013 01:40:28 +0530
branch
soc.2013.gobjectification
changeset 34581
b4e0236019e6
parent 34580
ab3f70aaaf17
child 34582
67a520874aa9
permissions
-rw-r--r--

Fixed more PurpleAccount stuff.
* Changed back to PurpleAccountSetting and the union for value in PurpleAccountSetting to GValue
* Removed properties for password and public alias since they require a callback to be specified

34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1 /**
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
2 * @file accounts.c Accounts API
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
3 * @ingroup core
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
4 */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
5
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
6 /* purple
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
7 *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
10 * source distribution.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
11 *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
15 * (at your option) any later version.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
16 *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
20 * GNU General Public License for more details.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
21 *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
25 */
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
26 #include "internal.h"
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
27 #include "accounts.h"
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
28 #include "core.h"
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
29 #include "dbus-maybe.h"
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
30 #include "debug.h"
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
31
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
32 static PurpleAccountUiOps *account_ui_ops = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
33
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
34 static GList *accounts = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
35 static guint save_timer = 0;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
36 static gboolean accounts_loaded = FALSE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
37
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
38 /*********************************************************************
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
39 * Writing to disk *
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
40 *********************************************************************/
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
41 static xmlnode *
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
42 accounts_to_xmlnode(void)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
43 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
44 xmlnode *node, *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
45 GList *cur;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
46
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
47 node = xmlnode_new("account");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
48 xmlnode_set_attrib(node, "version", "1.0");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
49
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
50 for (cur = purple_accounts_get_all(); cur != NULL; cur = cur->next)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
51 {
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
52 child = purple_account_to_xmlnode(cur->data);
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
53 xmlnode_insert_child(node, child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
54 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
55
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
56 return node;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
57 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
58
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
59 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
60 sync_accounts(void)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
61 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
62 xmlnode *node;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
63 char *data;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
64
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
65 if (!accounts_loaded)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
66 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
67 purple_debug_error("account", "Attempted to save accounts before "
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
68 "they were read!\n");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
69 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
70 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
71
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
72 node = accounts_to_xmlnode();
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
73 data = xmlnode_to_formatted_str(node, NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
74 purple_util_write_data_to_file("accounts.xml", data, -1);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
75 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
76 xmlnode_free(node);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
77 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
78
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
79 static gboolean
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
80 save_cb(gpointer data)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
81 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
82 sync_accounts();
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
83 save_timer = 0;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
84 return FALSE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
85 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
86
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
87 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
88 schedule_accounts_save(void)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
89 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
90 if (save_timer == 0)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
91 save_timer = purple_timeout_add_seconds(5, save_cb, NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
92 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
93
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
94 /*********************************************************************
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
95 * Reading from disk *
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
96 *********************************************************************/
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
97 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
98 migrate_yahoo_japan(PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
99 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
100 /* detect a Yahoo! JAPAN account that existed prior to 2.6.0 and convert it
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
101 * to use the new prpl-yahoojp. Also remove the account-specific settings
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
102 * we no longer need */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
103
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
104 if(purple_strequal(purple_account_get_protocol_id(account), "prpl-yahoo")) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
105 if(purple_account_get_bool(account, "yahoojp", FALSE)) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
106 const char *serverjp = purple_account_get_string(account, "serverjp", NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
107 const char *xferjp_host = purple_account_get_string(account, "xferjp_host", NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
108
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
109 g_return_if_fail(serverjp != NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
110 g_return_if_fail(xferjp_host != NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
111
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
112 purple_account_set_string(account, "server", serverjp);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
113 purple_account_set_string(account, "xfer_host", xferjp_host);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
114
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
115 purple_account_set_protocol_id(account, "prpl-yahoojp");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
116 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
117
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
118 /* these should always be nuked */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
119 purple_account_remove_setting(account, "yahoojp");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
120 purple_account_remove_setting(account, "serverjp");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
121 purple_account_remove_setting(account, "xferjp_host");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
122
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
123 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
124 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
125
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
126 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
127 migrate_icq_server(PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
128 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
129 /* Migrate the login server setting for ICQ accounts. See
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
130 * 'mtn log --last 1 --no-graph --from b6d7712e90b68610df3bd2d8cbaf46d94c8b3794'
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
131 * for details on the change. */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
132
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
133 if(purple_strequal(purple_account_get_protocol_id(account), "prpl-icq")) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
134 const char *tmp = purple_account_get_string(account, "server", NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
135
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
136 /* Non-secure server */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
137 if(purple_strequal(tmp, "login.messaging.aol.com") ||
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
138 purple_strequal(tmp, "login.oscar.aol.com"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
139 purple_account_set_string(account, "server", "login.icq.com");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
140
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
141 /* Secure server */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
142 if(purple_strequal(tmp, "slogin.oscar.aol.com"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
143 purple_account_set_string(account, "server", "slogin.icq.com");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
144 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
145 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
146
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
147 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
148 migrate_xmpp_encryption(PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
149 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
150 /* When this is removed, nuke the "old_ssl" and "require_tls" settings */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
151 if (g_str_equal(purple_account_get_protocol_id(account), "prpl-jabber")) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
152 const char *sec = purple_account_get_string(account, "connection_security", "");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
153
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
154 if (g_str_equal("", sec)) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
155 const char *val = "require_tls";
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
156 if (purple_account_get_bool(account, "old_ssl", FALSE))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
157 val = "old_ssl";
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
158 else if (!purple_account_get_bool(account, "require_tls", TRUE))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
159 val = "opportunistic_tls";
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
160
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
161 purple_account_set_string(account, "connection_security", val);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
162 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
163 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
164 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
165
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
166 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
167 parse_settings(xmlnode *node, PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
168 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
169 const char *ui;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
170 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
171
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
172 /* Get the UI string, if these are UI settings */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
173 ui = xmlnode_get_attrib(node, "ui");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
174
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
175 /* Read settings, one by one */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
176 for (child = xmlnode_get_child(node, "setting"); child != NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
177 child = xmlnode_get_next_twin(child))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
178 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
179 const char *name, *str_type;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
180 PurplePrefType type;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
181 char *data;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
182
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
183 name = xmlnode_get_attrib(child, "name");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
184 if (name == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
185 /* Ignore this setting */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
186 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
187
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
188 str_type = xmlnode_get_attrib(child, "type");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
189 if (str_type == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
190 /* Ignore this setting */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
191 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
192
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
193 if (purple_strequal(str_type, "string"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
194 type = PURPLE_PREF_STRING;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
195 else if (purple_strequal(str_type, "int"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
196 type = PURPLE_PREF_INT;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
197 else if (purple_strequal(str_type, "bool"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
198 type = PURPLE_PREF_BOOLEAN;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
199 else
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
200 /* Ignore this setting */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
201 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
202
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
203 data = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
204 if (data == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
205 /* Ignore this setting */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
206 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
207
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
208 if (ui == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
209 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
210 if (type == PURPLE_PREF_STRING)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
211 purple_account_set_string(account, name, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
212 else if (type == PURPLE_PREF_INT)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
213 purple_account_set_int(account, name, atoi(data));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
214 else if (type == PURPLE_PREF_BOOLEAN)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
215 purple_account_set_bool(account, name,
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
216 (*data == '0' ? FALSE : TRUE));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
217 } else {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
218 if (type == PURPLE_PREF_STRING)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
219 purple_account_set_ui_string(account, ui, name, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
220 else if (type == PURPLE_PREF_INT)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
221 purple_account_set_ui_int(account, ui, name, atoi(data));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
222 else if (type == PURPLE_PREF_BOOLEAN)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
223 purple_account_set_ui_bool(account, ui, name,
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
224 (*data == '0' ? FALSE : TRUE));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
225 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
226
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
227 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
228 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
229
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
230 /* we do this here because we need access to account settings to determine
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
231 * if we can/should migrate an old Yahoo! JAPAN account */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
232 migrate_yahoo_japan(account);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
233 /* we do this here because we need access to account settings to determine
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
234 * if we can/should migrate an ICQ account's server setting */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
235 migrate_icq_server(account);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
236 /* we do this here because we need to do it before the user views the
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
237 * Edit Account dialog. */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
238 migrate_xmpp_encryption(account);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
239 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
240
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
241 static GList *
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
242 parse_status_attrs(xmlnode *node, PurpleStatus *status)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
243 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
244 GList *list = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
245 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
246 PurpleValue *attr_value;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
247
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
248 for (child = xmlnode_get_child(node, "attribute"); child != NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
249 child = xmlnode_get_next_twin(child))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
250 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
251 const char *id = xmlnode_get_attrib(child, "id");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
252 const char *value = xmlnode_get_attrib(child, "value");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
253
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
254 if (!id || !*id || !value || !*value)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
255 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
256
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
257 attr_value = purple_status_get_attr_value(status, id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
258 if (!attr_value)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
259 continue;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
260
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
261 list = g_list_append(list, (char *)id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
262
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
263 switch (purple_value_get_type(attr_value))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
264 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
265 case PURPLE_TYPE_STRING:
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
266 list = g_list_append(list, (char *)value);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
267 break;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
268 case PURPLE_TYPE_INT:
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
269 case PURPLE_TYPE_BOOLEAN:
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
270 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
271 int v;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
272 if (sscanf(value, "%d", &v) == 1)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
273 list = g_list_append(list, GINT_TO_POINTER(v));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
274 else
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
275 list = g_list_remove(list, id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
276 break;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
277 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
278 default:
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
279 break;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
280 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
281 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
282
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
283 return list;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
284 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
285
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
286 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
287 parse_status(xmlnode *node, PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
288 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
289 gboolean active = FALSE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
290 const char *data;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
291 const char *type;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
292 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
293 GList *attrs = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
294
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
295 /* Get the active/inactive state */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
296 data = xmlnode_get_attrib(node, "active");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
297 if (data == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
298 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
299 if (g_ascii_strcasecmp(data, "true") == 0)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
300 active = TRUE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
301 else if (g_ascii_strcasecmp(data, "false") == 0)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
302 active = FALSE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
303 else
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
304 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
305
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
306 /* Get the type of the status */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
307 type = xmlnode_get_attrib(node, "type");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
308 if (type == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
309 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
310
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
311 /* Read attributes into a GList */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
312 child = xmlnode_get_child(node, "attributes");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
313 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
314 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
315 attrs = parse_status_attrs(child,
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
316 purple_account_get_status(account, type));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
317 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
318
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
319 purple_account_set_status_list(account, type, active, attrs);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
320
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
321 g_list_free(attrs);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
322 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
323
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
324 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
325 parse_statuses(xmlnode *node, PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
326 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
327 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
328
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
329 for (child = xmlnode_get_child(node, "status"); child != NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
330 child = xmlnode_get_next_twin(child))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
331 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
332 parse_status(child, account);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
333 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
334 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
335
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
336 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
337 parse_proxy_info(xmlnode *node, PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
338 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
339 PurpleProxyInfo *proxy_info;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
340 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
341 char *data;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
342
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
343 proxy_info = purple_proxy_info_new();
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
344
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
345 /* Use the global proxy settings, by default */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
346 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_GLOBAL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
347
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
348 /* Read proxy type */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
349 child = xmlnode_get_child(node, "type");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
350 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
351 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
352 if (purple_strequal(data, "global"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
353 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_GLOBAL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
354 else if (purple_strequal(data, "none"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
355 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
356 else if (purple_strequal(data, "http"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
357 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_HTTP);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
358 else if (purple_strequal(data, "socks4"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
359 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS4);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
360 else if (purple_strequal(data, "socks5"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
361 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_SOCKS5);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
362 else if (purple_strequal(data, "tor"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
363 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_TOR);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
364 else if (purple_strequal(data, "envvar"))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
365 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_USE_ENVVAR);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
366 else
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
367 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
368 purple_debug_error("account", "Invalid proxy type found when "
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
369 "loading account information for %s\n",
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
370 purple_account_get_username(account));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
371 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
372 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
373 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
374
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
375 /* Read proxy host */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
376 child = xmlnode_get_child(node, "host");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
377 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
378 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
379 purple_proxy_info_set_host(proxy_info, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
380 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
381 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
382
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
383 /* Read proxy port */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
384 child = xmlnode_get_child(node, "port");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
385 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
386 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
387 purple_proxy_info_set_port(proxy_info, atoi(data));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
388 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
389 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
390
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
391 /* Read proxy username */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
392 child = xmlnode_get_child(node, "username");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
393 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
394 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
395 purple_proxy_info_set_username(proxy_info, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
396 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
397 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
398
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
399 /* Read proxy password */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
400 child = xmlnode_get_child(node, "password");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
401 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
402 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
403 purple_proxy_info_set_password(proxy_info, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
404 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
405 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
406
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
407 /* If there are no values set then proxy_info NULL */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
408 if ((purple_proxy_info_get_type(proxy_info) == PURPLE_PROXY_USE_GLOBAL) &&
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
409 (purple_proxy_info_get_host(proxy_info) == NULL) &&
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
410 (purple_proxy_info_get_port(proxy_info) == 0) &&
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
411 (purple_proxy_info_get_username(proxy_info) == NULL) &&
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
412 (purple_proxy_info_get_password(proxy_info) == NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
413 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
414 purple_proxy_info_destroy(proxy_info);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
415 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
416 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
417
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
418 purple_account_set_proxy_info(account, proxy_info);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
419 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
420
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
421 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
422 parse_current_error(xmlnode *node, PurpleAccount *account)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
423 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
424 guint type;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
425 char *type_str = NULL, *description = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
426 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
427 PurpleConnectionErrorInfo *current_error = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
428
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
429 child = xmlnode_get_child(node, "type");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
430 if (child == NULL || (type_str = xmlnode_get_data(child)) == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
431 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
432 type = atoi(type_str);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
433 g_free(type_str);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
434
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
435 if (type > PURPLE_CONNECTION_ERROR_OTHER_ERROR)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
436 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
437 purple_debug_error("account",
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
438 "Invalid PurpleConnectionError value %d found when "
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
439 "loading account information for %s\n",
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
440 type, purple_account_get_username(account));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
441 type = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
442 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
443
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
444 child = xmlnode_get_child(node, "description");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
445 if (child)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
446 description = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
447 if (description == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
448 description = g_strdup("");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
449
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
450 current_error = g_new0(PurpleConnectionErrorInfo, 1);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
451 PURPLE_DBUS_REGISTER_POINTER(current_error, PurpleConnectionErrorInfo);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
452 current_error->type = type;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
453 current_error->description = description;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
454
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
455 set_current_error(account, current_error);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
456 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
457
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
458 static PurpleAccount *
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
459 parse_account(xmlnode *node)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
460 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
461 PurpleAccount *ret;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
462 xmlnode *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
463 char *protocol_id = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
464 char *name = NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
465 char *data;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
466
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
467 child = xmlnode_get_child(node, "protocol");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
468 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
469 protocol_id = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
470
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
471 child = xmlnode_get_child(node, "name");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
472 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
473 name = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
474 if (name == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
475 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
476 /* Do we really need to do this? */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
477 child = xmlnode_get_child(node, "username");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
478 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
479 name = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
480 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
481
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
482 if ((protocol_id == NULL) || (name == NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
483 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
484 g_free(protocol_id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
485 g_free(name);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
486 return NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
487 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
488
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
489 ret = purple_account_new(name, protocol_id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
490 g_free(name);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
491 g_free(protocol_id);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
492
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
493 /* Read the alias */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
494 child = xmlnode_get_child(node, "alias");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
495 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
496 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
497 if (*data != '\0')
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
498 purple_account_set_alias(ret, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
499 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
500 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
501
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
502 /* Read the statuses */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
503 child = xmlnode_get_child(node, "statuses");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
504 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
505 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
506 parse_statuses(child, ret);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
507 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
508
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
509 /* Read the userinfo */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
510 child = xmlnode_get_child(node, "userinfo");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
511 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
512 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
513 purple_account_set_user_info(ret, data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
514 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
515 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
516
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
517 /* Read an old buddyicon */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
518 child = xmlnode_get_child(node, "buddyicon");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
519 if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
520 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
521 const char *dirname = purple_buddy_icons_get_cache_dir();
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
522 char *filename = g_build_filename(dirname, data, NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
523 gchar *contents;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
524 gsize len;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
525
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
526 if (g_file_get_contents(filename, &contents, &len, NULL))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
527 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
528 purple_buddy_icons_set_account_icon(ret, (guchar *)contents, len);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
529 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
530
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
531 g_free(filename);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
532 g_free(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
533 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
534
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
535 /* Read settings (both core and UI) */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
536 for (child = xmlnode_get_child(node, "settings"); child != NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
537 child = xmlnode_get_next_twin(child))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
538 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
539 parse_settings(child, ret);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
540 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
541
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
542 /* Read proxy */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
543 child = xmlnode_get_child(node, "proxy");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
544 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
545 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
546 parse_proxy_info(child, ret);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
547 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
548
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
549 /* Read current error */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
550 child = xmlnode_get_child(node, "current_error");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
551 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
552 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
553 parse_current_error(child, ret);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
554 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
555
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
556 /* Read the password */
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
557 child = xmlnode_get_child(node, "password");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
558 if (child != NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
559 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
560 const char *keyring_id = xmlnode_get_attrib(child, "keyring_id");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
561 const char *mode = xmlnode_get_attrib(child, "mode");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
562 gboolean result;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
563
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
564 data = xmlnode_get_data(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
565 result = purple_keyring_import_password(ret, keyring_id, mode, data, NULL);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
566
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
567 if (result == TRUE || purple_keyring_get_inuse() == NULL) {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
568 purple_account_set_remember_password(ret, TRUE);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
569 } else {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
570 purple_debug_error("account", "Failed to import password.\n");
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
571 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
572 purple_str_wipe(data);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
573 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
574
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
575 return ret;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
576 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
577
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
578 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
579 load_accounts(void)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
580 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
581 xmlnode *node, *child;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
582
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
583 accounts_loaded = TRUE;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
584
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
585 node = purple_util_read_xml_from_file("accounts.xml", _("accounts"));
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
586
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
587 if (node == NULL)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
588 return;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
589
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
590 for (child = xmlnode_get_child(node, "account"); child != NULL;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
591 child = xmlnode_get_next_twin(child))
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
592 {
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
593 PurpleAccount *new_acct;
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
594 new_acct = parse_account(child);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
595 purple_accounts_add(new_acct);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
596 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
597
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
598 xmlnode_free(node);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
599
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
600 _purple_buddy_icons_account_loaded_cb();
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
601 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
602
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
603
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
604 static void
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
605 delete_setting(void *data)
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
606 {
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
607 PurpleAccountSetting *setting = (PurpleAccountSetting *)data;
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
608
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
609 g_free(setting->ui);
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
610 g_value_unset(&setting->value);
34579
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
611
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
612 g_free(setting);
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
613 }
e718d0eea155 Moved some local functions from account.c to accounts.c
Ankit Vani <a@nevitus.org>
parents: 34574
diff changeset
614
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
615
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
616 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
617 purple_accounts_add(PurpleAccount *account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
618 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
619 g_return_if_fail(account != NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
620
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
621 if (g_list_find(accounts, account) != NULL)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
622 return;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
623
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
624 accounts = g_list_append(accounts, account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
625
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
626 schedule_accounts_save();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
627
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
628 purple_signal_emit(purple_accounts_get_handle(), "account-added", account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
629 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
630
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
631 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
632 purple_accounts_remove(PurpleAccount *account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
633 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
634 g_return_if_fail(account != NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
635
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
636 accounts = g_list_remove(accounts, account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
637
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
638 schedule_accounts_save();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
639
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
640 /* Clearing the error ensures that account-error-changed is emitted,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
641 * which is the end of the guarantee that the the error's pointer is
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
642 * valid.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
643 */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
644 purple_account_clear_current_error(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
645 purple_signal_emit(purple_accounts_get_handle(), "account-removed", account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
646 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
647
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
648 static void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
649 purple_accounts_delete_set(PurpleAccount *account, GError *error, gpointer data)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
650 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
651 purple_account_destroy(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
652 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
653
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
654 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
655 purple_accounts_delete(PurpleAccount *account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
656 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
657 PurpleBlistNode *gnode, *cnode, *bnode;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
658 GList *iter;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
659
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
660 g_return_if_fail(account != NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
661
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
662 /*
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
663 * Disable the account before blowing it out of the water.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
664 * Conceptually it probably makes more sense to disable the
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
665 * account for all UIs rather than the just the current UI,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
666 * but it doesn't really matter.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
667 */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
668 purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
669
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
670 purple_notify_close_with_handle(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
671 purple_request_close_with_handle(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
672
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
673 purple_accounts_remove(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
674
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
675 /* Remove this account's buddies */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
676 for (gnode = purple_blist_get_root();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
677 gnode != NULL;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
678 gnode = purple_blist_node_get_sibling_next(gnode))
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
679 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
680 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
681 continue;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
682
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
683 cnode = purple_blist_node_get_first_child(gnode);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
684 while (cnode) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
685 PurpleBlistNode *cnode_next = purple_blist_node_get_sibling_next(cnode);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
686
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
687 if(PURPLE_BLIST_NODE_IS_CONTACT(cnode)) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
688 bnode = purple_blist_node_get_first_child(cnode);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
689 while (bnode) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
690 PurpleBlistNode *bnode_next = purple_blist_node_get_sibling_next(bnode);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
691
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
692 if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
693 PurpleBuddy *b = (PurpleBuddy *)bnode;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
694
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
695 if (purple_buddy_get_account(b) == account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
696 purple_blist_remove_buddy(b);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
697 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
698 bnode = bnode_next;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
699 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
700 } else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
701 PurpleChat *c = (PurpleChat *)cnode;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
702
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
703 if (purple_chat_get_account(c) == account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
704 purple_blist_remove_chat(c);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
705 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
706 cnode = cnode_next;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
707 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
708 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
709
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
710 /* Remove any open conversation for this account */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
711 for (iter = purple_get_conversations(); iter; ) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
712 PurpleConversation *conv = iter->data;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
713 iter = iter->next;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
714 if (purple_conversation_get_account(conv) == account)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
715 purple_conversation_destroy(conv);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
716 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
717
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
718 /* Remove this account's pounces */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
719 purple_pounce_destroy_all_by_account(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
720
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
721 /* This will cause the deletion of an old buddy icon. */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
722 purple_buddy_icons_set_account_icon(account, NULL, 0);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
723
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
724 /* This is async because we do not want the
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
725 * account being overwritten before we are done.
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
726 */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
727 purple_keyring_set_password(account, NULL,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
728 purple_accounts_delete_set, NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
729 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
730
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
731 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
732 purple_accounts_reorder(PurpleAccount *account, gint new_index)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
733 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
734 gint index;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
735 GList *l;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
736
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
737 g_return_if_fail(account != NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
738 g_return_if_fail(new_index <= g_list_length(accounts));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
739
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
740 index = g_list_index(accounts, account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
741
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
742 if (index == -1) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
743 purple_debug_error("account",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
744 "Unregistered account (%s) discovered during reorder!\n",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
745 purple_account_get_username(account));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
746 return;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
747 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
748
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
749 l = g_list_nth(accounts, index);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
750
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
751 if (new_index > index)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
752 new_index--;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
753
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
754 /* Remove the old one. */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
755 accounts = g_list_delete_link(accounts, l);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
756
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
757 /* Insert it where it should go. */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
758 accounts = g_list_insert(accounts, account, new_index);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
759
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
760 schedule_accounts_save();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
761 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
762
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
763 GList *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
764 purple_accounts_get_all(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
765 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
766 return accounts;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
767 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
768
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
769 GList *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
770 purple_accounts_get_all_active(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
771 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
772 GList *list = NULL;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
773 GList *all = purple_accounts_get_all();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
774
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
775 while (all != NULL) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
776 PurpleAccount *account = all->data;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
777
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
778 if (purple_account_get_enabled(account, purple_core_get_ui()))
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
779 list = g_list_append(list, account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
780
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
781 all = all->next;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
782 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
783
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
784 return list;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
785 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
786
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
787 PurpleAccount *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
788 purple_accounts_find(const char *name, const char *protocol_id)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
789 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
790 PurpleAccount *account = NULL;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
791 GList *l;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
792 char *who;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
793
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
794 g_return_val_if_fail(name != NULL, NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
795 g_return_val_if_fail(protocol_id != NULL, NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
796
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
797 for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
798 account = (PurpleAccount *)l->data;
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
799
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
800 if (!purple_strequal(purple_account_get_protocol_id(account), protocol_id))
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
801 continue;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
802
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
803 who = g_strdup(purple_normalize(account, name));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
804 if (purple_strequal(purple_normalize(account, purple_account_get_username(account)), who)) {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
805 g_free(who);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
806 return account;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
807 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
808 g_free(who);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
809 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
810
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
811 return NULL;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
812 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
813
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
814 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
815 purple_accounts_restore_current_statuses()
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
816 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
817 GList *l;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
818 PurpleAccount *account;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
819
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
820 /* If we're not connected to the Internet right now, we bail on this */
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
821 if (!purple_network_is_available())
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
822 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
823 purple_debug_warning("account", "Network not connected; skipping reconnect\n");
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
824 return;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
825 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
826
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
827 for (l = purple_accounts_get_all(); l != NULL; l = l->next)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
828 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
829 account = (PurpleAccount *)l->data;
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
830
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
831 if (purple_account_get_enabled(account, purple_core_get_ui()) &&
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
832 (purple_presence_is_online(purple_account_get_presence(account))))
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
833 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
834 purple_account_connect(account);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
835 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
836 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
837 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
838
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
839 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
840 purple_accounts_set_ui_ops(PurpleAccountUiOps *ops)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
841 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
842 account_ui_ops = ops;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
843 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
844
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
845 PurpleAccountUiOps *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
846 purple_accounts_get_ui_ops(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
847 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
848 return account_ui_ops;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
849 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
850
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
851 void *
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
852 purple_accounts_get_handle(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
853 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
854 static int handle;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
855
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
856 return &handle;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
857 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
858
34581
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
859 static void
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
860 signed_on_cb(PurpleConnection *gc,
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
861 gpointer unused)
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
862 {
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
863 PurpleAccount *account = purple_connection_get_account(gc);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
864 purple_account_clear_current_error(account);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
865
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
866 purple_signal_emit(purple_accounts_get_handle(), "account-signed-on",
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
867 account);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
868 }
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
869
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
870 static void
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
871 signed_off_cb(PurpleConnection *gc,
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
872 gpointer unused)
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
873 {
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
874 PurpleAccount *account = purple_connection_get_account(gc);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
875
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
876 purple_signal_emit(purple_accounts_get_handle(), "account-signed-off",
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
877 account);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
878 }
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
879
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
880 static void
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
881 connection_error_cb(PurpleConnection *gc,
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
882 PurpleConnectionError type,
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
883 const gchar *description,
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
884 gpointer unused)
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
885 {
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
886 PurpleAccount *account;
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
887 PurpleConnectionErrorInfo *err;
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
888
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
889 account = purple_connection_get_account(gc);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
890
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
891 g_return_if_fail(account != NULL);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
892
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
893 err = g_new0(PurpleConnectionErrorInfo, 1);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
894 PURPLE_DBUS_REGISTER_POINTER(err, PurpleConnectionErrorInfo);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
895
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
896 err->type = type;
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
897 err->description = g_strdup(description);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
898
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
899 set_current_error(account, err);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
900
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
901 purple_signal_emit(purple_accounts_get_handle(), "account-connection-error",
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
902 account, type, description);
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
903 }
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
904
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
905 static void
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
906 password_migration_cb(PurpleAccount *account)
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
907 {
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
908 /* account may be NULL (means: all) */
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
909
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
910 schedule_accounts_save();
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
911 }
b4e0236019e6 Fixed more PurpleAccount stuff.
Ankit Vani <a@nevitus.org>
parents: 34580
diff changeset
912
34574
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
913 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
914 purple_accounts_init(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
915 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
916 void *handle = purple_accounts_get_handle();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
917 void *conn_handle = purple_connections_get_handle();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
918
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
919 purple_signal_register(handle, "account-connecting",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
920 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
921 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
922 PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
923
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
924 purple_signal_register(handle, "account-disabled",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
925 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
926 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
927 PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
928
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
929 purple_signal_register(handle, "account-enabled",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
930 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
931 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
932 PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
933
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
934 purple_signal_register(handle, "account-setting-info",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
935 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
936 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
937 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
938 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
939
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
940 purple_signal_register(handle, "account-set-info",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
941 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
942 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
943 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
944 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
945
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
946 purple_signal_register(handle, "account-created",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
947 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
948 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
949
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
950 purple_signal_register(handle, "account-destroying",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
951 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
952 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
953
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
954 purple_signal_register(handle, "account-added",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
955 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
956 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
957
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
958 purple_signal_register(handle, "account-removed",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
959 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
960 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
961
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
962 purple_signal_register(handle, "account-status-changed",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
963 purple_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
964 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
965 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
966 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
967 PURPLE_SUBTYPE_STATUS),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
968 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
969 PURPLE_SUBTYPE_STATUS));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
970
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
971 purple_signal_register(handle, "account-actions-changed",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
972 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
973 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
974
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
975 purple_signal_register(handle, "account-alias-changed",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
976 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
977 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
978 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
979 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
980
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
981 purple_signal_register(handle, "account-authorization-requested",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
982 purple_marshal_INT__POINTER_POINTER_POINTER,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
983 purple_value_new(PURPLE_TYPE_INT), 4,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
984 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
985 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
986 purple_value_new(PURPLE_TYPE_STRING),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
987 purple_value_new(PURPLE_TYPE_STRING),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
988 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
989
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
990 purple_signal_register(handle, "account-authorization-denied",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
991 purple_marshal_VOID__POINTER_POINTER, NULL, 3,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
992 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
993 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
994 purple_value_new(PURPLE_TYPE_STRING),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
995 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
996
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
997 purple_signal_register(handle, "account-authorization-granted",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
998 purple_marshal_VOID__POINTER_POINTER, NULL, 3,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
999 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1000 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1001 purple_value_new(PURPLE_TYPE_STRING),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1002 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1003
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1004 purple_signal_register(handle, "account-error-changed",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1005 purple_marshal_VOID__POINTER_POINTER_POINTER,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1006 NULL, 3,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1007 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1008 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1009 purple_value_new(PURPLE_TYPE_POINTER),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1010 purple_value_new(PURPLE_TYPE_POINTER));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1011
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1012 purple_signal_register(handle, "account-signed-on",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1013 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1014 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1015 PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1016
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1017 purple_signal_register(handle, "account-signed-off",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1018 purple_marshal_VOID__POINTER, NULL, 1,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1019 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1020 PURPLE_SUBTYPE_ACCOUNT));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1021
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1022 purple_signal_register(handle, "account-connection-error",
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1023 purple_marshal_VOID__POINTER_INT_POINTER, NULL, 3,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1024 purple_value_new(PURPLE_TYPE_SUBTYPE,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1025 PURPLE_SUBTYPE_ACCOUNT),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1026 purple_value_new(PURPLE_TYPE_ENUM),
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1027 purple_value_new(PURPLE_TYPE_STRING));
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1028
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1029 purple_signal_connect(conn_handle, "signed-on", handle,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1030 PURPLE_CALLBACK(signed_on_cb), NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1031 purple_signal_connect(conn_handle, "signed-off", handle,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1032 PURPLE_CALLBACK(signed_off_cb), NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1033 purple_signal_connect(conn_handle, "connection-error", handle,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1034 PURPLE_CALLBACK(connection_error_cb), NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1035 purple_signal_connect(purple_keyring_get_handle(), "password-migration", handle,
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1036 PURPLE_CALLBACK(password_migration_cb), NULL);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1037
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1038 load_accounts();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1039
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1040 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1041
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1042 void
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1043 purple_accounts_uninit(void)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1044 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1045 gpointer handle = purple_accounts_get_handle();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1046 if (save_timer != 0)
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1047 {
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1048 purple_timeout_remove(save_timer);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1049 save_timer = 0;
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1050 sync_accounts();
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1051 }
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1052
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1053 for (; accounts; accounts = g_list_delete_link(accounts, accounts))
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1054 purple_account_destroy(accounts->data);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1055
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1056 purple_signals_disconnect_by_handle(handle);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1057 purple_signals_unregister_by_instance(handle);
19850cd1b2de Begun GObjectification of PurpleAccount. Moved things around, see details.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1058 }

mercurial