]> andersk Git - libfaim.git/blob - utils/faimtest/faimtest.c
Small fixes.
[libfaim.git] / utils / faimtest / faimtest.c
1 /* 
2  *  -----------------------------------------------------------
3  *  ProtoFAIM: v1.xx.xxplxx
4  *  -----------------------------------------------------------
5  *
6  *  This is ProtoFAIM v1.xx.xxplxx!!! Its nearly completely 
7  *  different than that ugly thing called v0.  This app is
8  *  compatible with the latest version of the libfaim library.
9  *  Work is continuing. 
10  *
11  *  ProtoFAIM should only be used for two things...
12  *   1) Testing the libfaim backend.
13  *   2) For reference on the libfaim API when developing clients.
14  * 
15  *  Its very ugly.  Probably always will be.  Nothing is more
16  *  ugly than the backend itself, however.
17  *
18  *  -----------------------------------------------------------
19  *
20  *  I'm releasing this code and all it's associated linkage
21  *  under the GNU General Public License.  For more information,
22  *  please refer to http://www.fsf.org.  For any questions,
23  *  please contact me at the address below.
24  *
25  *  Most everything:
26  *  (c) 1998 Adam Fritzler, PST, afritz@iname.com
27  *
28  *  The password algorithms
29  *  (c) 1998 Brock Wilcox, awwaiid@iname.com
30  *
31  *  THERE IS NO CODE FROM AOL'S AIM IN THIS CODE, NOR
32  *  WAS THERE ANY DISASSEMBLAGE TO DEFINE PROTOCOL.  All
33  *  information was gained through painstakingly comparing
34  *  TCP dumps while the AIM Java client was running.  Nothing
35  *  more than that, except for a lot of experimenting.
36  *
37  *  -----------------------------------------------------------
38  *
39  */
40
41 /*
42   Current status:
43
44
45  */
46
47 #include <faim/aim.h> 
48
49 int faimtest_parse_oncoming(struct aim_session_t *, struct command_rx_struct *, ...);
50 int faimtest_parse_offgoing(struct aim_session_t *, struct command_rx_struct *, ...);
51 int faimtest_parse_login_phase3d_f(struct aim_session_t *, struct command_rx_struct *, ...);
52 int faimtest_parse_authresp(struct aim_session_t *, struct command_rx_struct *, ...);
53 int faimtest_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *command, ...);
54 int faimtest_parse_userinfo(struct aim_session_t *, struct command_rx_struct *command, ...);
55 int faimtest_handleredirect(struct aim_session_t *, struct command_rx_struct *command, ...);
56 int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *command, ...);
57 int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...);
58 int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...);
59 int faimtest_parse_misses(struct aim_session_t *, struct command_rx_struct *command, ...);
60 int faimtest_parse_msgack(struct aim_session_t *, struct command_rx_struct *command, ...);
61 int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...);
62 int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...);
63 int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...);
64 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...);
65 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
66 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...);
67 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...);
68 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...);
69 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
70
71 int faimtest_directim_request(struct aim_session_t *sess, struct command_rx_struct *command, ...);
72 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...);
73 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
74 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...);
75 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...);
76 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...);
77 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...);
78
79 int faimtest_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...)
80 {
81   if (command->data) {
82     printf("aim: minimum report interval: %d (seconds?)\n", aimutil_get16(command->data+10));
83   } else
84     printf("aim: NULL minimum report interval!\n");
85   return 1;
86 }
87
88 static char *screenname,*password,*server=NULL;
89
90 int main(void)
91 {
92   struct aim_session_t aimsess;
93   struct aim_conn_t *authconn = NULL, *waitingconn = NULL;
94   int keepgoing = 1;
95
96   int selstat = 0;
97
98   if ( !(screenname = getenv("SCREENNAME")) ||
99        !(password = getenv("PASSWORD")))
100     {
101       printf("Must specify SCREENAME and PASSWORD in environment.\n");
102       return -1;
103     }
104
105   server = getenv("AUTHSERVER");
106
107   aim_session_init(&aimsess);
108
109   authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, server?server:FAIM_LOGIN_SERVER);
110
111   if (authconn == NULL) {
112     fprintf(stderr, "faimtest: internal connection error while in aim_login.  bailing out.\n");
113     return -1;
114   } else if (authconn->fd == -1) {
115     if (authconn->status & AIM_CONN_STATUS_RESOLVERR)
116       fprintf(stderr, "faimtest: could not resolve authorizer name\n");
117     else if (authconn->status & AIM_CONN_STATUS_CONNERR)
118       fprintf(stderr, "faimtest: could not connect to authorizer\n");
119     aim_conn_kill(&aimsess, &authconn);
120     return -1;
121   }
122
123   aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0);
124   aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0);
125     
126   aim_sendconnack(&aimsess, authconn);
127   aim_request_login(&aimsess, authconn, screenname);
128
129   aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT, faimtest_debugconn_connect, 0);
130
131   printf("faimtest: login request sent\n");
132
133   while (keepgoing) {
134     waitingconn = aim_select(&aimsess, NULL, &selstat);
135
136     switch(selstat) {
137     case -1: /* error */
138       keepgoing = 0; /* fall through and hit the aim_logoff() */
139       break;
140
141     case 0: /* no events pending */
142       break;
143
144     case 1: /* outgoing data pending */
145       aim_tx_flushqueue(&aimsess);
146       break;
147
148     case 2: /* incoming data pending */
149       if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
150         if (aim_handlerendconnect(&aimsess, waitingconn) < 0) {
151           printf("connection error (rend)\n");
152         }
153       } else {
154         if (aim_get_command(&aimsess, waitingconn) >= 0) {
155           aim_rxdispatch(&aimsess);
156         } else {
157           printf("connection error\n");
158           aim_conn_kill(&aimsess, &waitingconn);
159           if (!aim_getconn_type(&aimsess, AIM_CONN_TYPE_BOS)) {
160             printf("major connetion error\n");
161             keepgoing = 0;
162           }
163         }
164       }
165       break;
166       
167     default:
168       break; /* invalid */
169     }
170   }
171
172   /* Close up */
173   printf("AIM just decided we didn't need to be here anymore, closing up...\n");
174   
175   /* close up all connections, dead or no */
176   aim_logoff(&aimsess); 
177
178   /* Get out */
179   exit(0);
180 }
181
182 int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
183 {
184   switch (command->conn->type)
185     {
186     case AIM_CONN_TYPE_BOS:
187
188       aim_bos_reqrate(sess, command->conn); /* request rate info */
189       aim_bos_ackrateresp(sess, command->conn);  /* ack rate info response -- can we say timing? */
190       aim_bos_setprivacyflags(sess, command->conn, 0x00000003);
191       
192 #if 0
193       aim_bos_reqpersonalinfo(sess, command->conn);
194 #endif
195       
196       /* Request advertisement service -- see comment in handleredirect */
197       aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS);
198       aim_setversions(sess, command->conn);
199
200 #if 0
201       aim_bos_reqrights(sess, command->conn);
202       aim_bos_reqbuddyrights(sess, command->conn);
203       aim_bos_reqlocaterights(sess, command->conn);
204       aim_bos_reqicbmparaminfo(sess, command->conn);
205 #endif
206       
207       /* set group permissions */
208       aim_bos_setgroupperm(sess, command->conn, 0x1f);
209       fprintf(stderr, "faimtest: done with BOS ServerReady\n");
210       break;
211
212     case AIM_CONN_TYPE_CHATNAV:
213       fprintf(stderr, "faimtest: chatnav: got server ready\n");
214       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0);
215       aim_bos_reqrate(sess, command->conn);
216       aim_bos_ackrateresp(sess, command->conn);
217       aim_chatnav_clientready(sess, command->conn);
218       aim_chatnav_reqrights(sess, command->conn);
219
220       break;
221     case AIM_CONN_TYPE_CHAT:
222       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0);
223       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0);
224       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0);
225       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0);
226       aim_bos_reqrate(sess, command->conn);
227       aim_bos_ackrateresp(sess, command->conn);
228       aim_chat_clientready(sess, command->conn);
229       break;
230
231     case AIM_CONN_TYPE_RENDEZVOUS: /* this is an overloaded function?? - mid */
232       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
233       aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
234       break;
235
236     default:
237       fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
238     }
239   return 1;
240 }
241
242 /*
243   handleredirect()...
244
245   This, of course, handles Service Redirects from OSCAR.
246
247   Should get passed in the following:
248      struct command_rx_struct *command
249        the raw command data
250      int serviceid
251        the destination service ID
252      char *serverip
253        the IP address of the service's server
254      char *cookie
255        the raw auth cookie
256  */
257 int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
258 {
259   va_list ap;
260   int serviceid;
261   char *ip;
262   char *cookie;
263
264   /* this is the new buddy list */
265   char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&";
266   /* this is the new profile */
267   char profile[] = "Hello";  
268
269   va_start(ap, command);
270   serviceid = va_arg(ap, int);
271   ip = va_arg(ap, char *);
272   cookie = va_arg(ap, char *);
273  
274   switch(serviceid)
275     {
276     case 0x0005: /* Advertisements */
277       /*
278        * The craziest explanation yet as to why we finish logging in when
279        * we get the advertisements redirect, of which we don't use anyway....
280        *                    IT WAS EASY!
281        */
282
283       /* send the buddy list and profile (required, even if empty) */
284       aim_bos_setbuddylist(sess, command->conn, buddies);
285       aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_VOICE | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE);
286
287       /* send final login command (required) */
288       aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */
289
290       /* you should now be ready to go */
291       printf("\nYou are now officially online.\n");      
292
293       break;
294     case 0x0007: /* Authorizer */
295       {
296         struct aim_conn_t *tstconn;
297         /* Open a connection to the Auth */
298         tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
299         if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) )
300           fprintf(stderr, "faimtest: unable to reconnect with authorizer\n");
301         else
302           /* Send the cookie to the Auth */
303           aim_auth_sendcookie(sess, tstconn, cookie);
304
305       }  
306       break;
307     case 0x000d: /* ChatNav */
308       {
309         struct aim_conn_t *tstconn = NULL;
310         tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
311         if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) {
312           fprintf(stderr, "faimtest: unable to connect to chatnav server\n");
313           if (tstconn) aim_conn_kill(sess, &tstconn);
314           return 1;
315         }
316 #if 0
317         aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
318         aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
319 #endif
320         aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
321         aim_auth_sendcookie(sess, tstconn, cookie);
322         fprintf(stderr, "\achatnav: connected\n");
323       }
324       break;
325     case 0x000e: /* Chat */
326       {
327         char *roomname = NULL;
328         struct aim_conn_t *tstconn = NULL;
329
330         roomname = va_arg(ap, char *);
331
332         tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
333         if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR))
334           {
335             fprintf(stderr, "faimtest: unable to connect to chat server\n");
336             if (tstconn) aim_conn_kill(sess, &tstconn);
337             return 1;
338           }             
339         printf("faimtest: chat: connected\n");
340
341         /*
342          * We must do this to attach the stored name to the connection!
343          */
344         aim_chat_attachname(tstconn, roomname);
345
346         aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0);
347         aim_auth_sendcookie(sess, tstconn, cookie);
348       }
349       break;
350     default:
351       printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
352       /* dunno */
353     }
354
355   va_end(ap);
356
357   return 1;
358 }
359
360 int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...)
361 {
362   struct aim_conn_t *bosconn = NULL;
363   
364
365   printf("Screen name: %s\n", sess->logininfo.screen_name);
366
367   /*
368    * Check for error.
369    */
370   if (sess->logininfo.errorcode)
371     {
372       printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode);
373       printf("Error URL: %s\n", sess->logininfo.errorurl);
374       aim_conn_kill(sess, &command->conn);
375       exit(0); /* XXX: should return in order to let the above things get free()'d. */
376     }
377
378   printf("Reg status: %2d\n", sess->logininfo.regstatus);
379   printf("Email: %s\n", sess->logininfo.email);
380   printf("BOS IP: %s\n", sess->logininfo.BOSIP);
381
382   printf("Closing auth connection...\n");
383   aim_conn_kill(sess, &command->conn);
384   bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP);
385   if (bosconn == NULL) {
386     fprintf(stderr, "faimtest: could not connect to BOS: internal error\n");
387   } else if (bosconn->status != 0) {    
388     fprintf(stderr, "faimtest: could not connect to BOS\n");
389     aim_conn_kill(sess, &bosconn);
390   } else {
391     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0);
392     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0);
393     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0);
394     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0);
395     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, faimtest_reportinterval, 0);
396     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0);
397     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0);
398     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
399     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0);
400     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0);
401     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0);
402     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0);
403     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0);
404     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0);
405
406     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0);
407     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0);
408     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0);
409     
410     aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0);
411     
412     aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie);
413   }
414   return 1;
415 }
416
417 int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...)
418 {
419   struct aim_userinfo_s *userinfo;
420   char *prof_encoding = NULL;
421   char *prof = NULL;
422   unsigned short inforeq = 0;
423
424   va_list ap;
425   va_start(ap, command);
426   userinfo = va_arg(ap, struct aim_userinfo_s *);
427   prof_encoding = va_arg(ap, char *);
428   prof = va_arg(ap, char *);
429   inforeq = va_arg(ap, unsigned short);
430   va_end(ap);
431   
432   printf("faimtest: userinfo: sn: %s\n", userinfo->sn);
433   printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel);
434   printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class);
435
436   /*
437    *  00000000  (binary)
438    *         1  Trial  
439    *        2   Unknown
440    *       3    AOL
441    *      4     Unknown
442    *     5      Free
443    * 
444    * ORed together.
445    *
446    */
447
448   if (userinfo->class & 0x0001)
449     printf("TRIAL ");
450   if (userinfo->class & 0x0002)
451     printf("UNKNOWN_BIT2 ");
452   if (userinfo->class & 0x0004)
453     printf("AOL ");
454   if (userinfo->class & 0x0008)
455     printf("UNKNOWN_BIT4 ");
456   if (userinfo->class & 0x0010)
457     printf("FREE ");
458   if (userinfo->class & 0x0040)
459     printf("ICQ? ");
460   printf("\n");
461   
462   printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince);
463   printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince);
464   printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime);
465   
466   if (inforeq == AIM_GETINFO_GENERALINFO) {
467     printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
468     printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]");
469   } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) {
470     printf("faimtest: userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]");
471     printf("faimtest: userinfo: awaymsg: %s\n", prof ? prof : "[none]");
472   } else 
473     printf("faimtest: userinfo: unknown info request\n");
474   
475   return 1;
476 }
477
478 /*
479  * The user-level Incoming ICBM callback.
480  *
481  * Arguments:
482  *  struct command_rx_struct *  command     if you feel like doing it yourself
483  *  char *                      srcsn       the source name
484  *  char *                      msg         message
485  *  int                         warnlevel   warning/evil level
486  *  int                         class       user class
487  *  ulong                       membersince time_t of date of signup
488  *  ulong                       onsince     time_t of date of singon
489  *  int                         idletime    min (sec?) idle
490  *  u_int                       icbmflags   sets AIM_IMFLAGS_{AWAY,ACK}
491  *
492  */
493 int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...)
494 {
495   int channel;
496   va_list ap;
497
498   va_start(ap, command);
499   channel = va_arg(ap, int);
500
501   /*
502    * Channel 1: Standard Message
503    */
504   if (channel == 1) {
505     struct aim_userinfo_s *userinfo;
506     char *msg = NULL;
507     u_int icbmflags = 0;
508     char *tmpstr = NULL;
509     u_short flag1, flag2;
510     
511     userinfo = va_arg(ap, struct aim_userinfo_s *);
512     msg = va_arg(ap, char *);
513     icbmflags = va_arg(ap, u_int);
514     flag1 = va_arg(ap, u_short);
515     flag2 = va_arg(ap, u_short);
516     va_end(ap);
517     
518     printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn);
519     printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel);
520     printf("faimtest: icbm: class = 0x%04x ", userinfo->class);
521     if (userinfo->class & 0x0010)
522       printf("(FREE) ");
523     if (userinfo->class & 0x0001)
524       printf("(TRIAL) ");
525     if (userinfo->class & 0x0004)
526       printf("(AOL) ");
527     printf("\n");
528     printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince);
529     printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince);
530     printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime);
531     printf("faimtest: icbm: capabilities = 0x%04x\n", userinfo->capabilities);
532     
533     printf("faimtest: icbm: icbmflags = ");
534     if (icbmflags & AIM_IMFLAGS_AWAY)
535       printf("away ");
536     if (icbmflags & AIM_IMFLAGS_ACK)
537       printf("ackrequest ");
538     printf("\n");
539     
540     printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2);
541     
542     printf("faimtest: icbm: message: %s\n", msg);
543     
544     if (msg) {
545       int i = 0;
546
547       while (msg[i] == '<') {
548         if (msg[i] == '<') {
549           while (msg[i] != '>')
550             i++;
551           i++;
552         }
553       }
554       tmpstr = msg+i;
555
556       printf("tmpstr = %s\n", tmpstr);
557       
558       if ( (strlen(tmpstr) >= 10) &&
559            (!strncmp(tmpstr, "disconnect", 10)) ) {
560           aim_send_im(sess, command->conn, "midendian", 0, "ta ta...");
561           aim_logoff(sess);
562       } else if (strstr(tmpstr, "goodday")) {
563         printf("faimtest: icbm: sending response\n");
564         aim_send_im(sess, command->conn, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");
565       } else if (!strncmp(tmpstr, "open chatnav", 12)) {
566         aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV);
567         //aim_chat_join(sess, command->conn, "thishereisaname2_chat85");
568       } else if (!strncmp(tmpstr, "create", 6)) {
569         aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004);
570       } else if (!strncmp(tmpstr, "close chatnav", 13)) {
571         struct aim_conn_t *chatnavconn;
572         chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV);
573         aim_conn_kill(sess, &chatnavconn);
574       } else if (!strncmp(tmpstr, "join", 4)) {
575           aim_chat_join(sess, command->conn, 0x0004, "worlddomination");
576       } else if (!strncmp(tmpstr, "leave", 5))
577             aim_chat_leaveroom(sess, "worlddomination");
578       else if (!strncmp(tmpstr, "getinfo", 7)) {
579         aim_getinfo(sess, command->conn, "75784102", AIM_GETINFO_GENERALINFO);
580         aim_getinfo(sess, command->conn, "15853637", AIM_GETINFO_AWAYMESSAGE);
581       } else if (!strncmp(tmpstr, "open directim", 13)) {
582         struct aim_conn_t *newconn;
583         newconn = aim_directim_initiate(sess, command->conn, NULL, userinfo->sn);
584         //aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate, 0);
585       } else if (!strncmp(tmpstr, "sendmsg", 7)) {
586         int i;
587         i = atoi(tmpstr+8);
588         if (i < 10000) {
589           char *newbuf;
590           int z;
591
592           newbuf = malloc(i+1);
593           for (z = 0; z < i; z++) {
594             newbuf[z] = (z % 10)+0x30;
595           }
596           newbuf[i] = '\0';
597           aim_send_im(sess, command->conn, userinfo->sn, 0, newbuf);
598           free(newbuf);
599         }
600       } else {
601         printf("unknown command.\n");
602         aim_add_buddy(sess, command->conn, userinfo->sn);
603       }
604       
605     }
606   }
607   /*
608    * Channel 2: Rendevous Request
609    */
610   else if (channel == 2) {
611     struct aim_userinfo_s *userinfo;
612     unsigned short reqclass;
613     
614     reqclass = va_arg(ap, unsigned short);
615     switch (reqclass) {
616     case AIM_CAPS_VOICE: {
617       userinfo = va_arg(ap, struct aim_userinfo_s *);
618       va_end(ap);
619       
620       printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn);
621       printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
622       printf("faimtest: voice invitation: \tclass = 0x%04x ", userinfo->class);
623       if (userinfo->class & 0x0010)
624         printf("(FREE) ");
625       if (userinfo->class & 0x0001)
626         printf("(TRIAL) ");
627       if (userinfo->class & 0x0004)
628         printf("(AOL) ");
629       printf("\n");
630       /* we dont get membersince on chat invites! */
631       printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
632       printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime);
633       
634       break;
635     }
636     case AIM_CAPS_GETFILE: {
637       printf("faimtset: get file!\n");
638       break;
639     }
640     case AIM_CAPS_SENDFILE: {
641       printf("faimtest: send file!\n");
642       break;
643     }
644     case AIM_CAPS_CHAT: {
645       char *msg,*encoding,*lang;
646       struct aim_chat_roominfo *roominfo;
647       
648       userinfo = va_arg(ap, struct aim_userinfo_s *);
649       roominfo = va_arg(ap, struct aim_chat_roominfo *);
650       msg = va_arg(ap, char *);
651       encoding = va_arg(ap, char *);
652       lang = va_arg(ap, char *);
653       va_end(ap);
654       
655       printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn);
656       printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel);
657       printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class);
658       if (userinfo->class & 0x0010)
659         printf("(FREE) ");
660       if (userinfo->class & 0x0001)
661         printf("(TRIAL) ");
662       if (userinfo->class & 0x0004)
663         printf("(AOL) ");
664       printf("\n");
665       /* we dont get membersince on chat invites! */
666       printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince);
667       printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime);
668       
669       printf("faimtest: chat invitation: message = %s\n", msg);
670       printf("faimtest: chat invitation: room name = %s\n", roominfo->name);
671       printf("faimtest: chat invitation: encoding = %s\n", encoding);
672       printf("faimtest: chat invitation: language = %s\n", lang);
673       printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange);
674       printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance);
675       printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name);
676       /*
677        * Automatically join room...
678        */ 
679       aim_chat_join(sess, command->conn, 0x0004, roominfo->name);
680       break;
681     }   
682     case AIM_CAPS_IMIMAGE: {
683       struct aim_directim_priv *priv;
684       struct aim_conn_t *newconn;
685
686       printf("faimtest: icbm: rendezvous imimage\n");
687      
688       userinfo = va_arg(ap, struct aim_userinfo_s *);
689       priv = va_arg(ap, struct aim_directim_priv *);
690       va_end(ap);
691
692       printf("faimtest: OFT: DirectIM: request from %s (%s)\n", userinfo->sn, priv->ip);
693       
694       if (!(newconn = aim_directim_connect(sess, command->conn, priv))) {
695         printf("faimtest: icbm: imimage: could not connect\n");
696         break;
697       }
698       aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
699       aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
700       aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
701
702       aim_send_im_direct(sess, newconn, "goodday");
703
704       printf("faimtest: OFT: DirectIM: connected to %s\n", userinfo->sn);
705
706       break;
707     }
708     default:
709       printf("faimtest: icbm: unknown reqclass (%d)\n", reqclass);
710     } /* switch */
711   } else
712     printf("faimtest does not support channels > 2 (chan = %02x)\n", channel);
713   printf("faimtest: icbm: done with ICBM handling\n");
714
715   return 1;
716 }
717
718 #if 0
719 int faimtest_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
720 {
721   va_list ap;
722   struct aim_directim_priv *priv;
723   struct aim_conn_t *newconn;
724
725   ap = va_start(ap, command);
726   newconn = va_arg(ap, struct aim_conn_t *);
727   va_end(ap);
728
729   priv = (struct aim_directim_priv *)newconn->priv;
730
731   printf("faimtest: OFT: DirectIM: intitiate success to %s\n", priv->ip);
732   
733   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, faimtest_directim_incoming, 0);
734   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMDISCONNECT, faimtest_directim_disconnect, 0);
735   aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, faimtest_directim_typing, 0);
736
737   aim_send_im_direct(sess, newconn, "goodday");
738
739   printf("faimtest: OFT: DirectIM: connected to %s\n", priv->sn);
740
741   return 1;
742 }
743 #endif
744
745 int faimtest_directim_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
746 {
747   va_list ap;
748   struct aim_directim_priv *priv;
749   
750   ap = va_start(ap, command);
751   priv = va_arg(ap, struct aim_directim_priv *);
752
753   va_end(ap);
754   
755   printf("faimtest: directim_connect\n");
756
757   return 1;
758 }
759
760 int faimtest_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
761 {
762   va_list ap;
763   char *sn = NULL, *msg = NULL;
764   struct aim_conn_t *conn;
765
766   ap = va_start(ap, command);
767   conn = va_arg(ap, struct aim_conn_t *);
768   sn = va_arg(ap, char *);
769   msg = va_arg(ap, char *);
770   va_end(ap);
771
772   printf("faimtest: Directim from %s: %s\n", sn, msg);
773   if (!strncmp(msg, "sendmsg", 7)) {
774     int i;
775     i = atoi(msg+8);
776     if (i < 10000) {
777       char *newbuf;
778       int z;
779       
780       newbuf = malloc(i+1);
781       for (z = 0; z < i; z++) {
782         newbuf[z] = (z % 10)+0x30;
783       }
784       newbuf[i] = '\0';
785       aim_send_im_direct(sess, conn, newbuf);
786       free(newbuf);
787     }
788   } else if (!strncmp(msg, "goodday", 7)) {
789     aim_send_im_direct(sess, conn, "Good day to you, too");
790   } else {
791     char newmsg[1024];
792     snprintf(newmsg, sizeof(newmsg), "unknown (%s)\n", msg);
793     aim_send_im_direct(sess, conn, newmsg);
794   }
795   return 1;
796 }
797
798 int faimtest_directim_disconnect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
799 {
800   printf("faimtest: directim_disconnect\n");
801   return 1;
802 }
803
804 int faimtest_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
805 {
806   va_list ap;
807   char *sn;
808   
809   ap = va_start(ap, command);
810   sn = va_arg(ap, char *);
811   va_end(ap);
812
813   printf("faimtest: ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn);
814   return 1;
815 }
816
817 int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...)
818 {
819   printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type);
820   sleep(10);
821   /* should just be able to tell it we're ready too... */
822   aim_auth_clientready(sess, command->conn);
823
824 #if 0
825   /*
826    * This is where you'd really begin changing your password.
827    *   However, this callback may get called for reasons other
828    *   than you wanting to change your password.  You should 
829    *   probably check that before actually doing it.
830    */
831   aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2");
832 #endif
833
834   return 1;
835 }
836
837 int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...)
838 {
839   printf("PASSWORD CHANGE SUCCESSFUL!!!\n");
840   return 1;
841 }
842
843 int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...)
844 {
845   struct aim_userinfo_s *userinfo;
846    
847   va_list ap;
848   va_start(ap, command);
849   userinfo = va_arg(ap, struct aim_userinfo_s *);
850   va_end(ap);
851
852   printf("\n%s is now online (class: %04x = %s%s%s%s%s%s%s%s) (caps = 0x%04x)\n",
853          userinfo->sn, userinfo->class,
854          (userinfo->class&AIM_CLASS_TRIAL)?" TRIAL":"",
855          (userinfo->class&AIM_CLASS_UNKNOWN2)?" UNKNOWN2":"",
856          (userinfo->class&AIM_CLASS_AOL)?" AOL":"",
857          (userinfo->class&AIM_CLASS_UNKNOWN4)?" UNKNOWN4":"",
858          (userinfo->class&AIM_CLASS_FREE)?" FREE":"",
859          (userinfo->class&AIM_CLASS_AWAY)?" AWAY":"",
860          (userinfo->class&AIM_CLASS_UNKNOWN40)?" UNKNOWN40":"",
861          (userinfo->class&AIM_CLASS_UNKNOWN80)?" UNKNOWN80":"",
862          userinfo->capabilities);
863   return 1;
864 }
865
866 int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...)
867 {
868   char *sn;
869   va_list ap;
870   
871   va_start(ap, command);
872   sn = va_arg(ap, char *);
873   va_end(ap);
874
875   printf("\n%s has left\n", sn);
876
877   return 1;
878 }
879
880 int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...)
881 {
882   char *msg;
883   u_short id;
884   va_list ap;
885   
886   va_start(ap, command);
887   id = va_arg(ap, u_short);
888   msg = va_arg(ap, char *);
889   va_end(ap);
890
891   printf("faimtest: motd: %s\n", msg);
892
893   return 1;
894 }
895
896 /* 
897  * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR, 
898  *   AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL.
899  */
900 int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...)
901 {
902   u_short family;
903   u_short subtype;
904
905   family = aimutil_get16(command->data+0);
906   subtype= aimutil_get16(command->data+2);
907   
908   switch (family)
909     {
910     case 0x0001:
911       if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */
912         printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n");
913       break;
914     case 0x0002:
915       if (subtype == 0x0001) /* or AIM_CB_USERERROR */
916         {
917           u_long snacid = 0x00000000;
918           
919           snacid = aimutil_get32(&command->data[6]);
920           
921           printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid);
922         }
923       break;
924     case 0x0004:
925       if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */
926         printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n");
927       else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */
928         printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13]));
929       break;
930     }
931
932   return 0;
933 }
934
935 int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...)
936 {
937   struct client_info_s info = {"faimtest (with SNAC login)", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x0000004b}; /* 4.1.2010 */
938   unsigned char *key;
939   va_list ap;
940   
941   va_start(ap, command);
942   key = va_arg(ap, char *);
943   va_end(ap);
944
945   aim_send_login(sess, command->conn, screenname, password, &info, key);
946  
947   return 1;
948 }
949
950 int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...)
951 {
952   va_list ap;
953   struct aim_userinfo_s *userinfo;
954   int count = 0, i = 0;
955   
956   va_start(ap, command);
957   count = va_arg(ap, int);
958   userinfo = va_arg(ap, struct aim_userinfo_s *);
959   va_end(ap);
960
961   printf("faimtest: chat: %s:  New occupants have joined:\n", (char *)command->conn->priv);
962   while (i < count)
963     printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
964
965   return 1;
966 }
967
968 int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...)
969 {
970   va_list ap;
971   struct aim_userinfo_s *userinfo;
972   int count = 0, i = 0;
973   
974   va_start(ap, command);
975   count = va_arg(ap, int);
976   userinfo = va_arg(ap, struct aim_userinfo_s *);
977   va_end(ap);
978
979   printf("faimtest: chat: %s:  Some occupants have left:\n", (char *)command->conn->priv);
980   while (i < count)
981     printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
982
983   return 1;
984 }
985
986 int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...)
987 {
988   va_list ap;
989   struct aim_userinfo_s *userinfo;
990   struct aim_chat_roominfo *roominfo;
991   char *roomname;
992   int usercount,i;
993   char *roomdesc;
994   unsigned short unknown_c9, unknown_d2, unknown_d5, maxmsglen;
995   unsigned long creationtime;
996
997   va_start(ap, command);
998   roominfo = va_arg(ap, struct aim_chat_roominfo *);
999   roomname = va_arg(ap, char *);
1000   usercount= va_arg(ap, int);
1001   userinfo = va_arg(ap, struct aim_userinfo_s *);
1002   roomdesc = va_arg(ap, char *);
1003   unknown_c9 = va_arg(ap, unsigned short);
1004   creationtime = va_arg(ap, unsigned long);
1005   maxmsglen = va_arg(ap, unsigned short);
1006   unknown_d2 = va_arg(ap, unsigned short);
1007   unknown_d5 = va_arg(ap, unsigned short);
1008   va_end(ap);
1009
1010   printf("faimtest: chat: %s:  info update:\n", (char *)command->conn->priv);
1011   printf("faimtest: chat: %s:  \tRoominfo: {%04x, %s, %04x}\n", 
1012          (char *)command->conn->priv,
1013          roominfo->exchange,
1014          roominfo->name,
1015          roominfo->instance);
1016   printf("faimtest: chat: %s:  \tRoomname: %s\n", (char *)command->conn->priv, roomname);
1017   printf("faimtest: chat: %s:  \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc);
1018   printf("faimtest: chat: %s:  \tOccupants: (%d)\n", (char *)command->conn->priv, usercount);
1019   
1020   i = 0;
1021   while (i < usercount)
1022     printf("faimtest: chat: %s:  \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn);
1023
1024   printf("faimtest: chat: %s:  \tUnknown_c9: 0x%04x\n", (char *)command->conn->priv, unknown_c9);
1025   printf("faimtest: chat: %s:  \tCreation time: %lu (time_t)\n", (char *)command->conn->priv, creationtime);
1026   printf("faimtest: chat: %s:  \tMax message length: %d bytes\n", (char *)command->conn->priv, maxmsglen);
1027   printf("faimtest: chat: %s:  \tUnknown_d2: 0x%04x\n", (char *)command->conn->priv, unknown_d2);
1028   printf("faimtest: chat: %s:  \tUnknown_d5: 0x%02x\n", (char *)command->conn->priv, unknown_d5);
1029
1030   return 1;
1031 }
1032
1033 int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1034 {
1035   va_list ap;
1036   struct aim_userinfo_s *userinfo;
1037   char *msg;
1038   char tmpbuf[1152];
1039  
1040   va_start(ap, command);
1041   userinfo = va_arg(ap, struct aim_userinfo_s *);       
1042   msg = va_arg(ap, char *);
1043   va_end(ap);
1044
1045   printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg);
1046
1047   /*
1048    * Do an echo for testing purposes.  But not for ourselves ("oops!")
1049    */
1050   if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0)
1051     {
1052       sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg);
1053       aim_chat_send_im(sess, command->conn, tmpbuf);
1054     }
1055
1056   return 1;
1057 }
1058
1059 int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1060 {
1061   u_short type;
1062   va_list ap;
1063
1064   ap = va_start(ap, command);
1065   type = va_arg(ap, u_short);
1066
1067   switch(type)
1068     {
1069     case 0x0002:
1070       {
1071         int maxrooms;
1072         struct aim_chat_exchangeinfo *exchanges;
1073         int exchangecount,i = 0;
1074         
1075         maxrooms = va_arg(ap, u_char);
1076         exchangecount = va_arg(ap, int);
1077         exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
1078         va_end(ap);
1079
1080         printf("faimtest: chat info: Chat Rights:\n");
1081         printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms);
1082         
1083         printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount);
1084         while (i < exchangecount)
1085           {
1086             printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n", 
1087                    exchanges[i].number, 
1088                    exchanges[i].name,
1089                    exchanges[i].charset1,
1090                    exchanges[i].lang1);
1091             i++;
1092           }
1093         
1094       }
1095       break;
1096     default:
1097       va_end(ap);
1098       printf("faimtest: chatnav info: unknown type (%04x)\n", type);
1099     }
1100   return 1;
1101 }
1102
1103 int faimtest_parse_connerr(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1104 {
1105   va_list ap;
1106   unsigned short code;
1107   char *msg = NULL;
1108
1109   ap = va_start(ap, command);
1110   code = va_arg(ap, unsigned short);
1111   msg = va_arg(ap, char *);
1112   va_end(ap);
1113
1114   printf("faimtest: connerr: Code 0x%04x: %s\n", code, msg);
1115   aim_conn_kill(sess, &command->conn); /* this will break the main loop */
1116
1117   return 1;
1118 }
1119
1120 int faimtest_debugconn_connect(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1121 {       
1122   printf("faimtest: connecting to an aimdebugd!\n");
1123
1124   /* convert the authorizer connection to a BOS connection */
1125   command->conn->type = AIM_CONN_TYPE_BOS;
1126
1127   aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0);
1128
1129   /* tell the aimddebugd we're ready */
1130   aim_debugconn_sendconnect(sess, command->conn); 
1131
1132   /* go right into main loop (don't open a BOS connection, etc) */
1133   return 1;
1134 }
1135
1136 /*
1137  * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option.
1138  */
1139 int faimtest_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1140 {
1141   va_list ap;
1142   unsigned short type;
1143   char *sn = NULL;
1144
1145   ap = va_start(ap, command);
1146   type = va_arg(ap, unsigned short);
1147   sn = va_arg(ap, char *);
1148   va_end(ap);
1149
1150   printf("faimtest: msgack: 0x%04x / %s\n", type, sn);
1151
1152   return 1;
1153 }
1154
1155 int faimtest_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...)
1156 {
1157   va_list ap;
1158   unsigned long newrate;
1159   
1160   va_start(ap, command); 
1161   newrate = va_arg(ap, unsigned long);
1162   va_end(ap);
1163
1164   printf("faimtest: ratechange: %lu\n", newrate);
1165
1166   return (1);
1167 };
This page took 0.199247 seconds and 5 git commands to generate.