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