+ } else if (reqclass & AIM_CAPS_VOICE) {
+ struct aim_msgcookie_t *cachedcook;
+
+ printf("faim: rend: voice!\n");
+
+ if(!(cachedcook = (struct aim_msgcookie_t*)calloc(1, sizeof(struct aim_msgcookie_t))))
+ return 1;
+
+ memcpy(cachedcook->cookie, cookie, 8);
+ cachedcook->type = AIM_COOKIETYPE_OFTVOICE;
+ cachedcook->data = NULL;
+
+ if (aim_cachecookie(sess, cachedcook) != 0)
+ printf("faim: ERROR caching message cookie\n");
+
+ /* XXX: implement all this */
+
+ /*
+ * Call client.
+ */
+ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+ if (userfunc || (i = 0)) {
+ i = userfunc(sess, command, channel, reqclass, &userinfo);
+ }
+ } else if ((reqclass & AIM_CAPS_IMIMAGE) || (reqclass & AIM_CAPS_BUDDYICON)) {
+ char ip[30];
+ struct aim_directim_priv *priv;
+
+ memset(ip, 0, 30);
+
+ 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)*/);
+ }
+
+ printf("faim: rend: directIM request from %s (%s)\n",
+ userinfo.sn,
+ ip);
+
+ /* XXX: there are a couple of different request packets for
+ * different things */
+
+ priv = (struct aim_directim_priv *)calloc(1, sizeof(struct aim_directim_priv));
+ memcpy(priv->ip, ip, sizeof(priv->ip));
+ memcpy(priv->sn, userinfo.sn, sizeof(priv->sn));
+ memcpy(priv->cookie, cookie, sizeof(priv->cookie));
+
+ /*
+ * Call client.
+ */
+ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+ if (userfunc || (i = 0))
+ i = userfunc(sess,
+ command,
+ channel,
+ reqclass,
+ &userinfo, priv);
+
+ } else if (reqclass & AIM_CAPS_CHAT) {
+ struct aim_tlv_t *miscinfo;
+ struct aim_chat_roominfo roominfo;
+ char *msg=NULL,*encoding=NULL,*lang=NULL;
+
+ miscinfo = aim_gettlv(list2, 0x2711, 1);
+ aim_chat_readroominfo(miscinfo->value, &roominfo);
+
+ if (aim_gettlv(list2, 0x000c, 1))
+ msg = aim_gettlv_str(list2, 0x000c, 1);
+
+ if (aim_gettlv(list2, 0x000d, 1))
+ encoding = aim_gettlv_str(list2, 0x000d, 1);
+
+ if (aim_gettlv(list2, 0x000e, 1))
+ lang = aim_gettlv_str(list2, 0x000e, 1);
+
+ /*
+ * Call client.
+ */
+ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+ if (userfunc || (i = 0))
+ i = userfunc(sess,
+ command,
+ channel,
+ reqclass,
+ &userinfo,
+ &roominfo,
+ msg,
+ encoding?encoding+1:NULL,
+ lang?lang+1:NULL);
+ free(roominfo.name);
+ free(msg);
+ free(encoding);
+ free(lang);
+ } else if (reqclass & AIM_CAPS_GETFILE) {
+ char ip[30];
+ struct aim_msgcookie_t *cachedcook;
+ struct aim_tlv_t *miscinfo;
+
+ if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t))))
+ return 0;
+
+ memset(ip, 0, 30);
+
+ if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) {
+ free(cachedcook);
+ return 0;
+ }
+
+ if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) {
+ struct aim_tlv_t *iptlv, *porttlv;
+
+ if (!(iptlv = aim_gettlv(list2, 0x0003, 1)) || !(porttlv = aim_gettlv(list2, 0x0005, 1))) {
+ free(cachedcook);
+ 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));
+ }
+
+ printf("faim: rend: file get request from %s (%s)\n", userinfo.sn, ip);
+
+ /*
+ * Call client.
+ */
+ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+ if (userfunc || (i = 0))
+ i = userfunc(sess,
+ command,
+ channel,
+ reqclass,
+ &userinfo,
+ ip,
+ cookie);
+
+ } else if (reqclass & AIM_CAPS_SENDFILE) {
+#if 0
+ char ip[30];
+ char *desc = NULL;
+ struct aim_msgcookie_t *cachedcook;
+ struct aim_filetransfer_priv *ft;
+ struct aim_tlv_t *miscinfo;
+
+ memset(ip, 0, sizeof(ip));
+
+ if (!(miscinfo = aim_gettlv(list2, 0x2711, 1)))
+ return 0;
+
+ if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) {
+ struct aim_tlv_t *iptlv, *porttlv;
+
+ iptlv = aim_gettlv(list2, 0x0003, 1);
+ porttlv = aim_gettlv(list2, 0x0005, 1);
+
+ snprintf(ip, sizeof(ip)-1, "%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);
+ }
+
+ printf("faim: rend: file transfer request from %s for %s: %s (%s)\n",
+ userinfo.sn,
+ miscinfo->value+8,
+ desc,
+ ip);
+
+ memcpy(cachedcook->cookie, cookie, 8);
+
+ ft = malloc(sizeof(struct aim_filetransfer_priv));
+ 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) != 0)
+ printf("faim: ERROR caching message cookie\n");
+
+
+ aim_accepttransfer(sess, command->conn, ft->sn, cookie, AIM_CAPS_SENDFILE);
+
+ if (desc)
+ free(desc);
+#endif
+ /*
+ * Call client.
+ */
+ userfunc = aim_callhandler(command->conn, 0x0004, 0x0007);
+ if (userfunc || (i = 0))
+ i = userfunc(sess,
+ command,
+ channel,
+ reqclass,
+ &userinfo);
+ } else {
+ printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass);
+ }
+
+ aim_freetlvchain(&list2);