changeset 16312:555e82810506

merge of '5ee6fd5ddac3a8e8920941dee8be3ae5a615c105' and '7830aa7a90e0189972d55c8344f57cb2cff4de68'
author Mark Doliner <mark@kingant.net>
date Mon, 23 Apr 2007 01:06:06 +0000
parents 9326d4cf5497 (diff) 2195e8f2518d (current diff)
children e06b387d79bd
files
diffstat 2 files changed, 30 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_feedbag.c	Sun Apr 22 23:56:41 2007 +0000
+++ b/libpurple/protocols/oscar/family_feedbag.c	Mon Apr 23 01:06:06 2007 +0000
@@ -132,8 +132,21 @@
 			do {
 				new->gid += 0x0001;
 				for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
-					if ((cur->type == AIM_SSI_TYPE_GROUP) && (cur->gid == new->gid))
+					if ((cur->type == AIM_SSI_TYPE_GROUP) && (cur->gid == new->gid)) {
 						i=1;
+						break;
+					}
+			} while (i);
+		}
+	} else if (new->gid == 0x0000) {
+		if (new->bid == 0xFFFF) {
+			do {
+				new->bid += 0x0001;
+				for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
+					if (((cur->bid == new->bid) && (cur->gid == new->gid)) || (cur->gid == new->bid)) {
+						i=1;
+						break;
+					}
 			} while (i);
 		}
 	} else {
@@ -141,8 +154,10 @@
 			do {
 				new->bid += 0x0001;
 				for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
-					if ((cur->bid == new->bid) && (cur->gid == new->gid))
+					if ((cur->bid == new->bid) && (cur->gid == new->gid)) {
 						i=1;
+						break;
+					}
 			} while (i);
 		}
 	}
@@ -550,8 +565,10 @@
 
 	/* We're out of stuff to do, so tell the AIM servers we're done and exit */
 	if (!od->ssi.pending) {
-		aim_ssi_modend(od);
-		od->ssi.in_transaction = FALSE;
+		if (od->ssi.in_transaction) {
+			aim_ssi_modend(od);
+			od->ssi.in_transaction = FALSE;
+		}
 		return 0;
 	}
 
@@ -764,7 +781,7 @@
 int aim_ssi_addpermit(OscarData *od, const char *name)
 {
 
-	if (!od || !name)
+	if (!od || !name || !od->ssi.received_data)
 		return -EINVAL;
 
 	/* Make sure the master group exists */
@@ -790,7 +807,7 @@
 int aim_ssi_adddeny(OscarData *od, const char *name)
 {
 
-	if (!od || !name)
+	if (!od || !name || !od->ssi.received_data)
 		return -EINVAL;
 
 	/* Make sure the master group exists */
@@ -1040,7 +1057,7 @@
 {
 	struct aim_ssi_item *tmp;
 
-	if (!od)
+	if (!od || !od->ssi.received_data)
 		return -EINVAL;
 
 	/* Find the PDINFO item, or add it if it does not exist */
@@ -1072,12 +1089,12 @@
  * @param iconcsumlen Length of the MD5 checksum given above.  Should be 0x10 bytes.
  * @return Return 0 if no errors, otherwise return the error number.
  */
-int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint16 iconsumlen)
+int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint8 iconsumlen)
 {
 	struct aim_ssi_item *tmp;
 	guint8 *csumdata;
 
-	if (!od || !iconsum || !iconsumlen)
+	if (!od || !iconsum || !iconsumlen || !od->ssi.received_data)
 		return -EINVAL;
 
 	/* Find the ICONINFO item, or add it if it does not exist */
@@ -1091,7 +1108,8 @@
 
 	/* Need to add the 0x00d5 TLV to the TLV chain */
 	csumdata = (guint8 *)malloc((iconsumlen+2)*sizeof(guint8));
-	aimutil_put16(&csumdata[0], iconsumlen);
+	aimutil_put8(&csumdata[0], 0x00);
+	aimutil_put8(&csumdata[1], iconsumlen);
 	memcpy(&csumdata[2], iconsum, iconsumlen);
 	aim_tlvlist_replace_raw(&tmp->data, 0x00d5, (iconsumlen+2) * sizeof(guint8), csumdata);
 	free(csumdata);
@@ -1134,7 +1152,7 @@
 int aim_ssi_setpresence(OscarData *od, guint32 presence) {
 	struct aim_ssi_item *tmp;
 
-	if (!od)
+	if (!od || !od->ssi.received_data)
 		return -EINVAL;
 
 	/* Find the PRESENCEPREFS item, or add it if it does not exist */
--- a/libpurple/protocols/oscar/oscar.h	Sun Apr 22 23:56:41 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Mon Apr 23 01:06:06 2007 +0000
@@ -1214,7 +1214,7 @@
 int aim_ssi_deletelist(OscarData *od);
 int aim_ssi_setpermdeny(OscarData *od, guint8 permdeny, guint32 vismask);
 int aim_ssi_setpresence(OscarData *od, guint32 presence);
-int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint16 iconsumlen);
+int aim_ssi_seticon(OscarData *od, const guint8 *iconsum, guint8 iconsumlen);
 int aim_ssi_delicon(OscarData *od);