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