changeset 4826:e6654fab588b

[gaim-migrate @ 5151] Defibrillator?! I don't even know her!! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 18 Mar 2003 22:30:21 +0000
parents 682e91a2fcd3
children a4d3243499bb
files src/protocols/oscar/aim.h src/protocols/oscar/aim_cbtypes.h src/protocols/oscar/ft.c src/protocols/oscar/icon.c src/protocols/oscar/info.c src/protocols/oscar/oscar.c
diffstat 6 files changed, 134 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/aim.h	Tue Mar 18 22:30:21 2003 +0000
@@ -432,6 +432,7 @@
 
 	aim_msgcookie_t *msgcookies;
 	struct aim_icq_info *icq_info;
+	struct aim_oft_info *oft_info;
 
 	void *modlistv;
 } aim_session_t;
@@ -992,11 +993,11 @@
 				/* 256 */
 };
 
-struct aim_filetransfer_priv {
+struct aim_oft_info {
 	char cookie[8];
 	char ip[30];
-	int state;
-	struct aim_fileheader_t fh;
+	struct aim_fileheader_t *fh;
+	struct aim_oft_info *next;
 };
 
 faim_export fu32_t aim_oft_checksum_chunk(const fu8_t *buffer, int bufferlen, fu32_t prevcheck);
--- a/src/protocols/oscar/aim_cbtypes.h	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/aim_cbtypes.h	Tue Mar 18 22:30:21 2003 +0000
@@ -291,7 +291,9 @@
 
 #define AIM_CB_OFT_GETFILE_REQUESTLISTING 0x1108 /* request a listing.txt file from the remote user */
 #define AIM_CB_OFT_GETFILE_SENDLISTING 0x1208	/* we're going to send a listing.txt file */
-#define AIM_CB_OFT_GETFILE_ACKLISTING 0x120b	/* we received the listing.txt file, yay */
+#define AIM_CB_OFT_GETFILE_RECEIVELISTING 0x1209 /* the other dude sent us a listing.txt file */
+#define AIM_CB_OFT_GETFILE_RECEIVEDLISTING 0x120a /* we received a listing.txt file, thanks */ /* I'm just guessting about this one... */
+#define AIM_CB_OFT_GETFILE_ACKLISTING 0x120b	/* other user received the listing.txt file, yay */
 #define AIM_CB_OFT_GETFILE_REQUESTFILE 0x120c	/* request a specific file from the remote user */
 
 #define AIM_CB_OFT_ESTABLISHED 0xFFFF		/* connection to buddy initiated */
--- a/src/protocols/oscar/ft.c	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/ft.c	Tue Mar 18 22:30:21 2003 +0000
@@ -613,6 +613,91 @@
 }
 
 /**
+ * Sometimes you just don't know with these kinds of people.
+ *
+ * @param sess The session.
+ * @param conn The ODC connection of the incoming data.
+ * @param frr The frame allocated for the incoming data.
+ * @param bs It stands for "bologna sandwich."
+ * @return Return 0 if no errors, otherwise return the error number.
+ */
+static int handlehdr_odc(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *frr, aim_bstream_t *bs)
+{
+	aim_frame_t fr;
+	aim_rxcallback_t userfunc;
+	fu32_t payloadlength;
+	fu16_t flags, encoding;
+	char *snptr = NULL;
+
+	fr.conn = conn;
+
+	/* AAA - ugly */
+	aim_bstream_setpos(bs, 20);
+	payloadlength = aimbs_get32(bs);
+
+	aim_bstream_setpos(bs, 24);
+	encoding = aimbs_get16(bs);
+
+	aim_bstream_setpos(bs, 30);
+	flags = aimbs_get16(bs);
+
+	aim_bstream_setpos(bs, 36);
+	/* XXX - create an aimbs_getnullstr function? */
+	snptr = aimbs_getstr(bs, MAXSNLEN);
+
+	faimdprintf(sess, 2, "faim: OFT frame: handlehdr_odc: %04x / %04x / %s\n", payloadlength, flags, snptr);
+
+	if (flags & 0x0002) {
+		int ret = 0;
+
+		if (flags & 0x000c) {
+			if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING)))
+				ret = userfunc(sess, &fr, snptr, 1);
+			return ret;
+		}
+
+		if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING)))
+			ret = userfunc(sess, &fr, snptr, 0);
+
+		return ret;
+
+	} else if (((flags & 0x000f) == 0x0000) && payloadlength) {
+		char *msg, *msg2;
+		int ret = 0;
+		int recvd = 0;
+		int i;
+
+		if (!(msg = calloc(1, payloadlength+1)))
+			return -1;
+		msg2 = msg;
+		
+		while (payloadlength - recvd) {
+			if (payloadlength - recvd >= 1024)
+				i = aim_recv(conn->fd, msg2, 1024);
+			else 
+				i = aim_recv(conn->fd, msg2, payloadlength - recvd);
+			if (i <= 0) {
+				free(msg);
+				return -1;
+			}
+			recvd = recvd + i;
+			msg2 = msg2 + i;
+			if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER)))
+				userfunc(sess, &fr, snptr, (double)recvd / payloadlength);
+		}
+		
+		if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)) )
+			ret = userfunc(sess, &fr, snptr, msg, payloadlength, encoding);
+
+		free(msg);
+
+		return ret;
+	}
+
+	return 0;
+}
+
+/**
  * Creates a listener socket so the other dude can connect to us.
  *
  * You'll want to set up some kind of watcher on this socket.  
@@ -793,6 +878,7 @@
 
 	/* apparently 0 is ASCII, 2 is UCS-2 */
 	/* it is likely that 3 is ISO 8859-1 */
+	/* I think "nlanguage" might be the same thing as "subenc" in im.c */
 	fh->nencode = 0x0000;
 	fh->nlanguage = 0x0000;
 
@@ -821,91 +907,6 @@
 }
 
 /**
- * Sometimes you just don't know with these kinds of people.
- *
- * @param sess The session.
- * @param conn The ODC connection of the incoming data.
- * @param frr The frame allocated for the incoming data.
- * @param bs It stands for "bologna sandwich."
- * @return Return 0 if no errors, otherwise return the error number.
- */
-static int handlehdr_odc(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *frr, aim_bstream_t *bs)
-{
-	aim_frame_t fr;
-	aim_rxcallback_t userfunc;
-	fu32_t payloadlength;
-	fu16_t flags, encoding;
-	char *snptr = NULL;
-
-	fr.conn = conn;
-
-	/* AAA - ugly */
-	aim_bstream_setpos(bs, 20);
-	payloadlength = aimbs_get32(bs);
-
-	aim_bstream_setpos(bs, 24);
-	encoding = aimbs_get16(bs);
-
-	aim_bstream_setpos(bs, 30);
-	flags = aimbs_get16(bs);
-
-	aim_bstream_setpos(bs, 36);
-	/* XXX - create an aimbs_getnullstr function? */
-	snptr = aimbs_getstr(bs, MAXSNLEN);
-
-	faimdprintf(sess, 2, "faim: OFT frame: handlehdr_odc: %04x / %04x / %s\n", payloadlength, flags, snptr);
-
-	if (flags & 0x0002) {
-		int ret = 0;
-
-		if (flags & 0x000c) {
-			if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING)))
-				ret = userfunc(sess, &fr, snptr, 1);
-			return ret;
-		}
-
-		if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING)))
-			ret = userfunc(sess, &fr, snptr, 0);
-
-		return ret;
-
-	} else if (((flags & 0x000f) == 0x0000) && payloadlength) {
-		char *msg, *msg2;
-		int ret = 0;
-		int recvd = 0;
-		int i;
-
-		if (!(msg = calloc(1, payloadlength+1)))
-			return -1;
-		msg2 = msg;
-		
-		while (payloadlength - recvd) {
-			if (payloadlength - recvd >= 1024)
-				i = aim_recv(conn->fd, msg2, 1024);
-			else 
-				i = aim_recv(conn->fd, msg2, payloadlength - recvd);
-			if (i <= 0) {
-				free(msg);
-				return -1;
-			}
-			recvd = recvd + i;
-			msg2 = msg2 + i;
-			if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER)))
-				userfunc(sess, &fr, snptr, (double)recvd / payloadlength);
-		}
-		
-		if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)) )
-			ret = userfunc(sess, &fr, snptr, msg, payloadlength, encoding);
-
-		free(msg);
-
-		return ret;
-	}
-
-	return 0;
-}
-
-/**
  * Handle incoming data on a rendezvous connection.  This is analogous to the 
  * consumesnac function in rxhandlers.c, and I really think this should probably 
  * be in rxhandlers.c as well, but I haven't finished cleaning everything up yet.
@@ -926,28 +927,7 @@
 		else
 			faimdprintf(sess, 0, "faim: ODC directim frame unknown, type is %04x\n", fr->hdr.rend.type);
 
-	} else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_GETFILE) {
-		switch (fr->hdr.rend.type) {
-			case 0x1108: /* getfile listing.txt incoming tx->rx */
-				break;
-			case 0x1209: /* get file listing ack rx->tx */
-				break;
-			case 0x120b: /* get file listing rx confirm */
-				break;
-			case 0x120c: /* getfile request */
-				break;
-			case 0x0101: /* getfile sending data */
-				break;
-			case 0x0202: /* getfile recv data */
-				break;
-			case 0x0204: /* getfile finished */
-				break;
-			default:
-				faimdprintf(sess, 2, "faim: OFT getfile frame uknown, type is %04x\n", fr->hdr.rend.type);
-				break;
-		}
-
-	} else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) {
+	} else {
 		aim_rxcallback_t userfunc;
 		struct aim_fileheader_t *header = aim_oft_getheader(&fr->data);
 		aim_oft_dirconvert_fromstupid(header->name); /* XXX - This should be client-side */
--- a/src/protocols/oscar/icon.c	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/icon.c	Tue Mar 18 22:30:21 2003 +0000
@@ -25,7 +25,7 @@
 	if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !sn || !strlen(sn) || !iconstr || !iconstrlen)
 		return -EINVAL;
 
-	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 1 + iconstrlen)))
+	if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconstrlen)))
 		return -ENOMEM;
 	snacid = aim_cachesnac(sess, 0x0010, 0x0004, 0x0000, NULL, 0);
 	aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid);
@@ -34,10 +34,13 @@
 	aimbs_put8(&fr->data, strlen(sn));
 	aimbs_putraw(&fr->data, sn, strlen(sn));
 
-	/* The number "1" */
+	/* Some numbers.  You like numbers, right? */
+	aimbs_put8(&fr->data, 0x01);
+	aimbs_put16(&fr->data, 0x0001);
 	aimbs_put8(&fr->data, 0x01);
 
 	/* Icon string */
+	aimbs_put8(&fr->data, iconstrlen);
 	aimbs_putraw(&fr->data, iconstr, iconstrlen);
 
 	aim_tx_enqueue(sess, fr);
--- a/src/protocols/oscar/info.c	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/info.c	Tue Mar 18 22:30:21 2003 +0000
@@ -633,16 +633,31 @@
 			 * about the buddy icon that the user has stored on 
 			 * the server.
 			 */
-			outinfo->iconstrlen = length-4;
-			outinfo->iconstrlen -= aim_bstream_advance(bs, aimbs_get16(bs));
-			outinfo->iconstrlen -= aim_bstream_advance(bs, aimbs_get16(bs));
-			if (aim_bstream_empty(bs) >= outinfo->iconstrlen) {
-				char *iconstr = aimbs_getraw(bs, outinfo->iconstrlen);
-				memcpy(outinfo->iconstr, iconstr, outinfo->iconstrlen);
-				free(iconstr);
-			} else {
-				outinfo->iconstrlen = 0;
-				outinfo->iconstr[0] = '\0';
+			int type, subtype, len;
+			char *iconstr;
+/*
+int i;
+debug_printf("iconstr: 0x");
+for (i=0; i<length; i++)
+	debug_printf("%02hhx ", bs->data[bs->offset+i]);
+debug_printf("\n");
+*/
+			while (aim_bstream_curpos(bs) < endpos) {
+				type = aimbs_get16(bs);
+				subtype = aimbs_get8(bs);
+				if ((type != 0x0001) || (subtype != 0x01)) {
+					aim_bstream_advance(bs, aimbs_get8(bs));
+				} else {
+					len = aimbs_get8(bs);
+					if (len < 30) {
+						iconstr = aimbs_getraw(bs, len);
+						memcpy(outinfo->iconstr, iconstr, len);
+						outinfo->iconstrlen = len;
+						free(iconstr);
+					} else {
+						aim_bstream_advance(bs, len);
+					}
+				}
 			}
 
 		} else if (type == 0x001e) {
--- a/src/protocols/oscar/oscar.c	Tue Mar 18 17:51:50 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Tue Mar 18 22:30:21 2003 +0000
@@ -1760,8 +1760,8 @@
 			g_source_remove(od->icontimer);
 		od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc);
 		memcpy(bi->iconstr, info->iconstr, info->iconstrlen);
-	}
-	bi->iconstrlen = info->iconstrlen;
+		bi->iconstrlen = info->iconstrlen;
+	}
 
 	serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon,
 			time_idle, type);
@@ -5504,6 +5504,14 @@
 			pbm->callback = oscar_ask_sendfile;
 			pbm->gc = gc;
 			m = g_list_append(m, pbm);
+
+#if 0
+			pbm = g_new0(struct proto_buddy_menu, 1);
+			pbm->label = _("Get File");
+			pbm->callback = oscar_ask_getfile;
+			pbm->gc = gc;
+			m = g_list_append(m, pbm);
+#endif
 		}
 	}