Mercurial > pidgin
comparison src/protocols/oscar/ssi.c @ 3140:aa18e79365b7
[gaim-migrate @ 3155]
The king ant ate my picnic
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 12 Apr 2002 02:40:41 +0000 |
parents | 51f49dcbd14b |
children | 5e90ecb578c5 |
comparison
equal
deleted
inserted
replaced
3139:b9cd7332adb7 | 3140:aa18e79365b7 |
---|---|
6 * to be stored on the server, so that they can be accessed from any client. | 6 * to be stored on the server, so that they can be accessed from any client. |
7 * | 7 * |
8 * This is entirely too complicated. | 8 * This is entirely too complicated. |
9 * You don't know the half of it. | 9 * You don't know the half of it. |
10 * | 10 * |
11 * XXX - Make sure moving buddies from group to group moves the buddy in the server list also | |
12 * XXX - Test for memory leaks | 11 * XXX - Test for memory leaks |
13 * XXX - Better parsing of rights, and use the rights info to limit adds | 12 * XXX - Better parsing of rights, and use the rights info to limit adds |
14 * | 13 * |
15 */ | 14 */ |
16 | 15 |
601 /* Send the add item SNAC */ | 600 /* Send the add item SNAC */ |
602 aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD); | 601 aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD); |
603 | 602 |
604 /* Free the array of pointers to each of the new items */ | 603 /* Free the array of pointers to each of the new items */ |
605 free(newitems); | 604 free(newitems); |
605 | |
606 /* Begin sending SSI SNACs */ | |
607 aim_ssi_dispatch(sess, conn); | |
608 | |
609 return 0; | |
610 } | |
611 | |
612 faim_export int aim_ssi_movebuddy(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *newgn, char *sn) | |
613 { | |
614 struct aim_ssi_item **groups, *buddy, *cur; | |
615 fu16_t i; | |
616 | |
617 if (!sess || !conn || !oldgn || !newgn || !sn) | |
618 return -EINVAL; | |
619 | |
620 /* Look up the buddy */ | |
621 if (!(buddy = get_ssi_item(sess->ssi.items, sn, AIM_SSI_TYPE_BUDDY))) | |
622 return -ENOMEM; | |
623 | |
624 /* Allocate an array of pointers to the two groups */ | |
625 if (!(groups = (struct aim_ssi_item **)malloc(2*sizeof(struct aim_ssi_item *)))) | |
626 return -ENOMEM; | |
627 | |
628 /* Look up the old parent group */ | |
629 if (!(groups[0] = get_ssi_item(sess->ssi.items, oldgn, AIM_SSI_TYPE_GROUP))) { | |
630 free(groups); | |
631 return -ENOMEM; | |
632 } | |
633 | |
634 /* Look up the new parent group */ | |
635 if (!(groups[1] = get_ssi_item(sess->ssi.items, newgn, AIM_SSI_TYPE_GROUP))) { | |
636 free(groups); | |
637 return -ENOMEM; | |
638 } | |
639 | |
640 /* Send the delete item SNAC */ | |
641 aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_DEL); | |
642 | |
643 /* Put the buddy in the new group */ | |
644 buddy->gid = groups[1]->gid; | |
645 | |
646 /* Assign a new buddy ID#, because the new group might already have a buddy with this ID# */ | |
647 buddy->bid = 0; | |
648 do { | |
649 buddy->bid += 0x0001; | |
650 for (cur=sess->ssi.items, i=0; ((cur) && (!i)); cur=cur->next) | |
651 if ((cur->bid == buddy->bid) && (cur->gid == buddy->gid) && (cur->type == AIM_SSI_TYPE_BUDDY) && (cur->name) && aim_sncmp(cur->name, buddy->name)) | |
652 i=1; | |
653 } while (i); | |
654 | |
655 /* Rebuild the additional data in the two parent groups */ | |
656 aim_ssi_rebuildgroup(sess, conn, groups[0]); | |
657 aim_ssi_rebuildgroup(sess, conn, groups[1]); | |
658 | |
659 /* Send the add item SNAC */ | |
660 aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_ADD); | |
661 | |
662 /* Send the mod item SNAC */ | |
663 aim_ssi_addmoddel(sess, conn, groups, 2, AIM_CB_SSI_MOD); | |
664 | |
665 /* Free the temporary array */ | |
666 free(groups); | |
606 | 667 |
607 /* Begin sending SSI SNACs */ | 668 /* Begin sending SSI SNACs */ |
608 aim_ssi_dispatch(sess, conn); | 669 aim_ssi_dispatch(sess, conn); |
609 | 670 |
610 return 0; | 671 return 0; |