]>
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, ...); | |
01b59e1e | 60 | int faimtest_parse_motd(struct aim_session_t *, struct command_rx_struct *command, ...); |
61 | int faimtest_parse_login(struct aim_session_t *, struct command_rx_struct *command, ...); | |
0c20631f | 62 | int faimtest_chatnav_info(struct aim_session_t *, struct command_rx_struct *command, ...); |
63 | int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...); | |
64 | int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...); | |
65 | int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...); | |
66 | int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...); | |
49c8a2fa | 67 | |
26af6789 | 68 | static char *screenname,*password; |
69 | ||
9de3ca7e | 70 | int main(void) |
71 | { | |
397055b1 | 72 | struct aim_session_t aimsess; |
9de3ca7e | 73 | struct aim_conn_t *authconn = NULL; |
74 | int stayconnected = 1; | |
01b59e1e | 75 | struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"}; |
76 | ||
397055b1 | 77 | aim_session_init(&aimsess); |
9de3ca7e | 78 | |
26af6789 | 79 | if ( !(screenname = getenv("SCREENNAME")) || |
80 | !(password = getenv("PASSWORD"))) | |
81 | { | |
82 | printf("Must specify SCREENAME and PASSWORD in environment.\n"); | |
83 | return -1; | |
84 | } | |
85 | ||
397055b1 | 86 | /* |
87 | * (I used a goto-based loop here because n wanted quick proof | |
88 | * that reconnecting without restarting was actually possible...) | |
89 | */ | |
9de3ca7e | 90 | enter: |
01b59e1e | 91 | authconn = aim_newconn(&aimsess, AIM_CONN_TYPE_AUTH, FAIM_LOGIN_SERVER); |
397055b1 | 92 | |
9de3ca7e | 93 | if (authconn == NULL) |
94 | { | |
95 | fprintf(stderr, "faimtest: internal connection error while in aim_login. bailing out.\n"); | |
96 | return -1; | |
97 | } | |
98 | else if (authconn->fd == -1) | |
99 | { | |
100 | if (authconn->status & AIM_CONN_STATUS_RESOLVERR) | |
101 | fprintf(stderr, "faimtest: could not resolve authorizer name\n"); | |
102 | else if (authconn->status & AIM_CONN_STATUS_CONNERR) | |
103 | fprintf(stderr, "faimtest: could not connect to authorizer\n"); | |
104 | return -1; | |
105 | } | |
106 | else | |
107 | { | |
01b59e1e | 108 | #ifdef SNACLOGIN |
109 | /* new login code -- not default -- pending new password encryption algo */ | |
110 | aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0007, faimtest_parse_login, 0); | |
111 | aim_conn_addhandler(&aimsess, authconn, 0x0017, 0x0003, faimtest_parse_authresp, 0); | |
112 | ||
113 | aim_sendconnack(&aimsess, authconn); | |
114 | aim_request_login(&aimsess, authconn, FAIMTEST_SCREENNAME); | |
115 | #else | |
116 | aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_AUTHSUCCESS, faimtest_parse_authresp, 0); | |
397055b1 | 117 | aim_conn_addhandler(&aimsess, authconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_authsvrready, 0); |
26af6789 | 118 | aim_send_login(&aimsess, authconn, screenname, password, &info); |
01b59e1e | 119 | |
120 | #endif | |
9de3ca7e | 121 | } |
122 | ||
397055b1 | 123 | while (aim_select(&aimsess, NULL) > (struct aim_conn_t *)0) |
9de3ca7e | 124 | { |
397055b1 | 125 | if (aimsess.queue_outgoing) |
126 | aim_tx_flushqueue(&aimsess); | |
9de3ca7e | 127 | |
397055b1 | 128 | if (aim_get_command(&aimsess) < 0) |
9de3ca7e | 129 | { |
130 | printf("\afaimtest: connection error!\n"); | |
131 | } | |
132 | else | |
397055b1 | 133 | aim_rxdispatch(&aimsess); |
9de3ca7e | 134 | } |
135 | ||
136 | /* Close up */ | |
137 | printf("AIM just decided we didn't need to be here anymore, closing up.,,\n"); | |
138 | ||
139 | /* close up all connections, dead or no */ | |
397055b1 | 140 | aim_logoff(&aimsess); |
9de3ca7e | 141 | |
142 | if (stayconnected) | |
143 | { | |
144 | printf("\nTrying to reconnect in 2 seconds...\n"); | |
145 | sleep(2); | |
146 | goto enter; | |
147 | } | |
148 | ||
149 | /* Get out */ | |
150 | exit(0); | |
151 | } | |
152 | ||
397055b1 | 153 | int faimtest_serverready(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 154 | { |
155 | switch (command->conn->type) | |
156 | { | |
157 | case AIM_CONN_TYPE_BOS: | |
26af6789 | 158 | |
397055b1 | 159 | aim_bos_reqrate(sess, command->conn); /* request rate info */ |
160 | aim_bos_ackrateresp(sess, command->conn); /* ack rate info response -- can we say timing? */ | |
161 | aim_bos_setprivacyflags(sess, command->conn, 0x00000003); | |
9de3ca7e | 162 | |
163 | #if 0 | |
397055b1 | 164 | aim_bos_reqpersonalinfo(sess, command->conn); |
9de3ca7e | 165 | #endif |
166 | ||
397055b1 | 167 | /* Request advertisement service -- see comment in handleredirect */ |
168 | aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS); | |
01b59e1e | 169 | aim_setversions(sess, command->conn); |
9de3ca7e | 170 | |
171 | #if 0 | |
397055b1 | 172 | aim_bos_reqrights(sess, command->conn); |
173 | aim_bos_reqbuddyrights(sess, command->conn); | |
174 | aim_bos_reqlocaterights(sess, command->conn); | |
175 | aim_bos_reqicbmparaminfo(sess, command->conn); | |
9de3ca7e | 176 | #endif |
177 | ||
178 | /* set group permissions */ | |
397055b1 | 179 | aim_bos_setgroupperm(sess, command->conn, 0x1f); |
9de3ca7e | 180 | fprintf(stderr, "faimtest: done with BOS ServerReady\n"); |
181 | break; | |
0c20631f | 182 | |
9de3ca7e | 183 | case AIM_CONN_TYPE_CHATNAV: |
184 | fprintf(stderr, "faimtest: chatnav: got server ready\n"); | |
0c20631f | 185 | aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, faimtest_chatnav_info, 0); |
186 | aim_bos_reqrate(sess, command->conn); | |
187 | aim_bos_ackrateresp(sess, command->conn); | |
188 | aim_chatnav_clientready(sess, command->conn); | |
189 | aim_chatnav_reqrights(sess, command->conn); | |
190 | ||
191 | break; | |
192 | case AIM_CONN_TYPE_CHAT: | |
193 | aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0); | |
194 | aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0); | |
195 | aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0); | |
196 | aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0); | |
197 | aim_bos_reqrate(sess, command->conn); | |
198 | aim_bos_ackrateresp(sess, command->conn); | |
199 | aim_chat_clientready(sess, command->conn); | |
9de3ca7e | 200 | break; |
201 | default: | |
202 | fprintf(stderr, "faimtest: unknown connection type on Server Ready\n"); | |
203 | } | |
204 | return 1; | |
205 | } | |
206 | ||
207 | /* | |
208 | handleredirect()... | |
209 | ||
210 | This, of course, handles Service Redirects from OSCAR. | |
211 | ||
212 | Should get passed in the following: | |
213 | struct command_rx_struct *command | |
214 | the raw command data | |
215 | int serviceid | |
216 | the destination service ID | |
217 | char *serverip | |
218 | the IP address of the service's server | |
219 | char *cookie | |
220 | the raw auth cookie | |
221 | */ | |
397055b1 | 222 | int faimtest_handleredirect(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 223 | { |
224 | va_list ap; | |
225 | int serviceid; | |
226 | char *ip; | |
227 | char *cookie; | |
228 | ||
229 | /* this is the new buddy list */ | |
0c20631f | 230 | char buddies[] = "Buddy1&Buddy2&ThisHereIsAName2&"; |
9de3ca7e | 231 | /* this is the new profile */ |
232 | char profile[] = "Hello"; | |
233 | ||
234 | va_start(ap, command); | |
235 | serviceid = va_arg(ap, int); | |
236 | ip = va_arg(ap, char *); | |
237 | cookie = va_arg(ap, char *); | |
0c20631f | 238 | |
9de3ca7e | 239 | switch(serviceid) |
240 | { | |
241 | case 0x0005: /* Advertisements */ | |
242 | /* | |
243 | * The craziest explanation yet as to why we finish logging in when | |
244 | * we get the advertisements redirect, of which we don't use anyway.... | |
245 | * IT WAS EASY! | |
246 | */ | |
247 | ||
248 | /* send the buddy list and profile (required, even if empty) */ | |
397055b1 | 249 | aim_bos_setbuddylist(sess, command->conn, buddies); |
0c20631f | 250 | aim_bos_setprofile(sess, command->conn, profile, NULL); |
9de3ca7e | 251 | |
252 | /* send final login command (required) */ | |
397055b1 | 253 | aim_bos_clientready(sess, command->conn); /* tell BOS we're ready to go live */ |
9de3ca7e | 254 | |
255 | /* you should now be ready to go */ | |
397055b1 | 256 | printf("\nYou are now officially online.\n"); |
9de3ca7e | 257 | |
258 | break; | |
259 | case 0x0007: /* Authorizer */ | |
260 | { | |
261 | struct aim_conn_t *tstconn; | |
262 | /* Open a connection to the Auth */ | |
397055b1 | 263 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); |
9de3ca7e | 264 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR) ) |
265 | fprintf(stderr, "faimtest: unable to reconnect with authorizer\n"); | |
266 | else | |
267 | /* Send the cookie to the Auth */ | |
397055b1 | 268 | aim_auth_sendcookie(sess, tstconn, cookie); |
9de3ca7e | 269 | |
270 | } | |
271 | break; | |
272 | case 0x000d: /* ChatNav */ | |
273 | { | |
274 | struct aim_conn_t *tstconn = NULL; | |
397055b1 | 275 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); |
9de3ca7e | 276 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) |
277 | { | |
278 | fprintf(stderr, "faimtest: unable to connect to chatnav server\n"); | |
279 | return 1; | |
280 | } | |
0c20631f | 281 | #if 0 |
397055b1 | 282 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_CTN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); |
283 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_GEN, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | |
0c20631f | 284 | #endif |
285 | aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); | |
397055b1 | 286 | aim_auth_sendcookie(sess, tstconn, cookie); |
9de3ca7e | 287 | fprintf(stderr, "\achatnav: connected\n"); |
288 | } | |
289 | break; | |
290 | case 0x000e: /* Chat */ | |
291 | { | |
0c20631f | 292 | char *roomname = NULL; |
9de3ca7e | 293 | struct aim_conn_t *tstconn = NULL; |
0c20631f | 294 | |
295 | roomname = va_arg(ap, char *); | |
296 | ||
397055b1 | 297 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); |
9de3ca7e | 298 | if ( (tstconn==NULL) || (tstconn->status >= AIM_CONN_STATUS_RESOLVERR)) |
299 | { | |
300 | fprintf(stderr, "faimtest: unable to connect to chat server\n"); | |
301 | return 1; | |
0c20631f | 302 | } |
303 | printf("faimtest: chat: connected\n"); | |
304 | ||
305 | /* | |
306 | * We must do this to attach the stored name to the connection! | |
307 | */ | |
308 | aim_chat_attachname(tstconn, roomname); | |
309 | ||
310 | aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, faimtest_serverready, 0); | |
311 | aim_auth_sendcookie(sess, tstconn, cookie); | |
9de3ca7e | 312 | } |
313 | break; | |
314 | default: | |
315 | printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid); | |
316 | /* dunno */ | |
317 | } | |
318 | ||
9de3ca7e | 319 | va_end(ap); |
320 | ||
0c20631f | 321 | return 1; |
9de3ca7e | 322 | } |
323 | ||
01b59e1e | 324 | int faimtest_parse_authresp(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 325 | { |
9de3ca7e | 326 | struct aim_conn_t *bosconn = NULL; |
9de3ca7e | 327 | |
01b59e1e | 328 | |
397055b1 | 329 | printf("Screen name: %s\n", sess->logininfo.screen_name); |
01b59e1e | 330 | |
331 | /* | |
332 | * Check for error. | |
333 | */ | |
334 | if (sess->logininfo.errorcode) | |
335 | { | |
336 | printf("Login Error Code 0x%04x\n", sess->logininfo.errorcode); | |
337 | printf("Error URL: %s\n", sess->logininfo.errorurl); | |
338 | aim_conn_close(command->conn); | |
339 | exit(0); /* XXX: should return in order to let the above things get free()'d. */ | |
340 | } | |
341 | ||
397055b1 | 342 | printf("Reg status: %2d\n", sess->logininfo.regstatus); |
343 | printf("Email: %s\n", sess->logininfo.email); | |
397055b1 | 344 | printf("BOS IP: %s\n", sess->logininfo.BOSIP); |
9de3ca7e | 345 | |
346 | printf("Closing auth connection...\n"); | |
347 | aim_conn_close(command->conn); | |
397055b1 | 348 | bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP); |
9de3ca7e | 349 | if (bosconn == NULL) |
350 | { | |
351 | fprintf(stderr, "faimtest: could not connect to BOS: internal error\n"); | |
352 | } | |
353 | else if (bosconn->status != 0) | |
354 | { | |
355 | fprintf(stderr, "faimtest: could not connect to BOS\n"); | |
356 | } | |
357 | else | |
358 | { | |
397055b1 | 359 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); |
360 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, faimtest_serverready, 0); | |
361 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0); | |
362 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0); | |
397055b1 | 363 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, NULL, 0); |
364 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0); | |
365 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0); | |
366 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); | |
367 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_misses, 0); | |
368 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0); | |
369 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_misses, 0); | |
370 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_misses, 0); | |
371 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0); | |
372 | ||
373 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); | |
374 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | |
01b59e1e | 375 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0); |
397055b1 | 376 | aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie); |
9de3ca7e | 377 | } |
378 | return 1; | |
379 | } | |
380 | ||
397055b1 | 381 | int faimtest_parse_userinfo(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 382 | { |
383 | struct aim_userinfo_s *userinfo; | |
384 | char *prof_encoding = NULL; | |
385 | char *prof = NULL; | |
386 | ||
387 | va_list ap; | |
388 | va_start(ap, command); | |
389 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
390 | prof_encoding = va_arg(ap, char *); | |
391 | prof = va_arg(ap, char *); | |
392 | va_end(ap); | |
393 | ||
394 | printf("faimtest: userinfo: sn: %s\n", userinfo->sn); | |
395 | printf("faimtest: userinfo: warnlevel: 0x%04x\n", userinfo->warnlevel); | |
396 | printf("faimtest: userinfo: class: 0x%04x = ", userinfo->class); | |
397 | ||
398 | /* | |
399 | * 00000000 (binary) | |
400 | * 1 Trial | |
401 | * 2 Unknown | |
402 | * 3 AOL | |
403 | * 4 Unknown | |
404 | * 5 Free | |
405 | * | |
406 | * ORed together. | |
407 | * | |
408 | */ | |
409 | ||
410 | if (userinfo->class & 0x0001) | |
411 | printf("TRIAL "); | |
412 | if (userinfo->class & 0x0002) | |
413 | printf("UNKNOWN_BIT2 "); | |
414 | if (userinfo->class & 0x0004) | |
415 | printf("AOL "); | |
416 | if (userinfo->class & 0x0008) | |
417 | printf("UNKNOWN_BIT4 "); | |
418 | if (userinfo->class & 0x0010) | |
419 | printf("FREE "); | |
420 | printf("\n"); | |
421 | ||
422 | printf("faimtest: userinfo: membersince: %lu\n", userinfo->membersince); | |
423 | printf("faimtest: userinfo: onlinesince: %lu\n", userinfo->onlinesince); | |
424 | printf("faimtest: userinfo: idletime: 0x%04x\n", userinfo->idletime); | |
425 | ||
426 | printf("faimtest: userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); | |
427 | printf("faimtest: userinfo: prof: %s\n", prof ? prof : "[none]"); | |
428 | ||
429 | return 1; | |
430 | } | |
431 | ||
432 | /* | |
433 | * The user-level Incoming ICBM callback. | |
434 | * | |
435 | * Arguments: | |
436 | * struct command_rx_struct * command if you feel like doing it yourself | |
437 | * char * srcsn the source name | |
438 | * char * msg message | |
439 | * int warnlevel warning/evil level | |
440 | * int class user class | |
441 | * ulong membersince time_t of date of signup | |
442 | * ulong onsince time_t of date of singon | |
443 | * int idletime min (sec?) idle | |
24286d93 | 444 | * u_int icbmflags sets AIM_IMFLAGS_{AWAY,ACK} |
9de3ca7e | 445 | * |
446 | */ | |
397055b1 | 447 | int faimtest_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 448 | { |
26af6789 | 449 | int channel; |
9de3ca7e | 450 | va_list ap; |
9de3ca7e | 451 | |
452 | va_start(ap, command); | |
26af6789 | 453 | channel = va_arg(ap, int); |
9de3ca7e | 454 | |
26af6789 | 455 | /* |
456 | * Channel 1: Standard Message | |
457 | */ | |
458 | if (channel == 1) | |
9de3ca7e | 459 | { |
26af6789 | 460 | struct aim_userinfo_s *userinfo; |
461 | char *msg = NULL; | |
462 | u_int icbmflags = 0; | |
463 | char *tmpstr = NULL; | |
464 | u_short flag1, flag2; | |
465 | ||
466 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
467 | msg = va_arg(ap, char *); | |
468 | icbmflags = va_arg(ap, u_int); | |
469 | flag1 = va_arg(ap, u_short); | |
470 | flag2 = va_arg(ap, u_short); | |
471 | va_end(ap); | |
9de3ca7e | 472 | |
26af6789 | 473 | printf("faimtest: icbm: sn = \"%s\"\n", userinfo->sn); |
474 | printf("faimtest: icbm: warnlevel = 0x%04x\n", userinfo->warnlevel); | |
475 | printf("faimtest: icbm: class = 0x%04x ", userinfo->class); | |
476 | if (userinfo->class & 0x0010) | |
477 | printf("(FREE) "); | |
478 | if (userinfo->class & 0x0001) | |
479 | printf("(TRIAL) "); | |
480 | if (userinfo->class & 0x0004) | |
481 | printf("(AOL) "); | |
482 | printf("\n"); | |
483 | printf("faimtest: icbm: membersince = %lu\n", userinfo->membersince); | |
484 | printf("faimtest: icbm: onlinesince = %lu\n", userinfo->onlinesince); | |
485 | printf("faimtest: icbm: idletime = 0x%04x\n", userinfo->idletime); | |
486 | ||
487 | printf("faimtest: icbm: icbmflags = "); | |
488 | if (icbmflags & AIM_IMFLAGS_AWAY) | |
489 | printf("away "); | |
490 | if (icbmflags & AIM_IMFLAGS_ACK) | |
491 | printf("ackrequest "); | |
492 | printf("\n"); | |
493 | ||
494 | printf("faimtest: icbm: encoding flags = {%04x, %04x}\n", flag1, flag2); | |
495 | ||
496 | printf("faimtest: icbm: message: %s\n", msg); | |
497 | ||
498 | if (msg) | |
9de3ca7e | 499 | { |
26af6789 | 500 | tmpstr = index(msg, '>'); |
501 | if (tmpstr != NULL) | |
502 | tmpstr+=1; | |
503 | else | |
504 | tmpstr = msg; | |
505 | ||
506 | if ( (strlen(tmpstr) >= 10) && | |
507 | (!strncmp(tmpstr, "disconnect", 10)) ) | |
508 | { | |
509 | aim_send_im(sess, command->conn, "midendian", 0, "ta ta..."); | |
510 | aim_logoff(sess); | |
511 | } | |
512 | else if (strstr(tmpstr, "goodday")) | |
513 | { | |
514 | printf("faimtest: icbm: sending response\n"); | |
515 | aim_send_im(sess, command->conn, userinfo->sn, 0, "Good day to you too."); | |
516 | } | |
0c20631f | 517 | else if (!strncmp(tmpstr, "open chatnav", 12)) |
26af6789 | 518 | { |
0c20631f | 519 | aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); |
520 | //aim_chat_join(sess, command->conn, "thishereisaname2_chat85"); | |
26af6789 | 521 | } |
0c20631f | 522 | else if (!strncmp(tmpstr, "create", 6)) |
523 | { | |
524 | aim_chatnav_createroom(sess, aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), "WorldDomination", 0x0004); | |
525 | } | |
526 | else if (!strncmp(tmpstr, "close chatnav", 13)) | |
527 | aim_conn_close(aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV)); | |
528 | else if (!strncmp(tmpstr, "join", 4)) | |
529 | { | |
530 | aim_chat_join(sess, command->conn, 0x0004, "worlddomination"); | |
531 | } | |
532 | else if (!strncmp(tmpstr, "leave", 5)) | |
533 | aim_chat_leaveroom(sess, "worlddomination"); | |
26af6789 | 534 | else |
535 | { | |
9de3ca7e | 536 | #if 0 |
26af6789 | 537 | printf("faimtest: icbm: starting chat...\n"); |
538 | aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
9de3ca7e | 539 | #else |
26af6789 | 540 | aim_bos_setidle(sess, command->conn, 0x0ffffffe); |
9de3ca7e | 541 | #endif |
26af6789 | 542 | } |
543 | ||
9de3ca7e | 544 | } |
9de3ca7e | 545 | } |
26af6789 | 546 | /* |
0c20631f | 547 | * Channel 2: Rendevous Request |
26af6789 | 548 | */ |
549 | else if (channel == 2) | |
550 | { | |
551 | struct aim_userinfo_s *userinfo; | |
0c20631f | 552 | int rendtype = 0; |
26af6789 | 553 | |
0c20631f | 554 | rendtype = va_arg(ap, int); |
555 | if (rendtype == 0) | |
556 | { | |
557 | char *msg,*encoding,*lang; | |
558 | struct aim_chat_roominfo *roominfo; | |
559 | ||
560 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
561 | roominfo = va_arg(ap, struct aim_chat_roominfo *); | |
562 | msg = va_arg(ap, char *); | |
563 | encoding = va_arg(ap, char *); | |
564 | lang = va_arg(ap, char *); | |
565 | va_end(ap); | |
566 | ||
567 | printf("faimtest: chat invitation: source sn = %s\n", userinfo->sn); | |
568 | printf("faimtest: chat invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel); | |
569 | printf("faimtest: chat invitation: \tclass = 0x%04x ", userinfo->class); | |
570 | if (userinfo->class & 0x0010) | |
571 | printf("(FREE) "); | |
572 | if (userinfo->class & 0x0001) | |
573 | printf("(TRIAL) "); | |
574 | if (userinfo->class & 0x0004) | |
575 | printf("(AOL) "); | |
576 | printf("\n"); | |
577 | /* we dont get membersince on chat invites! */ | |
578 | printf("faimtest: chat invitation: \tonlinesince = %lu\n", userinfo->onlinesince); | |
579 | printf("faimtest: chat invitation: \tidletime = 0x%04x\n", userinfo->idletime); | |
580 | ||
581 | printf("faimtest: chat invitation: message = %s\n", msg); | |
582 | printf("faimtest: chat invitation: room name = %s\n", roominfo->name); | |
583 | printf("faimtest: chat invitation: encoding = %s\n", encoding); | |
584 | printf("faimtest: chat invitation: language = %s\n", lang); | |
585 | printf("faimtest: chat invitation: exchange = 0x%04x\n", roominfo->exchange); | |
586 | printf("faimtest: chat invitation: instance = 0x%04x\n", roominfo->instance); | |
587 | printf("faimtest: chat invitiation: autojoining %s...\n", roominfo->name); | |
588 | /* | |
589 | * Automatically join room... | |
590 | */ | |
591 | aim_chat_join(sess, command->conn, 0x0004, roominfo->name); | |
592 | } | |
593 | else if (rendtype == 1) | |
594 | { | |
595 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
596 | va_end(ap); | |
597 | ||
598 | printf("faimtest: voice invitation: source sn = %s\n", userinfo->sn); | |
599 | printf("faimtest: voice invitation: \twarnlevel = 0x%04x\n", userinfo->warnlevel); | |
600 | printf("faimtest: voice invitation: \tclass = 0x%04x ", userinfo->class); | |
601 | if (userinfo->class & 0x0010) | |
602 | printf("(FREE) "); | |
603 | if (userinfo->class & 0x0001) | |
604 | printf("(TRIAL) "); | |
605 | if (userinfo->class & 0x0004) | |
606 | printf("(AOL) "); | |
607 | printf("\n"); | |
608 | /* we dont get membersince on chat invites! */ | |
609 | printf("faimtest: voice invitation: \tonlinesince = %lu\n", userinfo->onlinesince); | |
610 | printf("faimtest: voice invitation: \tidletime = 0x%04x\n", userinfo->idletime); | |
611 | ||
612 | } | |
613 | else | |
614 | printf("faimtest: icbm: unknown rendtype (%d)\n", rendtype); | |
26af6789 | 615 | } |
616 | else | |
617 | printf("faimtest does not support channels > 2 (chan = %02x)\n", channel); | |
9de3ca7e | 618 | printf("faimtest: icbm: done with ICBM handling\n"); |
619 | ||
620 | return 1; | |
621 | } | |
622 | ||
397055b1 | 623 | int faimtest_authsvrready(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 624 | { |
625 | printf("faimtest_authsvrready: called (contype: %d)\n", command->conn->type); | |
626 | sleep(10); | |
627 | /* should just be able to tell it we're ready too... */ | |
397055b1 | 628 | aim_auth_clientready(sess, command->conn); |
9de3ca7e | 629 | |
630 | #if 0 | |
631 | /* | |
632 | * This is where you'd really begin changing your password. | |
633 | * However, this callback may get called for reasons other | |
634 | * than you wanting to change your password. You should | |
635 | * probably check that before actually doing it. | |
636 | */ | |
397055b1 | 637 | aim_auth_changepasswd(sess, command->conn, "PWD1", "PWD2"); |
9de3ca7e | 638 | #endif |
639 | ||
640 | return 1; | |
641 | } | |
642 | ||
397055b1 | 643 | int faimtest_pwdchngdone(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 644 | { |
645 | printf("PASSWORD CHANGE SUCCESSFUL!!!\n"); | |
646 | return 1; | |
647 | } | |
648 | ||
397055b1 | 649 | int faimtest_parse_oncoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 650 | { |
651 | struct aim_userinfo_s *userinfo; | |
652 | ||
653 | va_list ap; | |
654 | va_start(ap, command); | |
655 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
656 | va_end(ap); | |
657 | ||
0c20631f | 658 | printf("\n%s is now online (class: %04x = %s%s%s%s%s%s%s%s)\n", userinfo->sn, userinfo->class, |
659 | (userinfo->class&AIM_CLASS_TRIAL)?" TRIAL":"", | |
660 | (userinfo->class&AIM_CLASS_UNKNOWN2)?" UNKNOWN2":"", | |
661 | (userinfo->class&AIM_CLASS_AOL)?" AOL":"", | |
662 | (userinfo->class&AIM_CLASS_UNKNOWN4)?" UNKNOWN4":"", | |
663 | (userinfo->class&AIM_CLASS_FREE)?" FREE":"", | |
664 | (userinfo->class&AIM_CLASS_AWAY)?" AWAY":"", | |
665 | (userinfo->class&AIM_CLASS_UNKNOWN40)?" UNKNOWN40":"", | |
666 | (userinfo->class&AIM_CLASS_UNKNOWN80)?" UNKNOWN80":""); | |
9de3ca7e | 667 | |
668 | return 1; | |
669 | } | |
670 | ||
397055b1 | 671 | int faimtest_parse_offgoing(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 672 | { |
397055b1 | 673 | char *sn; |
674 | va_list ap; | |
675 | ||
676 | va_start(ap, command); | |
677 | sn = va_arg(ap, char *); | |
678 | va_end(ap); | |
9de3ca7e | 679 | |
397055b1 | 680 | printf("\n%s has left\n", sn); |
9de3ca7e | 681 | |
682 | return 1; | |
683 | } | |
684 | ||
01b59e1e | 685 | int faimtest_parse_motd(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
686 | { | |
687 | char *msg; | |
688 | u_short id; | |
689 | va_list ap; | |
690 | ||
691 | va_start(ap, command); | |
692 | id = va_arg(ap, u_short); | |
693 | msg = va_arg(ap, char *); | |
694 | va_end(ap); | |
695 | ||
696 | printf("faimtest: motd: %s\n", msg); | |
697 | ||
698 | return 1; | |
699 | } | |
9de3ca7e | 700 | |
701 | /* | |
702 | * Handles callbacks for: AIM_CB_RATECHANGE, AIM_CB_USERERROR, | |
703 | * AIM_CB_MISSED_IM, and AIM_CB_MISSED_CALL. | |
704 | */ | |
397055b1 | 705 | int faimtest_parse_misses(struct aim_session_t *sess, struct command_rx_struct *command, ...) |
9de3ca7e | 706 | { |
707 | u_short family; | |
708 | u_short subtype; | |
709 | ||
397055b1 | 710 | family = aimutil_get16(command->data+0); |
711 | subtype= aimutil_get16(command->data+2); | |
9de3ca7e | 712 | |
713 | switch (family) | |
714 | { | |
715 | case 0x0001: | |
716 | if (subtype == 0x000a) /* or AIM_CB_RATECHANGE */ | |
717 | printf("\n****STOP SENDING/RECIEVING MESSAGES SO FAST!****\n\n"); | |
718 | break; | |
719 | case 0x0002: | |
720 | if (subtype == 0x0001) /* or AIM_CB_USERERROR */ | |
721 | { | |
722 | u_long snacid = 0x00000000; | |
723 | ||
724 | snacid = aimutil_get32(&command->data[6]); | |
725 | ||
726 | printf("Received unknown error in SNAC family 0x0002 (snacid = %08lx)\n", snacid); | |
727 | } | |
728 | break; | |
729 | case 0x0004: | |
730 | if (subtype == 0x0001) /* or AIM_CB_MISSED_IM */ | |
731 | printf("\n***LAST IM DIDN\'T MAKE IT BECAUSE THE BUDDY IS NOT ONLINE***\n\n"); | |
732 | else if (subtype == 0x000a) /* or AIM_CB_MISSED_CALL */ | |
733 | printf("You missed some messages from %s because they were sent too fast\n", &(command->data[13])); | |
734 | break; | |
735 | } | |
736 | ||
737 | return 0; | |
738 | } | |
739 | ||
01b59e1e | 740 | #ifdef SNACLOGIN |
741 | int faimtest_parse_login(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
742 | { | |
743 | struct client_info_s info = {"FAIMtest (Hi guys!)", 3, 5, 1670, "us", "en"}; | |
744 | u_char authcookie[11]; | |
745 | int i; | |
746 | ||
747 | for (i = 0; i < (int)command->data[11]; i++) | |
748 | authcookie[i] = command->data[12+i]; | |
749 | authcookie[i] = '\0'; | |
9de3ca7e | 750 | |
01b59e1e | 751 | printf("faimtest: logincookie: %s\n", authcookie); |
752 | ||
753 | aim_send_login(sess, command->conn, FAIMTEST_SCREENNAME, FAIMTEST_PASSWORD, &info); | |
754 | ||
755 | return 1; | |
756 | } | |
757 | #endif | |
0c20631f | 758 | |
759 | int faimtest_chat_join(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
760 | { | |
761 | va_list ap; | |
762 | struct aim_userinfo_s *userinfo; | |
763 | int count = 0, i = 0; | |
764 | ||
765 | va_start(ap, command); | |
766 | count = va_arg(ap, int); | |
767 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
768 | va_end(ap); | |
769 | ||
770 | printf("faimtest: chat: %s: New occupants have joined:\n", (char *)command->conn->priv); | |
771 | while (i < count) | |
772 | printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); | |
773 | ||
774 | return 1; | |
775 | } | |
776 | ||
777 | int faimtest_chat_leave(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
778 | { | |
779 | va_list ap; | |
780 | struct aim_userinfo_s *userinfo; | |
781 | int count = 0, i = 0; | |
782 | ||
783 | va_start(ap, command); | |
784 | count = va_arg(ap, int); | |
785 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
786 | va_end(ap); | |
787 | ||
788 | printf("faimtest: chat: %s: Some occupants have left:\n", (char *)command->conn->priv); | |
789 | while (i < count) | |
790 | printf("faimtest: chat: %s: \t%s\n", (char *)command->conn->priv, userinfo[i++].sn); | |
791 | ||
792 | return 1; | |
793 | } | |
794 | ||
795 | int faimtest_chat_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
796 | { | |
797 | va_list ap; | |
798 | struct aim_userinfo_s *userinfo; | |
799 | struct aim_chat_roominfo *roominfo; | |
800 | char *roomname; | |
801 | int usercount,i; | |
802 | char *roomdesc; | |
803 | ||
804 | va_start(ap, command); | |
805 | roominfo = va_arg(ap, struct aim_chat_roominfo *); | |
806 | roomname = va_arg(ap, char *); | |
807 | usercount= va_arg(ap, int); | |
808 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
809 | roomdesc = va_arg(ap, char *); | |
810 | va_end(ap); | |
811 | ||
812 | printf("faimtest: chat: %s: info update:\n", (char *)command->conn->priv); | |
813 | printf("faimtest: chat: %s: \tRoominfo: {%04x, %s, %04x}\n", | |
814 | (char *)command->conn->priv, | |
815 | roominfo->exchange, | |
816 | roominfo->name, | |
817 | roominfo->instance); | |
818 | printf("faimtest: chat: %s: \tRoomname: %s\n", (char *)command->conn->priv, roomname); | |
819 | printf("faimtest: chat: %s: \tRoomdesc: %s\n", (char *)command->conn->priv, roomdesc); | |
820 | printf("faimtest: chat: %s: \tOccupants: (%d)\n", (char *)command->conn->priv, usercount); | |
821 | ||
822 | i = 0; | |
823 | while (i < usercount) | |
824 | printf("faimtest: chat: %s: \t\t%s\n", (char *)command->conn->priv, userinfo[i++].sn); | |
825 | ||
826 | return 1; | |
827 | } | |
828 | ||
829 | int faimtest_chat_incomingmsg(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
830 | { | |
831 | va_list ap; | |
832 | struct aim_userinfo_s *userinfo; | |
833 | char *msg; | |
834 | char tmpbuf[1152]; | |
835 | ||
836 | va_start(ap, command); | |
837 | userinfo = va_arg(ap, struct aim_userinfo_s *); | |
838 | msg = va_arg(ap, char *); | |
839 | va_end(ap); | |
840 | ||
841 | printf("faimtest: chat: %s: incoming msg from %s: %s\n", (char *)command->conn->priv, userinfo->sn, msg); | |
842 | ||
843 | /* | |
844 | * Do an echo for testing purposes. But not for ourselves ("oops!") | |
845 | */ | |
846 | if (strcmp(userinfo->sn, sess->logininfo.screen_name) != 0) | |
847 | { | |
848 | sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); | |
849 | aim_chat_send_im(sess, command->conn, tmpbuf); | |
850 | } | |
851 | ||
852 | return 1; | |
853 | } | |
854 | ||
855 | int faimtest_chatnav_info(struct aim_session_t *sess, struct command_rx_struct *command, ...) | |
856 | { | |
857 | u_short type; | |
858 | va_list ap; | |
859 | ||
860 | ap = va_start(ap, command); | |
861 | type = va_arg(ap, u_short); | |
862 | ||
863 | switch(type) | |
864 | { | |
865 | case 0x0002: | |
866 | { | |
867 | int maxrooms; | |
868 | struct aim_chat_exchangeinfo *exchanges; | |
869 | int exchangecount,i = 0; | |
870 | ||
871 | maxrooms = va_arg(ap, u_char); | |
872 | exchangecount = va_arg(ap, int); | |
873 | exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
874 | va_end(ap); | |
875 | ||
876 | printf("faimtest: chat info: Chat Rights:\n"); | |
877 | printf("faimtest: chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
878 | ||
879 | printf("faimtest: chat info: \tExchange List: (%d total)\n", exchangecount); | |
880 | while (i < exchangecount) | |
881 | { | |
882 | printf("faimtest: chat info: \t\t%x: %s (%s/%s)\n", | |
883 | exchanges[i].number, | |
884 | exchanges[i].name, | |
885 | exchanges[i].charset1, | |
886 | exchanges[i].lang1); | |
887 | i++; | |
888 | } | |
889 | ||
890 | } | |
891 | break; | |
892 | default: | |
893 | va_end(ap); | |
894 | printf("faimtest: chatnav info: unknown type (%04x)\n", type); | |
895 | } | |
896 | return 1; | |
897 | } |