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