changeset 4282:aa20cc16dc08

[gaim-migrate @ 4533] Let's see here... I kinda rewrote normalize. I think it should be more efficient this way, because memory isn't allocated. I dunno. That function is called quite a bit, though. The ngettext thing is cool, but having parameters in the right order is cooler. :-) I made is so aliases on the server list overwrite the local aliases. They would only be the same if you sign on elsewhere and change them, so this should be ok. I renamed some variables in ssi.c. Time Warner is still a horrible, horrible company. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 10 Jan 2003 23:08:56 +0000
parents d956ac6157cd
children cbcbfdb8a485
files src/protocols/oscar/oscar.c src/protocols/oscar/ssi.c src/util.c
diffstat 3 files changed, 36 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Fri Jan 10 22:45:53 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Fri Jan 10 23:08:56 2003 +0000
@@ -2350,8 +2350,8 @@
 				   "You missed %hu message from %s because it was invalid.",
 				   "You missed %hu messages from %s because they were invalid.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 		case 1:
 			/* Message too large */
@@ -2361,8 +2361,8 @@
 				   "You missed %hu message from %s because it was too large.",
 				   "You missed %hu messages from %s because they were too large.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 		case 2:
 			/* Rate exceeded */
@@ -2372,8 +2372,8 @@
 				   "You missed %hu message from %s because the rate limit has been exceeded.",
 				   "You missed %hu messages from %s because the rate limit has been exceeded.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 		case 3:
 			/* Evil Sender */
@@ -2383,8 +2383,8 @@
 				   "You missed %hu message from %s because he/she was too evil.",
 				   "You missed %hu messages from %s because he/she was too evil.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 		case 4:
 			/* Evil Receiver */
@@ -2394,8 +2394,8 @@
 				   "You missed %hu message from %s because you are too evil.",
 				   "You missed %hu messages from %s because you are too evil.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 		default:
 			g_snprintf(buf,
@@ -2404,8 +2404,8 @@
 				   "You missed %hu message from %s for an unknown reason.",
 				   "You missed %hu messages from %s for an unknown reason.",
 				   nummissed),
-				   userinfo->sn,
-				   nummissed);
+				   nummissed,
+				   userinfo->sn);
 			break;
 	}
 	do_error_dialog(buf, NULL, GAIM_ERROR);
@@ -4125,22 +4125,24 @@
 			case 0x0000: { /* Buddy */
 				if (curitem->name) {
 					char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, curitem->name);
-					if (!find_buddy(gc, curitem->name)) {
-						char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);
+					char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);
+					struct buddy *buddy = find_buddy(gc, curitem->name);
+					if (buddy) {
+						if (alias)
+							strcpy(buddy->alias, alias);
+					} else {
 						debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname);
 						add_buddy(gc, (gname ? gname : "orphans"), curitem->name, alias);
-						free(alias);
 						tmp++;
 					}
 					if (curitem->name && gname && aim_ssi_waitingforauth(sess->ssi.local, gname, curitem->name))
 						gaim_auth_sendrequest(gc, curitem->name);
-
+					free(alias);
 				}
 			} break;
 
 			case 0x0001: { /* Group */
-				if (curitem->name && !find_group(gc, curitem->name))
-					add_group(gc, curitem->name);
+				/* Shouldn't add empty groups */
 			} break;
 
 			case 0x0002: { /* Permit buddy */
--- a/src/protocols/oscar/ssi.c	Fri Jan 10 22:45:53 2003 +0000
+++ b/src/protocols/oscar/ssi.c	Fri Jan 10 23:08:56 2003 +0000
@@ -418,7 +418,7 @@
 		if (tlvlist) {
 			aim_tlv_t *tlv = aim_gettlv(tlvlist, 0x0131, 1);
 			if (tlv && tlv->length) {
-				char *alias = (char *)(char *)malloc((tlv->length+1)*sizeof(char));
+				char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
 				strncpy(alias, tlv->value, tlv->length);
 				alias[tlv->length] = 0;
 				return alias;
@@ -1097,7 +1097,7 @@
  * Note that the client should never increment the revision, only the server.
  * 
  */
-faim_export int aim_ssi_reqdata(aim_session_t *sess, aim_conn_t *conn, time_t localstamp, fu16_t localrev)
+faim_export int aim_ssi_reqdata(aim_session_t *sess, aim_conn_t *conn, time_t timestamp, fu16_t numitems)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
@@ -1111,8 +1111,8 @@
 	snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_REQLIST, 0x0000, NULL, 0);
 
 	aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_REQLIST, 0x0000, snacid);
-	aimbs_put32(&fr->data, localstamp);
-	aimbs_put16(&fr->data, localrev);
+	aimbs_put32(&fr->data, timestamp);
+	aimbs_put16(&fr->data, numitems);
 
 	aim_tx_enqueue(sess, fr);
 
@@ -1130,8 +1130,7 @@
 	int ret = 0;
 	aim_rxcallback_t userfunc;
 	fu8_t fmtver; /* guess */
-	fu16_t numitems, namelen, gid, bid, type;
-	fu32_t timestamp;
+	fu16_t namelen, gid, bid, type;
 	char *name;
 	aim_tlvlist_t *data;
 
@@ -1140,8 +1139,7 @@
 	}
 
 	fmtver = aimbs_get8(bs); /* Version of ssi data.  Should be 0x00 */
-	numitems = aimbs_get16(bs); /* # of items in this SSI SNAC */
-	sess->ssi.numitems += numitems;
+	sess->ssi.numitems += aimbs_get16(bs); /* # of items in this SSI SNAC */
 
 	/* Read in the list */
 	while (aim_bstream_empty(bs) > 4) { /* last four bytes are timestamp */
@@ -1159,8 +1157,7 @@
 	}
 
 	/* Read in the timestamp */
-	timestamp = aimbs_get32(bs);
-	sess->ssi.timestamp = timestamp;
+	sess->ssi.timestamp = aimbs_get32(bs);
 
 	if (!(snac->flags & 0x0001)) {
 		/* Make a copy of the list */
--- a/src/util.c	Fri Jan 10 22:45:53 2003 +0000
+++ b/src/util.c	Fri Jan 10 23:08:56 2003 +0000
@@ -466,25 +466,19 @@
 char *normalize(const char *s)
 {
 	static char buf[BUF_LEN];
-	char *t, *u;
-	int x = 0;
+	int i, j;
 
 	g_return_val_if_fail((s != NULL), NULL);
 
-	u = t = g_strdup(s);
-
-	strcpy(t, s);
-	g_strdown(t);
+	strncpy(buf, s, BUF_LEN);
+	for (i=0, j=0; buf[j]; i++, j++) {
+		while (buf[j] == ' ')
+			j++;
+		buf[i] = buf[j];
+	}
+	buf[i] = '\0';
+	g_strdown(buf);
 
-	while (*t && (x < BUF_LEN - 1)) {
-		if (*t != ' ') {
-			buf[x] = *t;
-			x++;
-		}
-		t++;
-	}
-	buf[x] = '\0';
-	g_free(u);
 	return buf;
 }