+/*
+ * Simple wrapper for aim_send_im_ext()
+ *
+ * You cannot use aim_send_im if you need the HASICON flag. You must
+ * use aim_send_im_ext directly for that.
+ *
+ * aim_send_im also cannot be used if you require UNICODE messages, because
+ * that requires an explicit message length. Use aim_send_im_ext().
+ *
+ */
+faim_export unsigned long aim_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, const char *destsn, unsigned short flags, const char *msg)
+{
+ struct aim_sendimext_args args;
+
+ args.destsn = destsn;
+ args.flags = flags;
+ args.msg = msg;
+ args.msglen = strlen(msg);
+
+ return aim_send_im_ext(sess, conn, &args);
+}
+
+faim_export int aim_send_icon(struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn, const unsigned char *icon, int iconlen, time_t stamp)
+{
+ struct command_tx_struct *np;
+ int i,curbyte = 0;
+ unsigned char ck[8];
+
+ if (!sess || !conn || !sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN))
+ return -1;
+
+ if (conn->type != AIM_CONN_TYPE_BOS)
+ return -1;
+
+ for (i = 0, curbyte = 0; i < 8; i++)
+ curbyte += aimutil_put8(ck+curbyte, (u_char)rand());
+
+ if (!(np = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+8+2+1+strlen(sn)+2+2+2+8+16+2+2+2+2+2+2+2+4+4+4+iconlen+strlen(AIM_ICONIDENT)+2+2)))
+ return -1;
+
+ np->lock = 1;
+
+ curbyte = aim_putsnac(np->data, 0x0004, 0x0006, 0x0000, sess->snac_nextid);
+
+ /*
+ * Cookie
+ */
+ memcpy(np->data+curbyte, ck, 8);
+ curbyte += 8;
+
+ /*
+ * Channel (2)
+ */
+ curbyte += aimutil_put16(np->data+curbyte, 0x0002);
+
+ /*
+ * Dest sn
+ */
+ curbyte += aimutil_put8(np->data+curbyte, strlen(sn));
+ curbyte += aimutil_putstr(np->data+curbyte, sn, strlen(sn));
+
+ /*
+ * TLV t(0005)
+ */
+ curbyte += aimutil_put16(np->data+curbyte, 0x0005);
+ curbyte += aimutil_put16(np->data+curbyte, 2+8+16+6+4+4+iconlen+4+4+4+strlen(AIM_ICONIDENT));
+
+ curbyte += aimutil_put16(np->data+curbyte, 0x0000);
+
+ memcpy(np->data+curbyte, ck, 8);
+ curbyte += 8;
+
+ curbyte += aim_putcap(np->data+curbyte, 16, AIM_CAPS_BUDDYICON);
+
+ /* TLV t(000a) */
+ curbyte += aimutil_put16(np->data+curbyte, 0x000a);
+ curbyte += aimutil_put16(np->data+curbyte, 0x0002);
+ curbyte += aimutil_put16(np->data+curbyte, 0x0001);
+
+ /* TLV t(000f) */
+ curbyte += aimutil_put16(np->data+curbyte, 0x000f);
+ curbyte += aimutil_put16(np->data+curbyte, 0x0000);
+
+ /* TLV t(2711) */
+ curbyte += aimutil_put16(np->data+curbyte, 0x2711);
+ curbyte += aimutil_put16(np->data+curbyte, 4+4+4+iconlen+strlen(AIM_ICONIDENT));
+ curbyte += aimutil_put32(np->data+curbyte, 0x00000000/*0x0000d92c*/);
+ curbyte += aimutil_put32(np->data+curbyte, iconlen);
+ curbyte += aimutil_put32(np->data+curbyte, stamp);
+ memcpy(np->data+curbyte, icon, iconlen);
+ curbyte += iconlen;
+ memcpy(np->data+curbyte, AIM_ICONIDENT, strlen(AIM_ICONIDENT));
+ curbyte += strlen(AIM_ICONIDENT);
+
+ /* TLV t(0003) */
+ curbyte += aimutil_put16(np->data+curbyte, 0x0003);
+ curbyte += aimutil_put16(np->data+curbyte, 0x0000);
+
+ np->commandlen = curbyte;
+ np->lock = 0;
+ aim_tx_enqueue(sess, np);
+
+ return 0;
+}
+