From: Rob F. <rob...@us...> - 2002-04-12 02:40:44
|
Update of /cvsroot/gaim/gaim/src/protocols/oscar In directory usw-pr-cvs1:/tmp/cvs-serv12504/src/protocols/oscar Modified Files: aim.h oscar.c ssi.c Log Message: The king ant ate my picnic Index: aim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/aim.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- aim.h 29 Mar 2002 04:08:41 -0000 1.37 +++ aim.h 12 Apr 2002 02:40:41 -0000 1.38 @@ -1034,6 +1034,7 @@ faim_export int aim_ssi_addmastergroup(aim_session_t *sess, aim_conn_t *conn); faim_export int aim_ssi_addgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num); faim_export int aim_ssi_addpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned int num, fu16_t type); +faim_export int aim_ssi_movebuddy(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *newgn, char *sn); faim_export int aim_ssi_delbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **sn, unsigned int num); faim_export int aim_ssi_delmastergroup(aim_session_t *sess, aim_conn_t *conn); faim_export int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num); Index: oscar.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/oscar.c,v retrieving revision 1.129 retrieving revision 1.130 diff -u -d -r1.129 -r1.130 --- oscar.c 12 Apr 2002 02:32:28 -0000 1.129 +++ oscar.c 12 Apr 2002 02:40:41 -0000 1.130 @@ -2727,6 +2727,15 @@ } } +static void oscar_move_buddy(struct gaim_connection *g, char *name, char *old_group, char *new_group) { + struct oscar_data *odata = (struct oscar_data *)g->proto_data; + if (!odata->icq) + if (odata->sess->ssi.received_data) { + aim_ssi_movebuddy(odata->sess, odata->conn, old_group, new_group, name); + debug_printf("ssi: moved buddy %s from group %s to group %s\n", name, old_group, new_group); + } +} + static void oscar_remove_buddy(struct gaim_connection *g, char *name, char *group) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; if (odata->icq) { @@ -3611,6 +3620,7 @@ ret->change_passwd = oscar_change_passwd; ret->add_buddy = oscar_add_buddy; ret->add_buddies = oscar_add_buddies; + ret->group_buddy = oscar_move_buddy; ret->remove_buddy = oscar_remove_buddy; ret->remove_buddies = oscar_remove_buddies; ret->add_permit = oscar_add_permit; Index: ssi.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/ssi.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ssi.c 29 Mar 2002 04:08:41 -0000 1.7 +++ ssi.c 12 Apr 2002 02:40:41 -0000 1.8 @@ -8,7 +8,6 @@ * This is entirely too complicated. * You don't know the half of it. * - * XXX - Make sure moving buddies from group to group moves the buddy in the server list also * XXX - Test for memory leaks * XXX - Better parsing of rights, and use the rights info to limit adds * @@ -603,6 +602,68 @@ /* Free the array of pointers to each of the new items */ free(newitems); + + /* Begin sending SSI SNACs */ + aim_ssi_dispatch(sess, conn); + + return 0; +} + +faim_export int aim_ssi_movebuddy(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *newgn, char *sn) +{ + struct aim_ssi_item **groups, *buddy, *cur; + fu16_t i; + + if (!sess || !conn || !oldgn || !newgn || !sn) + return -EINVAL; + + /* Look up the buddy */ + if (!(buddy = get_ssi_item(sess->ssi.items, sn, AIM_SSI_TYPE_BUDDY))) + return -ENOMEM; + + /* Allocate an array of pointers to the two groups */ + if (!(groups = (struct aim_ssi_item **)malloc(2*sizeof(struct aim_ssi_item *)))) + return -ENOMEM; + + /* Look up the old parent group */ + if (!(groups[0] = get_ssi_item(sess->ssi.items, oldgn, AIM_SSI_TYPE_GROUP))) { + free(groups); + return -ENOMEM; + } + + /* Look up the new parent group */ + if (!(groups[1] = get_ssi_item(sess->ssi.items, newgn, AIM_SSI_TYPE_GROUP))) { + free(groups); + return -ENOMEM; + } + + /* Send the delete item SNAC */ + aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_DEL); + + /* Put the buddy in the new group */ + buddy->gid = groups[1]->gid; + + /* Assign a new buddy ID#, because the new group might already have a buddy with this ID# */ + buddy->bid = 0; + do { + buddy->bid += 0x0001; + for (cur=sess->ssi.items, i=0; ((cur) && (!i)); cur=cur->next) + if ((cur->bid == buddy->bid) && (cur->gid == buddy->gid) && (cur->type == AIM_SSI_TYPE_BUDDY) && (cur->name) && aim_sncmp(cur->name, buddy->name)) + i=1; + } while (i); + + /* Rebuild the additional data in the two parent groups */ + aim_ssi_rebuildgroup(sess, conn, groups[0]); + aim_ssi_rebuildgroup(sess, conn, groups[1]); + + /* Send the add item SNAC */ + aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_ADD); + + /* Send the mod item SNAC */ + aim_ssi_addmoddel(sess, conn, groups, 2, AIM_CB_SSI_MOD); + + /* Free the temporary array */ + free(groups); /* Begin sending SSI SNACs */ aim_ssi_dispatch(sess, conn); |