annotate src/list.c @ 5187:7c1c9bdc1f8e

[gaim-migrate @ 5552] fixes a crash toggling preferences. thanks for pointing that out ari. also fixes some stupid warnings when you sign on and off too fast. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 20 Apr 2003 22:50:09 +0000
parents 13ffa9ae4282
children fefad67de2c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
4 * Copyright (C) 2003, Sean Egan <sean.egan@binghamton.edu>
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * (at your option) any later version.
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * GNU General Public License for more details.
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include <config.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #endif
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <string.h>
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
27 #include <stdlib.h>
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <sys/types.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <sys/stat.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
30 #ifndef _WIN32
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <unistd.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
32 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
33 #include <direct.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
34 #endif
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
35 #include <ctype.h>
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include "gaim.h"
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include "prpl.h"
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
38 #include "list.h"
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
40 #ifdef _WIN32
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
41 #include "win32dep.h"
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
42 #endif
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
43
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #define PATHSIZE 1024
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
46 struct gaim_buddy_list *gaimbuddylist = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
47 static struct gaim_blist_ui_ops *blist_ui_ops = NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
49 /*****************************************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
50 * Private Utility functions *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
51 *****************************************************************************/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
52 static GaimBlistNode *gaim_blist_get_last_sibling(GaimBlistNode *node)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
53 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
54 GaimBlistNode *n = node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
55 if (!n)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
56 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
57 while (n->next)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
58 n = n->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
59 return n;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
60 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
61 static GaimBlistNode *gaim_blist_get_last_child(GaimBlistNode *node)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
62 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
63 if (!node)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
64 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
65 return gaim_blist_get_last_sibling(node->child);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
66 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
68 /*****************************************************************************
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
69 * Public API functions *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
70 *****************************************************************************/
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
71
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
72 struct gaim_buddy_list *gaim_blist_new()
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
73 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
74 struct gaim_buddy_list *gbl = g_new0(struct gaim_buddy_list, 1);
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
75
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
76 gbl->ui_ops = gaim_get_blist_ui_ops();
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
77
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
78 if (gbl->ui_ops != NULL && gbl->ui_ops->new_list != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
79 gbl->ui_ops->new_list(gbl);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
80
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
81 return gbl;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
82 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
84 void
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
85 gaim_set_blist(struct gaim_buddy_list *list)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
86 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
87 gaimbuddylist = list;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
88 }
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
89
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
90 struct gaim_buddy_list *
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
91 gaim_get_blist(void)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
92 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
93 return gaimbuddylist;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
94 }
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
95
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
96 void gaim_blist_show ()
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
97 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
98 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
99 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
100 ops->show(gaimbuddylist);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
101 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
103 void gaim_blist_destroy()
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
104 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
105 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
106 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
107 ops->destroy(gaimbuddylist);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
108 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
110 void gaim_blist_set_visible (gboolean show)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
111 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
112 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
113 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
114 ops->set_visible(gaimbuddylist, show);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
115 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
117 void gaim_blist_update_buddy_status (struct buddy *buddy, int status)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
118 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
119 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
120 buddy->uc = status;
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
121
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
122 if(!(status & UC_UNAVAILABLE))
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
123 plugin_event(event_buddy_back, buddy->account->gc, buddy->name);
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
124 else
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
125 plugin_event(event_buddy_away, buddy->account->gc, buddy->name);
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
126
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
127 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
128 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
131 static gboolean presence_update_timeout_cb(struct buddy *buddy) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
132 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
4988
070181118a77 [gaim-migrate @ 5323]
Nathan Walp <nwalp@pidgin.im>
parents: 4971
diff changeset
133
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
134 if(buddy->present == GAIM_BUDDY_SIGNING_ON) {
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
135 buddy->present = GAIM_BUDDY_ONLINE;
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
136 plugin_event(event_buddy_signon, buddy->account->gc, buddy->name);
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
137 } else if(buddy->present == GAIM_BUDDY_SIGNING_OFF) {
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
138 buddy->present = GAIM_BUDDY_OFFLINE;
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
139 }
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
140
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
141 buddy->timer = 0;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
142
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
143 if (ops)
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
144 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
145
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
146 return FALSE;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
147 }
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
148
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
149 void gaim_blist_update_buddy_presence(struct buddy *buddy, int presence) {
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
150 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
151 gboolean do_timer = FALSE;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
152
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
153 if (!GAIM_BUDDY_IS_ONLINE(buddy) && presence) {
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
154 buddy->present = GAIM_BUDDY_SIGNING_ON;
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
155 plugin_event(event_buddy_signon, buddy->account->gc, buddy->name);
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
156 do_timer = TRUE;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
157 } else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) {
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
158 buddy->present = GAIM_BUDDY_SIGNING_OFF;
5170
13ffa9ae4282 [gaim-migrate @ 5534]
Nathan Walp <nwalp@pidgin.im>
parents: 5142
diff changeset
159 plugin_event(event_buddy_signoff, buddy->account->gc, buddy->name);
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
160 do_timer = TRUE;
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
161 }
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
162
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
163 if(do_timer) {
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
164 if(buddy->timer > 0)
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
165 g_source_remove(buddy->timer);
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
166 buddy->timer = g_timeout_add(10000, (GSourceFunc)presence_update_timeout_cb, buddy);
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
167 }
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
168
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
169 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
170 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
171 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
174 void gaim_blist_update_buddy_idle (struct buddy *buddy, int idle)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
175 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
176 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
177 buddy->idle = idle;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
178 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
179 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
180 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
181 void gaim_blist_update_buddy_evil (struct buddy *buddy, int warning)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
182 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
183 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
184 buddy->evil = warning;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
185 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
186 ops->update(gaimbuddylist,(GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
187 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
188 void gaim_blist_update_buddy_icon(struct buddy *buddy) {
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
189 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
190 if(ops)
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
191 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
192 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
193 void gaim_blist_rename_buddy (struct buddy *buddy, const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
194 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
195 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
196 g_free(buddy->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
197 buddy->name = g_strdup(name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
198 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
199 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
200 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
201 void gaim_blist_alias_buddy (struct buddy *buddy, const char *alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
202 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
203 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
4942
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
204 struct gaim_conversation *conv;
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
205
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
206 g_free(buddy->alias);
4942
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
207
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
208 buddy->alias = g_strdup(alias);
4942
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
209
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
210 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
211 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
4942
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
212
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
213 conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
214
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
215 if (conv)
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
216 gaim_conversation_autoset_title(conv);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
217 }
4942
6a0b1eb407e5 [gaim-migrate @ 5276]
Christian Hammond <chipx86@chipx86.com>
parents: 4941
diff changeset
218
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
219 void gaim_blist_rename_group(struct group *group, const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
220 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
221 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
222 g_free(group->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
223 group->name = g_strdup(name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
224 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
225 ops->update(gaimbuddylist, (GaimBlistNode*)group);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
226 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
227 struct buddy *gaim_buddy_new(struct gaim_account *account, const char *screenname, const char *alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
228 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
229 struct buddy *b;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
230 struct gaim_blist_ui_ops *ops;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
231
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
232 b = g_new0(struct buddy, 1);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
233 b->account = account;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
234 b->name = g_strdup(screenname);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
235 b->alias = g_strdup(alias);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
236 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
237 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
239 ops = gaim_get_blist_ui_ops();
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
240
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
241 if (ops != NULL && ops->new_node != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
242 ops->new_node((GaimBlistNode *)b);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
243
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
246 void gaim_blist_add_buddy (struct buddy *buddy, struct group *group, GaimBlistNode *node)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 {
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
248 GaimBlistNode *n = node, *bnode = (GaimBlistNode*)buddy;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
249 struct group *g = group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
250 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
251 gboolean save = FALSE;
4865
3bc5a65728fb [gaim-migrate @ 5195]
Nathan Walp <nwalp@pidgin.im>
parents: 4830
diff changeset
252
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
253 if (!n) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
254 if (!g) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
255 g = gaim_group_new(_("Buddies"));
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
256 gaim_blist_add_group(g, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
257 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
258 n = gaim_blist_get_last_child((GaimBlistNode*)g);
4971
da7a91c2e0dc [gaim-migrate @ 5305]
Nathan Walp <nwalp@pidgin.im>
parents: 4954
diff changeset
259 } else {
da7a91c2e0dc [gaim-migrate @ 5305]
Nathan Walp <nwalp@pidgin.im>
parents: 4954
diff changeset
260 g = (struct group*)n->parent;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
261 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
262
4941
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
263 /* if we're moving to overtop of ourselves, do nothing */
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
264 if(bnode == n)
4941
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
265 return;
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
266
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
267 if (bnode->parent) {
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
268 /* This buddy was already in the list and is
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
269 * being moved.
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
270 */
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
271 if(bnode->next)
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
272 bnode->next->prev = bnode->prev;
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
273 if(bnode->prev)
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
274 bnode->prev->next = bnode->next;
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
275 if(bnode->parent->child == bnode)
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
276 bnode->parent->child = bnode->next;
4865
3bc5a65728fb [gaim-migrate @ 5195]
Nathan Walp <nwalp@pidgin.im>
parents: 4830
diff changeset
277
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
278 ops->remove(gaimbuddylist, bnode);
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
279
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
280 if (bnode->parent != ((GaimBlistNode*)g))
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
281 serv_move_buddy(buddy, (struct group*)bnode->parent, g);
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
282 save = TRUE;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
283 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
285 if (n) {
5041
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
286 if(n->next)
c4b691b0cc0d [gaim-migrate @ 5385]
Nathan Walp <nwalp@pidgin.im>
parents: 4988
diff changeset
287 n->next->prev = (GaimBlistNode*)buddy;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
288 ((GaimBlistNode*)buddy)->next = n->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
289 ((GaimBlistNode*)buddy)->prev = n;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
290 ((GaimBlistNode*)buddy)->parent = n->parent;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
291 n->next = (GaimBlistNode*)buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
292 } else {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
293 ((GaimBlistNode*)g)->child = (GaimBlistNode*)buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
294 ((GaimBlistNode*)buddy)->next = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
295 ((GaimBlistNode*)buddy)->prev = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
296 ((GaimBlistNode*)buddy)->parent = (GaimBlistNode*)g;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
297 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
299 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
300 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
4865
3bc5a65728fb [gaim-migrate @ 5195]
Nathan Walp <nwalp@pidgin.im>
parents: 4830
diff changeset
301 if (save)
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
302 gaim_blist_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
303 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
305 struct group *gaim_group_new(const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
306 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
307 struct group *g = gaim_find_group(name);
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
308
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
309 if (!g) {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
310 struct gaim_blist_ui_ops *ops;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
311 g= g_new0(struct group, 1);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
312 g->name = g_strdup(name);
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
313 g->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
314 g_free, g_free);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
315 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
317 ops = gaim_get_blist_ui_ops();
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
318
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
319 if (ops != NULL && ops->new_node != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
320 ops->new_node((GaimBlistNode *)g);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
321
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
322 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
326 void gaim_blist_add_group (struct group *group, GaimBlistNode *node)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
328 struct gaim_blist_ui_ops *ops;
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
329 GaimBlistNode *gnode = (GaimBlistNode*)group;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
330 gboolean save = FALSE;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
331
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
332 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
333 gaimbuddylist = gaim_blist_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
334 ops = gaimbuddylist->ui_ops;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
335
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
336 if (!gaimbuddylist->root) {
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
337 gaimbuddylist->root = gnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
338 return;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
339 }
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
340
4941
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
341 if (!node)
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
342 node = gaim_blist_get_last_sibling(gaimbuddylist->root);
d7a549ab95c2 [gaim-migrate @ 5275]
Nathan Walp <nwalp@pidgin.im>
parents: 4938
diff changeset
343
4937
4228bddbf2cd [gaim-migrate @ 5271]
Nathan Walp <nwalp@pidgin.im>
parents: 4936
diff changeset
344 /* if we're moving to overtop of ourselves, do nothing */
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
345 if(gnode == node)
4937
4228bddbf2cd [gaim-migrate @ 5271]
Nathan Walp <nwalp@pidgin.im>
parents: 4936
diff changeset
346 return;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
347
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
348 if (gaim_find_group(group->name)) {
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
349 /* This is just being moved */
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
351 ops->remove(gaimbuddylist, (GaimBlistNode*)group);
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
352
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
353 if(gnode == gaimbuddylist->root)
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
354 gaimbuddylist->root = gnode->next;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
355 if(gnode->prev)
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
356 gnode->prev->next = gnode->next;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
357 if(gnode->next)
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
358 gnode->next->prev = gnode->prev;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
359
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
360 save = TRUE;
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
361 }
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
362
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
363 gnode->next = node->next;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
364 gnode->prev = node;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
365 if(node->next)
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
366 node->next->prev = gnode;
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
367 node->next = gnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
368
5055
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
369 if (ops) {
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
370 ops->update(gaimbuddylist, gnode);
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
371 for(node = gnode->child; node; node = node->next)
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
372 ops->update(gaimbuddylist, node);
5b1d70deda02 [gaim-migrate @ 5406]
Nathan Walp <nwalp@pidgin.im>
parents: 5041
diff changeset
373 }
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
374 if (save)
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
375 gaim_blist_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
376 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
377
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
378 void gaim_blist_remove_buddy (struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
379 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
380 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
381
4721
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
382 GaimBlistNode *gnode, *node = (GaimBlistNode*)buddy;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
383 struct group *group;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
384
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
385 gnode = node->parent;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
386 group = (struct group *)gnode;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
387
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
388 if(gnode->child == node)
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
389 gnode->child = node->next;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
390 if (node->prev)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
391 node->prev->next = node->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
392 if (node->next)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
393 node->next->prev = node->prev;
4721
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
394
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
395 ops->remove(gaimbuddylist, node);
4954
decdf19454ab [gaim-migrate @ 5288]
Nathan Walp <nwalp@pidgin.im>
parents: 4950
diff changeset
396 g_hash_table_destroy(buddy->settings);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
397 g_free(buddy->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
398 g_free(buddy->alias);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
399 g_free(buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
402 void gaim_blist_remove_group (struct group *group)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
403 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
404 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
405 GaimBlistNode *node = (GaimBlistNode*)group;
4938
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
406
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
407 if(node->child) {
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
408 char *buf;
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
409 int count = 0;
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
410 GaimBlistNode *child = node->child;
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
411
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
412 while(child) {
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
413 count++;
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
414 child = child->next;
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
415 }
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
416
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
417 buf = g_strdup_printf(_("%d buddies from group %s were not "
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
418 "removed because their accounts were not logged in. These "
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
419 "buddies, and the group were not removed.\n"),
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
420 count, group->name);
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
421 do_error_dialog(_("Group Not Removed"), buf, GAIM_ERROR);
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
422 g_free(buf);
461e8c89514f [gaim-migrate @ 5272]
Nathan Walp <nwalp@pidgin.im>
parents: 4937
diff changeset
423 return;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
424 }
4936
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
425
5056
18ec87e54201 [gaim-migrate @ 5407]
Nathan Walp <nwalp@pidgin.im>
parents: 5055
diff changeset
426 if(gaimbuddylist->root == node)
18ec87e54201 [gaim-migrate @ 5407]
Nathan Walp <nwalp@pidgin.im>
parents: 5055
diff changeset
427 gaimbuddylist->root = node->next;
4936
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
428 if (node->prev)
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
429 node->prev->next = node->next;
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
430 if (node->next)
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
431 node->next->prev = node->prev;
cfeab08d4be9 [gaim-migrate @ 5270]
Nathan Walp <nwalp@pidgin.im>
parents: 4919
diff changeset
432
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
433 ops->remove(gaimbuddylist, node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
434 g_free(group->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
435 g_free(group);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
436 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
437
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
438 char *gaim_get_buddy_alias_only(struct buddy *b) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
439 if(!b)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
440 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
441 if(b->alias && b->alias[0])
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
442 return b->alias;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
443 else if((misc_options & OPT_MISC_USE_SERVER_ALIAS) && b->server_alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
444 return b->server_alias;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
445 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
446 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
447
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
448 char * gaim_get_buddy_alias (struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
449 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
450 char *ret = gaim_get_buddy_alias_only(buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
451 if(!ret)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
452 return buddy ? buddy->name : _("Unknown");
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
453 return ret;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
454
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
455 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
456
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
457 struct buddy *gaim_find_buddy(struct gaim_account *account, const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
458 {
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
459 GaimBlistNode *group;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
460 GaimBlistNode *buddy;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
461 char *norm_name = g_strdup(normalize(name));
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
462
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
463 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
464 return NULL;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
465
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
466 group = gaimbuddylist->root;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
467 while (group) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
468 buddy = group->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
469 while (buddy) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
470 if (!gaim_utf8_strcasecmp(normalize(((struct buddy*)buddy)->name), norm_name) && account == ((struct buddy*)buddy)->account) {
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
471 g_free(norm_name);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
472 return (struct buddy*)buddy;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
473 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
474 buddy = buddy->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
475 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
476 group = group->next;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
477 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
478 g_free(norm_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
479 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
480 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
481
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
482 struct group *gaim_find_group(const char *name)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
484 GaimBlistNode *node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
485 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
486 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
487 node = gaimbuddylist->root;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
488 while(node) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
489 if (!strcmp(((struct group*)node)->name, name))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
490 return (struct group*)node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
491 node = node->next;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
493 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
495 struct group *gaim_find_buddys_group(struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
496 {
4830
46fb754a3c10 [gaim-migrate @ 5155]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
497 if (!buddy)
46fb754a3c10 [gaim-migrate @ 5155]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
498 return NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
499 return (struct group*)(((GaimBlistNode*)buddy)->parent);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
500 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
501
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
502 GSList *gaim_group_get_accounts(struct group *g)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
503 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
504 GSList *l = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
505 GaimBlistNode *child = ((GaimBlistNode *)g)->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
506
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
507 while (child) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
508 if (!g_slist_find(l, ((struct buddy*)child)->account))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
509 l = g_slist_append(l, ((struct buddy*)child)->account);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
510 child = child->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
511 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
512 return l;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
513 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
514
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
515 void gaim_blist_remove_account(struct gaim_account *account)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
516 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
517 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
518 GaimBlistNode *group = gaimbuddylist->root;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
519 GaimBlistNode *buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
520 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
521 return;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
522 while (group) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
523 buddy = group->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
524 while (buddy) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
525 if (account == ((struct buddy*)buddy)->account) {
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
526 ((struct buddy*)buddy)->present = GAIM_BUDDY_OFFLINE;
4919
a1551892049c [gaim-migrate @ 5253]
Nathan Walp <nwalp@pidgin.im>
parents: 4891
diff changeset
527 if(ops)
a1551892049c [gaim-migrate @ 5253]
Nathan Walp <nwalp@pidgin.im>
parents: 4891
diff changeset
528 ops->remove(gaimbuddylist, buddy);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
529 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
530 buddy = buddy->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
531 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
532 group = group->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
533 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
534 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
536 void parse_toc_buddy_list(struct gaim_account *account, char *config)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 char *c;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 char current[256];
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
540 GList *bud = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
541
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 if (config != NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
544
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 /* skip "CONFIG:" (if it exists) */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ?
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
547 strtok(config, "\n") :
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
548 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 do {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 if (c == NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 if (*c == 'g') {
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
553 char *utf8 = NULL;
4458
a46c57f2d58b [gaim-migrate @ 4733]
Luke Schierer <lschiere@pidgin.im>
parents: 4444
diff changeset
554 utf8 = gaim_try_conv_to_utf8(c + 2);
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
555 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
556 g_strlcpy(current, _("Invalid Groupname"), sizeof(current));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
557 } else {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
558 g_strlcpy(current, utf8, sizeof(current));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
559 g_free(utf8);
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
560 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
561 if (!gaim_find_group(current)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
562 struct group *g = gaim_group_new(current);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
563 gaim_blist_add_group(g, NULL);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
564 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
565 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
566 char nm[80], sw[388], *a, *utf8 = NULL;
4408
94bf204f837e [gaim-migrate @ 4677]
Nathan Walp <nwalp@pidgin.im>
parents: 4404
diff changeset
567
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
568 if ((a = strchr(c + 2, ':')) != NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
569 *a++ = '\0'; /* nul the : */
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
570 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
571
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
572 g_strlcpy(nm, c + 2, sizeof(nm));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
573 if (a) {
4458
a46c57f2d58b [gaim-migrate @ 4733]
Luke Schierer <lschiere@pidgin.im>
parents: 4444
diff changeset
574 utf8 = gaim_try_conv_to_utf8(a);
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
575 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
576 debug_printf ("Failed to convert alias for '%s' to UTF-8\n", nm);
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
577 }
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
578 }
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
579 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
580 sw[0] = '\0';
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
581 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
582 /* This can leave a partial sequence at the end,
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
583 * but who cares? */
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
584 g_strlcpy(sw, utf8, sizeof(sw));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
585 g_free(utf8);
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
586 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
587
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
588 if (!gaim_find_buddy(account, nm)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
589 struct buddy *b = gaim_buddy_new(account, nm, sw);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
590 struct group *g = gaim_find_group(current);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
591 gaim_blist_add_buddy(b, g, NULL);
4950
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
592 bud = g_list_append(bud, g_strdup(nm));
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
593 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594 } else if (*c == 'p') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
595 gaim_privacy_permit_add(account, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 } else if (*c == 'd') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
597 gaim_privacy_deny_add(account, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 } else if (!strncmp("toc", c, 3)) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
599 sscanf(c + strlen(c) - 1, "%d", &account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
600 debug_printf("permdeny: %d\n", account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
601 if (account->permdeny == 0)
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
602 account->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 } else if (*c == 'm') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
604 sscanf(c + 2, "%d", &account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
605 debug_printf("permdeny: %d\n", account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
606 if (account->permdeny == 0)
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
607 account->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 } while ((c = strtok(NULL, "\n")));
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
610
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
611 if(account->gc) {
4950
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
612 if(bud) {
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
613 GList *node = bud;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
614 serv_add_buddies(account->gc, bud);
4950
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
615 while(node) {
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
616 g_free(node->data);
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
617 node = node->next;
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
618 }
e81625009ab3 [gaim-migrate @ 5284]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4942
diff changeset
619 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
620 serv_set_permit_deny(account->gc);
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
621 }
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
622 g_list_free(bud);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
626 #if 0
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
627 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
628 static GString *translate_lst(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 char line[BUF_LEN], *line2;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 char *name;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
634 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 while (fgets(line, BUF_LEN, src_fp)) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
637 line2 = g_strchug(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 if (strstr(line2, "group") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
640 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
643 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
644 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 if (strstr(line2, "buddy") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
648 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
651 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
652 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
656 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
660 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
661 static GString *translate_blt(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 char line[BUF_LEN];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 char *buddy;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
667 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 while (1) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
673 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674 if (strchr(line, '}') != NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 if (strchr(line, '{') != NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
678 /* Syntax starting with "<group> {" */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
679
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
680 dest = g_string_append(dest, "g ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
681 buddy = g_strchug(strtok(line, "{"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
682 for (i = 0; i < strlen(buddy); i++)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
683 if (buddy[i] != '\"')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
684 dest = g_string_append_c(dest, buddy[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
685 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
687 gboolean pounce = FALSE;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
688 char *e;
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
689 g_strchomp(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
690 buddy = g_strchug(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
691 debug_printf("\nbuddy: \"%s\"\n\n", buddy);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
692 dest = g_string_append(dest, "b ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
693 if (strchr(buddy, '{') != NULL) {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
694 /* buddy pounce, etc */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
695 char *pos = strchr(buddy, '{') - 1;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
696 *pos = 0;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
697 pounce = TRUE;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
698 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
699 if ((e = strchr(buddy, '\"')) != NULL) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
700 *e = '\0';
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 buddy++;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
702 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
703 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
704 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
705 if (pounce)
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
706 do
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
707 fgets(line, BUF_LEN, src_fp);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
708 while (!strchr(line, '}'));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 }
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
710 } else {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
711
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
712 /* Syntax "group buddy buddy ..." */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
713 buddy = g_strchug(strtok(line, " \n"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
714 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
716 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
717 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
718 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
720 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
721 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
722 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
724 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
725 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
727 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
729 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
730 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
731 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
733 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
734 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
735 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
737 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
738 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
739 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
741 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
742 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
744 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
746 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
751 return dest;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
752 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
753
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
754 static GString *translate_gnomeicu(FILE *src_fp)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
755 {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
756 char line[BUF_LEN];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
757 GString *dest = g_string_new("m 1\ng Buddies\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
758
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
759 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
760
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
761 while (fgets(line, BUF_LEN, src_fp)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
762 char *eq;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
763 g_strchomp(line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
764 if (line[0] == '\n' || line[0] == '[')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
765 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
766 eq = strchr(line, '=');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
767 if (!eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
768 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
769 *eq = ':';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
770 eq = strchr(eq, ',');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
771 if (eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
772 *eq = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
773 dest = g_string_append(dest, "b ");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
774 dest = g_string_append(dest, line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
775 dest = g_string_append_c(dest, '\n');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
776 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
777
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
778 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
780 #endif
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 static gchar *get_screenname_filename(const char *name)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 gchar **split;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 gchar *good;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
786 gchar *ret;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 good = g_strjoinv(NULL, split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 g_strfreev(split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
792 ret = g_utf8_strup(good, -1);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
794 g_free(good);
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
795
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
796 return ret;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
799 static gboolean gaim_blist_read(const char *filename);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
801
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
802 static void do_import(struct gaim_account *account, const char *filename)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
804 GString *buf = NULL;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
805 char first[64];
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 int len;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 FILE *f;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
809 struct stat st;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
811 if (filename) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 g_snprintf(path, sizeof(path), "%s", filename);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
814 char *g_screenname = get_screenname_filename(account->username);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
815 char *file = gaim_user_dir();
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
816 int protocol = (account->protocol == PROTO_OSCAR) ? (isalpha(account->username[0]) ? PROTO_TOC : PROTO_ICQ): account->protocol;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 if (file != (char *)NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
819 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
827 if (stat(path, &st)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
828 debug_printf("Unable to stat %s.\n", path);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
829 return;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
830 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
831
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 if (!(f = fopen(path, "r"))) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 debug_printf("Unable to open %s.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 fgets(first, 64, f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
839 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
840 fgets(first, 64, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
841
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
842 #if 0
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
843 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
844 /* new gaim XML buddy list */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
845 gaim_blist_read(path);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
846
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
847 /* We really don't need to bother doing stuf like translating AIM 3 buddy lists anymore */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
848
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
849 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
850 /* AIM 4 buddy list */
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 debug_printf("aim 4\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
853 buf = translate_blt(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
854 } else if (strstr(first, "group") != NULL) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 /* AIM 3 buddy list */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856 debug_printf("aim 3\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
858 buf = translate_lst(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
859 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
860 /* GnomeICU (hopefully) */
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
861 debug_printf("gnomeicu\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
862 rewind(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
863 buf = translate_gnomeicu(f);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
864
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
865 } else
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
866 #endif
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
867 if (first[0] == 'm') {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
868 /* Gaim buddy list - no translation */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
869 char buf2[BUF_LONG * 2];
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
870 buf = g_string_new("");
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
871 rewind(f);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
872 while (1) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
873 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
874 if (len <= 0)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
875 break;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
876 buf2[len] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
877 buf = g_string_append(buf, buf2);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
878 if (len != BUF_LONG * 2 - 1)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
879 break;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
880 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
881 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
882
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 fclose(f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
885 if (buf) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
886 buf = g_string_prepend(buf, "toc_set_config {");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
887 buf = g_string_append(buf, "}\n");
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
888 parse_toc_buddy_list(account, buf->str);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
889 g_string_free(buf, TRUE);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
890 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
893 gboolean gaim_group_on_account(struct group *g, struct gaim_account *account) {
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
894 GaimBlistNode *bnode;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
895 for(bnode = g->node.child; bnode; bnode = bnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
896 struct buddy *b = (struct buddy *)bnode;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
897 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
898 continue;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
899 if((!account && b->account->gc) || b->account == account)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
900 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
901 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
902 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
903 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
904
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
905 static gboolean blist_safe_to_write = FALSE;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
906
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
907 static char *blist_parser_group_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
908 static char *blist_parser_person_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
909 static char *blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
910 static int blist_parser_account_protocol = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
911 static char *blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
912 static char *blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
913 static char *blist_parser_setting_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
914 static char *blist_parser_setting_value = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
915 static GHashTable *blist_parser_buddy_settings = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
916 static GHashTable *blist_parser_group_settings = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
917 static int blist_parser_privacy_mode = 0;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
918 static GList *tag_stack = NULL;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
919 enum {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
920 BLIST_TAG_GAIM,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
921 BLIST_TAG_BLIST,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
922 BLIST_TAG_GROUP,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
923 BLIST_TAG_PERSON,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
924 BLIST_TAG_BUDDY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
925 BLIST_TAG_NAME,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
926 BLIST_TAG_ALIAS,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
927 BLIST_TAG_SETTING,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
928 BLIST_TAG_PRIVACY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
929 BLIST_TAG_ACCOUNT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
930 BLIST_TAG_PERMIT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
931 BLIST_TAG_BLOCK,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
932 BLIST_TAG_IGNORE
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
933 };
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
934 static gboolean blist_parser_error_occurred = FALSE;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
935
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
936 static void blist_start_element_handler (GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
937 const gchar *element_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
938 const gchar **attribute_names,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
939 const gchar **attribute_values,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
940 gpointer user_data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
941 GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
942 int i;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
943
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
944 if(!strcmp(element_name, "gaim")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
945 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GAIM));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
946 } else if(!strcmp(element_name, "blist")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
947 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLIST));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
948 } else if(!strcmp(element_name, "group")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
949 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_GROUP));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
950 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
951 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
952 g_free(blist_parser_group_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
953 blist_parser_group_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
954 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
955 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
956 if(blist_parser_group_name) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
957 struct group *g = gaim_group_new(blist_parser_group_name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
958 gaim_blist_add_group(g,NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
959 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
960 } else if(!strcmp(element_name, "person")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
961 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERSON));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
962 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
963 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
964 g_free(blist_parser_person_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
965 blist_parser_person_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
966 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
967 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
968 } else if(!strcmp(element_name, "buddy")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
969 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BUDDY));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
970 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
971 if(!strcmp(attribute_names[i], "account")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
972 g_free(blist_parser_account_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
973 blist_parser_account_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
974 } else if(!strcmp(attribute_names[i], "protocol")) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
975 blist_parser_account_protocol = atoi(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
976 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
977 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
978 } else if(!strcmp(element_name, "name")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
979 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_NAME));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
980 } else if(!strcmp(element_name, "alias")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
981 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ALIAS));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
982 } else if(!strcmp(element_name, "setting")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
983 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_SETTING));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
984 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
985 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
986 g_free(blist_parser_setting_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
987 blist_parser_setting_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
988 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
989 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
990 } else if(!strcmp(element_name, "privacy")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
991 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PRIVACY));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
992 } else if(!strcmp(element_name, "account")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
993 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_ACCOUNT));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
994 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
995 if(!strcmp(attribute_names[i], "protocol"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
996 blist_parser_account_protocol = atoi(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
997 else if(!strcmp(attribute_names[i], "mode"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
998 blist_parser_privacy_mode = atoi(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
999 else if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
1000 g_free(blist_parser_account_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1001 blist_parser_account_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
1002 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1003 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1004 } else if(!strcmp(element_name, "permit")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1005 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_PERMIT));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1006 } else if(!strcmp(element_name, "block")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1007 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_BLOCK));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1008 } else if(!strcmp(element_name, "ignore")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1009 tag_stack = g_list_prepend(tag_stack, GINT_TO_POINTER(BLIST_TAG_IGNORE));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1010 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1011 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1012
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1013 static void blist_end_element_handler(GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1014 const gchar *element_name, gpointer user_data, GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1015 if(!strcmp(element_name, "gaim")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1016 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1017 } else if(!strcmp(element_name, "blist")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1018 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1019 } else if(!strcmp(element_name, "group")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1020 if(blist_parser_group_settings) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1021 struct group *g = gaim_find_group(blist_parser_group_name);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1022 g_hash_table_destroy(g->settings);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1023 g->settings = blist_parser_group_settings;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1024 }
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1025 tag_stack = g_list_delete_link(tag_stack, tag_stack);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1026 blist_parser_group_settings = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1027 } else if(!strcmp(element_name, "person")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1028 g_free(blist_parser_person_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1029 blist_parser_person_name = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1030 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1031 } else if(!strcmp(element_name, "buddy")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1032 struct gaim_account *account = gaim_account_find(blist_parser_account_name,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1033 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1034 if(account) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1035 struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1036 struct group *g = gaim_find_group(blist_parser_group_name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1037 gaim_blist_add_buddy(b,g,NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1038 if(blist_parser_buddy_settings) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1039 g_hash_table_destroy(b->settings);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1040 b->settings = blist_parser_buddy_settings;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1041 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1042 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1043 g_free(blist_parser_buddy_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1044 blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1045 g_free(blist_parser_buddy_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1046 blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1047 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1048 blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1049 blist_parser_buddy_settings = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1050 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1051 } else if(!strcmp(element_name, "name")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1052 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1053 } else if(!strcmp(element_name, "alias")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1054 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1055 } else if(!strcmp(element_name, "setting")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1056 if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_BUDDY) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1057 if(!blist_parser_buddy_settings)
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1058 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1059 g_str_equal, g_free, g_free);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1060 if(blist_parser_setting_name && blist_parser_setting_value) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1061 g_hash_table_replace(blist_parser_buddy_settings,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1062 g_strdup(blist_parser_setting_name),
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1063 g_strdup(blist_parser_setting_value));
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1064 }
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1065 } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1066 if(!blist_parser_group_settings)
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1067 blist_parser_group_settings = g_hash_table_new_full(g_str_hash,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1068 g_str_equal, g_free, g_free);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1069 if(blist_parser_setting_name && blist_parser_setting_value) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1070 g_hash_table_replace(blist_parser_group_settings,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1071 g_strdup(blist_parser_setting_name),
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1072 g_strdup(blist_parser_setting_value));
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1073 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1074 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1075 g_free(blist_parser_setting_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1076 g_free(blist_parser_setting_value);
4720
06e8e5858121 [gaim-migrate @ 5032]
Nathan Walp <nwalp@pidgin.im>
parents: 4701
diff changeset
1077 blist_parser_setting_name = NULL;
06e8e5858121 [gaim-migrate @ 5032]
Nathan Walp <nwalp@pidgin.im>
parents: 4701
diff changeset
1078 blist_parser_setting_value = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1079 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1080 } else if(!strcmp(element_name, "privacy")) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1081 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1082 } else if(!strcmp(element_name, "account")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1083 struct gaim_account *account = gaim_account_find(blist_parser_account_name,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1084 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1085 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1086 account->permdeny = blist_parser_privacy_mode;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1087 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1088 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1089 blist_parser_account_name = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1090 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1091 } else if(!strcmp(element_name, "permit")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1092 struct gaim_account *account = gaim_account_find(blist_parser_account_name,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1093 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1094 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1095 gaim_privacy_permit_add(account, blist_parser_buddy_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1096 }
4442
fd53864d880f [gaim-migrate @ 4717]
Nathan Walp <nwalp@pidgin.im>
parents: 4441
diff changeset
1097 g_free(blist_parser_buddy_name);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
1098 blist_parser_buddy_name = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1099 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1100 } else if(!strcmp(element_name, "block")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1101 struct gaim_account *account = gaim_account_find(blist_parser_account_name,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1102 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1103 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1104 gaim_privacy_deny_add(account, blist_parser_buddy_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1105 }
4442
fd53864d880f [gaim-migrate @ 4717]
Nathan Walp <nwalp@pidgin.im>
parents: 4441
diff changeset
1106 g_free(blist_parser_buddy_name);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
1107 blist_parser_buddy_name = NULL;
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1108 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1109 } else if(!strcmp(element_name, "ignore")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1110 /* we'll apparently do something with this later */
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1111 tag_stack = g_list_delete_link(tag_stack, tag_stack);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1112 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1113 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1114
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1115 static void blist_text_handler(GMarkupParseContext *context, const gchar *text,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1116 gsize text_len, gpointer user_data, GError **error) {
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1117 switch(GPOINTER_TO_INT(tag_stack->data)) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1118 case BLIST_TAG_NAME:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1119 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1120 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1121 case BLIST_TAG_ALIAS:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1122 blist_parser_buddy_alias = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1123 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1124 case BLIST_TAG_PERMIT:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1125 case BLIST_TAG_BLOCK:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1126 case BLIST_TAG_IGNORE:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1127 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1128 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1129 case BLIST_TAG_SETTING:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1130 blist_parser_setting_value = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1131 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1132 default:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1133 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1134 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1135 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1136
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1137 static void blist_error_handler(GMarkupParseContext *context, GError *error,
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1138 gpointer user_data) {
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1139 blist_parser_error_occurred = TRUE;
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1140 debug_printf("error parsing blist.xml: %s\n", error->message);
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1141 }
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1142
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1143 static GMarkupParser blist_parser = {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1144 blist_start_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1145 blist_end_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1146 blist_text_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1147 NULL,
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1148 blist_error_handler
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1149 };
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1150
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1151 static gboolean gaim_blist_read(const char *filename) {
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1152 gchar *contents = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1153 gsize length;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1154 GMarkupParseContext *context;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1155 GError *error = NULL;
4496
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1156
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1157 debug_printf("gaim_blist_read: reading %s\n", filename);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1158 if(!g_file_get_contents(filename, &contents, &length, &error)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1159 debug_printf("error reading blist: %s\n", error->message);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1160 g_error_free(error);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1161 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1162 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1163
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1164 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1165
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1166 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1167 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1168 g_free(contents);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1169 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1170 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1171
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1172 if(!g_markup_parse_context_end_parse(context, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1173 debug_printf("error parsing blist\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1174 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1175 g_free(contents);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1176 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1177 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1178
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1179 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1180 g_free(contents);
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1181
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1182 if(blist_parser_error_occurred)
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1183 return FALSE;
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1184
4496
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1185 debug_printf("gaim_blist_read: finished reading %s\n", filename);
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1186
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1187 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1188 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1189
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1190 void gaim_blist_load() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1191 GSList *accts;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1192 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1193 char *filename;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1194 char *msg;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1195
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1196 blist_safe_to_write = TRUE;
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1197
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1198 if(!user_dir)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1199 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1200
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1201 filename = g_build_filename(user_dir, "blist.xml", NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1202
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1203 if(g_file_test(filename, G_FILE_TEST_EXISTS)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1204 if(!gaim_blist_read(filename)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1205 msg = g_strdup_printf(_("An error was encountered parsing your "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1206 "buddy list. It has not been loaded."));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1207 do_error_dialog(_("Buddy List Error"), msg, GAIM_ERROR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1208 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1209 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1210 } else if(g_slist_length(gaim_accounts)) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1211 /* rob wants to inform the user that their buddy lists are
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1212 * being converted */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1213 msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1214 "to a new format, which will now be located at %s"),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1215 filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1216 do_error_dialog(_("Converting Buddy List"), msg, GAIM_INFO);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1217 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1218
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1219 /* now, let gtk actually display the dialog before we start anything */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1220 while(gtk_events_pending())
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1221 gtk_main_iteration();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1222
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1223 /* read in the old lists, then save to the new format */
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1224 for(accts = gaim_accounts; accts; accts = accts->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1225 do_import(accts->data, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1226 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1227 gaim_blist_save();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1228 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1229
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1230 g_free(filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1231 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1232
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1233 static void blist_print_group_settings(gpointer key, gpointer data,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1234 gpointer user_data) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1235 char *key_val;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1236 char *data_val;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1237 FILE *file = user_data;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1238
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1239 if(!key || !data)
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1240 return;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1241
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1242 key_val = g_markup_escape_text(key, -1);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1243 data_val = g_markup_escape_text(data, -1);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1244
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1245 fprintf(file, "\t\t\t<setting name=\"%s\">%s</setting>\n", key_val,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1246 data_val);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1247 g_free(key_val);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1248 g_free(data_val);
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1249 }
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1250
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1251 static void blist_print_buddy_settings(gpointer key, gpointer data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1252 gpointer user_data) {
5125
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1253 char *key_val;
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1254 char *data_val;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1255 FILE *file = user_data;
5125
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1256
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1257 if(!key || !data)
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1258 return;
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1259
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1260 key_val = g_markup_escape_text(key, -1);
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1261 data_val = g_markup_escape_text(data, -1);
74139d2562f5 [gaim-migrate @ 5488]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1262
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1263 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1264 data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1265 g_free(key_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1266 g_free(data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1267 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1268
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1269 static void gaim_blist_write(FILE *file, struct gaim_account *exp_acct) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1270 GSList *accounts, *buds;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1271 GaimBlistNode *gnode,*bnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1272 struct group *group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1273 struct buddy *bud;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1274 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1275 fprintf(file, "<gaim version=\"1\">\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1276 fprintf(file, "\t<blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1277
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1278 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1279 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1280 continue;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1281 group = (struct group *)gnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1282 if(!exp_acct || gaim_group_on_account(group, exp_acct)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1283 char *group_name = g_markup_escape_text(group->name, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1284 fprintf(file, "\t\t<group name=\"%s\">\n", group_name);
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1285 g_hash_table_foreach(group->settings, blist_print_group_settings, file);
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1286 for(bnode = gnode->child; bnode; bnode = bnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1287 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1288 continue;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1289 bud = (struct buddy *)bnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1290 if(!exp_acct || bud->account == exp_acct) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1291 char *bud_name = g_markup_escape_text(bud->name, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1292 char *bud_alias = NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1293 char *acct_name = g_markup_escape_text(bud->account->username, -1);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1294 if(bud->alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1295 bud_alias= g_markup_escape_text(bud->alias, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1296 fprintf(file, "\t\t\t<person name=\"%s\">\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1297 bud_alias ? bud_alias : bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1298 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" "
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1299 "account=\"%s\">\n", bud->account->protocol,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1300 acct_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1301 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1302 if(bud_alias) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1303 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1304 bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1305 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1306 g_hash_table_foreach(bud->settings,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1307 blist_print_buddy_settings, file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1308 fprintf(file, "\t\t\t\t</buddy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1309 fprintf(file, "\t\t\t</person>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1310 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1311 g_free(bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1312 g_free(acct_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1313 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1314 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1315 fprintf(file, "\t\t</group>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1316 g_free(group_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1317 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1318 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1319
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1320 fprintf(file, "\t</blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1321 fprintf(file, "\t<privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1322
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1323 for(accounts = gaim_accounts; accounts; accounts = accounts->next) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1324 struct gaim_account *account = accounts->data;
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1325 char *acct_name = g_markup_escape_text(account->username, -1);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1326 if(!exp_acct || account == exp_acct) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1327 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" "
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1328 "mode=\"%d\">\n", account->protocol, acct_name, account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1329 for(buds = account->permit; buds; buds = buds->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1330 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1331 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1332 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1333 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1334 for(buds = account->deny; buds; buds = buds->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1335 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1336 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1337 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1338 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1339 fprintf(file, "\t\t</account>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1340 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1341 g_free(acct_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1342 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1343
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1344 fprintf(file, "\t</privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1345 fprintf(file, "</gaim>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1346 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1347
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1348 void gaim_blist_save() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1349 FILE *file;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1350 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1351 char *filename;
4891
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1352 char *filename_real;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1353
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1354 if(!user_dir)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1355 return;
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1356 if(!blist_safe_to_write) {
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1357 debug_printf("AHH!! tried to write the blist before we read it!\n");
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1358 return;
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1359 }
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1360
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1361 file = fopen(user_dir, "r");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1362 if(!file)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1363 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1364 else
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1365 fclose(file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1366
4891
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1367 filename = g_build_filename(user_dir, "blist.xml.save", NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1368
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1369 if((file = fopen(filename, "w"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1370 gaim_blist_write(file, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1371 fclose(file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1372 chmod(filename, S_IRUSR | S_IWUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1373 } else {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1374 debug_printf("unable to write %s\n", filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1375 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1376
4891
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1377 filename_real = g_build_filename(user_dir, "blist.xml", NULL);
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1378
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1379 if(rename(filename, filename_real) < 0)
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1380 debug_printf("error renaming %s to %s\n", filename, filename_real);
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1381
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1382
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1383 g_free(filename);
4891
cfa045006bec [gaim-migrate @ 5221]
Nathan Walp <nwalp@pidgin.im>
parents: 4865
diff changeset
1384 g_free(filename_real);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1385 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1386
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1387 gboolean gaim_privacy_permit_add(struct gaim_account *account, const char *who) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1388 GSList *d = account->permit;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1389 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1390 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1391 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1392 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1393 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1394 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1395 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1396 if(!d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1397 account->permit = g_slist_append(account->permit, g_strdup(who));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1398 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1399 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1400
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1401 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1402 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1403
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1404 gboolean gaim_privacy_permit_remove(struct gaim_account *account, const char *who) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1405 GSList *d = account->permit;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1406 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1407 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1408 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1409 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1410 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1411 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1412 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1413 if(d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1414 account->permit = g_slist_remove(account->permit, d->data);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1415 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1416 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1417 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1418 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1419 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1420
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1421 gboolean gaim_privacy_deny_add(struct gaim_account *account, const char *who) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1422 GSList *d = account->deny;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1423 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1424 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1425 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1426 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1427 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1428 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1429 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1430 if(!d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1431 account->deny = g_slist_append(account->deny, g_strdup(who));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1432 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1433 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1434
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1435 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1436 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1437
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1438 gboolean gaim_privacy_deny_remove(struct gaim_account *account, const char *who) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1439 GSList *d = account->deny;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1440 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1441 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1442 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1443 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1444 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1445 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1446 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1447 if(d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1448 account->deny = g_slist_remove(account->deny, d->data);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1449 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1450 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1451 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1452 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1453 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1454
5142
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1455 void gaim_group_set_setting(struct group *g, const char *key,
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1456 const char *value) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1457 if(!g)
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1458 return;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1459 g_hash_table_replace(g->settings, g_strdup(key), g_strdup(value));
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1460 }
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1461
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1462 char *gaim_group_get_setting(struct group *g, const char *key) {
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1463 if(!g)
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1464 return NULL;
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1465 return g_strdup(g_hash_table_lookup(g->settings, key));
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1466 }
94f11800cac5 [gaim-migrate @ 5506]
Nathan Walp <nwalp@pidgin.im>
parents: 5125
diff changeset
1467
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1468 void gaim_buddy_set_setting(struct buddy *b, const char *key,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1469 const char *value) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1470 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1471 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1472 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1473 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1474
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1475 char *gaim_buddy_get_setting(struct buddy *b, const char *key) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1476 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1477 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1478 return g_strdup(g_hash_table_lookup(b->settings, key));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1479 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1480
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1481 void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1482 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1483 blist_ui_ops = ops;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1484 }
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1485
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1486 struct gaim_blist_ui_ops *
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1487 gaim_get_blist_ui_ops(void)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1488 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1489 return blist_ui_ops;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1490 }
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1491
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1492 int gaim_blist_get_group_size(struct group *group, gboolean offline) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1493 GaimBlistNode *node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1494 int count = 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1495
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1496 if(!group)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1497 return 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1498
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1499 for(node = group->node.child; node; node = node->next) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1500 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1501 struct buddy *b = (struct buddy *)node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1502 if(b->account->gc || offline)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1503 count++;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1504 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1505 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1506
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1507 return count;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1508 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1509
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1510 int gaim_blist_get_group_online_count(struct group *group) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1511 GaimBlistNode *node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1512 int count = 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1513
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1514 if(!group)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1515 return 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1516
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1517 for(node = group->node.child; node; node = node->next) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1518 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1519 struct buddy *b = (struct buddy *)node;
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5056
diff changeset
1520 if(GAIM_BUDDY_IS_ONLINE(b))
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1521 count++;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1522 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1523 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1524
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1525 return count;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1526 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1527
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1528