+ if (aim_gettlv(list2, 0x000b, 1))
+ errorcode = aim_gettlv16(list2, 0x000b, 1);
+
+ /* XXX this should make it up to the client, you know.. */
+ if (errorcode)
+ faimdprintf(sess, 0, "transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sn, ft->ip, ft->fh.name, errorcode);
+ } /* args.status != 0x0002 */
+
+ } else {
+ faimdprintf(sess, 0, "no data attached to file transfer\n");
+ } /* !cook->data */
+
+ } else if (cook->type == AIM_CAPS_VOICE) {
+
+ faimdprintf(sess, 0, "voice request cancelled\n");
+
+ } else {
+
+ faimdprintf(sess, 0, "unknown cookie cache type %d\n", cook->type);
+ }
+
+ aim_freetlvchain(&list2);
+
+ return 1;
+ }
+
+ /*
+ * The rest of the handling depends on what type it is.
+ */
+ if (args.reqclass & AIM_CAPS_BUDDYICON) {
+ struct aim_tlv_t *miscinfo;
+ int curpos = 0;
+
+ miscinfo = aim_gettlv(list2, 0x2711, 1);
+
+ args.info.icon.checksum = aimutil_get32(miscinfo->value+curpos);
+ curpos += 4;
+ args.info.icon.length = aimutil_get32(miscinfo->value+curpos);
+ curpos += 4;
+ args.info.icon.timestamp = aimutil_get32(miscinfo->value+curpos);
+ curpos += 4;
+ args.info.icon.icon = malloc(args.info.icon.length);
+ memcpy(args.info.icon.icon, miscinfo->value+curpos, args.info.icon.length);
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);
+
+ free(args.info.icon.icon);
+
+ } else if (args.reqclass & AIM_CAPS_VOICE) {
+ struct aim_msgcookie_t *cachedcook;
+
+ faimdprintf(sess, 1, "rend: voice!\n");
+
+ if(!(cachedcook = (struct aim_msgcookie_t*)calloc(1, sizeof(struct aim_msgcookie_t)))) {
+ aim_freetlvchain(&list2);
+ return 0;
+ }
+
+ memcpy(cachedcook->cookie, cookie, 8);
+ cachedcook->type = AIM_COOKIETYPE_OFTVOICE;
+ cachedcook->data = NULL;
+
+ if (aim_cachecookie(sess, cachedcook) == -1)
+ faimdprintf(sess, 0, "ERROR caching message cookie\n");
+
+ /* XXX: implement all this */
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);
+
+ } else if (args.reqclass & AIM_CAPS_IMIMAGE) {
+ char ip[30];
+ struct aim_directim_priv *priv;
+
+ memset(ip, 0, sizeof(ip));
+
+ if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) {
+ struct aim_tlv_t *iptlv, *porttlv;
+
+ iptlv = aim_gettlv(list2, 0x0003, 1);
+ porttlv = aim_gettlv(list2, 0x0005, 1);
+
+ snprintf(ip, 30, "%d.%d.%d.%d:%d",
+ aimutil_get8(iptlv->value+0),
+ aimutil_get8(iptlv->value+1),
+ aimutil_get8(iptlv->value+2),
+ aimutil_get8(iptlv->value+3),
+ 4443 /*aimutil_get16(porttlv->value)*/);
+ }
+
+ faimdprintf(sess, 1, "rend: directIM request from %s (%s)\n",
+ userinfo->sn, ip);
+
+ /*
+ * XXX: there are a couple of different request packets for
+ * different things
+ */
+
+ args.info.directim = priv = (struct aim_directim_priv *)calloc(1, sizeof(struct aim_directim_priv)); /* XXX error */
+ memcpy(priv->ip, ip, sizeof(priv->ip));
+ memcpy(priv->sn, userinfo->sn, sizeof(priv->sn));
+ memcpy(priv->cookie, cookie, sizeof(priv->cookie));
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);
+
+ } else if (args.reqclass & AIM_CAPS_CHAT) {
+ struct aim_tlv_t *miscinfo;
+
+ miscinfo = aim_gettlv(list2, 0x2711, 1);
+ aim_chat_readroominfo(miscinfo->value, &args.info.chat.roominfo);
+
+ if (aim_gettlv(list2, 0x000c, 1))
+ args.info.chat.msg = aim_gettlv_str(list2, 0x000c, 1);
+
+ if (aim_gettlv(list2, 0x000d, 1))
+ args.info.chat.encoding = aim_gettlv_str(list2, 0x000d, 1);
+
+ if (aim_gettlv(list2, 0x000e, 1))
+ args.info.chat.lang = aim_gettlv_str(list2, 0x000e, 1);
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);
+
+ free(args.info.chat.roominfo.name);
+ free(args.info.chat.msg);
+ free(args.info.chat.encoding);
+ free(args.info.chat.lang);
+
+ } else if (args.reqclass & AIM_CAPS_GETFILE) {
+ char ip[30];
+ struct aim_msgcookie_t *cachedcook;
+ struct aim_tlv_t *miscinfo;
+ struct aim_tlv_t *iptlv, *porttlv;
+
+ memset(ip, 0, 30);
+
+ if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t)))) {
+ aim_freetlvchain(&list2);
+ return 0;
+ }
+
+ if (!(miscinfo = aim_gettlv(list2, 0x2711, 1)) ||
+ !(iptlv = aim_gettlv(list2, 0x0003, 1)) ||
+ !(porttlv = aim_gettlv(list2, 0x0005, 1))) {
+
+ faimdprintf(sess, 0, "rend: badly damaged file get request from %s...\n", userinfo->sn);
+ aim_cookie_free(sess, cachedcook);
+ aim_freetlvchain(&list2);
+
+ return 0;
+ }
+
+ snprintf(ip, 30, "%d.%d.%d.%d:%d",
+ aimutil_get8(iptlv->value+0),
+ aimutil_get8(iptlv->value+1),
+ aimutil_get8(iptlv->value+2),
+ aimutil_get8(iptlv->value+3),
+ aimutil_get16(porttlv->value));
+
+ faimdprintf(sess, 0, "rend: file get request from %s (%s)\n", userinfo->sn, ip);
+
+ args.info.getfile.ip = ip;
+ args.info.getfile.cookie = cookie;
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);
+
+ } else if (args.reqclass & AIM_CAPS_SENDFILE) {
+#if 0
+ char ip[30];
+ struct aim_msgcookie_t *cachedcook;
+ struct aim_tlv_t *miscinfo;
+ struct aim_tlv_t *iptlv, *porttlv;
+
+ memset(ip, 0, 30);
+
+ if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t)))) {
+ aim_freetlvchain(&list2);
+ return 0;
+ }
+
+ if (!(miscinfo = aim_gettlv(list2, 0x2711, 1)) ||
+ !(iptlv = aim_gettlv(list2, 0x0003, 1)) ||
+ !(porttlv = aim_gettlv(list2, 0x0005, 1))) {
+
+ faimdprintf(sess, 0, "rend: badly damaged file get request from %s...\n", userinfo->sn);
+ aim_cookie_free(sess, cachedcook);
+ aim_freetlvchain(&list2);
+
+ return 0;
+ }
+
+ snprintf(ip, 30, "%d.%d.%d.%d:%d",
+ aimutil_get8(iptlv->value+0),
+ aimutil_get8(iptlv->value+1),
+ aimutil_get8(iptlv->value+2),
+ aimutil_get8(iptlv->value+3),
+ aimutil_get16(porttlv->value));
+
+ if (aim_gettlv(list2, 0x000c, 1))
+ desc = aim_gettlv_str(list2, 0x000c, 1);
+
+ faimdprintf(sess, 0, "rend: file transfer request from %s: %s (%s)\n",
+ userinfo->sn, desc, ip);
+
+ memcpy(cachedcook->cookie, cookie, 8);
+
+ ft = malloc(sizeof(struct aim_filetransfer_priv)); /* XXX */
+ strncpy(ft->sn, userinfo.sn, sizeof(ft->sn));
+ strncpy(ft->ip, ip, sizeof(ft->ip));
+ strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name));
+ cachedcook->type = AIM_COOKIETYPE_OFTSEND;
+ cachedcook->data = ft;
+
+ if (aim_cachecookie(sess, cachedcook) == -1)
+ faimdprintf(sess, 0, "ERROR caching message cookie\n");
+
+ aim_accepttransfer(sess, rx->conn, ft->sn, cookie, AIM_CAPS_SENDFILE);
+
+ if (desc)
+ free(desc);
+
+ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
+ ret = userfunc(sess, rx, channel, userinfo, &args);