annotate src/list.c @ 4849:adf9ca39578f

[gaim-migrate @ 5174] Christian, I got the following backtrace after opening and closing some convos: #4 <signal handler called> #5 0x08066e47 in gaim_window_get_active_conversation (win=0x82b44d8) at conversation.c:775 #6 0x08085599 in update_send_as_selection (win=0x82b44d8) at gtkconv.c:1964 #7 0x4067fa4c in g_timeout_dispatch () from /usr/lib/libglib-2.0.so.0 So although I couldn't reproduce it, I guess it's still possible for Gaim to crash there. This fixes that by making sure that win still exists before it tries to update the send as menu for it. The other way to fix this would be to keep track of the g_timer thingy and then remove it when destroying win. I don't know which was is better. Probably the other way. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 21 Mar 2003 20:59:31 +0000
parents 46fb754a3c10
children 3bc5a65728fb
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;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
121 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
122 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
125 void gaim_blist_update_buddy_presence(struct buddy *buddy, int presence) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
126 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
127 if (!buddy->present && presence)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
128 buddy->present = 2;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
129 else if (buddy->present != 2)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
130 buddy->present = presence;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
131 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
132 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
133 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
136 void gaim_blist_update_buddy_idle (struct buddy *buddy, int idle)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
137 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
138 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
139 buddy->idle = idle;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
140 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
141 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
142 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
143 void gaim_blist_update_buddy_evil (struct buddy *buddy, int warning)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
144 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
145 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
146 buddy->evil = warning;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
147 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
148 ops->update(gaimbuddylist,(GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
149 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
150 void gaim_blist_update_buddy_icon(struct buddy *buddy) {
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
151 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
152 if(ops)
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
153 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
154 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
155 void gaim_blist_rename_buddy (struct buddy *buddy, const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
156 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
157 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
158 g_free(buddy->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
159 buddy->name = g_strdup(name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
160 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
161 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
162 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
163 void gaim_blist_alias_buddy (struct buddy *buddy, const char *alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
164 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
165 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
166 g_free(buddy->alias);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
167 buddy->alias = g_strdup(alias);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
168 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
169 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
170 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
171 void gaim_blist_rename_group(struct group *group, const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
172 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
173 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
174 g_free(group->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
175 group->name = g_strdup(name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
176 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
177 ops->update(gaimbuddylist, (GaimBlistNode*)group);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
178 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
179 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
180 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
181 struct buddy *b;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
182 struct gaim_blist_ui_ops *ops;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
183
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
184 b = g_new0(struct buddy, 1);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
185 b->account = account;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
186 b->name = g_strdup(screenname);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
187 b->alias = g_strdup(alias);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
188 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
189 ((GaimBlistNode*)b)->type = GAIM_BLIST_BUDDY_NODE;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
191 ops = gaim_get_blist_ui_ops();
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
192
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
193 if (ops != NULL && ops->new_node != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
194 ops->new_node((GaimBlistNode *)b);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
195
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
198 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
199 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
200 GaimBlistNode *n = node, *node2, *node3;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
201 struct group *g = group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
202 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
203 gboolean save = FALSE;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
204 if (!n) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
205 if (!g) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
206 g = gaim_group_new(_("Buddies"));
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
207 gaim_blist_add_group(g, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
208 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
209 n = gaim_blist_get_last_child((GaimBlistNode*)g);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
210 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
211
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
212 if (((GaimBlistNode*)buddy)->parent) {
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
213 /* This buddy was already in the list and is
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
214 * being moved.
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
215 */
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
216 ops->remove(gaimbuddylist, (GaimBlistNode*)buddy);
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
217 node2 = ((GaimBlistNode*)buddy)->next;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
218 node3 = ((GaimBlistNode*)buddy)->prev;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
219
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
220 if (node2)
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
221 node2->prev = node3;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
222 if (node3)
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
223 node3->next = node2;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
224
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
225 if (((GaimBlistNode*)buddy)->parent != n->parent)
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
226 serv_move_buddy(buddy, (struct group*)((GaimBlistNode*)buddy)->parent,
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
227 (struct group*)n->parent);
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
228 save = TRUE;
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
229 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
231 if (n) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
232 ((GaimBlistNode*)buddy)->next = n->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
233 ((GaimBlistNode*)buddy)->prev = n;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
234 ((GaimBlistNode*)buddy)->parent = n->parent;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
235 n->next = (GaimBlistNode*)buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
236 } else {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
237 ((GaimBlistNode*)g)->child = (GaimBlistNode*)buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
238 ((GaimBlistNode*)buddy)->next = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
239 ((GaimBlistNode*)buddy)->prev = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
240 ((GaimBlistNode*)buddy)->parent = (GaimBlistNode*)g;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
241 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
243 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
244 ops->update(gaimbuddylist, (GaimBlistNode*)buddy);
4770
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
245 if (save)
c4c28874ecd3 [gaim-migrate @ 5088]
Sean Egan <seanegan@gmail.com>
parents: 4757
diff changeset
246 gaim_blist_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
247 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
249 struct group *gaim_group_new(const char *name)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
250 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
251 struct group *g = gaim_find_group(name);
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
252
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
253 if (!g) {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
254 struct gaim_blist_ui_ops *ops;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
255 g= g_new0(struct group, 1);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
256 g->name = g_strdup(name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
257 ((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
259 ops = gaim_get_blist_ui_ops();
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
260
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
261 if (ops != NULL && ops->new_node != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
262 ops->new_node((GaimBlistNode *)g);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
263
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
264 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
268 void gaim_blist_add_group (struct group *group, GaimBlistNode *node)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
270 struct gaim_blist_ui_ops *ops;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
271 gboolean save = FALSE;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
272
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
273 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
274 gaimbuddylist = gaim_blist_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
275 ops = gaimbuddylist->ui_ops;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
276
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
277 if (!gaimbuddylist->root) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
278 gaimbuddylist->root = (GaimBlistNode*)group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
279 return;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
280 }
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
281
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
282
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
283 if (!node)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
284 node = gaim_blist_get_last_sibling(gaimbuddylist->root);
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
285
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
286 if (gaim_find_group(group->name)) {
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
287 /* This is just being moved */
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
288 GaimBlistNode *node2 = ((GaimBlistNode*)group)->next;
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
289 GaimBlistNode *node3 = ((GaimBlistNode*)group)->prev;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
291 ops->remove(gaimbuddylist, (GaimBlistNode*)group);
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
292
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
293 if (node2)
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
294 node2->prev = node3;
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
295 if (node3)
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
296 node3->next = node2;
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
297 save = TRUE;
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
298 }
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
299
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
300 ((GaimBlistNode*)group)->next = node ? node->next : NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
301 ((GaimBlistNode*)group)->prev = node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
302 node->next = (GaimBlistNode*)group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
303
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
304 if (ops)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
305 ops->update(gaimbuddylist, (GaimBlistNode*)group);
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
306 if (save)
4781
b6f33ba0a0c0 [gaim-migrate @ 5101]
Sean Egan <seanegan@gmail.com>
parents: 4770
diff changeset
307 gaim_blist_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
308 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
309
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
310 void gaim_blist_remove_buddy (struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
311 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
312 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
313
4721
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
314 GaimBlistNode *gnode, *node = (GaimBlistNode*)buddy;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
315 struct group *group;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
316
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
317 gnode = node->parent;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
318 group = (struct group *)gnode;
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
319
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
320 if(gnode->child == node)
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
321 gnode->child = node->next;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
322 if (node->prev)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
323 node->prev->next = node->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
324 if (node->next)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
325 node->next->prev = node->prev;
4721
91ef4fae4a49 [gaim-migrate @ 5033]
Nathan Walp <nwalp@pidgin.im>
parents: 4720
diff changeset
326
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
327 ops->remove(gaimbuddylist, node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
328 g_free(buddy->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
329 g_free(buddy->alias);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
330 g_free(buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
333 void gaim_blist_remove_group (struct group *group)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
334 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
335 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
336 GaimBlistNode *node = (GaimBlistNode*)group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
337 GaimBlistNode *child = node->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
338 while (child) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
339 GaimBlistNode *n = child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
340 child = child->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
341 gaim_blist_remove_buddy((struct buddy*)n);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
342 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
343 ops->remove(gaimbuddylist, node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
344 g_free(group->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
345 g_free(group);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
346 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
347
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
348 char *gaim_get_buddy_alias_only(struct buddy *b) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
349 if(!b)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
350 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
351 if(b->alias && b->alias[0])
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
352 return b->alias;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
353 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
354 return b->server_alias;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
355 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
356 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
357
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
358 char * gaim_get_buddy_alias (struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
359 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
360 char *ret = gaim_get_buddy_alias_only(buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
361 if(!ret)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
362 return buddy ? buddy->name : _("Unknown");
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
363 return ret;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
364
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
365 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
366
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
367 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
368 {
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
369 GaimBlistNode *group;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
370 GaimBlistNode *buddy;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
371 char *norm_name = g_strdup(normalize(name));
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
372
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
373 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
374 return NULL;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
375
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
376 group = gaimbuddylist->root;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
377 while (group) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
378 buddy = group->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
379 while (buddy) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
380 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
381 g_free(norm_name);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
382 return (struct buddy*)buddy;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
383 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
384 buddy = buddy->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
385 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
386 group = group->next;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
387 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4753
diff changeset
388 g_free(norm_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
389 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
390 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
391
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
392 struct group *gaim_find_group(const char *name)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
394 GaimBlistNode *node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
395 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
396 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
397 node = gaimbuddylist->root;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
398 while(node) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
399 if (!strcmp(((struct group*)node)->name, name))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
400 return (struct group*)node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
401 node = node->next;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
403 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
405 struct group *gaim_find_buddys_group(struct buddy *buddy)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
406 {
4830
46fb754a3c10 [gaim-migrate @ 5155]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
407 if (!buddy)
46fb754a3c10 [gaim-migrate @ 5155]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
408 return NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
409 return (struct group*)(((GaimBlistNode*)buddy)->parent);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
410 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
411
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
412 GSList *gaim_group_get_accounts(struct group *g)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
413 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
414 GSList *l = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
415 GaimBlistNode *child = ((GaimBlistNode *)g)->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
416
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
417 while (child) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
418 if (!g_slist_find(l, ((struct buddy*)child)->account))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
419 l = g_slist_append(l, ((struct buddy*)child)->account);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
420 child = child->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
421 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
422 return l;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
423 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
424
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
425 void gaim_blist_remove_account(struct gaim_account *account)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
426 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
427 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
428 GaimBlistNode *group = gaimbuddylist->root;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
429 GaimBlistNode *buddy;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
430 if (!gaimbuddylist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
431 return;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
432 while (group) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
433 buddy = group->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
434 while (buddy) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
435 if (account == ((struct buddy*)buddy)->account) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
436 ((struct buddy*)buddy)->present = 0;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
437 ops->remove(gaimbuddylist, buddy);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
438 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
439 buddy = buddy->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
440 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
441 group = group->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
442 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
443 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
445 void parse_toc_buddy_list(struct gaim_account *account, char *config)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 char *c;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 char current[256];
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
449 GList *bud = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
450
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 if (config != NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
453
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 /* skip "CONFIG:" (if it exists) */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 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
456 strtok(config, "\n") :
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
457 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 do {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 if (c == NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 if (*c == 'g') {
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
462 char *utf8 = NULL;
4458
a46c57f2d58b [gaim-migrate @ 4733]
Luke Schierer <lschiere@pidgin.im>
parents: 4444
diff changeset
463 utf8 = gaim_try_conv_to_utf8(c + 2);
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
464 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
465 g_strlcpy(current, _("Invalid Groupname"), sizeof(current));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
466 } else {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
467 g_strlcpy(current, utf8, sizeof(current));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
468 g_free(utf8);
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
469 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
470 if (!gaim_find_group(current)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
471 struct group *g = gaim_group_new(current);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
472 gaim_blist_add_group(g, NULL);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
473 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
474 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
475 char nm[80], sw[388], *a, *utf8 = NULL;
4408
94bf204f837e [gaim-migrate @ 4677]
Nathan Walp <nwalp@pidgin.im>
parents: 4404
diff changeset
476
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
477 if ((a = strchr(c + 2, ':')) != NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
478 *a++ = '\0'; /* nul the : */
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
479 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
480
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
481 g_strlcpy(nm, c + 2, sizeof(nm));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
482 if (a) {
4458
a46c57f2d58b [gaim-migrate @ 4733]
Luke Schierer <lschiere@pidgin.im>
parents: 4444
diff changeset
483 utf8 = gaim_try_conv_to_utf8(a);
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
484 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
485 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
486 }
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
487 }
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
488 if (utf8 == NULL) {
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
489 sw[0] = '\0';
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
490 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
491 /* This can leave a partial sequence at the end,
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
492 * but who cares? */
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
493 g_strlcpy(sw, utf8, sizeof(sw));
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
494 g_free(utf8);
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
495 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
496
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
497 if (!gaim_find_buddy(account, nm)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
498 struct buddy *b = gaim_buddy_new(account, nm, sw);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
499 struct group *g = gaim_find_group(current);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
500 gaim_blist_add_buddy(b, g, NULL);
4404
16f7f9451814 [gaim-migrate @ 4673]
Mark Doliner <mark@kingant.net>
parents: 4352
diff changeset
501 bud = g_list_append(bud, nm);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
502 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 } else if (*c == 'p') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
504 gaim_privacy_permit_add(account, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 } else if (*c == 'd') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
506 gaim_privacy_deny_add(account, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 } else if (!strncmp("toc", c, 3)) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
508 sscanf(c + strlen(c) - 1, "%d", &account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
509 debug_printf("permdeny: %d\n", account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
510 if (account->permdeny == 0)
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
511 account->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 } else if (*c == 'm') {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
513 sscanf(c + 2, "%d", &account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
514 debug_printf("permdeny: %d\n", account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
515 if (account->permdeny == 0)
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
516 account->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 } while ((c = strtok(NULL, "\n")));
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
519
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
520 if(account->gc) {
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
521 if(bud)
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
522 serv_add_buddies(account->gc, bud);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
523 serv_set_permit_deny(account->gc);
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
524 }
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
525 g_list_free(bud);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
529 #if 0
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
530 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
531 static GString *translate_lst(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 char line[BUF_LEN], *line2;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 char *name;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
537 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 while (fgets(line, BUF_LEN, src_fp)) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
540 line2 = g_strchug(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 if (strstr(line2, "group") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
543 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
546 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
547 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 if (strstr(line2, "buddy") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
551 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
554 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
555 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
559 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
563 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
564 static GString *translate_blt(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 char line[BUF_LEN];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 char *buddy;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
570 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 while (1) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
576 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 if (strchr(line, '}') != NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 if (strchr(line, '{') != NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
581 /* Syntax starting with "<group> {" */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
582
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
583 dest = g_string_append(dest, "g ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
584 buddy = g_strchug(strtok(line, "{"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
585 for (i = 0; i < strlen(buddy); i++)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
586 if (buddy[i] != '\"')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
587 dest = g_string_append_c(dest, buddy[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
588 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
590 gboolean pounce = FALSE;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
591 char *e;
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
592 g_strchomp(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
593 buddy = g_strchug(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
594 debug_printf("\nbuddy: \"%s\"\n\n", buddy);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
595 dest = g_string_append(dest, "b ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
596 if (strchr(buddy, '{') != NULL) {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
597 /* buddy pounce, etc */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
598 char *pos = strchr(buddy, '{') - 1;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
599 *pos = 0;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
600 pounce = TRUE;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
601 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
602 if ((e = strchr(buddy, '\"')) != NULL) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
603 *e = '\0';
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 buddy++;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
605 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
606 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
607 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
608 if (pounce)
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
609 do
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
610 fgets(line, BUF_LEN, src_fp);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
611 while (!strchr(line, '}'));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612 }
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
613 } else {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
614
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
615 /* Syntax "group buddy buddy ..." */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
616 buddy = g_strchug(strtok(line, " \n"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
617 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
619 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
620 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
621 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
623 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
624 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
625 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
627 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
628 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
630 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
632 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
633 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
634 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
636 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
637 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
638 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
640 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
641 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
642 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
644 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
645 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
647 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
649 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
654 return dest;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
655 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
656
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
657 static GString *translate_gnomeicu(FILE *src_fp)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
658 {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
659 char line[BUF_LEN];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
660 GString *dest = g_string_new("m 1\ng Buddies\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
661
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
662 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
663
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
664 while (fgets(line, BUF_LEN, src_fp)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
665 char *eq;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
666 g_strchomp(line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
667 if (line[0] == '\n' || line[0] == '[')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
668 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
669 eq = strchr(line, '=');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
670 if (!eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
671 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
672 *eq = ':';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
673 eq = strchr(eq, ',');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
674 if (eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
675 *eq = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
676 dest = g_string_append(dest, "b ");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
677 dest = g_string_append(dest, line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
678 dest = g_string_append_c(dest, '\n');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
679 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
680
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
681 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
683 #endif
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685 static gchar *get_screenname_filename(const char *name)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 gchar **split;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 gchar *good;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
689 gchar *ret;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 good = g_strjoinv(NULL, split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 g_strfreev(split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
695 ret = g_utf8_strup(good, -1);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
697 g_free(good);
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
698
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
699 return ret;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
702 static gboolean gaim_blist_read(const char *filename);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
704
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
705 static void do_import(struct gaim_account *account, const char *filename)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
707 GString *buf = NULL;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
708 char first[64];
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 int len;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 FILE *f;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
712 struct stat st;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 if (filename) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 g_snprintf(path, sizeof(path), "%s", filename);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
717 char *g_screenname = get_screenname_filename(account->username);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
718 char *file = gaim_user_dir();
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
719 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
720
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 if (file != (char *)NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
722 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
723 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
730 if (stat(path, &st)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
731 debug_printf("Unable to stat %s.\n", path);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
732 return;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
733 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
734
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 if (!(f = fopen(path, "r"))) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 debug_printf("Unable to open %s.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 fgets(first, 64, f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
742 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
743 fgets(first, 64, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
744
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
745 #if 0
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
746 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
747 /* new gaim XML buddy list */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
748 gaim_blist_read(path);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
749
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
750 /* 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
751
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
752 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
753 /* AIM 4 buddy list */
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 debug_printf("aim 4\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
756 buf = translate_blt(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
757 } else if (strstr(first, "group") != NULL) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 /* AIM 3 buddy list */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 debug_printf("aim 3\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
761 buf = translate_lst(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
762 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
763 /* GnomeICU (hopefully) */
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
764 debug_printf("gnomeicu\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
765 rewind(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
766 buf = translate_gnomeicu(f);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
767
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
768 } else
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
769 #endif
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
770 if (first[0] == 'm') {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
771 /* Gaim buddy list - no translation */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
772 char buf2[BUF_LONG * 2];
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
773 buf = g_string_new("");
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
774 rewind(f);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
775 while (1) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
776 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
777 if (len <= 0)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
778 break;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
779 buf2[len] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
780 buf = g_string_append(buf, buf2);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
781 if (len != BUF_LONG * 2 - 1)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
782 break;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
783 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
784 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
785
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 fclose(f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
788 if (buf) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
789 buf = g_string_prepend(buf, "toc_set_config {");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
790 buf = g_string_append(buf, "}\n");
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
791 parse_toc_buddy_list(account, buf->str);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
792 g_string_free(buf, TRUE);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
793 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
796 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
797 GaimBlistNode *bnode;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
798 for(bnode = g->node.child; bnode; bnode = bnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
799 struct buddy *b = (struct buddy *)bnode;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
800 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
801 continue;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
802 if((!account && b->account->gc) || b->account == account)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
803 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
804 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
805 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
806 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
807
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
808 static gboolean blist_safe_to_write = FALSE;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
809
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
810 static char *blist_parser_group_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
811 static char *blist_parser_person_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
812 static char *blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
813 static int blist_parser_account_protocol = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
814 static char *blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
815 static char *blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
816 static char *blist_parser_setting_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
817 static char *blist_parser_setting_value = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
818 static GHashTable *blist_parser_buddy_settings = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
819 static int blist_parser_privacy_mode = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
820 static enum {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
821 BLIST_TAG_GAIM,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
822 BLIST_TAG_BLIST,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
823 BLIST_TAG_GROUP,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
824 BLIST_TAG_PERSON,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
825 BLIST_TAG_BUDDY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
826 BLIST_TAG_NAME,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
827 BLIST_TAG_ALIAS,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
828 BLIST_TAG_SETTING,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
829 BLIST_TAG_PRIVACY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
830 BLIST_TAG_ACCOUNT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
831 BLIST_TAG_PERMIT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
832 BLIST_TAG_BLOCK,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
833 BLIST_TAG_IGNORE
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
834 } blist_parser_current_tag;
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
835 static gboolean blist_parser_error_occurred = FALSE;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
836
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
837 static void blist_start_element_handler (GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
838 const gchar *element_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
839 const gchar **attribute_names,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
840 const gchar **attribute_values,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
841 gpointer user_data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
842 GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
843 int i;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
844
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
845 if(!strcmp(element_name, "gaim")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
846 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
847 } else if(!strcmp(element_name, "blist")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
848 blist_parser_current_tag = BLIST_TAG_BLIST;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
849 } else if(!strcmp(element_name, "group")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
850 blist_parser_current_tag = BLIST_TAG_GROUP;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
851 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
852 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
853 g_free(blist_parser_group_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
854 blist_parser_group_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
855 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
856 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
857 if(blist_parser_group_name) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
858 struct group *g = gaim_group_new(blist_parser_group_name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
859 gaim_blist_add_group(g,NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
860 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
861 } else if(!strcmp(element_name, "person")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
862 blist_parser_current_tag = BLIST_TAG_PERSON;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
863 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
864 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
865 g_free(blist_parser_person_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
866 blist_parser_person_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
867 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
868 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
869 } else if(!strcmp(element_name, "buddy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
870 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
871 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
872 if(!strcmp(attribute_names[i], "account")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
873 g_free(blist_parser_account_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
874 blist_parser_account_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
875 } else if(!strcmp(attribute_names[i], "protocol")) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
876 blist_parser_account_protocol = atoi(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
877 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
878 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
879 } else if(!strcmp(element_name, "name")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
880 blist_parser_current_tag = BLIST_TAG_NAME;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
881 } else if(!strcmp(element_name, "alias")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
882 blist_parser_current_tag = BLIST_TAG_ALIAS;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
883 } else if(!strcmp(element_name, "setting")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
884 blist_parser_current_tag = BLIST_TAG_SETTING;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
885 for(i=0; attribute_names[i]; i++) {
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
886 if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
887 g_free(blist_parser_setting_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
888 blist_parser_setting_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
889 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
890 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
891 } else if(!strcmp(element_name, "privacy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
892 blist_parser_current_tag = BLIST_TAG_PRIVACY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
893 } else if(!strcmp(element_name, "account")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
894 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
895 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
896 if(!strcmp(attribute_names[i], "protocol"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
897 blist_parser_account_protocol = atoi(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
898 else if(!strcmp(attribute_names[i], "mode"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
899 blist_parser_privacy_mode = atoi(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
900 else if(!strcmp(attribute_names[i], "name")) {
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
901 g_free(blist_parser_account_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
902 blist_parser_account_name = g_strdup(attribute_values[i]);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
903 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
904 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
905 } else if(!strcmp(element_name, "permit")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
906 blist_parser_current_tag = BLIST_TAG_PERMIT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
907 } else if(!strcmp(element_name, "block")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
908 blist_parser_current_tag = BLIST_TAG_BLOCK;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
909 } else if(!strcmp(element_name, "ignore")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
910 blist_parser_current_tag = BLIST_TAG_IGNORE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
911 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
912 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
913
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
914 static void blist_end_element_handler(GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
915 const gchar *element_name, gpointer user_data, GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
916 if(!strcmp(element_name, "gaim")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
917 } else if(!strcmp(element_name, "blist")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
918 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
919 } else if(!strcmp(element_name, "group")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
920 blist_parser_current_tag = BLIST_TAG_BLIST;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
921 } else if(!strcmp(element_name, "person")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
922 blist_parser_current_tag = BLIST_TAG_GROUP;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
923 g_free(blist_parser_person_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
924 blist_parser_person_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
925 } else if(!strcmp(element_name, "buddy")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
926 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
927 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
928 if(account) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
929 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
930 struct group *g = gaim_find_group(blist_parser_group_name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
931 gaim_blist_add_buddy(b,g,NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
932 if(blist_parser_buddy_settings) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
933 g_hash_table_destroy(b->settings);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
934 b->settings = blist_parser_buddy_settings;
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 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
937 blist_parser_current_tag = BLIST_TAG_PERSON;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
938 g_free(blist_parser_buddy_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
939 blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
940 g_free(blist_parser_buddy_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
941 blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
942 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
943 blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
944 blist_parser_buddy_settings = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
945 } else if(!strcmp(element_name, "name")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
946 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
947 } else if(!strcmp(element_name, "alias")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
948 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
949 } else if(!strcmp(element_name, "setting")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
950 if(!blist_parser_buddy_settings)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
951 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
952 g_str_equal, g_free, g_free);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
953 if(blist_parser_setting_name && blist_parser_setting_value) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
954 g_hash_table_replace(blist_parser_buddy_settings,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
955 g_strdup(blist_parser_setting_name),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
956 g_strdup(blist_parser_setting_value));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
957 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
958 g_free(blist_parser_setting_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
959 g_free(blist_parser_setting_value);
4720
06e8e5858121 [gaim-migrate @ 5032]
Nathan Walp <nwalp@pidgin.im>
parents: 4701
diff changeset
960 blist_parser_setting_name = NULL;
06e8e5858121 [gaim-migrate @ 5032]
Nathan Walp <nwalp@pidgin.im>
parents: 4701
diff changeset
961 blist_parser_setting_value = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
962 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
963 } else if(!strcmp(element_name, "privacy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
964 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
965 } else if(!strcmp(element_name, "account")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
966 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
967 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
968 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
969 account->permdeny = blist_parser_privacy_mode;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
970 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
971 blist_parser_current_tag = BLIST_TAG_PRIVACY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
972 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
973 blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
974 } else if(!strcmp(element_name, "permit")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
975 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
976 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
977 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
978 gaim_privacy_permit_add(account, blist_parser_buddy_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
979 }
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
980 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
4442
fd53864d880f [gaim-migrate @ 4717]
Nathan Walp <nwalp@pidgin.im>
parents: 4441
diff changeset
981 g_free(blist_parser_buddy_name);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
982 blist_parser_buddy_name = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
983 } else if(!strcmp(element_name, "block")) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
984 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
985 blist_parser_account_protocol);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
986 if(account) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
987 gaim_privacy_deny_add(account, blist_parser_buddy_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
988 }
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
989 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
4442
fd53864d880f [gaim-migrate @ 4717]
Nathan Walp <nwalp@pidgin.im>
parents: 4441
diff changeset
990 g_free(blist_parser_buddy_name);
4444
fd83159169db [gaim-migrate @ 4719]
Nathan Walp <nwalp@pidgin.im>
parents: 4442
diff changeset
991 blist_parser_buddy_name = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
992 } else if(!strcmp(element_name, "ignore")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
993 /* we'll apparently do something with this later */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
994 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
995 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
996 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
997
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
998 static void blist_text_handler(GMarkupParseContext *context, const gchar *text,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
999 gsize text_len, gpointer user_data, GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1000 switch(blist_parser_current_tag) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1001 case BLIST_TAG_NAME:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1002 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1003 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1004 case BLIST_TAG_ALIAS:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1005 blist_parser_buddy_alias = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1006 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1007 case BLIST_TAG_PERMIT:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1008 case BLIST_TAG_BLOCK:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1009 case BLIST_TAG_IGNORE:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1010 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1011 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1012 case BLIST_TAG_SETTING:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1013 blist_parser_setting_value = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1014 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1015 default:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1016 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1017 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1018 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1019
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1020 static void blist_error_handler(GMarkupParseContext *context, GError *error,
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1021 gpointer user_data) {
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1022 blist_parser_error_occurred = TRUE;
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1023 debug_printf("error parsing blist.xml: %s\n", error->message);
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1024 }
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1025
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1026 static GMarkupParser blist_parser = {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1027 blist_start_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1028 blist_end_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1029 blist_text_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1030 NULL,
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1031 blist_error_handler
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1032 };
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1033
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1034 static gboolean gaim_blist_read(const char *filename) {
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1035 gchar *contents = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1036 gsize length;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1037 GMarkupParseContext *context;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1038 GError *error = NULL;
4496
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1039
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1040 debug_printf("gaim_blist_read: reading %s\n", filename);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1041 if(!g_file_get_contents(filename, &contents, &length, &error)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1042 debug_printf("error reading blist: %s\n", error->message);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1043 g_error_free(error);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1044 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1045 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1046
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1047 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1048
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1049 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1050 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1051 g_free(contents);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1052 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1053 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1054
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1055 if(!g_markup_parse_context_end_parse(context, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1056 debug_printf("error parsing blist\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1057 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1058 g_free(contents);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1059 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1060 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1061
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1062 g_markup_parse_context_free(context);
4441
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1063 g_free(contents);
474a0a88dd5e [gaim-migrate @ 4716]
Nathan Walp <nwalp@pidgin.im>
parents: 4439
diff changeset
1064
4439
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1065 if(blist_parser_error_occurred)
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1066 return FALSE;
7693d84255e7 [gaim-migrate @ 4714]
Nathan Walp <nwalp@pidgin.im>
parents: 4408
diff changeset
1067
4496
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1068 debug_printf("gaim_blist_read: finished reading %s\n", filename);
71e8b8e62a54 [gaim-migrate @ 4771]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
1069
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1070 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1071 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1072
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1073 void gaim_blist_load() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1074 GSList *accts;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1075 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1076 char *filename;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1077 char *msg;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1078
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1079 blist_safe_to_write = TRUE;
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1080
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1081 if(!user_dir)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1082 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1083
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1084 filename = g_build_filename(user_dir, "blist.xml", NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1085
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1086 if(g_file_test(filename, G_FILE_TEST_EXISTS)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1087 if(!gaim_blist_read(filename)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1088 msg = g_strdup_printf(_("An error was encountered parsing your "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1089 "buddy list. It has not been loaded."));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1090 do_error_dialog(_("Buddy List Error"), msg, GAIM_ERROR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1091 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1092 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1093 } else if(g_slist_length(gaim_accounts)) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1094 /* rob wants to inform the user that their buddy lists are
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1095 * being converted */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1096 msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1097 "to a new format, which will now be located at %s"),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1098 filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1099 do_error_dialog(_("Converting Buddy List"), msg, GAIM_INFO);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1100 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1101
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1102 /* now, let gtk actually display the dialog before we start anything */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1103 while(gtk_events_pending())
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1104 gtk_main_iteration();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1105
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1106 /* 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
1107 for(accts = gaim_accounts; accts; accts = accts->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1108 do_import(accts->data, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1109 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1110 gaim_blist_save();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1111 }
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 g_free(filename);
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
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1116 static void blist_print_buddy_settings(gpointer key, gpointer data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1117 gpointer user_data) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1118 char *key_val = g_markup_escape_text(key, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1119 char *data_val = g_markup_escape_text(data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1120 FILE *file = user_data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1121 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
1122 data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1123 g_free(key_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1124 g_free(data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1125 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1126
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1127 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
1128 GSList *accounts, *buds;
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1129 GaimBlistNode *gnode,*bnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1130 struct group *group;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1131 struct buddy *bud;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1132 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1133 fprintf(file, "<gaim version=\"1\">\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1134 fprintf(file, "\t<blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1135
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1136 for(gnode = gaimbuddylist->root; gnode; gnode = gnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1137 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1138 continue;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1139 group = (struct group *)gnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1140 if(!exp_acct || gaim_group_on_account(group, exp_acct)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1141 char *group_name = g_markup_escape_text(group->name, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1142 fprintf(file, "\t\t<group name=\"%s\">\n", group_name);
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1143 for(bnode = gnode->child; bnode; bnode = bnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1144 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1145 continue;
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4781
diff changeset
1146 bud = (struct buddy *)bnode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1147 if(!exp_acct || bud->account == exp_acct) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1148 char *bud_name = g_markup_escape_text(bud->name, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1149 char *bud_alias = NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1150 char *acct_name = g_markup_escape_text(bud->account->username, -1);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1151 if(bud->alias)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1152 bud_alias= g_markup_escape_text(bud->alias, -1);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1153 fprintf(file, "\t\t\t<person name=\"%s\">\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1154 bud_alias ? bud_alias : bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1155 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" "
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1156 "account=\"%s\">\n", bud->account->protocol,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1157 acct_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1158 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
1159 if(bud_alias) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1160 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1161 bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1162 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1163 g_hash_table_foreach(bud->settings,
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1164 blist_print_buddy_settings, file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1165 fprintf(file, "\t\t\t\t</buddy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1166 fprintf(file, "\t\t\t</person>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1167 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1168 g_free(bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1169 g_free(acct_name);
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 fprintf(file, "\t\t</group>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1173 g_free(group_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1174 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1175 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1176
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1177 fprintf(file, "\t</blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1178 fprintf(file, "\t<privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1179
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1180 for(accounts = gaim_accounts; accounts; accounts = accounts->next) {
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1181 struct gaim_account *account = accounts->data;
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1182 char *acct_name = g_markup_escape_text(account->username, -1);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1183 if(!exp_acct || account == exp_acct) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1184 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" "
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1185 "mode=\"%d\">\n", account->protocol, acct_name, account->permdeny);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1186 for(buds = account->permit; buds; buds = buds->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1187 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1188 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1189 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1190 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1191 for(buds = account->deny; buds; buds = buds->next) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1192 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1193 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1194 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1195 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1196 fprintf(file, "\t\t</account>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1197 }
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1198 g_free(acct_name);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1199 }
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 fprintf(file, "\t</privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1202 fprintf(file, "</gaim>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1203 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1204
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1205 void gaim_blist_save() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1206 FILE *file;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1207 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1208 char *filename;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1209
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1210 if(!user_dir)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1211 return;
4497
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1212 if(!blist_safe_to_write) {
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1213 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
1214 return;
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1215 }
5968bcd8ddb6 [gaim-migrate @ 4772]
Nathan Walp <nwalp@pidgin.im>
parents: 4496
diff changeset
1216
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1217 file = fopen(user_dir, "r");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1218 if(!file)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1219 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1220 else
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1221 fclose(file);
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 filename = g_build_filename(user_dir, "blist.xml", NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1224
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1225 if((file = fopen(filename, "w"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1226 gaim_blist_write(file, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1227 fclose(file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1228 chmod(filename, S_IRUSR | S_IWUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1229 } else {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1230 debug_printf("unable to write %s\n", 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
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1233 g_free(filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1234 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1235
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1236 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
1237 GSList *d = account->permit;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1238 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1239 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1240 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1241 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1242 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1243 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1244 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1245 if(!d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1246 account->permit = g_slist_append(account->permit, g_strdup(who));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1247 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1248 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1249
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1250 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1251 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1252
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1253 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
1254 GSList *d = account->permit;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1255 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1256 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1257 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1258 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1259 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1260 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1261 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1262 if(d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1263 account->permit = g_slist_remove(account->permit, d->data);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1264 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1265 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1266 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1267 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1268 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1269
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1270 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
1271 GSList *d = account->deny;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1272 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1273 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1274 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1275 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1276 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1277 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1278 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1279 if(!d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1280 account->deny = g_slist_append(account->deny, g_strdup(who));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1281 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1282 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1283
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1284 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1285 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1286
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1287 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
1288 GSList *d = account->deny;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1289 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1290 while(d) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1291 if(!gaim_utf8_strcasecmp(n, normalize(d->data)))
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1292 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1293 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1294 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1295 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1296 if(d) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4458
diff changeset
1297 account->deny = g_slist_remove(account->deny, d->data);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1298 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1299 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1300 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1301 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1302 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1303
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1304 void gaim_buddy_set_setting(struct buddy *b, const char *key,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1305 const char *value) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1306 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1307 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1308 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
1309 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1310
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1311 char *gaim_buddy_get_setting(struct buddy *b, const char *key) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1312 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1313 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1314 return g_strdup(g_hash_table_lookup(b->settings, key));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1315 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1316
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1317 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
1318 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1319 blist_ui_ops = ops;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4497
diff changeset
1320 }
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1321
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1322 struct gaim_blist_ui_ops *
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1323 gaim_get_blist_ui_ops(void)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1324 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1325 return blist_ui_ops;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4690
diff changeset
1326 }
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1327
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1328 int gaim_blist_get_group_size(struct group *group, gboolean offline) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1329 GaimBlistNode *node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1330 int count = 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1331
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1332 if(!group)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1333 return 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1334
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1335 for(node = group->node.child; node; node = node->next) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1336 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1337 struct buddy *b = (struct buddy *)node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1338 if(b->account->gc || offline)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1339 count++;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1340 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1341 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1342
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1343 return count;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1344 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1345
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1346 int gaim_blist_get_group_online_count(struct group *group) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1347 GaimBlistNode *node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1348 int count = 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1349
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1350 if(!group)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1351 return 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1352
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1353 for(node = group->node.child; node; node = node->next) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1354 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1355 struct buddy *b = (struct buddy *)node;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1356 if(b->present)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1357 count++;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1358 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1359 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1360
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1361 return count;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1362 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1363
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
1364