comparison src/protocols/oscar/ssi.c @ 3348:dd34e0b40fed

[gaim-migrate @ 3367] Support for server-side synchronization on group rename. (Thanks, Mark Doliner) committer: Tailor Script <tailor@pidgin.im>
author Jim Seymour <jseymour>
date Sun, 07 Jul 2002 14:31:57 +0000
parents f56d084d4046
children 7a3f16a375a5
comparison
equal deleted inserted replaced
3347:d651e743ac64 3348:dd34e0b40fed
92 * @param parentgroup A pointer to the group who's additional data you want to rebuild. 92 * @param parentgroup A pointer to the group who's additional data you want to rebuild.
93 * @return Return 0 if no errors, otherwise return the error number. 93 * @return Return 0 if no errors, otherwise return the error number.
94 */ 94 */
95 static int aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item **list, struct aim_ssi_item *parentgroup) 95 static int aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item **list, struct aim_ssi_item *parentgroup)
96 { 96 {
97 int newlen, i; 97 int newlen;
98 struct aim_ssi_item *cur; 98 struct aim_ssi_item *cur;
99 99
100 /* Free the old additional data */ 100 /* Free the old additional data */
101 if (parentgroup->data) { 101 if (parentgroup->data) {
102 aim_freetlvchain((aim_tlvlist_t **)&parentgroup->data); 102 aim_freetlvchain((aim_tlvlist_t **)&parentgroup->data);
515 free(newitems); 515 free(newitems);
516 return -ENOMEM; 516 return -ENOMEM;
517 } 517 }
518 518
519 /* Send the add item SNAC */ 519 /* Send the add item SNAC */
520 if (i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD)) { 520 if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
521 free(newitems); 521 free(newitems);
522 return -i; 522 return -i;
523 } 523 }
524 524
525 /* Free the array of pointers to each of the new items */ 525 /* Free the array of pointers to each of the new items */
526 free(newitems); 526 free(newitems);
527 527
528 /* Rebuild the additional data in the parent group */ 528 /* Rebuild the additional data in the parent group */
529 if (i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)) 529 if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)))
530 return i; 530 return i;
531 531
532 /* Send the mod item SNAC */ 532 /* Send the mod item SNAC */
533 if (i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD)) 533 if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD)))
534 return i; 534 return i;
535 535
536 /* Begin sending SSI SNACs */ 536 /* Begin sending SSI SNACs */
537 if (!(i = aim_ssi_dispatch(sess, conn))) 537 if (!(i = aim_ssi_dispatch(sess, conn)))
538 return i; 538 return i;
606 free(newitems); 606 free(newitems);
607 return -ENOMEM; 607 return -ENOMEM;
608 } 608 }
609 609
610 /* Send the add item SNAC */ 610 /* Send the add item SNAC */
611 if (i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD)) { 611 if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
612 free(newitems); 612 free(newitems);
613 return -i; 613 return -i;
614 } 614 }
615 615
616 /* Free the array of pointers to each of the new items */ 616 /* Free the array of pointers to each of the new items */
617 free(newitems); 617 free(newitems);
618 618
619 /* Rebuild the additional data in the parent group */ 619 /* Rebuild the additional data in the parent group */
620 if (i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)) 620 if ((i = aim_ssi_itemlist_rebuildgroup(&sess->ssi.items, parentgroup)))
621 return i; 621 return i;
622 622
623 /* Send the mod item SNAC */ 623 /* Send the mod item SNAC */
624 if (i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD)) 624 if ((i = aim_ssi_addmoddel(sess, conn, &parentgroup, 1, AIM_CB_SSI_MOD)))
625 return i; 625 return i;
626 626
627 /* Begin sending SSI SNACs */ 627 /* Begin sending SSI SNACs */
628 if (!(i = aim_ssi_dispatch(sess, conn))) 628 if (!(i = aim_ssi_dispatch(sess, conn)))
629 return i; 629 return i;
662 free(newitems); 662 free(newitems);
663 return -ENOMEM; 663 return -ENOMEM;
664 } 664 }
665 665
666 /* Send the add item SNAC */ 666 /* Send the add item SNAC */
667 if (i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD)) { 667 if ((i = aim_ssi_addmoddel(sess, conn, newitems, num, AIM_CB_SSI_ADD))) {
668 free(newitems); 668 free(newitems);
669 return -i; 669 return -i;
670 } 670 }
671 671
672 /* Free the array of pointers to each of the new items */ 672 /* Free the array of pointers to each of the new items */
712 return -ENOMEM; 712 return -ENOMEM;
713 } 713 }
714 714
715 /* Look up the new parent group */ 715 /* Look up the new parent group */
716 if (!(groups[1] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, newgn, AIM_SSI_TYPE_GROUP))) { 716 if (!(groups[1] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, newgn, AIM_SSI_TYPE_GROUP))) {
717 free(groups); 717 aim_ssi_addgroups(sess, conn, &newgn, 1);
718 return -ENOMEM; 718 if (!(groups[1] = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, newgn, AIM_SSI_TYPE_GROUP))) {
719 free(groups);
720 return -ENOMEM;
721 }
719 } 722 }
720 723
721 /* Send the delete item SNAC */ 724 /* Send the delete item SNAC */
722 aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_DEL); 725 aim_ssi_addmoddel(sess, conn, &buddy, 1, AIM_CB_SSI_DEL);
723 726
751 754
752 return 0; 755 return 0;
753 } 756 }
754 757
755 /** 758 /**
759 * Rename a group. I really like how this is done. It turns me on.
760 *
761 * Did I say that out loud?...
762 *
763 * @param sess The oscar session.
764 * @param conn The bos connection for this session.
765 * @param oldgn The old group name.
766 * @param newgn The new group name.
767 * @return Return 0 if no errors, otherwise return the error number.
768 */
769 faim_export int aim_ssi_rename_group(aim_session_t *sess, aim_conn_t *conn, char *oldgn, char *newgn)
770 {
771 struct aim_ssi_item *group;
772
773 if (!sess || !conn || !oldgn || !newgn)
774 return -EINVAL;
775
776 /* Look up the group */
777 if (!(group = aim_ssi_itemlist_finditem(sess->ssi.items, NULL, oldgn, AIM_SSI_TYPE_GROUP)))
778 return -ENOMEM;
779
780 /* Free the old group name and copy the new one in its place. */
781 if (group->name)
782 free(group->name);
783 if (!(group->name = (char *)malloc((strlen(newgn)+1)*sizeof(char)))) {
784 group->name = NULL;
785 return -ENOMEM;
786 }
787 strcpy(group->name, newgn);
788
789 /* Send the mod item SNAC */
790 aim_ssi_addmoddel(sess, conn, &group, 1, AIM_CB_SSI_MOD);
791
792 /* Begin sending SSI SNACs */
793 aim_ssi_dispatch(sess, conn);
794
795 return 0;
796 }
797
798 /**
756 * Delete an array of screen names from the given group. 799 * Delete an array of screen names from the given group.
757 * 800 *
758 * @param sess The oscar session. 801 * @param sess The oscar session.
759 * @param conn The bos connection for this session. 802 * @param conn The bos connection for this session.
760 * @param gn The name of the group from which you want to delete these names. 803 * @param gn The name of the group from which you want to delete these names.
1010 * @param vismask A bitmask of the class of users to whom you want to be 1053 * @param vismask A bitmask of the class of users to whom you want to be
1011 * visible. See the AIM_FLAG_BLEH #defines in aim.h 1054 * visible. See the AIM_FLAG_BLEH #defines in aim.h
1012 * @return Return 0 if no errors, otherwise return the error number. 1055 * @return Return 0 if no errors, otherwise return the error number.
1013 */ 1056 */
1014 faim_export int aim_ssi_setpermdeny(aim_session_t *sess, aim_conn_t *conn, fu8_t permdeny, fu32_t vismask) { 1057 faim_export int aim_ssi_setpermdeny(aim_session_t *sess, aim_conn_t *conn, fu8_t permdeny, fu32_t vismask) {
1015 struct aim_ssi_item *cur, *tmp; 1058 struct aim_ssi_item *cur;
1016 fu16_t j;
1017 aim_tlv_t *tlv; 1059 aim_tlv_t *tlv;
1018 1060
1019 if (!sess || !conn) 1061 if (!sess || !conn)
1020 return -EINVAL; 1062 return -EINVAL;
1021 1063
1075 * @param presence I think it's a bitmask, but I only know what one of the bits is: 1117 * @param presence I think it's a bitmask, but I only know what one of the bits is:
1076 * 0x00000400 - Allow others to see your idle time 1118 * 0x00000400 - Allow others to see your idle time
1077 * @return Return 0 if no errors, otherwise return the error number. 1119 * @return Return 0 if no errors, otherwise return the error number.
1078 */ 1120 */
1079 faim_export int aim_ssi_setpresence(aim_session_t *sess, aim_conn_t *conn, fu32_t presence) { 1121 faim_export int aim_ssi_setpresence(aim_session_t *sess, aim_conn_t *conn, fu32_t presence) {
1080 struct aim_ssi_item *cur, *tmp; 1122 struct aim_ssi_item *cur;
1081 fu16_t j;
1082 aim_tlv_t *tlv; 1123 aim_tlv_t *tlv;
1083 1124
1084 if (!sess || !conn) 1125 if (!sess || !conn)
1085 return -EINVAL; 1126 return -EINVAL;
1086 1127