]>
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 *, ...); | |
52 | int faimtest_auth_error(struct aim_session_t *, struct command_rx_struct *, ...); | |
01b59e1e | 53 | int faimtest_parse_authresp(struct aim_session_t *, struct command_rx_struct *, ...); |
397055b1 | 54 | int faimtest_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *command, ...); |
55 | int faimtest_parse_userinfo(struct aim_session_t *, struct command_rx_struct *command, ...); | |
56 | int faimtest_handleredirect(struct aim_session_t *, struct command_rx_struct *command, ...); | |
57 | int faimtest_authsvrready(struct aim_session_t *, struct command_rx_struct *command, ...); | |
58 | int faimtest_pwdchngdone(struct aim_session_t *, struct command_rx_struct *command, ...); | |
59 | int faimtest_serverready(struct aim_session_t *, struct command_rx_struct *command, ...); | |
60 | int faimtest_parse_misses(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, ...); | |
49c8a2fa | 63 | |
26af6789 | 64 | static char *screenname,*password; |
65 | ||
9de3ca7e | 66 | int main(void) |
67 | { | |
397055b1 | 68 | struct aim_session_t aimsess; |
9de3ca7e | 69 | struct aim_conn_t *authconn = NULL; |
70 | int stayconnected = 1; | |
01b59e1e | 71 | struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"}; |
72 | ||
397055b1 | 73 | aim_session_init(&aimsess); |
9de3ca7e | 74 | |
26af6789 | 75 | if ( !(screenname = getenv("SCREENNAME")) || |
76 | !(password = getenv("PASSWORD"))) | |
77 | { | |
78 | printf("Must specify SCREENAME and PASSWORD in environment.\n"); | |
79 | return -1; | |
80 | } | |
81 | ||
397055b1 | 82 | /* |
83 | * (I used a goto-based loop here because n wanted quick proof | |
84 | * that reconnecting without restarting was actually possible...) | |
85 | */ | |
9de3ca7e | 86 | enter: |
01b59e1e | 87 | authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, FAIM_LOGIN_SERVER); |
397055b1 | 88 | |
9de3ca7e | 89 | if (authconn == NULL) |
90 | { | |
91 | fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n"); | |
92 | return -1; | |
93 | } | |
94 | else if (authconn->fd == -1) | |
95 | { | |
96 | if (authconn->status & AIM_CONN_STATUS_RESOLVERR) | |
97 | fprintf(stderr, "faimtest: could not resolve authorizer name\n"); | |
98 | else if (authconn->status & AIM_CONN_STATUS_CONNERR) | |
99 | fprintf(stderr, "faimtest: could not connect to authorizer\n"); | |
100 | return -1; | |
101 | } | |
102 | else | |
103 | { | |
01b59e1e | 104 | #ifdef SNACLOGIN |
105 | /* new login code -- not default -- pending new password encryption algo */ | |
106 | aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0); | |
107 | aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0); | |
108 | ||
109 | aim_sendconnack(&aimsess, authconn); | |
110 | aim_request_login(&aimsess, authconn, FAIMTEST_SCREENNAME); | |
111 | #else | |
112 | aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_AUTHSUCCESS, faimtest_parse_authresp, 0); | |
397055b1 | 113 | aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_authsvrready, 0); |
26af6789 | 114 | aim_send_login(&aimsess, authconn, screenname, password, &info); |
01b59e1e | 115 | |
116 | #endif | |
9de3ca7e | 117 | } |
118 | ||
397055b1 | 119 | while (aim_select(&aimsess, NULL) > (struct aim_conn_t *)0) |
9de3ca7e | 120 | { |
397055b1 | 121 | if (aimsess.queue_outgoing) |
122 | aim_tx_flushqueue(&aimsess); | |
9de3ca7e | 123 | |
397055b1 | 124 | if (aim_get_command(&aimsess) < 0) |
9de3ca7e | 125 | { |
126 | printf("\afaimtest: connection error!\n"); | |
127 | } | |
128 | else | |
397055b1 | 129 | aim_rxdispatch(&aimsess); |
9de3ca7e | 130 | } |
131 | ||
132 | /* Close up */ | |
133 | printf("AIM just decided we didn't need to be here anymore, closing up.,,\n"); | |
134 | ||
135 | /* close up all connections, dead or no */ | |
397055b1 | 136 | aim_logoff(&aimsess); |
9de3ca7e | 137 | |
138 | if (stayconnected) | |
139 | { | |
140 | printf("\nTrying to reconnect in 2 seconds...\n"); | |
141 | sleep(2); | |
142 | goto enter; | |
143 | } | |
144 | ||
145 | /* Get out */ | |
146 | exit(0); | |
147 | } | |
148 | ||
397055b1 | 149 | int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 150 | { |
151 | switch (command->conn->type) | |
152 | { | |
153 | case AIM_CONN_TYPE_BOS: | |
26af6789 | 154 | |
397055b1 | 155 | aim_bos_reqrate(sess, command->conn); /* request rate info */ |
156 | aim_bos_ackrateresp(sess, command->conn); /* ack rate info response -- can we say timing? */ | |
157 | aim_bos_setprivacyflags(sess, command->conn, 0x00000003); | |
9de3ca7e | 158 | |
159 | #if 0 | |
397055b1 | 160 | aim_bos_reqpersonalinfo(sess, command->conn); |
9de3ca7e | 161 | #endif |
162 | ||
397055b1 | 163 | /* Request advertisement service -- see comment in handleredirect */ |
164 | aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS); | |
01b59e1e | 165 | aim_setversions(sess, command->conn); |
9de3ca7e | 166 | |
167 | #if 0 | |
397055b1 | 168 | aim_bos_reqrights(sess, command->conn); |
169 | aim_bos_reqbuddyrights(sess, command->conn); | |
170 | aim_bos_reqlocaterights(sess, command->conn); | |
171 | aim_bos_reqicbmparaminfo(sess, command->conn); | |
9de3ca7e | 172 | #endif |
173 | ||
174 | /* set group permissions */ | |
397055b1 | 175 | aim_bos_setgroupperm(sess, command->conn, 0x1f); |
9de3ca7e | 176 | fprintf(stderr, "faimtest: done with BOS ServerReady\n"); |
177 | break; | |
178 | case AIM_CONN_TYPE_CHATNAV: | |
179 | fprintf(stderr, "faimtest: chatnav: got server ready\n"); | |
180 | break; | |
181 | default: | |
182 | fprintf(stderr, "faimtest: unknown connection type on Server Ready\n"); | |
183 | } | |
184 | return 1; | |
185 | } | |
186 | ||
187 | /* | |
188 | handleredirect()... | |
189 | ||
190 | This, of course, handles Service Redirects from OSCAR. | |
191 | ||
192 | Should get passed in the following: | |
193 | struct command_rx_struct *command | |
194 | the raw command data | |
195 | int serviceid | |
196 | the destination service ID | |
197 | char *serverip | |
198 | the IP address of the service's server | |
199 | char *cookie | |
200 | the raw auth cookie | |
201 | */ | |
397055b1 | 202 | int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 203 | { |
204 | va_list ap; | |
205 | int serviceid; | |
206 | char *ip; | |
207 | char *cookie; | |
208 | ||
209 | /* this is the new buddy list */ | |
210 | char buddies[] = "Buddy1&Buddy2&"; | |
211 | /* this is the new profile */ | |
212 | char profile[] = "Hello"; | |
213 | ||
214 | va_start(ap, command); | |
215 | serviceid = va_arg(ap, int); | |
216 | ip = va_arg(ap, char *); | |
217 | cookie = va_arg(ap, char *); | |
218 | va_end(ap); | |
219 | ||
220 | switch(serviceid) | |
221 | { | |
222 | case 0x0005: /* Advertisements */ | |
223 | /* | |
224 | * The craziest explanation yet as to why we finish logging in when | |
225 | * we get the advertisements redirect, of which we don't use anyway.... | |
226 | * IT WAS EASY! | |
227 | */ | |
228 | ||
229 | /* send the buddy list and profile (required, even if empty) */ | |
397055b1 | 230 | aim_bos_setbuddylist(sess, command->conn, buddies); |
231 | aim_bos_setprofile(sess, command->conn, profile); | |
9de3ca7e | 232 | |
233 | /* send final login command (required) */ | |
397055b1 | 234 | aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */ |
9de3ca7e | 235 | |
236 | /* you should now be ready to go */ | |
397055b1 | 237 | printf("\nYou are now officially online.\n"); |
9de3ca7e | 238 | |
239 | break; | |
240 | case 0x0007: /* Authorizer */ | |
241 | { | |
242 | struct aim_conn_t *tstconn; | |
243 | /* Open a connection to the Auth */ | |
397055b1 | 244 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); |
9de3ca7e | 245 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) ) |
246 | fprintf(stderr, "faimtest: unable to reconnect with authorizer\n"); | |
247 | else | |
248 | /* Send the cookie to the Auth */ | |
397055b1 | 249 | aim_auth_sendcookie(sess, tstconn, cookie); |
9de3ca7e | 250 | |
251 | } | |
252 | break; | |
253 | case 0x000d: /* ChatNav */ | |
254 | { | |
255 | struct aim_conn_t *tstconn = NULL; | |
397055b1 | 256 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); |
9de3ca7e | 257 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) |
258 | { | |
259 | fprintf(stderr, "faimtest: unable to connect to chatnav server\n"); | |
260 | return 1; | |
261 | } | |
397055b1 | 262 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); |
263 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | |
264 | aim_auth_sendcookie(sess, tstconn, cookie); | |
9de3ca7e | 265 | fprintf(stderr, "\achatnav: connected\n"); |
266 | } | |
267 | break; | |
268 | case 0x000e: /* Chat */ | |
269 | { | |
270 | #if 0 | |
271 | struct aim_conn_t *tstconn = NULL; | |
397055b1 | 272 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); |
9de3ca7e | 273 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) |
274 | { | |
275 | fprintf(stderr, "faimtest: unable to connect to chat server\n"); | |
276 | return 1; | |
277 | } | |
397055b1 | 278 | aim_auth_sendcookie(sess, aim_getconn_type(sess, AIM_CONN_TYPE_CHAT), cookie); |
9de3ca7e | 279 | fprintf(stderr, "\achat: connected\n"); |
280 | #endif | |
281 | } | |
282 | break; | |
283 | default: | |
284 | printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid); | |
285 | /* dunno */ | |
286 | } | |
287 | ||
288 | return 1; | |
289 | } | |
290 | ||
01b59e1e | 291 | #if 0 |
397055b1 | 292 | int faimtest_auth_error(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 293 | { |
294 | va_list ap; | |
9de3ca7e | 295 | char *errorurl; |
296 | short errorcode; | |
297 | ||
298 | va_start(ap, command); | |
397055b1 | 299 | printf("Screen name: %s\n", sess->logininfo.screen_name); |
9de3ca7e | 300 | errorurl = va_arg(ap, char *); |
301 | printf("Error URL: %s\n", errorurl); | |
302 | errorcode = va_arg(ap, short); | |
303 | printf("Error code: 0x%02x\n", errorcode); | |
304 | va_end(ap); | |
305 | ||
397055b1 | 306 | aim_conn_close(aim_getconn_type(sess, AIM_CONN_TYPE_AUTH)); |
9de3ca7e | 307 | exit(0); |
308 | ||
309 | return 0; | |
310 | } | |
01b59e1e | 311 | #endif |
9de3ca7e | 312 | |
01b59e1e | 313 | int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 314 | { |
9de3ca7e | 315 | struct aim_conn_t *bosconn = NULL; |
9de3ca7e | 316 | |
01b59e1e | 317 | |
397055b1 | 318 | printf("Screen name: %s\n", sess->logininfo.screen_name); |
01b59e1e | 319 | |
320 | /* | |
321 | * Check for error. | |
322 | */ | |
323 | if (sess->logininfo.errorcode) | |
324 | { | |
325 | printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode); | |
326 | printf("Error URL: %s\n", sess->logininfo.errorurl); | |
327 | aim_conn_close(command->conn); | |
328 | exit(0); /* XXX: should return in order to let the above things get free()'d. */ | |
329 | } | |
330 | ||
397055b1 | 331 | printf("Reg status: %2d\n", sess->logininfo.regstatus); |
332 | printf("Email: %s\n", sess->logininfo.email); | |
397055b1 | 333 | printf("BOS IP: %s\n", sess->logininfo.BOSIP); |
9de3ca7e | 334 | |
335 | printf("Closing auth connection...\n"); | |
336 | aim_conn_close(command->conn); | |
397055b1 | 337 | bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP); |
9de3ca7e | 338 | if (bosconn == NULL) |
339 | { | |
340 | fprintf(stderr, "faimtest: could not connect to BOS: internal error\n"); | |
341 | } | |
342 | else if (bosconn->status != 0) | |
343 | { | |
344 | fprintf(stderr, "faimtest: could not connect to BOS\n"); | |
345 | } | |
346 | else | |
347 | { | |
397055b1 | 348 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); |
349 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0); | |
350 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0); | |
351 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0); | |
397055b1 | 352 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, NULL, 0); |
353 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0); | |
354 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0); | |
355 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); | |
356 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0); | |
357 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0); | |
358 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0); | |
359 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0); | |
360 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0); | |
361 | ||
362 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); | |
363 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | |
01b59e1e | 364 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0); |
397055b1 | 365 | aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie); |
9de3ca7e | 366 | } |
367 | return 1; | |
368 | } | |
369 | ||
397055b1 | 370 | int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 371 | { |
372 | struct aim_userinfo_s *userinfo; | |
373 | char *prof_encoding = NULL; | |
374 | char *prof = NULL; | |
375 | ||
376 | va_list ap; | |
377 | va_start(ap, command); | |
378 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
379 | prof_encoding = va_arg(ap, char *); | |
380 | prof = va_arg(ap, char *); | |
381 | va_end(ap); | |
382 | ||
383 | printf("faimtest: userinfo: sn: %s\n", userinfo->sn); | |
384 | printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel); | |
385 | printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class); | |
386 | ||
387 | /* | |
388 | * 00000000 (binary) | |
389 | * 1 Trial | |
390 | * 2 Unknown | |
391 | * 3 AOL | |
392 | * 4 Unknown | |
393 | * 5 Free | |
394 | * | |
395 | * ORed together. | |
396 | * | |
397 | */ | |
398 | ||
399 | if (userinfo->class & 0x0001) | |
400 | printf("TRIAL "); | |
401 | if (userinfo->class & 0x0002) | |
402 | printf("UNKNOWN_BIT2 "); | |
403 | if (userinfo->class & 0x0004) | |
404 | printf("AOL "); | |
405 | if (userinfo->class & 0x0008) | |
406 | printf("UNKNOWN_BIT4 "); | |
407 | if (userinfo->class & 0x0010) | |
408 | printf("FREE "); | |
409 | printf("\n"); | |
410 | ||
411 | printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince); | |
412 | printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince); | |
413 | printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime); | |
414 | ||
415 | printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); | |
416 | printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]"); | |
417 | ||
418 | return 1; | |
419 | } | |
420 | ||
421 | /* | |
422 | * The user-level Incoming ICBM callback. | |
423 | * | |
424 | * Arguments: | |
425 | * struct command_rx_struct * command if you feel like doing it yourself | |
426 | * char * srcsn the source name | |
427 | * char * msg message | |
428 | * int warnlevel warning/evil level | |
429 | * int class user class | |
430 | * ulong membersince time_t of date of signup | |
431 | * ulong onsince time_t of date of singon | |
432 | * int idletime min (sec?) idle | |
24286d93 | 433 | * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK} |
9de3ca7e | 434 | * |
435 | */ | |
397055b1 | 436 | int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 437 | { |
26af6789 | 438 | int channel; |
9de3ca7e | 439 | va_list ap; |
9de3ca7e | 440 | |
441 | va_start(ap, command); | |
26af6789 | 442 | channel = va_arg(ap, int); |
9de3ca7e | 443 | |
26af6789 | 444 | /* |
445 | * Channel 1: Standard Message | |
446 | */ | |
447 | if (channel == 1) | |
9de3ca7e | 448 | { |
26af6789 | 449 | struct aim_userinfo_s *userinfo; |
450 | char *msg = NULL; | |
451 | u_int icbmflags = 0; | |
452 | char *tmpstr = NULL; | |
453 | u_short flag1, flag2; | |
454 | ||
455 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
456 | msg = va_arg(ap, char *); | |
457 | icbmflags = va_arg(ap, u_int); | |
458 | flag1 = va_arg(ap, u_short); | |
459 | flag2 = va_arg(ap, u_short); | |
460 | va_end(ap); | |
9de3ca7e | 461 | |
26af6789 | 462 | printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn); |
463 | printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel); | |
464 | printf("faimtest: icbm: class = 0x%04x ", userinfo->class); | |
465 | if (userinfo->class & 0x0010) | |
466 | printf("(FREE) "); | |
467 | if (userinfo->class & 0x0001) | |
468 | printf("(TRIAL) "); | |
469 | if (userinfo->class & 0x0004) | |
470 | printf("(AOL) "); | |
471 | printf("\n"); | |
472 | printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince); | |
473 | printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince); | |
474 | printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime); | |
475 | ||
476 | printf("faimtest: icbm: icbmflags = "); | |
477 | if (icbmflags & AIM_IMFLAGS_AWAY) | |
478 | printf("away "); | |
479 | if (icbmflags & AIM_IMFLAGS_ACK) | |
480 | printf("ackrequest "); | |
481 | printf("\n"); | |
482 | ||
483 | printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2); | |
484 | ||
485 | printf("faimtest: icbm: message: %s\n", msg); | |
486 | ||
487 | if (msg) | |
9de3ca7e | 488 | { |
26af6789 | 489 | tmpstr = index(msg, '>'); |
490 | if (tmpstr != NULL) | |
491 | tmpstr+=1; | |
492 | else | |
493 | tmpstr = msg; | |
494 | ||
495 | if ( (strlen(tmpstr) >= 10) && | |
496 | (!strncmp(tmpstr, "disconnect", 10)) ) | |
497 | { | |
498 | aim_send_im(sess, command->conn, "midendian", 0, "ta ta..."); | |
499 | aim_logoff(sess); | |
500 | } | |
501 | else if (strstr(tmpstr, "goodday")) | |
502 | { | |
503 | printf("faimtest: icbm: sending response\n"); | |
504 | aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too."); | |
505 | } | |
9de3ca7e | 506 | #if 0 |
26af6789 | 507 | else if (!strncmp(tmpstr, "joinchat", 8)) |
508 | { | |
509 | aim_chat_join(sess, command->conn, "GoodDay"); | |
510 | } | |
9de3ca7e | 511 | #endif |
26af6789 | 512 | else |
513 | { | |
9de3ca7e | 514 | #if 0 |
26af6789 | 515 | printf("faimtest: icbm: starting chat...\n"); |
516 | aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
9de3ca7e | 517 | #else |
26af6789 | 518 | aim_bos_setidle(sess, command->conn, 0x0ffffffe); |
9de3ca7e | 519 | #endif |
26af6789 | 520 | } |
521 | ||
9de3ca7e | 522 | } |
9de3ca7e | 523 | } |
26af6789 | 524 | /* |
525 | * Channel 2: Chat Invitation | |
526 | */ | |
527 | else if (channel == 2) | |
528 | { | |
529 | struct aim_userinfo_s *userinfo; | |
530 | char *roomname,*msg,*encoding,*lang; | |
531 | u_short exchange, instance; | |
532 | ||
533 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
534 | roomname = va_arg(ap, char *); | |
535 | msg = va_arg(ap, char *); | |
536 | encoding = va_arg(ap, char *); | |
537 | lang = va_arg(ap, char *); | |
538 | exchange = va_arg(ap, u_short); | |
539 | instance = va_arg(ap, u_short); | |
540 | va_end(ap); | |
541 | ||
542 | printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn); | |
543 | printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel); | |
544 | printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class); | |
545 | if (userinfo->class & 0x0010) | |
546 | printf("(FREE) "); | |
547 | if (userinfo->class & 0x0001) | |
548 | printf("(TRIAL) "); | |
549 | if (userinfo->class & 0x0004) | |
550 | printf("(AOL) "); | |
551 | printf("\n"); | |
552 | /* we dont get membersince on chat invites! */ | |
553 | printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince); | |
554 | printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime); | |
555 | ||
556 | printf("faimtest: chat invitation: message = %s\n", msg); | |
557 | printf("faimtest: chat invitation: room name = %s\n", roomname); | |
558 | printf("faimtest: chat invitation: encoding = %s\n", encoding); | |
559 | printf("faimtest: chat invitation: language = %s\n", lang); | |
560 | printf("faimtest: chat invitation: exchange = 0x%04x\n", exchange); | |
561 | printf("faimtest: chat invitation: instance = 0x%04x\n", instance); | |
562 | } | |
563 | else | |
564 | printf("faimtest does not support channels > 2 (chan = %02x)\n", channel); | |
9de3ca7e | 565 | printf("faimtest: icbm: done with ICBM handling\n"); |
566 | ||
567 | return 1; | |
568 | } | |
569 | ||
397055b1 | 570 | int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 571 | { |
572 | printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type); | |
573 | sleep(10); | |
574 | /* should just be able to tell it we're ready too... */ | |
397055b1 | 575 | aim_auth_clientready(sess, command->conn); |
9de3ca7e | 576 | |
577 | #if 0 | |
578 | /* | |
579 | * This is where you'd really begin changing your password. | |
580 | * However, this callback may get called for reasons other | |
581 | * than you wanting to change your password. You should | |
582 | * probably check that before actually doing it. | |
583 | */ | |
397055b1 | 584 | aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2"); |
9de3ca7e | 585 | #endif |
586 | ||
587 | return 1; | |
588 | } | |
589 | ||
397055b1 | 590 | int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 591 | { |
592 | printf("PASSWORD CHANGE SUCCESSFUL!!!\n"); | |
593 | return 1; | |
594 | } | |
595 | ||
397055b1 | 596 | int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 597 | { |
598 | struct aim_userinfo_s *userinfo; | |
599 | ||
600 | va_list ap; | |
601 | va_start(ap, command); | |
602 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
603 | va_end(ap); | |
604 | ||
605 | printf("\n%s is now online\n", userinfo->sn); | |
606 | ||
607 | return 1; | |
608 | } | |
609 | ||
397055b1 | 610 | int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 611 | { |
397055b1 | 612 | char *sn; |
613 | va_list ap; | |
614 | ||
615 | va_start(ap, command); | |
616 | sn = va_arg(ap, char *); | |
617 | va_end(ap); | |
9de3ca7e | 618 | |
397055b1 | 619 | printf("\n%s has left\n", sn); |
9de3ca7e | 620 | |
621 | return 1; | |
622 | } | |
623 | ||
01b59e1e | 624 | int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
625 | { | |
626 | char *msg; | |
627 | u_short id; | |
628 | va_list ap; | |
629 | ||
630 | va_start(ap, command); | |
631 | id = va_arg(ap, u_short); | |
632 | msg = va_arg(ap, char *); | |
633 | va_end(ap); | |
634 | ||
635 | printf("faimtest: motd: %s\n", msg); | |
636 | ||
637 | return 1; | |
638 | } | |
9de3ca7e | 639 | |
640 | /* | |
641 | * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR, | |
642 | * AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL. | |
643 | */ | |
397055b1 | 644 | int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 645 | { |
646 | u_short family; | |
647 | u_short subtype; | |
648 | ||
397055b1 | 649 | family = aimutil_get16(command->data+0); |
650 | subtype= aimutil_get16(command->data+2); | |
9de3ca7e | 651 | |
652 | switch (family) | |
653 | { | |
654 | case 0x0001: | |
655 | if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */ | |
656 | printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n"); | |
657 | break; | |
658 | case 0x0002: | |
659 | if (subtype == 0x0001) /* or AIM_CB_USERERROR */ | |
660 | { | |
661 | u_long snacid = 0x00000000; | |
662 | ||
663 | snacid = aimutil_get32(&command->data[6]); | |
664 | ||
665 | printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid); | |
666 | } | |
667 | break; | |
668 | case 0x0004: | |
669 | if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */ | |
670 | printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n"); | |
671 | else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */ | |
672 | printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13])); | |
673 | break; | |
674 | } | |
675 | ||
676 | return 0; | |
677 | } | |
678 | ||
01b59e1e | 679 | #ifdef SNACLOGIN |
680 | int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
681 | { | |
682 | struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"}; | |
683 | u_char authcookie[11]; | |
684 | int i; | |
685 | ||
686 | for (i = 0; i < (int)command->data[11]; i++) | |
687 | authcookie[i] = command->data[12+i]; | |
688 | authcookie[i] = '\0'; | |
9de3ca7e | 689 | |
01b59e1e | 690 | printf("faimtest: logincookie: %s\n", authcookie); |
691 | ||
692 | aim_send_login(sess, command->conn, FAIMTEST_SCREENNAME, FAIMTEST_PASSWORD, &info); | |
693 | ||
694 | return 1; | |
695 | } | |
696 | #endif |