[gaim-migrate @ 4156]
[pidgin-git.git] / src / list.c
blobaf925c81c5b352d3ad5727ebeff0bdc3b19e4d5e
1 /*
2 * gaim
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #include <string.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #ifndef _WIN32
29 #include <unistd.h>
30 #else
31 #include <direct.h>
32 #endif
33 #include "gaim.h"
34 #include "prpl.h"
36 #ifdef _WIN32
37 #include "win32dep.h"
38 #endif
40 #define PATHSIZE 1024
42 void remove_buddy(struct gaim_connection *gc, struct group *rem_g, struct buddy *rem_b)
44 GSList *grp;
45 GSList *mem;
47 struct group *delg;
48 struct buddy *delb;
50 /* we assume that gc is not NULL and that the buddy exists somewhere within the
51 * gc's buddy list, therefore we can safely remove it. we need to ensure this
52 * via the UI
55 grp = g_slist_find(gc->groups, rem_g);
56 delg = (struct group *)grp->data;
57 mem = delg->members;
59 mem = g_slist_find(mem, rem_b);
60 delb = (struct buddy *)mem->data;
62 delg->members = g_slist_remove(delg->members, delb);
64 ui_remove_buddy(gc, rem_g, rem_b);
66 g_free(rem_b);
68 /* we don't flush buddy list to cache because in the case of remove_group that would
69 * mean writing to the buddy list file once for each buddy, plus one more time */
72 void remove_group(struct gaim_connection *gc, struct group *rem_g)
74 GSList *grp;
75 GSList *mem;
76 GList *tmp = NULL;
78 struct group *delg;
79 struct buddy *delb;
81 /* we assume that the group actually does exist within the gc, and that the gc is not NULL.
82 * the UI is responsible for this */
84 grp = g_slist_find(gc->groups, rem_g);
85 delg = (struct group *)grp->data;
86 mem = delg->members;
88 while (delg->members) {
89 delb = (struct buddy *)delg->members->data;
90 tmp = g_list_append(tmp, g_strdup(delb->name));
91 remove_buddy(gc, delg, delb); /* this should take care of removing
92 the group_show if necessary */
95 gc->groups = g_slist_remove(gc->groups, delg);
97 serv_remove_buddies(gc, tmp, rem_g->name);
98 while (tmp) {
99 g_free(tmp->data);
100 tmp = g_list_remove(tmp, tmp->data);
103 ui_remove_group(gc, rem_g);
105 g_free(rem_g);
107 /* don't flush buddy list to cache in order to be consistent with remove_buddy,
108 * mostly. remove_group is only called from one place, so we'll let it handle it. */
111 struct buddy *add_buddy(struct gaim_connection *gc, const char *group, const char *buddy, const char *show)
113 struct buddy *b;
114 struct group *g;
115 const char *good;
117 if (!g_slist_find(connections, gc))
118 return NULL;
120 if ((b = find_buddy(gc, buddy)) != NULL)
121 return b;
123 g = find_group(gc, group);
125 if (g == NULL)
126 g = add_group(gc, group);
128 b = (struct buddy *)g_new0(struct buddy, 1);
130 if (!b)
131 return NULL;
133 b->gc = gc;
134 b->present = 0;
136 if (gc->prpl->normalize)
137 good = gc->prpl->normalize(buddy);
138 else
139 good = buddy;
141 g_snprintf(b->name, sizeof(b->name), "%s", good);
142 g_snprintf(b->show, sizeof(b->show), "%s", show ? (show[0] ? show : good) : good);
144 g->members = g_slist_append(g->members, b);
146 b->idle = 0;
147 b->caps = 0;
149 ui_add_buddy(gc, g, b);
151 return b;
154 struct group *add_group(struct gaim_connection *gc, const char *group)
156 struct group *g = find_group(gc, group);
157 if (g)
158 return g;
159 if (!g_slist_find(connections, gc))
160 return NULL;
161 g = (struct group *)g_new0(struct group, 1);
162 if (!g)
163 return NULL;
165 g->gc = gc;
166 strncpy(g->name, group, sizeof(g->name));
167 gc->groups = g_slist_append(gc->groups, g);
169 g->members = NULL;
171 ui_add_group(gc, g);
173 return g;
176 struct group *find_group(struct gaim_connection *gc, const char *group)
178 struct group *g;
179 GSList *grp;
180 GSList *c = connections;
181 struct gaim_connection *z;
182 char *grpname = g_malloc(strlen(group) + 1);
184 strcpy(grpname, normalize (group));
185 if (gc) {
186 if (!g_slist_find(connections, gc))
187 return NULL;
188 grp = gc->groups;
189 while (grp) {
190 g = (struct group *)grp->data;
191 if (!g_strcasecmp(normalize (g->name), grpname)) {
192 g_free(grpname);
193 return g;
195 grp = g_slist_next(grp);
198 g_free(grpname);
199 return NULL;
200 } else {
201 while (c) {
202 z = (struct gaim_connection *)c->data;
203 grp = z->groups;
204 while (grp) {
205 g = (struct group *)grp->data;
206 if (!g_strcasecmp(normalize (g->name), grpname)) {
207 g_free(grpname);
208 return g;
210 grp = g_slist_next(grp);
213 c = c->next;
215 g_free(grpname);
216 return NULL;
220 struct group *find_group_by_buddy(struct gaim_connection *gc, const char *who)
222 struct group *g;
223 struct buddy *b;
224 GSList *grp;
225 GSList *mem;
226 char *whoname;
227 char *(*norm)(const char *);
229 if (gc) {
230 if (gc->prpl->normalize)
231 norm = gc->prpl->normalize;
232 else
233 norm = normalize;
234 whoname = g_strdup(norm(who));
235 grp = gc->groups;
236 while (grp) {
237 g = (struct group *)grp->data;
239 mem = g->members;
240 while (mem) {
241 b = (struct buddy *)mem->data;
242 if (!strcmp(norm(b->name), whoname)) {
243 g_free(whoname);
244 return g;
246 mem = mem->next;
248 grp = g_slist_next(grp);
250 g_free(whoname);
251 return NULL;
252 } else {
253 GSList *c = connections;
254 struct gaim_connection *z;
255 while (c) {
256 z = (struct gaim_connection *)c->data;
257 if (z->prpl->normalize)
258 norm = z->prpl->normalize;
259 else
260 norm = normalize;
261 whoname = g_strdup(norm(who));
262 grp = z->groups;
263 while (grp) {
264 g = (struct group *)grp->data;
266 mem = g->members;
267 while (mem) {
268 b = (struct buddy *)mem->data;
269 if (!strcmp(norm(b->name), whoname)) {
270 g_free(whoname);
271 return g;
273 mem = mem->next;
275 grp = g_slist_next(grp);
277 c = c->next;
278 g_free(whoname);
280 return NULL;
284 struct buddy *find_buddy(struct gaim_connection *gc, const char *who)
286 struct group *g;
287 struct buddy *b;
288 GSList *grp;
289 GSList *c;
290 struct gaim_connection *z;
291 GSList *mem;
292 char *whoname;
293 char *(*norm)(const char *);
295 if (gc) {
296 if (!g_slist_find(connections, gc))
297 return NULL;
298 if (gc->prpl->normalize)
299 norm = gc->prpl->normalize;
300 else
301 norm = normalize;
302 whoname = g_strdup(norm(who));
303 grp = gc->groups;
304 while (grp) {
305 g = (struct group *)grp->data;
307 mem = g->members;
308 while (mem) {
309 b = (struct buddy *)mem->data;
310 if (!strcmp(norm(b->name), whoname)) {
311 g_free(whoname);
312 return b;
314 mem = mem->next;
316 grp = g_slist_next(grp);
318 g_free(whoname);
319 return NULL;
320 } else {
321 c = connections;
322 while (c) {
323 z = (struct gaim_connection *)c->data;
324 if (z->prpl->normalize)
325 norm = z->prpl->normalize;
326 else
327 norm = normalize;
328 whoname = g_strdup(norm(who));
329 grp = z->groups;
330 while (grp) {
331 g = (struct group *)grp->data;
333 mem = g->members;
334 while (mem) {
335 b = (struct buddy *)mem->data;
336 if (!strcmp(norm(b->name), whoname)) {
337 g_free(whoname);
338 return b;
340 mem = mem->next;
342 grp = g_slist_next(grp);
344 c = c->next;
345 g_free(whoname);
347 return NULL;
351 void parse_toc_buddy_list(struct gaim_connection *gc, char *config)
353 char *c;
354 char current[256];
355 char *name;
356 GList *bud;
357 int how_many = 0;
359 bud = NULL;
361 if (config != NULL) {
363 /* skip "CONFIG:" (if it exists) */
364 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ?
365 strtok(config, "\n") :
366 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n");
367 do {
368 if (c == NULL)
369 break;
370 if (*c == 'g') {
371 strncpy(current, c + 2, sizeof(current));
372 if (!find_group(gc, current)) {
373 add_group(gc, current);
374 how_many++;
376 } else if (*c == 'b' && !find_buddy(gc, c + 2)) {
377 char nm[80], sw[BUDDY_ALIAS_MAXLEN], *tmp = c + 2;
378 int i = 0;
379 while (*tmp != ':' && *tmp && i < sizeof(nm) - 1)
380 nm[i++] = *tmp++;
382 while (*tmp != ':' && *tmp)
383 tmp++;
385 if (*tmp == ':')
386 *tmp++ = '\0';
388 nm[i] = '\0';
389 i = 0;
390 while (*tmp && i < sizeof(sw) - 1)
391 sw[i++] = *tmp++;
392 sw[i] = '\0';
393 if (!find_buddy(gc, nm)) {
394 add_buddy(gc, current, nm, sw);
395 how_many++;
396 bud = g_list_append(bud, c + 2);
398 } else if (*c == 'p') {
399 GSList *d = gc->permit;
400 char *n;
401 name = g_malloc(strlen(c + 2) + 2);
402 g_snprintf(name, strlen(c + 2) + 1, "%s", c + 2);
403 n = g_strdup(normalize (name));
404 while (d) {
405 if (!g_strcasecmp(n, normalize (d->data)))
406 break;
407 d = d->next;
409 g_free(n);
410 if (!d) {
411 gc->permit = g_slist_append(gc->permit, name);
412 how_many++;
413 } else
414 g_free(name);
415 } else if (*c == 'd') {
416 GSList *d = gc->deny;
417 char *n;
418 name = g_malloc(strlen(c + 2) + 2);
419 g_snprintf(name, strlen(c + 2) + 1, "%s", c + 2);
420 n = g_strdup(normalize (name));
421 while (d) {
422 if (!g_strcasecmp(n, normalize (d->data)))
423 break;
424 d = d->next;
426 g_free(n);
427 if (!d) {
428 gc->deny = g_slist_append(gc->deny, name);
429 how_many++;
430 } else
431 g_free(name);
432 } else if (!strncmp("toc", c, 3)) {
433 sscanf(c + strlen(c) - 1, "%d", &gc->permdeny);
434 debug_printf("permdeny: %d\n", gc->permdeny);
435 if (gc->permdeny == 0)
436 gc->permdeny = 1;
437 } else if (*c == 'm') {
438 sscanf(c + 2, "%d", &gc->permdeny);
439 debug_printf("permdeny: %d\n", gc->permdeny);
440 if (gc->permdeny == 0)
441 gc->permdeny = 1;
443 } while ((c = strtok(NULL, "\n")));
445 if (bud != NULL) {
446 serv_add_buddies(gc, bud);
447 g_list_free(bud);
449 serv_set_permit_deny(gc);
452 if (how_many != 0)
453 do_export(gc);
457 void toc_build_config(struct gaim_connection *gc, char *s, int len, gboolean show)
459 GSList *grp = gc->groups;
460 GSList *mem;
461 struct group *g;
462 struct buddy *b;
463 GSList *plist = gc->permit;
464 GSList *dlist = gc->deny;
466 int pos = 0;
468 if (!gc->permdeny)
469 gc->permdeny = 1;
471 pos += g_snprintf(&s[pos], len - pos, "m %d\n", gc->permdeny);
472 while (len > pos && grp) {
473 g = (struct group *)grp->data;
474 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
475 mem = g->members;
476 while (len > pos && mem) {
477 b = (struct buddy *)mem->data;
478 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", b->name,
479 (show && strcmp(b->name, b->show)) ? ":" : "",
480 (show && strcmp(b->name, b->show)) ? b->show : "");
481 mem = mem->next;
483 grp = g_slist_next(grp);
486 while (len > pos && plist) {
487 pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data);
488 plist = plist->next;
491 while (len > pos && dlist) {
492 pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data);
493 dlist = dlist->next;
497 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
498 static GString *translate_lst(FILE *src_fp)
500 char line[BUF_LEN], *line2;
501 char *name;
502 int i;
504 GString *dest = g_string_new("m 1\n");
506 while (fgets(line, BUF_LEN, src_fp)) {
507 line2 = g_strchug(line);
508 if (strstr(line2, "group") == line2) {
509 name = strpbrk(line2, " \t\n\r\f") + 1;
510 dest = g_string_append(dest, "g ");
511 for (i = 0; i < strcspn(name, "\n\r"); i++)
512 if (name[i] != '\"')
513 dest = g_string_append_c(dest, name[i]);
514 dest = g_string_append_c(dest, '\n');
516 if (strstr(line2, "buddy") == line2) {
517 name = strpbrk(line2, " \t\n\r\f") + 1;
518 dest = g_string_append(dest, "b ");
519 for (i = 0; i < strcspn(name, "\n\r"); i++)
520 if (name[i] != '\"')
521 dest = g_string_append_c(dest, name[i]);
522 dest = g_string_append_c(dest, '\n');
526 return dest;
530 /* translate an AIM 4 buddylist (*.blt) to Gaim format */
531 static GString *translate_blt(FILE *src_fp)
533 int i;
534 char line[BUF_LEN];
535 char *buddy;
537 GString *dest = g_string_new("m 1\n");
539 while (strstr(fgets(line, BUF_LEN, src_fp), "Buddy") == NULL);
540 while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
542 while (1) {
543 fgets(line, BUF_LEN, src_fp); g_strchomp(line);
544 if (strchr(line, '}') != NULL)
545 break;
547 if (strchr(line, '{') != NULL) {
548 /* Syntax starting with "<group> {" */
550 dest = g_string_append(dest, "g ");
551 buddy = g_strchug(strtok(line, "{"));
552 for (i = 0; i < strlen(buddy); i++)
553 if (buddy[i] != '\"')
554 dest = g_string_append_c(dest, buddy[i]);
555 dest = g_string_append_c(dest, '\n');
556 while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
557 gboolean pounce = FALSE;
558 char *e;
559 g_strchomp(line);
560 buddy = g_strchug(line);
561 debug_printf("\nbuddy: \"%s\"\n\n", buddy);
562 dest = g_string_append(dest, "b ");
563 if (strchr(buddy, '{') != NULL) {
564 /* buddy pounce, etc */
565 char *pos = strchr(buddy, '{') - 1;
566 *pos = 0;
567 pounce = TRUE;
569 if ((e = strchr(buddy, '\"')) != NULL) {
570 *e = '\0';
571 buddy++;
573 dest = g_string_append(dest, buddy);
574 dest = g_string_append_c(dest, '\n');
575 if (pounce)
577 fgets(line, BUF_LEN, src_fp);
578 while (!strchr(line, '}'));
580 } else {
582 /* Syntax "group buddy buddy ..." */
583 buddy = g_strchug(strtok(line, " \n"));
584 dest = g_string_append(dest, "g ");
585 if (strchr(buddy, '\"') != NULL) {
586 dest = g_string_append(dest, &buddy[1]);
587 dest = g_string_append_c(dest, ' ');
588 buddy = g_strchug(strtok(NULL, " \n"));
589 while (strchr(buddy, '\"') == NULL) {
590 dest = g_string_append(dest, buddy);
591 dest = g_string_append_c(dest, ' ');
592 buddy = g_strchug(strtok(NULL, " \n"));
594 buddy[strlen(buddy) - 1] = '\0';
595 dest = g_string_append(dest, buddy);
596 } else {
597 dest = g_string_append(dest, buddy);
599 dest = g_string_append_c(dest, '\n');
600 while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
601 dest = g_string_append(dest, "b ");
602 if (strchr(buddy, '\"') != NULL) {
603 dest = g_string_append(dest, &buddy[1]);
604 dest = g_string_append_c(dest, ' ');
605 buddy = g_strchug(strtok(NULL, " \n"));
606 while (strchr(buddy, '\"') == NULL) {
607 dest = g_string_append(dest, buddy);
608 dest = g_string_append_c(dest, ' ');
609 buddy = g_strchug(strtok(NULL, " \n"));
611 buddy[strlen(buddy) - 1] = '\0';
612 dest = g_string_append(dest, buddy);
613 } else {
614 dest = g_string_append(dest, buddy);
616 dest = g_string_append_c(dest, '\n');
621 return dest;
624 static GString *translate_gnomeicu(FILE *src_fp)
626 char line[BUF_LEN];
627 GString *dest = g_string_new("m 1\ng Buddies\n");
629 while (strstr(fgets(line, BUF_LEN, src_fp), "NewContacts") == NULL);
631 while (fgets(line, BUF_LEN, src_fp)) {
632 char *eq;
633 g_strchomp(line);
634 if (line[0] == '\n' || line[0] == '[')
635 break;
636 eq = strchr(line, '=');
637 if (!eq)
638 break;
639 *eq = ':';
640 eq = strchr(eq, ',');
641 if (eq)
642 *eq = '\0';
643 dest = g_string_append(dest, "b ");
644 dest = g_string_append(dest, line);
645 dest = g_string_append_c(dest, '\n');
648 return dest;
651 static gchar *get_screenname_filename(const char *name)
653 gchar **split;
654 gchar *good;
656 split = g_strsplit(name, G_DIR_SEPARATOR_S, -1);
657 good = g_strjoinv(NULL, split);
658 g_strfreev(split);
660 g_strup(good);
662 return good;
665 /* see if a buddy list cache file for this user exists */
667 gboolean bud_list_cache_exists(struct gaim_connection *gc)
669 gboolean ret = FALSE;
670 char path[PATHSIZE];
671 char *file;
672 struct stat sbuf;
673 char *g_screenname;
675 g_screenname = get_screenname_filename(gc->username);
677 file = gaim_user_dir();
678 if (file != (char *)NULL) {
679 g_snprintf(path, sizeof path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, gc->protocol);
680 if (!stat(path, &sbuf)) {
681 debug_printf("%s exists.\n", path);
682 ret = TRUE;
683 } else {
684 char path2[PATHSIZE];
685 debug_printf("%s does not exist.\n", path);
686 g_snprintf(path2, sizeof path2, "%s" G_DIR_SEPARATOR_S "%s.blist", file, g_screenname);
687 if (!stat(path2, &sbuf)) {
688 debug_printf("%s exists, moving to %s\n", path2, path);
689 if (rename(path2, path))
690 debug_printf("rename didn't work!\n");
691 else
692 ret = TRUE;
696 g_free(g_screenname);
697 return ret;
700 void do_import(struct gaim_connection *gc, const char *filename)
702 GString *buf = NULL;
703 char first[64];
704 char path[PATHSIZE];
705 int len;
706 FILE *f;
707 struct stat st;
709 if (filename) {
710 g_snprintf(path, sizeof(path), "%s", filename);
711 } else {
712 char *g_screenname = get_screenname_filename(gc->username);
713 char *file = gaim_user_dir();
715 if (file != (char *)NULL) {
716 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, gc->protocol);
717 g_free(g_screenname);
718 } else {
719 g_free(g_screenname);
720 return;
724 if (stat(path, &st)) {
725 debug_printf("Unable to stat %s.\n", path);
726 return;
729 if (!(f = fopen(path, "r"))) {
730 debug_printf("Unable to open %s.\n", path);
731 return;
734 fgets(first, 64, f);
736 if ((first[0] == '\n') || (first[0] == '\r' && first[1] == '\n'))
737 fgets(first, 64, f);
739 if (!g_strncasecmp(first, "Config {", strlen("Config {"))) {
740 /* AIM 4 buddy list */
741 debug_printf("aim 4\n");
742 rewind(f);
743 buf = translate_blt(f);
744 } else if (strstr(first, "group") != NULL) {
745 /* AIM 3 buddy list */
746 debug_printf("aim 3\n");
747 rewind(f);
748 buf = translate_lst(f);
749 } else if (!g_strncasecmp(first, "[User]", strlen("[User]"))) {
750 /* GnomeICU (hopefully) */
751 debug_printf("gnomeicu\n");
752 rewind(f);
753 buf = translate_gnomeicu(f);
754 } else if (first[0] == 'm') {
755 /* Gaim buddy list - no translation */
756 char buf2[BUF_LONG * 2];
757 buf = g_string_new("");
758 rewind(f);
759 while (1) {
760 len = fread(buf2, 1, BUF_LONG * 2 - 1, f);
761 if (len <= 0)
762 break;
763 buf2[len] = '\0';
764 buf = g_string_append(buf, buf2);
765 if (len != BUF_LONG * 2 - 1)
766 break;
770 fclose(f);
772 if (buf) {
773 buf = g_string_prepend(buf, "toc_set_config {");
774 buf = g_string_append(buf, "}\n");
775 parse_toc_buddy_list(gc, buf->str);
776 g_string_free(buf, TRUE);
780 void do_export(struct gaim_connection *g)
782 FILE *dir;
783 FILE *f;
784 char buf[32 * 1024];
785 char *file;
786 char path[PATHSIZE];
787 char *g_screenname;
789 file = gaim_user_dir();
790 if (!file)
791 return;
793 strcpy(buf, file);
794 dir = fopen(buf, "r");
795 if (!dir)
796 mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
797 else
798 fclose(dir);
800 g_screenname = get_screenname_filename(g->username);
802 sprintf(path, "%s" G_DIR_SEPARATOR_S "%s.%d.blist", file, g_screenname, g->protocol);
803 if ((f = fopen(path, "w"))) {
804 debug_printf("writing %s\n", path);
805 toc_build_config(g, buf, 8192 - 1, TRUE);
806 fprintf(f, "%s\n", buf);
807 fclose(f);
808 chmod(path, S_IRUSR | S_IWUSR);
809 } else {
810 debug_printf("unable to write %s\n", path);
813 g_free(g_screenname);
816 static gboolean is_blocked(struct buddy *b)
818 struct gaim_connection *gc = b->gc;
820 if (gc->permdeny == PERMIT_ALL)
821 return FALSE;
823 if (gc->permdeny == PERMIT_NONE) {
824 if (g_strcasecmp(b->name, gc->displayname))
825 return TRUE;
826 else
827 return FALSE;
830 if (gc->permdeny == PERMIT_SOME) {
831 char *x = g_strdup(normalize(b->name));
832 GSList *s = gc->permit;
833 while (s) {
834 if (!g_strcasecmp(x, normalize(s->data)))
835 break;
836 s = s->next;
838 g_free(x);
839 if (s)
840 return FALSE;
841 return TRUE;
844 if (gc->permdeny == DENY_SOME) {
845 char *x = g_strdup(normalize(b->name));
846 GSList *s = gc->deny;
847 while (s) {
848 if (!g_strcasecmp(x, normalize(s->data)))
849 break;
850 s = s->next;
852 g_free(x);
853 if (s)
854 return TRUE;
855 return FALSE;
858 return FALSE;
861 void signoff_blocked(struct gaim_connection *gc)
863 GSList *g = gc->groups;
864 while (g) {
865 GSList *m = ((struct group *)g->data)->members;
866 while (m) {
867 struct buddy *b = m->data;
868 if (is_blocked(b))
869 serv_got_update(gc, b->name, 0, 0, 0, 0, 0, 0);
870 m = m->next;
872 g = g->next;