annotate src/list.c @ 4398:a8249a5250b6

[gaim-migrate @ 4667] Made use of the new GAIM_IS_GTK_WINDOW() and GAIM_IS_GTK_CONVERSATION() macros. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 22 Jan 2003 23:46:59 +0000
parents d0cef2cc9660
children 16f7f9451814
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>
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
26 #include <stdlib.h>
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <sys/types.h>
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <sys/stat.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
29 #ifndef _WIN32
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <unistd.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
31 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
32 #include <direct.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3466
diff changeset
33 #endif
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
34 #include <ctype.h>
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include "gaim.h"
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include "prpl.h"
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
3717
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
38 #ifdef _WIN32
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
39 #include "win32dep.h"
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
40 #endif
988485669631 [gaim-migrate @ 3850]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
41
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #define PATHSIZE 1024
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
44 void remove_buddy(struct buddy *rem_b)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
46 if(rem_b->user->gc) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
47 struct group *rem_g = find_group_by_buddy(rem_b);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
49 ui_remove_buddy(rem_b);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
51 rem_g->members = g_slist_remove(rem_g->members, rem_b);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
53 g_hash_table_destroy(rem_b->settings);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
55 g_free(rem_b);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
56 } else {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
57 char *buf = g_strdup_printf(_("%s was not removed from your buddy "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
58 "list, because your account (%s) is not logged in."),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
59 rem_b->name, rem_b->user->username);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
60 do_error_dialog(_("Buddy Not Removed"), buf, GAIM_ERROR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
61 g_free(buf);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
62 }
2382
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
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
65 void remove_group(struct group *rem_g)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
67 GSList *users;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
69 for(users = aim_users; users; users = users->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
70 struct aim_user *user = users->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
71 if(user->gc) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
72 GList *tmp = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
73 GSList *buds = rem_g->members;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
74
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
75 while (buds) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
76 struct buddy *delb = (struct buddy *)buds->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
77 buds = buds->next;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
79 if(delb->user == user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
80 tmp = g_list_append(tmp, g_strdup(delb->name));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
81 remove_buddy(delb); /* this should take care of removing
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
82 the group_show if necessary */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
83 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
84 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
86 if(tmp)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
87 serv_remove_buddies(user->gc, tmp, rem_g->name);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
89 while (tmp) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
90 g_free(tmp->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
91 tmp = g_list_remove(tmp, tmp->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
92 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
93 }
2382
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
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
96 if(rem_g->members) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
97 char *buf = g_strdup_printf(_("%d buddies from group %s were not "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
98 "removed because their accounts were not logged in. These "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
99 "buddies, and the group were not removed.\n"),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
100 g_slist_length(rem_g->members), rem_g->name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
101 do_error_dialog(_("Group Not Removed"), buf, GAIM_ERROR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
102 g_free(buf);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
104 return;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
107 ui_remove_group(rem_g);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
108
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
109 groups = g_slist_remove(groups, rem_g);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 g_free(rem_g);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 /* 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
114 * 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
115 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
117 struct buddy *add_buddy(struct aim_user *user, const char *group, const char *buddy, const char *show)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 struct group *g;
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3398
diff changeset
121 const char *good;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
123 if ((b = find_buddy(user, buddy)) != NULL)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
126 g = find_group(group);
2382
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 (g == NULL)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
129 g = add_group(group);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 b = (struct buddy *)g_new0(struct buddy, 1);
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 if (!b)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 return NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
136 b->user = user;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 b->present = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
139 b->settings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
140
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
141 good = buddy;
2382
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 g_snprintf(b->name, sizeof(b->name), "%s", good);
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
144 if(show && show[0])
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
145 g_snprintf(b->alias, sizeof(b->alias), "%s", show);
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
146 else
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
147 b->alias[0] = '\0';
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 g->members = g_slist_append(g->members, b);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 b->idle = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 b->caps = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
154 ui_add_buddy(user->gc, g, b);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 return b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
159 struct group *add_group(const char *group)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
161 struct group *g = find_group(group);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 if (g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 g = (struct group *)g_new0(struct group, 1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 if (!g)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 return NULL;
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 strncpy(g->name, group, sizeof(g->name));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
169 groups = g_slist_append(groups, g);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 g->members = NULL;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
173 ui_add_group(g);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 return g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
178 struct group *find_group(const char *group)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 GSList *grp;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
182 char *grpname = g_strdup(normalize(group));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
184 grp = groups;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
185 while (grp) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
186 g = (struct group *)grp->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
187 if (!g_strcasecmp(normalize (g->name), grpname)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
188 g_free(grpname);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
189 return g;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
191 grp = g_slist_next(grp);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
193 g_free(grpname);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
194 return NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
197 struct group *find_group_by_buddy(struct buddy *b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
198 {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
199 GSList *grp = groups;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
200
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
201 while(grp) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
202 struct group *g = grp->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
203 if(g_slist_find(g->members, b))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
204 return g;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
205 grp = grp->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
206 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
207 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
208 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
209
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
210 struct buddy *find_buddy(struct aim_user *user, const char *who)
2382
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 *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 struct buddy *b;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 GSList *grp;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 GSList *mem;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
216 char *whoname = NULL;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 char *(*norm)(const char *);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
219 grp = groups;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
220 while (grp) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
221 g = (struct group *)grp->data;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
223 mem = g->members;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
224 while (mem) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
225 b = (struct buddy *)mem->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
226 /*
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
227 norm = (b->user->gc && b->user->gc->prpl->normalize) ? b->user->gc->prpl->normalize : normalize;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
228 */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
229 norm = normalize;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
230 whoname = g_strdup(norm(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
231 if ((b->user == user || !user) && !strcmp(norm(b->name), whoname)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
232 g_free(whoname);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
233 return b;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
235 g_free(whoname);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
236 mem = mem->next;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
238 grp = g_slist_next(grp);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
240 return NULL;
2382
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
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
243 void parse_toc_buddy_list(struct aim_user *user, char *config)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 char *c;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 char current[256];
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
247 GList *bud = NULL;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
248
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 if (config != NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
251
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 /* skip "CONFIG:" (if it exists) */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 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
254 strtok(config, "\n") :
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
255 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 do {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 if (c == NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 if (*c == 'g') {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 strncpy(current, c + 2, sizeof(current));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
261 if (!find_group(current)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
262 add_group(current);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
263 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
264 } else if (*c == 'b' && !find_buddy(user, c + 2)) {
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3048
diff changeset
265 char nm[80], sw[BUDDY_ALIAS_MAXLEN], *tmp = c + 2;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 int i = 0;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
267 while (*tmp != ':' && *tmp && i < sizeof(nm) - 1)
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
268 nm[i++] = *tmp++;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
269
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 while (*tmp != ':' && *tmp)
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 2998
diff changeset
271 tmp++;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
272
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 if (*tmp == ':')
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 *tmp++ = '\0';
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
275
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 nm[i] = '\0';
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 i = 0;
2998
6fe330f1b951 [gaim-migrate @ 3011]
Sean Egan <seanegan@gmail.com>
parents: 2962
diff changeset
278 while (*tmp && i < sizeof(sw) - 1)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 sw[i++] = *tmp++;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 sw[i] = '\0';
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
281 if (!find_buddy(user, nm)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
282 add_buddy(user, current, nm, sw);
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
283 bud = g_list_append(bud, c + 2);
2526
413a81136e3a [gaim-migrate @ 2539]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
284 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 } else if (*c == 'p') {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
286 gaim_privacy_permit_add(user, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 } else if (*c == 'd') {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
288 gaim_privacy_deny_add(user, c + 2);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 } else if (!strncmp("toc", c, 3)) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
290 sscanf(c + strlen(c) - 1, "%d", &user->permdeny);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
291 debug_printf("permdeny: %d\n", user->permdeny);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
292 if (user->permdeny == 0)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
293 user->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 } else if (*c == 'm') {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
295 sscanf(c + 2, "%d", &user->permdeny);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
296 debug_printf("permdeny: %d\n", user->permdeny);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
297 if (user->permdeny == 0)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
298 user->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 } while ((c = strtok(NULL, "\n")));
4351
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
301
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
302 if(user->gc) {
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
303 if(bud)
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
304 serv_add_buddies(user->gc, bud);
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
305 serv_set_permit_deny(user->gc);
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
306 }
bd1db4c2e00b [gaim-migrate @ 4616]
Nathan Walp <nwalp@pidgin.im>
parents: 4349
diff changeset
307 g_list_free(bud);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 }
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
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
311 void toc_build_config(struct aim_user *user, char *s, int len, gboolean show)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
313 GSList *grp = groups;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 GSList *mem;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 struct group *g;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 struct buddy *b;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
317 GSList *plist = user->permit;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
318 GSList *dlist = user->deny;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 int pos = 0;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
322 if (!user->permdeny)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
323 user->permdeny = 1;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
325 pos += g_snprintf(&s[pos], len - pos, "m %d\n", user->permdeny);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 while (len > pos && grp) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 g = (struct group *)grp->data;
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
328 if(gaim_group_on_account(g, user)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
329 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
330 mem = g->members;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
331 while (len > pos && mem) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
332 b = (struct buddy *)mem->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
333 if(b->user == user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
334 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
335 (show && b->alias[0]) ? ":" : "",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
336 (show && b->alias[0]) ? b->alias : "");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
337 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
338 mem = mem->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
339 }
2382
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 grp = g_slist_next(grp);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 while (len > pos && plist) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 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
346 plist = plist->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 while (len > pos && dlist) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 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
351 dlist = dlist->next;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
355 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
356 static GString *translate_lst(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 char line[BUF_LEN], *line2;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 char *name;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
362 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 while (fgets(line, BUF_LEN, src_fp)) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
365 line2 = g_strchug(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 if (strstr(line2, "group") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
368 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
371 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
372 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 if (strstr(line2, "buddy") == line2) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 name = strpbrk(line2, " \t\n\r\f") + 1;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
376 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 for (i = 0; i < strcspn(name, "\n\r"); i++)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 if (name[i] != '\"')
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
379 dest = g_string_append_c(dest, name[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
380 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
384 return dest;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
388 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
389 static GString *translate_blt(FILE *src_fp)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 int i;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 char line[BUF_LEN];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 char *buddy;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
395 GString *dest = g_string_new("m 1\n");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 while (1) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
401 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 if (strchr(line, '}') != NULL)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 break;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 if (strchr(line, '{') != NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
406 /* Syntax starting with "<group> {" */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
407
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
408 dest = g_string_append(dest, "g ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
409 buddy = g_strchug(strtok(line, "{"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
410 for (i = 0; i < strlen(buddy); i++)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
411 if (buddy[i] != '\"')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
412 dest = g_string_append_c(dest, buddy[i]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
413 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
415 gboolean pounce = FALSE;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
416 char *e;
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
417 g_strchomp(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
418 buddy = g_strchug(line);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
419 debug_printf("\nbuddy: \"%s\"\n\n", buddy);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
420 dest = g_string_append(dest, "b ");
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
421 if (strchr(buddy, '{') != NULL) {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
422 /* buddy pounce, etc */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
423 char *pos = strchr(buddy, '{') - 1;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
424 *pos = 0;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
425 pounce = TRUE;
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
426 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
427 if ((e = strchr(buddy, '\"')) != NULL) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
428 *e = '\0';
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 buddy++;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
430 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
431 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
432 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
433 if (pounce)
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
434 do
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
435 fgets(line, BUF_LEN, src_fp);
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
436 while (!strchr(line, '}'));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 }
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
438 } else {
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
439
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
440 /* Syntax "group buddy buddy ..." */
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
441 buddy = g_strchug(strtok(line, " \n"));
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
442 dest = g_string_append(dest, "g ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
444 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
445 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
446 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
448 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
449 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
450 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
452 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
453 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
455 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
457 dest = g_string_append_c(dest, '\n');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
458 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
459 dest = g_string_append(dest, "b ");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 if (strchr(buddy, '\"') != NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
461 dest = g_string_append(dest, &buddy[1]);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
462 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
463 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 while (strchr(buddy, '\"') == NULL) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
465 dest = g_string_append(dest, buddy);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
466 dest = g_string_append_c(dest, ' ');
2548
20418e5702eb [gaim-migrate @ 2561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2536
diff changeset
467 buddy = g_strchug(strtok(NULL, " \n"));
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
469 buddy[strlen(buddy) - 1] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
470 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 } else {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
472 dest = g_string_append(dest, buddy);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 }
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
474 dest = g_string_append_c(dest, '\n');
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 }
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
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
479 return dest;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
480 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
481
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
482 static GString *translate_gnomeicu(FILE *src_fp)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
483 {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
484 char line[BUF_LEN];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
485 GString *dest = g_string_new("m 1\ng Buddies\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
486
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
487 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
488
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
489 while (fgets(line, BUF_LEN, src_fp)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
490 char *eq;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
491 g_strchomp(line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
492 if (line[0] == '\n' || line[0] == '[')
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
493 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
494 eq = strchr(line, '=');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
495 if (!eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
496 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
497 *eq = ':';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
498 eq = strchr(eq, ',');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
499 if (eq)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
500 *eq = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
501 dest = g_string_append(dest, "b ");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
502 dest = g_string_append(dest, line);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
503 dest = g_string_append_c(dest, '\n');
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
504 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
505
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
506 return dest;
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
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 static gchar *get_screenname_filename(const char *name)
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 gchar **split;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 gchar *good;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 good = g_strjoinv(NULL, split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 g_strfreev(split);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 g_strup(good);
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 return good;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
523 static gboolean gaim_blist_read(const char *filename);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
525 void do_import(struct aim_user *user, const char *filename)
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
527 GString *buf = NULL;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
528 char first[64];
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 char path[PATHSIZE];
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 int len;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 FILE *f;
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
532 struct stat st;
2382
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 if (filename) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 g_snprintf(path, sizeof(path), "%s", filename);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 } else {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
537 char *g_screenname = get_screenname_filename(user->username);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
538 char *file = gaim_user_dir();
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
539 int protocol = (user->protocol == PROTO_OSCAR) ? (isalpha(user->username[0]) ? PROTO_TOC : PROTO_ICQ): user->protocol;
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 if (file != (char *)NULL) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
542 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, protocol);
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 } else {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 g_free(g_screenname);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
550 if (stat(path, &st)) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
551 debug_printf("Unable to stat %s.\n", path);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
552 return;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
553 }
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
554
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 if (!(f = fopen(path, "r"))) {
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 debug_printf("Unable to open %s.\n", path);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 return;
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 fgets(first, 64, f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
562 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
563 fgets(first, 64, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
564
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
565 if (!g_strncasecmp(first, "<xml", strlen("<xml"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
566 /* new gaim XML buddy list */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
567 gaim_blist_read(path);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
568 } else if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
569 /* AIM 4 buddy list */
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 debug_printf("aim 4\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
572 buf = translate_blt(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
573 } else if (strstr(first, "group") != NULL) {
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 /* AIM 3 buddy list */
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 debug_printf("aim 3\n");
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
577 buf = translate_lst(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
578 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
579 /* GnomeICU (hopefully) */
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
580 debug_printf("gnomeicu\n");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
581 rewind(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
582 buf = translate_gnomeicu(f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
583 } else if (first[0] == 'm') {
2536
0e0a54e5819a [gaim-migrate @ 2549]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2526
diff changeset
584 /* Gaim buddy list - no translation */
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
585 char buf2[BUF_LONG * 2];
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
586 buf = g_string_new("");
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 rewind(f);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
588 while (1) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
589 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
590 if (len <= 0)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
591 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
592 buf2[len] = '\0';
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
593 buf = g_string_append(buf, buf2);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
594 if (len != BUF_LONG * 2 - 1)
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
595 break;
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
596 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 fclose(f);
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
601 if (buf) {
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
602 buf = g_string_prepend(buf, "toc_set_config {");
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
603 buf = g_string_append(buf, "}\n");
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
604 parse_toc_buddy_list(user, buf->str);
2825
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
605 g_string_free(buf, TRUE);
8cd878c14090 [gaim-migrate @ 2838]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
606 }
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 }
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
609 static gboolean is_blocked(struct buddy *b)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
610 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
611 struct aim_user *user = b->user;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
612
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
613 if (user->permdeny == PERMIT_ALL)
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
614 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
615
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
616 if (user->permdeny == PERMIT_NONE) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
617 if (user->gc && g_strcasecmp(b->name, user->gc->username))
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
618 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
619 else
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
620 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
621 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
622
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
623 if (user->permdeny == PERMIT_SOME) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
624 char *x = g_strdup(normalize(b->name));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
625 GSList *s = user->permit;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
626 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
627 if (!g_strcasecmp(x, normalize(s->data)))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
628 break;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
629 s = s->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
630 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
631 g_free(x);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
632 if (s)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
633 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
634 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
635 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
636
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
637 if (user->permdeny == DENY_SOME) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
638 char *x = g_strdup(normalize(b->name));
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
639 GSList *s = user->deny;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
640 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
641 if (!g_strcasecmp(x, normalize(s->data)))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
642 break;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
643 s = s->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
644 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
645 g_free(x);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
646 if (s)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
647 return TRUE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
648 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
649 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
650
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
651 return FALSE;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
652 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
653
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
654 void signoff_blocked(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
655 {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
656 GSList *g = groups;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
657 while (g) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
658 GSList *m = ((struct group *)g->data)->members;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
659 while (m) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
660 struct buddy *b = m->data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
661 if (is_blocked(b))
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
662 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
663 m = m->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
664 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
665 g = g->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
666 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2590
diff changeset
667 }
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
668
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
669 char *get_buddy_alias_only(struct buddy *b) {
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
670 if(!b)
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
671 return NULL;
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
672 if(b->alias[0])
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
673 return b->alias;
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
674 else if((misc_options & OPT_MISC_USE_SERVER_ALIAS) && b->server_alias[0])
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
675 return b->server_alias;
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
676 return NULL;
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
677 }
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
678
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
679
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
680 char *get_buddy_alias(struct buddy *b) {
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
681 char *ret = get_buddy_alias_only(b);
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
682 if(!ret)
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
683 return b ? b->name : _("Unknown");
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
684 return ret;
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
685 }
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 3717
diff changeset
686
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
687 GSList *gaim_group_get_accounts(struct group *g) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
688 GSList *buds = g->members;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
689 GSList *ret = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
690 while(buds) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
691 struct buddy *b = buds->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
692 if(!g_slist_find(ret, b->user))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
693 ret = g_slist_append(ret, b->user);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
694 buds = buds->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
695 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
696 return ret;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
697 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
698
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
699 gboolean gaim_group_on_account(struct group *g, struct aim_user *user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
700 GSList *buds = g->members;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
701 while(buds) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
702 struct buddy *b = buds->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
703 if((!user && b->user->gc) || b->user == user)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
704 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
705 buds = buds->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
706 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
707 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
708 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
709
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
710
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
711 static char *blist_parser_group_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
712 static char *blist_parser_person_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
713 static char *blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
714 static int blist_parser_account_protocol = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
715 static char *blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
716 static char *blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
717 static char *blist_parser_setting_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
718 static char *blist_parser_setting_value = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
719 static GHashTable *blist_parser_buddy_settings = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
720 static int blist_parser_privacy_mode = 0;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
721 static enum {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
722 BLIST_TAG_GAIM,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
723 BLIST_TAG_BLIST,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
724 BLIST_TAG_GROUP,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
725 BLIST_TAG_PERSON,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
726 BLIST_TAG_BUDDY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
727 BLIST_TAG_NAME,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
728 BLIST_TAG_ALIAS,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
729 BLIST_TAG_SETTING,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
730 BLIST_TAG_PRIVACY,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
731 BLIST_TAG_ACCOUNT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
732 BLIST_TAG_PERMIT,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
733 BLIST_TAG_BLOCK,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
734 BLIST_TAG_IGNORE
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
735 } blist_parser_current_tag;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
736
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
737 static void blist_start_element_handler (GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
738 const gchar *element_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
739 const gchar **attribute_names,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
740 const gchar **attribute_values,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
741 gpointer user_data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
742 GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
743 int i;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
744
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
745 if(!strcmp(element_name, "gaim")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
746 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
747 } else if(!strcmp(element_name, "blist")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
748 blist_parser_current_tag = BLIST_TAG_BLIST;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
749 } else if(!strcmp(element_name, "group")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
750 blist_parser_current_tag = BLIST_TAG_GROUP;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
751 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
752 if(!strcmp(attribute_names[i], "name"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
753 blist_parser_group_name = g_strdup(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
754 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
755 if(blist_parser_group_name) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
756 add_group(blist_parser_group_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
757 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
758 } else if(!strcmp(element_name, "person")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
759 blist_parser_current_tag = BLIST_TAG_PERSON;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
760 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
761 if(!strcmp(attribute_names[i], "name"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
762 blist_parser_person_name = g_strdup(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
763 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
764 } else if(!strcmp(element_name, "buddy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
765 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
766 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
767 if(!strcmp(attribute_names[i], "account"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
768 blist_parser_account_name = g_strdup(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
769 else if(!strcmp(attribute_names[i], "protocol"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
770 blist_parser_account_protocol = atoi(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
771 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
772 } else if(!strcmp(element_name, "name")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
773 blist_parser_current_tag = BLIST_TAG_NAME;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
774 } else if(!strcmp(element_name, "alias")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
775 blist_parser_current_tag = BLIST_TAG_ALIAS;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
776 } else if(!strcmp(element_name, "setting")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
777 blist_parser_current_tag = BLIST_TAG_SETTING;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
778 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
779 if(!strcmp(attribute_names[i], "name"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
780 blist_parser_setting_name = g_strdup(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
781 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
782 } else if(!strcmp(element_name, "privacy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
783 blist_parser_current_tag = BLIST_TAG_PRIVACY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
784 } else if(!strcmp(element_name, "account")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
785 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
786 for(i=0; attribute_names[i]; i++) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
787 if(!strcmp(attribute_names[i], "protocol"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
788 blist_parser_account_protocol = atoi(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
789 else if(!strcmp(attribute_names[i], "mode"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
790 blist_parser_privacy_mode = atoi(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
791 else if(!strcmp(attribute_names[i], "name"))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
792 blist_parser_account_name = g_strdup(attribute_values[i]);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
793 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
794 } else if(!strcmp(element_name, "permit")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
795 blist_parser_current_tag = BLIST_TAG_PERMIT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
796 } else if(!strcmp(element_name, "block")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
797 blist_parser_current_tag = BLIST_TAG_BLOCK;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
798 } else if(!strcmp(element_name, "ignore")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
799 blist_parser_current_tag = BLIST_TAG_IGNORE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
800 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
801 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
802
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
803 static void blist_end_element_handler(GMarkupParseContext *context,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
804 const gchar *element_name, gpointer user_data, GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
805 if(!strcmp(element_name, "gaim")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
806 } else if(!strcmp(element_name, "blist")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
807 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
808 } else if(!strcmp(element_name, "group")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
809 blist_parser_current_tag = BLIST_TAG_BLIST;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
810 } else if(!strcmp(element_name, "person")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
811 blist_parser_current_tag = BLIST_TAG_GROUP;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
812 g_free(blist_parser_person_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
813 blist_parser_person_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
814 } else if(!strcmp(element_name, "buddy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
815 struct aim_user *user = find_user(blist_parser_account_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
816 blist_parser_account_protocol);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
817 if(user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
818 struct buddy *b = add_buddy(user, blist_parser_group_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
819 blist_parser_buddy_name, blist_parser_buddy_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
820 if(blist_parser_buddy_settings) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
821 g_hash_table_destroy(b->settings);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
822 b->settings = blist_parser_buddy_settings;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
823 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
824 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
825 blist_parser_current_tag = BLIST_TAG_PERSON;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
826 g_free(blist_parser_buddy_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
827 blist_parser_buddy_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
828 g_free(blist_parser_buddy_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
829 blist_parser_buddy_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
830 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
831 blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
832 blist_parser_buddy_settings = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
833 } else if(!strcmp(element_name, "name")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
834 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
835 } else if(!strcmp(element_name, "alias")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
836 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
837 } else if(!strcmp(element_name, "setting")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
838 if(!blist_parser_buddy_settings)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
839 blist_parser_buddy_settings = g_hash_table_new_full(g_str_hash,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
840 g_str_equal, g_free, g_free);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
841 if(blist_parser_setting_name && blist_parser_setting_value) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
842 g_hash_table_replace(blist_parser_buddy_settings,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
843 g_strdup(blist_parser_setting_name),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
844 g_strdup(blist_parser_setting_value));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
845 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
846 g_free(blist_parser_setting_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
847 g_free(blist_parser_setting_value);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
848 blist_parser_current_tag = BLIST_TAG_BUDDY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
849 } else if(!strcmp(element_name, "privacy")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
850 blist_parser_current_tag = BLIST_TAG_GAIM;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
851 } else if(!strcmp(element_name, "account")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
852 struct aim_user *user = find_user(blist_parser_account_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
853 blist_parser_account_protocol);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
854 if(user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
855 user->permdeny = blist_parser_privacy_mode;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
856 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
857 blist_parser_current_tag = BLIST_TAG_PRIVACY;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
858 g_free(blist_parser_account_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
859 blist_parser_account_name = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
860 } else if(!strcmp(element_name, "permit")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
861 struct aim_user *user = find_user(blist_parser_account_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
862 blist_parser_account_protocol);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
863 if(user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
864 gaim_privacy_permit_add(user, blist_parser_buddy_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
865 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
866 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
867 } else if(!strcmp(element_name, "block")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
868 struct aim_user *user = find_user(blist_parser_account_name,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
869 blist_parser_account_protocol);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
870 if(user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
871 gaim_privacy_deny_add(user, blist_parser_buddy_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
872 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
873 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
874 } else if(!strcmp(element_name, "ignore")) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
875 /* we'll apparently do something with this later */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
876 blist_parser_current_tag = BLIST_TAG_ACCOUNT;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
877 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
878 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
879
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
880 static void blist_text_handler(GMarkupParseContext *context, const gchar *text,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
881 gsize text_len, gpointer user_data, GError **error) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
882 switch(blist_parser_current_tag) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
883 case BLIST_TAG_NAME:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
884 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
885 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
886 case BLIST_TAG_ALIAS:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
887 blist_parser_buddy_alias = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
888 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
889 case BLIST_TAG_PERMIT:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
890 case BLIST_TAG_BLOCK:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
891 case BLIST_TAG_IGNORE:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
892 blist_parser_buddy_name = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
893 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
894 case BLIST_TAG_SETTING:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
895 blist_parser_setting_value = g_strndup(text, text_len);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
896 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
897 default:
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
898 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
899 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
900 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
901
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
902 static GMarkupParser blist_parser = {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
903 blist_start_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
904 blist_end_element_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
905 blist_text_handler,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
906 NULL,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
907 NULL
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
908 };
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
909
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
910 static gboolean gaim_blist_read(const char *filename) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
911 gchar *contents;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
912 gsize length;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
913 GMarkupParseContext *context;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
914 GError *error = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
915 if(!g_file_get_contents(filename, &contents, &length, &error)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
916 debug_printf("error reading blist: %s\n", error->message);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
917 g_error_free(error);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
918 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
919 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
920
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
921 context = g_markup_parse_context_new(&blist_parser, 0, NULL, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
922
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
923 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
924 g_markup_parse_context_free(context);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
925 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
926 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
927
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
928 if(!g_markup_parse_context_end_parse(context, NULL)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
929 debug_printf("error parsing blist\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
930 g_markup_parse_context_free(context);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
931 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
932 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
933
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
934 g_markup_parse_context_free(context);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
935 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
936 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
937
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
938 void gaim_blist_load() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
939 GSList *accts;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
940 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
941 char *filename;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
942 char *msg;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
943
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
944 if(!user_dir)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
945 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
946
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
947 filename = g_build_filename(user_dir, "blist.xml", NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
948
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
949 if(g_file_test(filename, G_FILE_TEST_EXISTS)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
950 if(!gaim_blist_read(filename)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
951 msg = g_strdup_printf(_("An error was encountered parsing your "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
952 "buddy list. It has not been loaded."));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
953 do_error_dialog(_("Buddy List Error"), msg, GAIM_ERROR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
954 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
955 }
4352
d0cef2cc9660 [gaim-migrate @ 4617]
Nathan Walp <nwalp@pidgin.im>
parents: 4351
diff changeset
956 } else if(g_slist_length(aim_users)) {
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
957 /* rob wants to inform the user that their buddy lists are
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
958 * being converted */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
959 msg = g_strdup_printf(_("Gaim is converting your old buddy lists "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
960 "to a new format, which will now be located at %s"),
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
961 filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
962 do_error_dialog(_("Converting Buddy List"), msg, GAIM_INFO);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
963 g_free(msg);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
964
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
965 /* now, let gtk actually display the dialog before we start anything */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
966 while(gtk_events_pending())
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
967 gtk_main_iteration();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
968
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
969 /* read in the old lists, then save to the new format */
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
970 for(accts = aim_users; accts; accts = accts->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
971 do_import(accts->data, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
972 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
973 gaim_blist_save();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
974 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
975
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
976 g_free(filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
977 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
978
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
979 static void blist_print_buddy_settings(gpointer key, gpointer data,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
980 gpointer user_data) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
981 char *key_val = g_markup_escape_text(key, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
982 char *data_val = g_markup_escape_text(data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
983 FILE *file = user_data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
984 fprintf(file, "\t\t\t\t\t<setting name=\"%s\">%s</setting>\n", key_val,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
985 data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
986 g_free(key_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
987 g_free(data_val);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
988 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
989
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
990 static void gaim_blist_write(FILE *file, struct aim_user *user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
991 GSList *grps, *buds, *users;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
992 fprintf(file, "<?xml version='1.0' encoding='UTF-8' ?>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
993 fprintf(file, "<gaim version=\"1\">\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
994 fprintf(file, "\t<blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
995
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
996 for(grps = groups; grps; grps = grps->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
997 struct group *g = grps->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
998 if(!user || gaim_group_on_account(g, user)) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
999 char *group_name = g_markup_escape_text(g->name, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1000 fprintf(file, "\t\t<group name=\"%s\">\n", group_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1001 for(buds = g->members; buds; buds = buds->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1002 struct buddy *b = buds->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1003 if(!user || b->user == user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1004 char *bud_name = g_markup_escape_text(b->name, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1005 char *bud_alias = NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1006 char *acct_name = g_markup_escape_text(b->user->username, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1007 if(b->alias[0])
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1008 bud_alias= g_markup_escape_text(b->alias, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1009 fprintf(file, "\t\t\t<person name=\"%s\">\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1010 bud_alias ? bud_alias : bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1011 fprintf(file, "\t\t\t\t<buddy protocol=\"%d\" "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1012 "account=\"%s\">\n", b->user->protocol,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1013 acct_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1014 fprintf(file, "\t\t\t\t\t<name>%s</name>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1015 if(bud_alias) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1016 fprintf(file, "\t\t\t\t\t<alias>%s</alias>\n",
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1017 bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1018 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1019 g_hash_table_foreach(b->settings,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1020 blist_print_buddy_settings, file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1021 fprintf(file, "\t\t\t\t</buddy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1022 fprintf(file, "\t\t\t</person>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1023 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1024 g_free(bud_alias);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1025 g_free(acct_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1026 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1027 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1028 fprintf(file, "\t\t</group>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1029 g_free(group_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1030 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1031 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1032
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1033 fprintf(file, "\t</blist>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1034 fprintf(file, "\t<privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1035
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1036 for(users = aim_users; users; users = users->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1037 struct aim_user *usr = users->data;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1038 char *acct_name = g_markup_escape_text(usr->username, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1039 if(!user || usr == user) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1040 fprintf(file, "\t\t<account protocol=\"%d\" name=\"%s\" "
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1041 "mode=\"%d\">\n", usr->protocol, acct_name, usr->permdeny);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1042 for(buds = usr->permit; buds; buds = buds->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1043 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1044 fprintf(file, "\t\t\t<permit>%s</permit>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1045 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1046 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1047 for(buds = usr->deny; buds; buds = buds->next) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1048 char *bud_name = g_markup_escape_text(buds->data, -1);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1049 fprintf(file, "\t\t\t<block>%s</block>\n", bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1050 g_free(bud_name);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1051 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1052 fprintf(file, "\t\t</account>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1053 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1054 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1055
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1056 fprintf(file, "\t</privacy>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1057 fprintf(file, "</gaim>\n");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1058 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1059
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1060 void gaim_blist_save() {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1061 FILE *file;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1062 char *user_dir = gaim_user_dir();
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1063 char *filename;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1064
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1065 if(!user_dir)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1066 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1067
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1068 file = fopen(user_dir, "r");
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1069 if(!file)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1070 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1071 else
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1072 fclose(file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1073
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1074 filename = g_build_filename(user_dir, "blist.xml", NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1075
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1076 if((file = fopen(filename, "w"))) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1077 gaim_blist_write(file, NULL);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1078 fclose(file);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1079 chmod(filename, S_IRUSR | S_IWUSR);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1080 } else {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1081 debug_printf("unable to write %s\n", filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1082 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1083
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1084 g_free(filename);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1085 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1086
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1087 gboolean gaim_privacy_permit_add(struct aim_user *user, const char *who) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1088 GSList *d = user->permit;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1089 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1090 while(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1091 if(!g_strcasecmp(n, normalize(d->data)))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1092 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1093 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1094 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1095 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1096 if(!d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1097 user->permit = g_slist_append(user->permit, g_strdup(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1098 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1099 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1100
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1101 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1102 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1103
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1104 gboolean gaim_privacy_permit_remove(struct aim_user *user, const char *who) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1105 GSList *d = user->permit;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1106 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1107 while(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1108 if(!g_strcasecmp(n, normalize(d->data)))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1109 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1110 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1111 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1112 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1113 if(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1114 user->permit = g_slist_remove(user->permit, d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1115 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1116 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1117 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1118 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1119 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1120
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1121 gboolean gaim_privacy_deny_add(struct aim_user *user, const char *who) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1122 GSList *d = user->deny;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1123 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1124 while(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1125 if(!g_strcasecmp(n, normalize(d->data)))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1126 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1127 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1128 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1129 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1130 if(!d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1131 user->deny = g_slist_append(user->deny, g_strdup(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1132 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1133 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1134
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1135 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1136 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1137
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1138 gboolean gaim_privacy_deny_remove(struct aim_user *user, const char *who) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1139 GSList *d = user->deny;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1140 char *n = g_strdup(normalize(who));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1141 while(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1142 if(!g_strcasecmp(n, normalize(d->data)))
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1143 break;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1144 d = d->next;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1145 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1146 g_free(n);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1147 if(d) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1148 user->deny = g_slist_remove(user->deny, d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1149 g_free(d->data);
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1150 return TRUE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1151 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1152 return FALSE;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1153 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1154
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1155 void gaim_buddy_set_setting(struct buddy *b, const char *key,
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1156 const char *value) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1157 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1158 return;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1159 g_hash_table_replace(b->settings, g_strdup(key), g_strdup(value));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1160 }
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1161
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1162 char *gaim_buddy_get_setting(struct buddy *b, const char *key) {
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1163 if(!b)
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1164 return NULL;
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1165 return g_strdup(g_hash_table_lookup(b->settings, key));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1166 }