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