Mercurial > pidgin.yaz
comparison src/protocols/gg/gg.c @ 9285:7a8aa87164ae
[gaim-migrate @ 10088]
Ok I'm done. This started out as shx's patch to make add/remove
buddy/buddies take GaimBuddy and GaimGroup's in various places.
I think his diff was like 2000 lines and mine is like 5000. I
tried to clean up blist.c a bit and make it more uniform. There
are some more g_return_if_fail() checks. Removed some code that
was deprecated--it's probably been long enough. Removed some
#include <multi.h>'s. Make blist.xml saving happen on a timer,
like prefs.xml and accounts.xml.
Sorry if this doesn't merge cleanly with whatever you're doing.
People should really test this a lot.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 15 Jun 2004 02:37:27 +0000 |
parents | 7ab20f829190 |
children | 3313eab5033d |
comparison
equal
deleted
inserted
replaced
9284:fe0291162312 | 9285:7a8aa87164ae |
---|---|
1 /* | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | 2 * gaim - Gadu-Gadu Protocol Plugin |
3 * $Id: gg.c 9806 2004-05-23 17:27:45Z thekingant $ | 3 * $Id: gg.c 10088 2004-06-15 02:37:27Z thekingant $ |
4 * | 4 * |
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> | 5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
324 g = gaim_group_new(group); | 324 g = gaim_group_new(group); |
325 gaim_blist_add_group(g, NULL); | 325 gaim_blist_add_group(g, NULL); |
326 } | 326 } |
327 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); | 327 b = gaim_buddy_new(gc->account, name, strlen(show) ? show : NULL); |
328 gaim_blist_add_buddy(b,NULL,g,NULL); | 328 gaim_blist_add_buddy(b,NULL,g,NULL); |
329 gaim_blist_save(); | |
330 | 329 |
331 userlist_size++; | 330 userlist_size++; |
332 userlist = g_renew(uin_t, userlist, userlist_size); | 331 userlist = g_renew(uin_t, userlist, userlist_size); |
333 userlist[userlist_size - 1] = | 332 userlist[userlist_size - 1] = |
334 (uin_t) strtol((char *)name, (char **)NULL, 10); | 333 (uin_t) strtol((char *)name, (char **)NULL, 10); |
344 gg_notify(gd->sess, userlist, userlist_size); | 343 gg_notify(gd->sess, userlist, userlist_size); |
345 g_free(userlist); | 344 g_free(userlist); |
346 } | 345 } |
347 } | 346 } |
348 | 347 |
349 static void agg_save_buddy_list (GaimConnection *gc, char *existlist) | 348 static void agg_save_buddy_list(GaimConnection *gc, char *existlist) |
350 { | 349 { |
350 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
351 GaimBlistNode *gnode, *cnode, *bnode; | 351 GaimBlistNode *gnode, *cnode, *bnode; |
352 char *buddylist = g_strdup(existlist ? existlist : ""); | 352 char *buddylist = g_strdup(existlist ? existlist : ""); |
353 char *ptr; | 353 char *ptr; |
354 struct agg_data *gd = (struct agg_data *)gc->proto_data; | |
355 | 354 |
356 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | 355 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
357 GaimGroup *g = (GaimGroup *)gnode; | 356 GaimGroup *g = (GaimGroup *)gnode; |
358 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 357 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
359 continue; | 358 continue; |
779 g_free(imsg); | 778 g_free(imsg); |
780 } | 779 } |
781 return 1; | 780 return 1; |
782 } | 781 } |
783 | 782 |
784 static void agg_add_buddy(GaimConnection *gc, const char *who, GaimGroup *group) | 783 static void agg_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
785 { | 784 { |
786 struct agg_data *gd = (struct agg_data *)gc->proto_data; | 785 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
787 if (invalid_uin(who)) | 786 if (invalid_uin(buddy->name)) |
788 return; | 787 return; |
789 gg_add_notify(gd->sess, strtol(who, (char **)NULL, 10)); | 788 gg_add_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
790 agg_save_buddy_list(gc, NULL); | 789 agg_save_buddy_list(gc, NULL); |
791 } | 790 } |
792 | 791 |
793 static void agg_rem_buddy(GaimConnection *gc, const char *who, const char *group) | 792 static void agg_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
794 { | 793 { |
795 struct agg_data *gd = (struct agg_data *)gc->proto_data; | 794 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
796 if (invalid_uin(who)) | 795 if (invalid_uin(buddy->name)) |
797 return; | 796 return; |
798 gg_remove_notify(gd->sess, strtol(who, (char **)NULL, 10)); | 797 gg_remove_notify(gd->sess, strtol(buddy->name, (char **)NULL, 10)); |
799 agg_save_buddy_list(gc, NULL); | 798 agg_save_buddy_list(gc, NULL); |
800 } | 799 } |
801 | 800 |
802 static void agg_add_buddies(GaimConnection *gc, GList *whos) | 801 static void agg_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) |
803 { | 802 { |
804 struct agg_data *gd = (struct agg_data *)gc->proto_data; | 803 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
805 uin_t *userlist = NULL; | 804 uin_t *userlist = NULL; |
806 int userlist_size = 0; | 805 int userlist_size = 0; |
807 | 806 |
808 while (whos) { | 807 while (buddies) { |
809 if (!invalid_uin(whos->data)) { | 808 GaimBuddy *buddy = buddies->data; |
809 if (!invalid_uin(buddy->name)) { | |
810 userlist_size++; | 810 userlist_size++; |
811 userlist = g_renew(uin_t, userlist, userlist_size); | 811 userlist = g_renew(uin_t, userlist, userlist_size); |
812 userlist[userlist_size - 1] = | 812 userlist[userlist_size - 1] = |
813 (uin_t) strtol((char *)whos->data, (char **)NULL, 10); | 813 (uin_t) strtol(buddy->name, (char **)NULL, 10); |
814 } | 814 } |
815 whos = g_list_next(whos); | 815 buddies = g_list_next(buddies); |
816 } | 816 } |
817 | 817 |
818 if (userlist) { | 818 if (userlist) { |
819 gg_notify(gd->sess, userlist, userlist_size); | 819 gg_notify(gd->sess, userlist, userlist_size); |
820 g_free(userlist); | 820 g_free(userlist); |
842 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); | 842 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); |
843 | 843 |
844 j = 0; | 844 j = 0; |
845 | 845 |
846 /* Parse array */ | 846 /* Parse array */ |
847 /* XXX - Make this use a GString */ | |
847 for (i = 0; webdata_tbl[i] != NULL; i++) { | 848 for (i = 0; webdata_tbl[i] != NULL; i++) { |
848 gchar *p, *oldibuf; | 849 gchar *p, *oldibuf; |
849 static gchar *ibuf; | 850 static gchar *ibuf; |
850 | 851 |
851 g_strdelimit(webdata_tbl[i], "\t\n", ' '); | 852 g_strdelimit(webdata_tbl[i], "\t\n", ' '); |
1517 show, show, show, show, "", gname, name, "", ""); | 1518 show, show, show, show, "", gname, name, "", ""); |
1518 agg_save_buddy_list(gc, newdata); | 1519 agg_save_buddy_list(gc, newdata); |
1519 g_free(newdata); | 1520 g_free(newdata); |
1520 } | 1521 } |
1521 | 1522 |
1522 static void agg_rename_group (GaimConnection *gc, const char *old_group, | 1523 static void agg_rename_group (GaimConnection *gc, const char *old_name, |
1523 const char *new_group, GList *members) | 1524 GaimGroup *group, GList *moved_buddies) |
1524 { | 1525 { |
1525 agg_save_buddy_list(gc, NULL); | 1526 agg_save_buddy_list(gc, NULL); |
1526 } | 1527 } |
1527 | 1528 |
1528 static GaimPlugin *my_protocol = NULL; | 1529 static GaimPlugin *my_protocol = NULL; |