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