From: mid Date: Sat, 8 Sep 2001 04:33:13 +0000 (+0000) Subject: - Fri Sep 7 21:18:51 PDT 2001 X-Git-Tag: rel_0_99_2~16 X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/commitdiff_plain/84e0ca17d85e2aaab4fa36bb0340d9716fc1f106 - Fri Sep 7 21:18:51 PDT 2001 - Make icon field names uniform - Add AIM_IMFLAGS_CUSTOMFEATURES. This allows the client to send/recieve the field in IMs that show client information. - This can be used to identify other open source OSCAR clients, if any one is interested. - Increase the size of args->icbmflags to 32bits - Make sure that extended-only flags are not set for aim_send_im() --- diff --git a/CHANGES b/CHANGES index 10bfd15..8f21d2f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,15 @@ No release numbers ------------------ + - Fri Sep 7 21:18:51 PDT 2001 + - Make icon field names uniform + - Add AIM_IMFLAGS_CUSTOMFEATURES. This allows the client to send/recieve + the field in IMs that show client information. + - This can be used to identify other open source OSCAR clients, if any + one is interested. + - Increase the size of args->icbmflags to 32bits + - Make sure that extended-only flags are not set for aim_send_im() + - Fri Sep 7 19:59:43 PDT 2001 - Fix buddyicons. Yay! (checksums are 32bits all the time. duh.) diff --git a/include/aim.h b/include/aim.h index fc125fa..cb0b8d4 100644 --- a/include/aim.h +++ b/include/aim.h @@ -664,37 +664,55 @@ struct aim_chat_roominfo { unsigned short instance; }; -#define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ -#define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ -#define AIM_IMFLAGS_UNICODE 0x04 -#define AIM_IMFLAGS_ISO_8859_1 0x08 -#define AIM_IMFLAGS_BUDDYREQ 0x10 /* buddy icon requested */ -#define AIM_IMFLAGS_HASICON 0x20 /* already has icon (timestamp included) */ -#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x40 /* damn that Steve Jobs! */ +#define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */ +#define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */ +#define AIM_IMFLAGS_UNICODE 0x0004 +#define AIM_IMFLAGS_ISO_8859_1 0x0008 +#define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */ +#define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */ +#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */ +#define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */ +#define AIM_IMFLAGS_EXTDATA 0x0100 struct aim_sendimext_args { + + /* These are _required_ */ const char *destsn; - unsigned short flags; + fu32_t flags; const char *msg; int msglen; - int iconlen; + + /* Only used if AIM_IMFLAGS_HASICON is set */ + fu32_t iconlen; time_t iconstamp; - unsigned short iconsum; + fu32_t iconsum; + + /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */ + fu8_t *features; + fu8_t featureslen; }; struct aim_incomingim_ch1_args { + + /* Always provided */ char *msg; int msglen; - unsigned long icbmflags; - unsigned short flag1; - unsigned short flag2; - int finlen; - unsigned char fingerprint[10]; + fu32_t icbmflags; + fu16_t flag1; + fu16_t flag2; + + /* Only provided if AIM_IMFLAGS_HASICON is set */ time_t iconstamp; - unsigned long iconlength; - unsigned long iconchecksum; - int extdatalen; - unsigned char *extdata; + fu32_t iconlen; + fu32_t iconsum; + + /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */ + fu8_t *features; + fu8_t featureslen; + + /* Only provided if AIM_IMFLAGS_EXTDATA is set */ + fu8_t extdatalen; + fu8_t *extdata; }; struct aim_incomingim_ch2_args { diff --git a/src/im.c b/src/im.c index c656557..e2070bc 100644 --- a/src/im.c +++ b/src/im.c @@ -143,7 +143,10 @@ faim_export fu32_t aim_iconsum(const fu8_t *buf, int buflen) */ faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct aim_sendimext_args *args) { - int i; + static const fu8_t deffeatures[] = { + 0x01, 0x01, 0x01, 0x02, 0x42, + }; + int i, msgtlvlen; aim_frame_t *fr; aim_snacid_t snacid; @@ -156,6 +159,12 @@ faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct ai if (args->msglen >= MAXMSGLEN) return -E2BIG; + msgtlvlen = 12 + args->msglen; + if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) + msgtlvlen += args->featureslen; + else + msgtlvlen += sizeof(deffeatures); + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, args->msglen+512))) return -ENOMEM; @@ -190,23 +199,22 @@ faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct ai * metaTLV start. */ aimbs_put16(&fr->data, 0x0002); - aimbs_put16(&fr->data, args->msglen + 0x10); + aimbs_put16(&fr->data, msgtlvlen); /* - * Flag data / ICBM Parameters? - * - * I don't know what these are... + * Features * */ aimbs_put8(&fr->data, 0x05); aimbs_put8(&fr->data, 0x01); - /* number of bytes to follow */ - aimbs_put16(&fr->data, 0x0004); - aimbs_put8(&fr->data, 0x01); - aimbs_put8(&fr->data, 0x01); - aimbs_put8(&fr->data, 0x01); - aimbs_put8(&fr->data, 0x02); + if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) { + aimbs_put16(&fr->data, args->featureslen); + aimbs_putraw(&fr->data, args->features, args->featureslen); + } else { + aimbs_put16(&fr->data, sizeof(deffeatures)); + aimbs_putraw(&fr->data, deffeatures, sizeof(deffeatures)); + } aimbs_put16(&fr->data, 0x0101); @@ -295,6 +303,9 @@ faim_export int aim_send_im(aim_session_t *sess, aim_conn_t *conn, const char *d args.msg = msg; args.msglen = strlen(msg); + /* Make these don't get set by accident -- they need aim_send_im_ext */ + args.flags &= ~(AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_HASICON); + return aim_send_im_ext(sess, conn, &args); } @@ -492,8 +503,6 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r endpos = aim_bstream_curpos(bs) + length; if (type == 0x0002) { /* Message Block */ - fu16_t featureslen; - int z; /* * This TLV consists of the following: @@ -506,16 +515,13 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r aimbs_get8(bs); /* 05 */ aimbs_get8(bs); /* 01 */ - featureslen = aimbs_get16(bs); - for (z = 0, args.finlen = 0; z < featureslen; z++) { - fu8_t tmp; - - tmp = aimbs_get8(bs); - if (z < sizeof(args.fingerprint)) { - args.fingerprint[z] = tmp; - args.finlen++; - } - } + + args.featureslen = aimbs_get16(bs); + /* XXX XXX this is all evil! */ + args.features = bs->data + bs->offset; + aim_bstream_advance(bs, args.featureslen); + args.icbmflags |= AIM_IMFLAGS_CUSTOMFEATURES; + aimbs_get8(bs); /* 01 */ aimbs_get8(bs); /* 01 */ @@ -579,8 +585,8 @@ static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *r } else if (type == 0x0008) { /* I-HAVE-A-REALLY-PURTY-ICON Flag */ - args.iconchecksum = aimbs_get32(bs); - args.iconlength = aimbs_get32(bs); + args.iconsum = aimbs_get32(bs); + args.iconlen = aimbs_get32(bs); args.iconstamp = aimbs_get32(bs); args.icbmflags |= AIM_IMFLAGS_HASICON; diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index e339f30..377295c 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -980,6 +980,20 @@ static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, struct aim_ aim_send_im_ext(sess, conn, &args); + } else if (strstr(tmpstr, "havefeat")) { + struct aim_sendimext_args args; + static const char featmsg[] = {"I have nifty features."}; + fu8_t features[] = {0x01, 0x01, 0x01, 0x02, 0x42, 0x43, 0x44, 0x45}; + + args.destsn = userinfo->sn; + args.flags = AIM_IMFLAGS_CUSTOMFEATURES; + args.msg = featmsg; + args.msglen = strlen(featmsg); + args.features = features; + args.featureslen = sizeof(features); + + aim_send_im_ext(sess, conn, &args); + } else if (strstr(tmpstr, "sendicon") && priv->buddyicon) { aim_send_icon(sess, conn, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); @@ -1114,7 +1128,7 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con args = va_arg(ap, struct aim_incomingim_ch1_args *); va_end(ap); - clienttype = aim_fingerprintclient(args->fingerprint, args->finlen); + clienttype = aim_fingerprintclient(args->features, args->featureslen); dvprintf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn); dvprintf("faimtest: icbm: probable client type: %d\n", clienttype);