]> andersk Git - libfaim.git/blobdiff - utils/faimtest/faimtest.c
- Tue Sep 11 04:42:28 PDT 2001
[libfaim.git] / utils / faimtest / faimtest.c
index 377295c597c60950c770edad7a5c90920aabbc34..6130f7cf082281fd8e24891bf24173589987405d 100644 (file)
@@ -306,12 +306,10 @@ int main(int argc, char **argv)
                                cmd_gotkey();
                        } else {
                                if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
-#if 0
                                        if (aim_handlerendconnect(&aimsess, waitingconn) < 0) {
                                                dprintf("connection error (rend out)\n");
                                                aim_conn_kill(&aimsess, &waitingconn);
                                        }
-#endif
                                } else {
                                        if (aim_get_command(&aimsess, waitingconn) >= 0) {
                                                aim_rxdispatch(&aimsess);
@@ -319,7 +317,8 @@ int main(int argc, char **argv)
                                                dvprintf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype);
                                                /* we should have callbacks for all these, else the library will do the conn_kill for us. */
                                                if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) {
-                                                       dprintf("connection error: rendezvous connection. you forgot register a disconnect callback, right?\n");          
+                                                       if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)
+                                                               dvprintf("disconnected from %s\n", aim_directim_getsn(waitingconn));
                                                        aim_conn_kill(&aimsess, &waitingconn);
                                                } else
                                                        aim_conn_kill(&aimsess, &waitingconn);
@@ -402,7 +401,6 @@ int faimtest_parse_connerr(aim_session_t *sess, aim_frame_t *fr, ...)
        return 1;
 }
 
-#if 0
 static int faimtest_rateresp_auth(aim_session_t *sess, aim_frame_t *fr, ...)
 {
 
@@ -428,9 +426,6 @@ int faimtest_accountconfirm(aim_session_t *sess, aim_frame_t *fr, ...)
        return 1;
 }
 
-
-#endif
-
 #if 0
 /* 
  * This kind of function is really not legal in the new bstream way...
@@ -457,6 +452,28 @@ int faimtest_parse_unknown(aim_session_t *sess, aim_frame_t *fr, ...)
 }
 #endif
 
+static int faimtest_infochange(aim_session_t *sess, aim_frame_t *fr, ...)
+{
+       fu16_t change = 0, perms, type;
+       int length, str;
+       char *val;
+       va_list ap;
+
+       va_start(ap, fr);
+       change = va_arg(ap, int);
+       perms = va_arg(ap, fu16_t);
+       type = va_arg(ap, fu16_t);
+       length = va_arg(ap, int);
+       val = va_arg(ap, char *);
+       str = va_arg(ap, int);
+       va_end(ap);
+
+       dvprintf("info%s: perms = %d, type = %x, length = %d, val = %s\n", change?" change":"", perms, type, length, str?val:"(not string)");
+
+       return 1;
+}
+
+
 int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...)
 {
        va_list ap;
@@ -487,7 +504,6 @@ int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...)
                }
 #endif
        } else if (serviceid == 0x0007) {  /* Authorizer */
-#if 0
                aim_conn_t *tstconn;
                
                tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
@@ -497,8 +513,8 @@ int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...)
                        aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0);
                        aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0);
                        aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
-                       aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp, 0); /* rate info */
-                       aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0);
+                       aim_conn_addhandler(sess, tstconn, 0x0001, 0x0007, faimtest_rateresp_auth, 0); /* rate info */
+                       //aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, 0x0018, faimtest_hostversions, 0);
                        aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, faimtest_accountconfirm, 0);
                        aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, faimtest_infochange, 0);
                        aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0);
@@ -506,7 +522,6 @@ int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...)
                        aim_auth_sendcookie(sess, tstconn, cookie);
                        dprintf("sent cookie to authorizer host\n");
                }
-#endif
        } else if (serviceid == 0x000d) {  /* ChatNav */
 
                chatnav_redirect(sess, ip, cookie);
@@ -543,7 +558,7 @@ static int faimtest_rateresp_bos(aim_session_t *sess, aim_frame_t *fr, ...)
        aim_bos_ackrateresp(sess, fr->conn);  /* ack rate info response */
        aim_bos_reqpersonalinfo(sess, fr->conn);
        aim_bos_reqlocaterights(sess, fr->conn);
-       aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE /*| AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS*/);
+       aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS | AIM_CAPS_SENDBUDDYLIST);
        aim_bos_reqbuddyrights(sess, fr->conn);
 
        /* send the buddy list and profile (required, even if empty) */
@@ -980,6 +995,107 @@ 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, "sendbin")) {
+               struct aim_sendimext_args args;
+               static const unsigned char data[] = {
+                       0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+                       0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+                       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+               };
+
+               /*
+                * I put this here as a demonstration of how to send 
+                * arbitrary binary data via OSCAR ICBM's without the need
+                * for escape or baseN encoding of any sort.  
+                *
+                * Apparently if you set the charset to something WinAIM
+                * doesn't recognize, it will completly ignore the message.
+                * That is, it will not display anything in the conversation
+                * window for the user that recieved it.
+                *
+                * HOWEVER, if they do not have a conversation window open
+                * for you, a new one will be created, but it will not have
+                * any messages in it.  Therefore sending these things could
+                * be a great way to seemingly subliminally convince people
+                * to talk to you...
+                *
+                */
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_CUSTOMCHARSET;
+               args.charset = args.charsubset = 0x4242;
+               args.msg = data;
+               args.msglen = sizeof(data);
+
+               aim_send_im_ext(sess, conn, &args);
+
+       } else if (strstr(tmpstr, "sendmulti")) {
+               struct aim_sendimext_args args;
+               aim_mpmsg_t mpm;
+               static const fu16_t unidata[] = { /* "UNICODE." */
+                       0x0055, 0x004e, 0x0049, 0x0043,
+                       0x004f, 0x0044, 0x0045, 0x002e,
+               };
+               static const int unidatalen = 8;
+
+               /*
+                * This is how multipart messages should be sent.
+                *
+                * This should render as:
+                *        "Part 1, ASCII.  UNICODE.Part 3, ASCII.  "
+                */
+
+               aim_mpmsg_init(sess, &mpm);
+
+               aim_mpmsg_addascii(sess, &mpm, "Part 1, ASCII.  ");
+               aim_mpmsg_addunicode(sess, &mpm, unidata, unidatalen);
+               aim_mpmsg_addascii(sess, &mpm, "Part 3, ASCII.  ");
+
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_MULTIPART;
+               args.mpmsg = &mpm;
+
+               aim_send_im_ext(sess, conn, &args);
+
+               aim_mpmsg_free(sess, &mpm);
+
+       } else if (strstr(tmpstr, "sendprebin")) {
+               static const unsigned char data[] = {
+                       0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                       0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                       0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                       0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+                       0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+                       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+               };
+               struct aim_sendimext_args args;
+               aim_mpmsg_t mpm;
+
+               /*
+                * This demonstrates sending a human-readable preamble,
+                * and then arbitrary binary data.
+                *
+                * This means that you can very inconspicuously send binary
+                * attachments to other users.  In WinAIM, this appears as
+                * though it only had the ASCII portion.
+                *
+                */
+
+               aim_mpmsg_init(sess, &mpm);
+
+               aim_mpmsg_addascii(sess, &mpm, "This message has binary data.");
+               aim_mpmsg_addraw(sess, &mpm, 0x4242, 0x4242, data, sizeof(data));
+
+               args.destsn = userinfo->sn;
+               args.flags = AIM_IMFLAGS_MULTIPART;
+               args.mpmsg = &mpm;
+
+               aim_send_im_ext(sess, conn, &args);
+
+               aim_mpmsg_free(sess, &mpm);
+
        } else if (strstr(tmpstr, "havefeat")) {
                struct aim_sendimext_args args;
                static const char featmsg[] = {"I have nifty features."};
@@ -1056,13 +1172,13 @@ static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, struct aim_
                aim_getinfo(sess, conn, "midendian", AIM_GETINFO_GENERALINFO);
                aim_getinfo(sess, conn, "midendian", AIM_GETINFO_AWAYMESSAGE);
 
-       } else if (!strncmp(tmpstr, "open directim", 13)) {
+       } else if (strstr(tmpstr, "open directim")) {
 
-               directim_start(sess, conn, (strlen(tmpstr) < 14)?userinfo->sn:tmpstr+14);
+               directim_start(sess, conn, userinfo->sn);
 
-       } else if(!(strncmp(tmpstr, "lookup", 6))) {
+       } else if(strstr(tmpstr, "lookup")) {
 
-               aim_usersearch_address(sess, conn, tmpstr+7);
+               aim_usersearch_address(sess, conn, "mid@auk.cx");
 
        } else if (!strncmp(tmpstr, "reqsendmsg", 10)) {
 
@@ -1153,7 +1269,8 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
                dinlineprintf("hasicon ");
        dinlineprintf("\n");
 
-       dvprintf("faimtest: icbm: encoding flags = {%04x, %04x}\n", args->flag1, args->flag2);
+       if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET)
+               dvprintf("faimtest: icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset);
 
        /*
         * Quickly convert it to eight bit format, replacing non-ASCII UNICODE 
@@ -1205,6 +1322,21 @@ static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *con
 
        dvprintf("faimtest: icbm: message: %s\n", realmsg);
 
+       if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
+               aim_mpmsg_section_t *sec;
+               int z;
+
+               dvprintf("faimtest: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
+
+               for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
+                       if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
+                               dvprintf("faimtest: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data);
+                       } else {
+                               dvprintf("faimtest: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset);
+                       }
+               }
+       }
+
        if (args->icbmflags & AIM_IMFLAGS_HASICON)
                aim_send_im(sess, conn, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon");
 
@@ -1323,31 +1455,6 @@ static int faimtest_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...)
        return 1;
 }
 
-#ifdef MID_REWROTE_ALL_THE_CRAP
-static int faimtest_infochange(aim_session_t *sess, aim_frame_t *fr, ...)
-{
-       fu16_t change = 0, perms, type;
-       int length, str;
-       char *val;
-       va_list ap;
-
-       va_start(ap, fr);
-       perms = va_arg(ap, fu16_t);
-       type = va_arg(ap, fu16_t);
-       length = va_arg(ap, int);
-       val = va_arg(ap, char *);
-       str = va_arg(ap, int);
-       va_end(ap);
-
-       if (aimutil_get16(command->data+2) == 0x0005)
-               change = 1;
-
-       dvprintf("info%s: perms = %d, type = %x, length = %d, val = %s\n", change?" change":"", perms, type, length, str?val:"(not string)");
-
-       return 1;
-}
-#endif
-
 static int faimtest_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...)
 {
        struct aim_userinfo_s *userinfo;
@@ -1633,6 +1740,46 @@ static int faimtest_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...)
        return 1;
 }
 
+static int serverpause(aim_session_t *sess, aim_frame_t *fr, ...)
+{
+
+       aim_sendpauseack(sess, fr->conn);
+
+       return 1;
+}
+
+static int migrate(aim_session_t *sess, aim_frame_t *fr, ...)
+{
+       va_list ap;
+       aim_conn_t *bosconn;
+       char *bosip;
+       fu8_t *cookie;
+
+       va_start(ap, fr);
+       bosip = va_arg(ap, char *);
+       cookie = va_arg(ap, fu8_t *);
+       va_end(ap);
+
+       dvprintf("migration in progress -- new BOS is %s -- disconnecting\n", bosip);
+       aim_conn_kill(sess, &fr->conn);
+
+       if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip))) {
+               dprintf("migrate: could not connect to BOS: internal error\n");
+               return 1;
+       } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) { 
+               dprintf("migrate: could not connect to BOS\n");
+               aim_conn_kill(sess, &bosconn);
+               return 1;
+       }
+
+       /* Login will happen all over again. */
+       addcb_bos(sess, bosconn);
+
+       aim_auth_sendcookie(sess, bosconn, cookie);
+
+       return 1;
+}
+
 void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn)
 {
 
@@ -1667,6 +1814,8 @@ void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn)
        aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, faimtest_parse_genericerr, 0);
        aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, faimtest_parse_genericerr, 0);
        aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, faimtest_parse_genericerr, 0);
+       aim_conn_addhandler(sess, bosconn, 0x0001, 0x000b, serverpause, 0);
+       aim_conn_addhandler(sess, bosconn, 0x0001, 0x0012, migrate, 0);
        
 #ifdef MID_REWROTE_ALL_THE_CRAP
        aim_conn_addhandler(sess, bosconn, 0xffff, 0xffff, faimtest_parse_unknown, 0);
This page took 0.114937 seconds and 4 git commands to generate.