annotate src/list.c @ 3364:d4c260bb5b6b

[gaim-migrate @ 3383] This too. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 02 Aug 2002 04:46:51 +0000
parents 1bd472b7f7a2
children 48a2e656bdf9
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 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * 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
8 * the Free Software Foundation; either version 2 of the License, or
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
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 #ifdef HAVE_CONFIG_H
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include <config.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #endif
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include <string.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <sys/types.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <sys/stat.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <unistd.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "gaim.h"
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include "prpl.h"
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #define PATHSIZE 1024
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 void remove_buddy(struct gaim_connection *gc, struct group *rem_g, struct buddy *rem_b)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 struct group *delg;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 struct buddy *delb;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 /* we assume that gc is not NULL and that the buddy exists somewhere within the
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 * gc's buddy list, therefore we can safely remove it. we need to ensure this
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 * via the UI
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 grp = g_slist_find(gc->groups, rem_g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 delg = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 mem = delg->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 mem = g_slist_find(mem, rem_b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 delb = (struct buddy *)mem->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 delg->members = g_slist_remove(delg->members, delb);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 ui_remove_buddy(gc, rem_g, rem_b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 g_free(rem_b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 /* we don't flush buddy list to cache because in the case of remove_group that would
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 * mean writing to the buddy list file once for each buddy, plus one more time */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 void remove_group(struct gaim_connection *gc, struct group *rem_g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 GList *tmp = NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 struct group *delg;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 struct buddy *delb;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 /* we assume that the group actually does exist within the gc, and that the gc is not NULL.
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 * the UI is responsible for this */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 grp = g_slist_find(gc->groups, rem_g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 delg = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 mem = delg->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 while (delg->members) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 delb = (struct buddy *)delg->members->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 tmp = g_list_append(tmp, g_strdup(delb->name));
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 remove_buddy(gc, delg, delb); /* this should take care of removing
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 the group_show if necessary */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 gc->groups = g_slist_remove(gc->groups, delg);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2662
diff changeset
89 serv_remove_buddies(gc, tmp, rem_g->name);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 while (tmp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 g_free(tmp->data);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 tmp = g_list_remove(tmp, tmp->data);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 ui_remove_group(gc, rem_g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 g_free(rem_g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 /* don't flush buddy list to cache in order to be consistent with remove_buddy,
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 * mostly. remove_group is only called from one place, so we'll let it handle it. */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 struct buddy *add_buddy(struct gaim_connection *gc, char *group, char *buddy, char *show)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 char *good;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108
2586
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
109 if (!g_slist_find(connections, gc))
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
110 return NULL;
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
111
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 if ((b = find_buddy(gc, buddy)) != NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 g = find_group(gc, group);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 if (g == NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 g = add_group(gc, group);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 b = (struct buddy *)g_new0(struct buddy, 1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 if (!b)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 b->gc = gc;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 b->present = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 if (gc->prpl->normalize)
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
129 good = gc->prpl->normalize(buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 good = buddy;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 g_snprintf(b->name, sizeof(b->name), "%s", good);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 g_snprintf(b->show, sizeof(b->show), "%s", show ? (show[0] ? show : good) : good);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 g->members = g_slist_append(g->members, b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 b->idle = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 b->caps = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 ui_add_buddy(gc, g, b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 struct group *add_group(struct gaim_connection *gc, char *group)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 struct group *g = find_group(gc, group);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 if (g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 return g;
2586
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
151 if (!g_slist_find(connections, gc))
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
152 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 g = (struct group *)g_new0(struct group, 1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 if (!g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 g->gc = gc;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 strncpy(g->name, group, sizeof(g->name));
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 gc->groups = g_slist_append(gc->groups, g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 g->members = NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 ui_add_group(gc, g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 struct group *find_group(struct gaim_connection *gc, char *group)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 GSList *c = connections;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 struct gaim_connection *z;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 char *grpname = g_malloc(strlen(group) + 1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 strcpy(grpname, normalize (group));
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 if (gc) {
2586
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
178 if (!g_slist_find(connections, gc))
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
179 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 grp = gc->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 if (!g_strcasecmp(normalize (g->name), grpname)) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 g_free(grpname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 g_free(grpname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 while (c) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 z = (struct gaim_connection *)c->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 grp = z->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 if (!g_strcasecmp(normalize (g->name), grpname)) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 g_free(grpname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 c = c->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 g_free(grpname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 struct group *find_group_by_buddy(struct gaim_connection *gc, char *who)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 char *whoname;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 char *(*norm)(const char *);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 if (gc) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 if (gc->prpl->normalize)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 norm = gc->prpl->normalize;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 norm = normalize;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
226 whoname = g_strdup(norm(who));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 grp = gc->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 mem = g->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 while (mem) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 b = (struct buddy *)mem->data;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
234 if (!strcmp(norm(b->name), whoname)) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 mem = mem->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 GSList *c = connections;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 struct gaim_connection *z;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 while (c) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 z = (struct gaim_connection *)c->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 if (z->prpl->normalize)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 norm = z->prpl->normalize;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 norm = normalize;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
253 whoname = g_strdup(norm(who));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 grp = z->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 mem = g->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 while (mem) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 b = (struct buddy *)mem->data;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
261 if (!strcmp(norm(b->name), whoname)) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 mem = mem->next;
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 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 c = c->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 struct buddy *find_buddy(struct gaim_connection *gc, char *who)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 GSList *c;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 struct gaim_connection *z;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 char *whoname;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 char *(*norm)(const char *);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 if (gc) {
2586
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
288 if (!g_slist_find(connections, gc))
0f5390176949 [gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2548
diff changeset
289 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 if (gc->prpl->normalize)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 norm = gc->prpl->normalize;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 norm = normalize;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
294 whoname = g_strdup(norm(who));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 grp = gc->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 mem = g->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 while (mem) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 b = (struct buddy *)mem->data;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
302 if (!strcmp(norm(b->name), whoname)) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 mem = mem->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 c = connections;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 while (c) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 z = (struct gaim_connection *)c->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 if (z->prpl->normalize)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 norm = z->prpl->normalize;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 norm = normalize;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
320 whoname = g_strdup(norm(who));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 grp = z->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 while (grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 mem = g->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 while (mem) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 b = (struct buddy *)mem->data;
2662
b0c5770156e1 [gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
328 if (!strcmp(norm(b->name), whoname)) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 return b;
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 mem = mem->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 c = c->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 g_free(whoname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
343 void parse_toc_buddy_list(struct gaim_connection *gc, char *config)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 char *c;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 char current[256];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 char *name;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 GList *bud;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 int how_many = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 bud = NULL;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
352
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 if (config != NULL) {
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
354
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 /* skip "CONFIG:" (if it exists) */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 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
357 strtok(config, "\n") :
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
358 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 do {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 if (c == NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 if (*c == 'g') {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 strncpy(current, c + 2, sizeof(current));
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
364 if (!find_group(gc, current)) {
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
365 add_group(gc, current);
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
366 how_many++;
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
367 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 } else if (*c == 'b' && !find_buddy(gc, c + 2)) {
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3048
diff changeset
369 char nm[80], sw[BUDDY_ALIAS_MAXLEN], *tmp = c + 2;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 int i = 0;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
371 while (*tmp != ':' && *tmp && i < sizeof(nm) - 1)
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
372 nm[i++] = *tmp++;
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
373
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 while (*tmp != ':' && *tmp)
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
375 tmp++;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
376
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 if (*tmp == ':')
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 *tmp++ = '\0';
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
379
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 nm[i] = '\0';
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 i = 0;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
382 while (*tmp && i < sizeof(sw) - 1)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 sw[i++] = *tmp++;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 sw[i] = '\0';
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
385 if (!find_buddy(gc, nm)) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 add_buddy(gc, current, nm, sw);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
387 how_many++;
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
388 bud = g_list_append(bud, c + 2);
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
389 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 } else if (*c == 'p') {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 GSList *d = gc->permit;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 char *n;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 name = g_malloc(strlen(c + 2) + 2);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 g_snprintf(name, strlen(c + 2) + 1, "%s", c + 2);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 n = g_strdup(normalize (name));
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 while (d) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 if (!g_strcasecmp(n, normalize (d->data)))
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
398 break;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 d = d->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 g_free(n);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
402 if (!d) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 gc->permit = g_slist_append(gc->permit, name);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
404 how_many++;
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
405 } else
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 g_free(name);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 } else if (*c == 'd') {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 GSList *d = gc->deny;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 char *n;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 name = g_malloc(strlen(c + 2) + 2);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 g_snprintf(name, strlen(c + 2) + 1, "%s", c + 2);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 n = g_strdup(normalize (name));
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 while (d) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 if (!g_strcasecmp(n, normalize (d->data)))
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
415 break;
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
416 d = d->next;
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
417 }
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
418 g_free(n);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
419 if (!d) {
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
420 gc->deny = g_slist_append(gc->deny, name);
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
421 how_many++;
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
422 } else
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
423 g_free(name);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 } else if (!strncmp("toc", c, 3)) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 sscanf(c + strlen(c) - 1, "%d", &gc->permdeny);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 debug_printf("permdeny: %d\n", gc->permdeny);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 if (gc->permdeny == 0)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 gc->permdeny = 1;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 } else if (*c == 'm') {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 sscanf(c + 2, "%d", &gc->permdeny);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 debug_printf("permdeny: %d\n", gc->permdeny);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 if (gc->permdeny == 0)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 gc->permdeny = 1;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 } while ((c = strtok(NULL, "\n")));
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
436
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 if (bud != NULL) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 serv_add_buddies(gc, bud);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 g_list_free(bud);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 serv_set_permit_deny(gc);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 }
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
443
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
444 if (how_many != 0)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 do_export(gc);
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
446
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 void toc_build_config(struct gaim_connection *gc, char *s, int len, gboolean show)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 GSList *grp = gc->groups;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 GSList *plist = gc->permit;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 GSList *dlist = gc->deny;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 int pos = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 if (!gc->permdeny)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 gc->permdeny = 1;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 pos += g_snprintf(&s[pos], len - pos, "m %d\n", gc->permdeny);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 while (len > pos && grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 g = (struct group *)grp->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 mem = g->members;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 while (len > pos && mem) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 b = (struct buddy *)mem->data;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name,
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 (show && strcmp(b->name, b->show)) ? ":" : "",
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 (show && strcmp(b->name, b->show)) ? b->show : "");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 mem = mem->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 while (len > pos && plist) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 plist = plist->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 while (len > pos && dlist) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 dlist = dlist->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
489 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
490 static GString *translate_lst(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 char line[BUF_LEN], *line2;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 char *name;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
496 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 while (fgets(line, BUF_LEN, src_fp)) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
499 line2 = g_strchug(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 if (strstr(line2, "group") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
502 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
505 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
506 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508 if (strstr(line2, "buddy") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
510 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
513 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
514 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
518 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
522 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
523 static GString *translate_blt(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 char line[BUF_LEN];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 char *buddy;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
529 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 while (1) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
535 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 if (strchr(line, '}') != NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 break;
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 if (strchr(line, '{') != NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
540 /* Syntax starting with "<group> {" */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
541
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
542 dest = g_string_append(dest, "g ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
543 buddy = g_strchug(strtok(line, "{"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
544 for (i = 0; i < strlen(buddy); i++)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
545 if (buddy[i] != '\"')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
546 dest = g_string_append_c(dest, buddy[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 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
549 gboolean pounce = FALSE;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
550 char *e;
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
551 g_strchomp(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
552 buddy = g_strchug(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
553 debug_printf("\nbuddy: \"%s\"\n\n", buddy);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
554 dest = g_string_append(dest, "b ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
555 if (strchr(buddy, '{') != NULL) {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
556 /* buddy pounce, etc */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
557 char *pos = strchr(buddy, '{') - 1;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
558 *pos = 0;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
559 pounce = TRUE;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
560 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
561 if ((e = strchr(buddy, '\"')) != NULL) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
562 *e = '\0';
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 buddy++;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
564 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
565 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
566 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
567 if (pounce)
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
568 do
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
569 fgets(line, BUF_LEN, src_fp);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
570 while (!strchr(line, '}'));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 }
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
572 } else {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
573
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
574 /* Syntax "group buddy buddy ..." */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
575 buddy = g_strchug(strtok(line, " \n"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
576 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
578 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
579 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
580 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
582 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
583 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
584 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
586 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
587 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
589 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
591 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
592 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
593 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
595 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
596 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
597 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
599 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
600 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
601 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
603 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
604 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
606 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
608 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
613 return dest;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
614 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
615
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
616 static GString *translate_gnomeicu(FILE *src_fp)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
617 {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
618 char line[BUF_LEN];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
619 GString *dest = g_string_new("m 1\ng Buddies\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
620
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
621 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
622
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
623 while (fgets(line, BUF_LEN, src_fp)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
624 char *eq;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
625 g_strchomp(line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
626 if (line[0] == '\n' || line[0] == '[')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
627 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
628 eq = strchr(line, '=');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
629 if (!eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
630 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
631 *eq = ':';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
632 eq = strchr(eq, ',');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
633 if (eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
634 *eq = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
635 dest = g_string_append(dest, "b ");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
636 dest = g_string_append(dest, line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
637 dest = g_string_append_c(dest, '\n');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
638 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
639
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
640 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 static gchar *get_screenname_filename(const char *name)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 gchar **split;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 gchar *good;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 good = g_strjoinv(NULL, split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 g_strfreev(split);
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 g_strup(good);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 return good;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 /* see if a buddy list cache file for this user exists */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 gboolean bud_list_cache_exists(struct gaim_connection *gc)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 gboolean ret = FALSE;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 char *file;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 struct stat sbuf;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 char *g_screenname;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 g_screenname = get_screenname_filename(gc->username);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 file = gaim_user_dir();
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 if (file != (char *)NULL) {
2590
2dd86a1af92b [gaim-migrate @ 2603]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2586
diff changeset
671 g_snprintf(path, sizeof path, "%s/%s.%d.blist", file, g_screenname, gc->protocol);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 if (!stat(path, &sbuf)) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 debug_printf("%s exists.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674 ret = TRUE;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676 char path2[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 debug_printf("%s does not exist.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 g_snprintf(path2, sizeof path2, "%s/%s.blist", file, g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 if (!stat(path2, &sbuf)) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 debug_printf("%s exists, moving to %s\n", path2, path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 if (rename(path2, path))
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 debug_printf("rename didn't work!\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 ret = TRUE;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685 }
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 g_free(file);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 return ret;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 void do_import(struct gaim_connection *gc, char *filename)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
695 GString *buf = NULL;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
696 char first[64];
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 int len;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 FILE *f;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
700 struct stat st;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 if (filename) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 g_snprintf(path, sizeof(path), "%s", filename);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
705 char *g_screenname = get_screenname_filename(gc->username);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
706 char *file = gaim_user_dir();
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 if (file != (char *)NULL) {
2590
2dd86a1af92b [gaim-migrate @ 2603]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2586
diff changeset
709 sprintf(path, "%s/%s.%d.blist", file, g_screenname, gc->protocol);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 g_free(file);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
718 if (stat(path, &st)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
719 debug_printf("Unable to stat %s.\n", path);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
720 return;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
721 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
722
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 if (!(f = fopen(path, "r"))) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724 debug_printf("Unable to open %s.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 }
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 fgets(first, 64, f);
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 ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
731 fgets(first, 64, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
732
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
734 /* AIM 4 buddy list */
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 debug_printf("aim 4\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
737 buf = translate_blt(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
738 } else if (strstr(first, "group") != NULL) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739 /* AIM 3 buddy list */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 debug_printf("aim 3\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
742 buf = translate_lst(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
743 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
744 /* GnomeICU (hopefully) */
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
745 debug_printf("gnomeicu\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
746 rewind(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
747 buf = translate_gnomeicu(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
748 } else if (first[0] == 'm') {
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
749 /* Gaim buddy list - no translation */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
750 char buf2[BUF_LONG * 2];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
751 buf = g_string_new("");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
753 while (1) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
754 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
755 if (len <= 0)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
756 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
757 buf2[len] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
758 buf = g_string_append(buf, buf2);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
759 if (len != BUF_LONG * 2 - 1)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
760 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
761 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 fclose(f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
766 if (buf) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
767 buf = g_string_prepend(buf, "toc_set_config {");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
768 buf = g_string_append(buf, "}\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
769 parse_toc_buddy_list(gc, buf->str);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
770 g_string_free(buf, TRUE);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
771 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 void do_export(struct gaim_connection *g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 FILE *dir;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 FILE *f;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 char buf[32 * 1024];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 char *file;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 char *g_screenname;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 file = gaim_user_dir();
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 if (!file)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 strcpy(buf, file);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 dir = fopen(buf, "r");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 if (!dir)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 else
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 fclose(dir);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794 g_screenname = get_screenname_filename(g->username);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
795
2590
2dd86a1af92b [gaim-migrate @ 2603]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2586
diff changeset
796 sprintf(path, "%s/%s.%d.blist", file, g_screenname, g->protocol);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797 if ((f = fopen(path, "w"))) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798 debug_printf("writing %s\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799 toc_build_config(g, buf, 8192 - 1, TRUE);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 fprintf(f, "%s\n", buf);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 fclose(f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802 chmod(buf, S_IRUSR | S_IWUSR);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804 debug_printf("unable to write %s\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 g_free(file);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
810
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
811 static gboolean is_blocked(struct buddy *b)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
812 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
813 struct gaim_connection *gc = b->gc;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
814
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
815 if (gc->permdeny == PERMIT_ALL)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
816 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
817
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
818 if (gc->permdeny == PERMIT_NONE) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
819 if (g_strcasecmp(b->name, gc->displayname))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
820 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
821 else
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
822 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
823 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
824
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
825 if (gc->permdeny == PERMIT_SOME) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
826 char *x = g_strdup(normalize(b->name));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
827 GSList *s = gc->permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
828 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
829 if (!g_strcasecmp(x, normalize(s->data)))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
830 break;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
831 s = s->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
832 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
833 g_free(x);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
834 if (s)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
835 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
836 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
837 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
838
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
839 if (gc->permdeny == DENY_SOME) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
840 char *x = g_strdup(normalize(b->name));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
841 GSList *s = gc->deny;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
842 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
843 if (!g_strcasecmp(x, normalize(s->data)))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
844 break;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
845 s = s->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
846 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
847 g_free(x);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
848 if (s)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
849 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
850 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
851 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
852
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
853 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
854 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
855
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
856 void signoff_blocked(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
857 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
858 GSList *g = gc->groups;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
859 while (g) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
860 GSList *m = ((struct group *)g->data)->members;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
861 while (m) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
862 struct buddy *b = m->data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
863 if (is_blocked(b))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
864 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
865 m = m->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
866 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
867 g = g->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
868 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
869 }