[d09e5a1] | 1 | #include <stdio.h> |
---|
| 2 | #include <stdio.h> |
---|
| 3 | #include <sys/stat.h> |
---|
| 4 | #include "owl.h" |
---|
| 5 | |
---|
| 6 | /**********************************************************************/ |
---|
| 7 | |
---|
| 8 | struct owlfaim_priv { |
---|
| 9 | char *aimbinarypath; |
---|
| 10 | char *screenname; |
---|
| 11 | char *password; |
---|
| 12 | char *server; |
---|
| 13 | int connected; |
---|
| 14 | }; |
---|
| 15 | |
---|
[e19eb97] | 16 | static const char *msgerrreasons[] = { |
---|
[d09e5a1] | 17 | "Invalid error", |
---|
| 18 | "Invalid SNAC", |
---|
| 19 | "Rate to host", |
---|
| 20 | "Rate to client", |
---|
| 21 | "Not logged on", |
---|
| 22 | "Service unavailable", |
---|
| 23 | "Service not defined", |
---|
| 24 | "Obsolete SNAC", |
---|
| 25 | "Not supported by host", |
---|
| 26 | "Not supported by client", |
---|
| 27 | "Refused by client", |
---|
| 28 | "Reply too big", |
---|
| 29 | "Responses lost", |
---|
| 30 | "Request denied", |
---|
| 31 | "Busted SNAC payload", |
---|
| 32 | "Insufficient rights", |
---|
| 33 | "In local permit/deny", |
---|
| 34 | "Too evil (sender)", |
---|
| 35 | "Too evil (receiver)", |
---|
| 36 | "User temporarily unavailable", |
---|
| 37 | "No match", |
---|
| 38 | "List overflow", |
---|
| 39 | "Request ambiguous", |
---|
| 40 | "Queue full", |
---|
| 41 | "Not while on AOL", |
---|
| 42 | }; |
---|
| 43 | static int msgerrreasonslen = 25; |
---|
| 44 | |
---|
| 45 | static void faimtest_debugcb(aim_session_t *sess, int level, const char *format, va_list va); |
---|
| 46 | static int faimtest_parse_login(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 47 | static int faimtest_parse_authresp(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 48 | int faimtest_flapversion(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 49 | int faimtest_conncomplete(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 50 | void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn); |
---|
| 51 | static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 52 | static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
[2674412] | 53 | static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); |
---|
[d09e5a1] | 54 | int logout(aim_session_t *sess); |
---|
| 55 | |
---|
| 56 | static int faimtest_parse_connerr(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 57 | static int faimtest_accountconfirm(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 58 | static int faimtest_infochange(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 59 | static int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 60 | static int faimtest_icbmparaminfo(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 61 | static int faimtest_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 62 | static int faimtest_bosrights(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 63 | static int faimtest_locrights(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 64 | static int faimtest_reportinterval(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
[f4d0975] | 65 | /* static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs); */ |
---|
[d09e5a1] | 66 | static int faimtest_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 67 | static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname); |
---|
| 68 | static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
[8c46404] | 69 | /* static void printuserflags(fu16_t flags); */ |
---|
[d09e5a1] | 70 | static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 71 | static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args); |
---|
| 72 | static int faimtest_parse_incoming_im_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args); |
---|
| 73 | static int faimtest_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 74 | static int faimtest_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 75 | static int faimtest_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 76 | int faimtest_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 77 | static int faimtest_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 78 | static int faimtest_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 79 | static int faimtest_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 80 | static int faimtest_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 81 | static int faimtest_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 82 | static int faimtest_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 83 | static int faimtest_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 84 | static int faimtest_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 85 | static int handlepopup(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 86 | static int serverpause(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 87 | static int migrate(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 88 | static int ssirights(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 89 | static int ssidata(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 90 | static int ssidatanochange(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 91 | static int offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
| 92 | static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...); |
---|
[cdf0ef1] | 93 | /* |
---|
[8c46404] | 94 | static int faimtest_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); |
---|
| 95 | static int faimtest_ssi_parserights (aim_session_t *, aim_frame_t *, ...); |
---|
| 96 | static int faimtest_ssi_parselist (aim_session_t *, aim_frame_t *, ...); |
---|
| 97 | static int faimtest_ssi_parseack (aim_session_t *, aim_frame_t *, ...); |
---|
| 98 | static int faimtest_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
---|
| 99 | static int faimtest_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); |
---|
| 100 | static int faimtest_ssi_authreply (aim_session_t *, aim_frame_t *, ...); |
---|
| 101 | static int faimtest_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); |
---|
[cdf0ef1] | 102 | */ |
---|
[8c46404] | 103 | |
---|
[d09e5a1] | 104 | void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir); |
---|
| 105 | void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir); |
---|
| 106 | |
---|
| 107 | /*****************************************************************/ |
---|
| 108 | |
---|
| 109 | void owl_aim_init(void) |
---|
| 110 | { |
---|
[2674412] | 111 | /* this has all been moved to owl_aim_login, but we'll leave the |
---|
| 112 | * function here, in case there's stuff we want to init in the |
---|
| 113 | * future. It's still called by Owl. |
---|
| 114 | */ |
---|
| 115 | |
---|
[d09e5a1] | 116 | } |
---|
| 117 | |
---|
[b7bb454] | 118 | void owl_aim_send_nop(owl_timer *t, void *data) { |
---|
| 119 | if(owl_global_is_doaimevents(&g)) { |
---|
| 120 | aim_session_t *sess = owl_global_get_aimsess(&g); |
---|
| 121 | aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS)); |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
[f4d0975] | 125 | |
---|
[e19eb97] | 126 | int owl_aim_login(const char *screenname, const char *password) |
---|
[d09e5a1] | 127 | { |
---|
| 128 | struct owlfaim_priv *priv; |
---|
[8c46404] | 129 | aim_conn_t *conn; |
---|
| 130 | aim_session_t *sess; |
---|
[d09e5a1] | 131 | |
---|
[8c46404] | 132 | sess=owl_global_get_aimsess(&g); |
---|
| 133 | |
---|
| 134 | aim_session_init(sess, TRUE, 0); |
---|
| 135 | aim_setdebuggingcb(sess, faimtest_debugcb); |
---|
| 136 | aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
---|
| 137 | |
---|
[d09e5a1] | 138 | /* this will leak, I know and just don't care right now */ |
---|
| 139 | priv=owl_malloc(sizeof(struct owlfaim_priv)); |
---|
| 140 | memset(priv, 0, sizeof(struct owlfaim_priv)); |
---|
| 141 | |
---|
| 142 | priv->screenname = owl_strdup(screenname); |
---|
| 143 | priv->password = owl_strdup(password); |
---|
[8c46404] | 144 | priv->server = owl_strdup(FAIM_LOGIN_SERVER); |
---|
| 145 | sess->aux_data = priv; |
---|
[f4d0975] | 146 | |
---|
[8c46404] | 147 | conn=aim_newconn(sess, AIM_CONN_TYPE_AUTH, priv->server ? priv->server : FAIM_LOGIN_SERVER); |
---|
| 148 | /* conn=aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); */ |
---|
| 149 | if (!conn) { |
---|
| 150 | owl_function_error("owl_aim_login: connection error during AIM login\n"); |
---|
| 151 | owl_global_set_aimnologgedin(&g); |
---|
| 152 | owl_global_set_no_doaimevents(&g); |
---|
| 153 | return (-1); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | /* |
---|
| 157 | else if (conn->fd == -1) { |
---|
| 158 | if (conn->status & AIM_CONN_STATUS_RESOLVERR) { |
---|
| 159 | owl_function_error("owl_aim_login: could not resolve authorize name"); |
---|
| 160 | } else if (conn->status & AIM_CONN_STATUS_CONNERR) { |
---|
| 161 | owl_function_error("owl_aim_login: could not connect to authorizer"); |
---|
| 162 | } else { |
---|
| 163 | owl_function_error("owl_aim_login: unknown connection error"); |
---|
| 164 | } |
---|
[d09e5a1] | 165 | owl_global_set_aimnologgedin(&g); |
---|
[a352335c] | 166 | owl_global_set_no_doaimevents(&g); |
---|
[8c46404] | 167 | aim_conn_kill(sess, &conn); |
---|
[d09e5a1] | 168 | return(-1); |
---|
| 169 | } |
---|
[8c46404] | 170 | */ |
---|
[a0a5179] | 171 | |
---|
[8c46404] | 172 | |
---|
| 173 | aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); |
---|
| 174 | aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 175 | |
---|
| 176 | aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_AUTHRESPONSE, faimtest_parse_login, 0); |
---|
| 177 | aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_LOGINRESPONSE, faimtest_parse_authresp, 0); |
---|
| 178 | /* aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); */ |
---|
| 179 | /* aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); */ |
---|
| 180 | /* aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); */ |
---|
| 181 | |
---|
[a0a5179] | 182 | /* start processing AIM events */ |
---|
[a352335c] | 183 | owl_global_set_doaimevents(&g); |
---|
[8c46404] | 184 | /* conn->status |= AIM_CONN_STATUS_INPROGRESS; */ |
---|
| 185 | owl_function_debugmsg("owl_aim_login: sending login request for %s", screenname); |
---|
| 186 | aim_request_login(sess, conn, screenname); |
---|
| 187 | owl_function_debugmsg("owl_aim_login: connecting"); |
---|
[c15bbfb] | 188 | |
---|
[c675b39] | 189 | g.aim_nop_timer = owl_select_add_timer(30, 30, owl_aim_send_nop, NULL, NULL); |
---|
[b7bb454] | 190 | |
---|
[a352335c] | 191 | return(0); |
---|
| 192 | } |
---|
| 193 | |
---|
[b7bb454] | 194 | void owl_aim_unset_ignorelogin(owl_timer *t, void *data) { /* noproto */ |
---|
| 195 | owl_global_unset_ignore_aimlogin(&g); |
---|
| 196 | } |
---|
| 197 | |
---|
[a352335c] | 198 | /* stuff to run once login has been successful */ |
---|
[e19eb97] | 199 | void owl_aim_successful_login(const char *screenname) |
---|
[a352335c] | 200 | { |
---|
[1db061d] | 201 | char *buff; |
---|
[8c92848] | 202 | owl_function_debugmsg("doing owl_aim_successful_login"); |
---|
[d09e5a1] | 203 | owl_global_set_aimloggedin(&g, screenname); |
---|
[a352335c] | 204 | owl_global_set_doaimevents(&g); /* this should already be on */ |
---|
| 205 | owl_function_makemsg("%s logged in", screenname); |
---|
[1db061d] | 206 | buff=owl_sprintf("Logged in to AIM as %s", screenname); |
---|
| 207 | owl_function_adminmsg("", buff); |
---|
| 208 | owl_free(buff); |
---|
[a352335c] | 209 | |
---|
| 210 | owl_function_debugmsg("Successful AIM login for %s", screenname); |
---|
| 211 | |
---|
| 212 | /* start the ingorelogin timer */ |
---|
[b7bb454] | 213 | owl_global_set_ignore_aimlogin(&g); |
---|
| 214 | owl_select_add_timer(owl_global_get_aim_ignorelogin_timer(&g), |
---|
[c675b39] | 215 | 0, owl_aim_unset_ignorelogin, NULL, NULL); |
---|
[c15bbfb] | 216 | |
---|
[2674412] | 217 | /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */ |
---|
[c15bbfb] | 218 | /* aim_bos_setidle(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), 5000); */ |
---|
[d09e5a1] | 219 | } |
---|
| 220 | |
---|
| 221 | void owl_aim_logout(void) |
---|
| 222 | { |
---|
| 223 | /* need to check if it's connected first, I think */ |
---|
[dff8d8a] | 224 | logout(owl_global_get_aimsess(&g)); |
---|
[1db061d] | 225 | |
---|
[e7bcd1b] | 226 | if (owl_global_is_aimloggedin(&g)) owl_function_adminmsg("", "Logged out of AIM"); |
---|
[d09e5a1] | 227 | owl_global_set_aimnologgedin(&g); |
---|
[a352335c] | 228 | owl_global_set_no_doaimevents(&g); |
---|
[b7bb454] | 229 | owl_select_remove_timer(g.aim_nop_timer); |
---|
[d09e5a1] | 230 | } |
---|
| 231 | |
---|
[1077753b] | 232 | void owl_aim_logged_out() |
---|
| 233 | { |
---|
[e7bcd1b] | 234 | if (owl_global_is_aimloggedin(&g)) owl_function_adminmsg("", "Logged out of AIM"); |
---|
[1077753b] | 235 | owl_aim_logout(); |
---|
| 236 | } |
---|
| 237 | |
---|
[e19eb97] | 238 | void owl_aim_login_error(const char *message) |
---|
[c045455] | 239 | { |
---|
[a352335c] | 240 | if (message) { |
---|
[554a2b8] | 241 | owl_function_error("%s", message); |
---|
[a352335c] | 242 | } else { |
---|
[836ea3a3] | 243 | owl_function_error("Authentication error on login"); |
---|
[a352335c] | 244 | } |
---|
[c045455] | 245 | owl_function_beep(); |
---|
| 246 | owl_global_set_aimnologgedin(&g); |
---|
[a352335c] | 247 | owl_global_set_no_doaimevents(&g); |
---|
[b7bb454] | 248 | owl_select_remove_timer(g.aim_nop_timer); |
---|
[c045455] | 249 | } |
---|
| 250 | |
---|
[e19eb97] | 251 | int owl_aim_send_im(const char *to, const char *msg) |
---|
[d09e5a1] | 252 | { |
---|
[f4d0975] | 253 | int ret; |
---|
| 254 | |
---|
[3645317] | 255 | ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, 0, msg); |
---|
[f4d0975] | 256 | |
---|
[9854278] | 257 | /* I don't know how to check for an error yet */ |
---|
| 258 | return(ret); |
---|
| 259 | } |
---|
| 260 | |
---|
[e19eb97] | 261 | int owl_aim_send_awaymsg(const char *to, const char *msg) |
---|
[9854278] | 262 | { |
---|
| 263 | int ret; |
---|
| 264 | |
---|
| 265 | ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_AWAY, msg); |
---|
[0ff8fb57] | 266 | |
---|
| 267 | /* I don't know how to check for an error yet */ |
---|
[ec6ff52] | 268 | return(ret); |
---|
[d09e5a1] | 269 | } |
---|
| 270 | |
---|
[e19eb97] | 271 | void owl_aim_addbuddy(const char *name) |
---|
[fd93b41] | 272 | { |
---|
[a0a5179] | 273 | |
---|
[257a22f] | 274 | aim_ssi_addbuddy(owl_global_get_aimsess(&g), name, "Buddies", NULL, NULL, NULL, 0); |
---|
[a0a5179] | 275 | |
---|
| 276 | /* |
---|
| 277 | aim_ssi_addbuddy(owl_global_get_aimsess(&g), |
---|
| 278 | name, |
---|
| 279 | "Buddies", |
---|
| 280 | NULL, NULL, NULL, |
---|
| 281 | aim_ssi_waitingforauth(owl_global_get_aimsess(&g)->ssi.local, "Buddies", name)); |
---|
| 282 | */ |
---|
[fd93b41] | 283 | } |
---|
| 284 | |
---|
[e19eb97] | 285 | void owl_aim_delbuddy(const char *name) |
---|
[fd93b41] | 286 | { |
---|
[257a22f] | 287 | aim_ssi_delbuddy(owl_global_get_aimsess(&g), name, "Buddies"); |
---|
| 288 | owl_buddylist_offgoing(owl_global_get_buddylist(&g), name); |
---|
[fd93b41] | 289 | } |
---|
| 290 | |
---|
[e19eb97] | 291 | void owl_aim_search(const char *email) |
---|
[952bb256] | 292 | { |
---|
| 293 | int ret; |
---|
| 294 | |
---|
| 295 | owl_function_debugmsg("owl_aim_search: doing search for %s", email); |
---|
| 296 | ret=aim_search_address(owl_global_get_aimsess(&g), |
---|
| 297 | aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), |
---|
| 298 | email); |
---|
| 299 | |
---|
| 300 | if (ret) owl_function_error("owl_aim_search: aim_search_address returned %i", ret); |
---|
| 301 | } |
---|
| 302 | |
---|
[1077753b] | 303 | |
---|
[e19eb97] | 304 | int owl_aim_set_awaymsg(const char *msg) |
---|
[de03334] | 305 | { |
---|
[9854278] | 306 | int len; |
---|
| 307 | char *foo; |
---|
[1077753b] | 308 | /* there is a max away message lentgh we should check against */ |
---|
| 309 | |
---|
[9854278] | 310 | foo=owl_strdup(msg); |
---|
| 311 | len=strlen(foo); |
---|
| 312 | if (len>500) { |
---|
| 313 | foo[500]='\0'; |
---|
| 314 | len=499; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | aim_locate_setprofile(owl_global_get_aimsess(&g), |
---|
| 318 | NULL, NULL, 0, |
---|
| 319 | "us-ascii", foo, len); |
---|
| 320 | owl_free(foo); |
---|
| 321 | |
---|
[c8735aa] | 322 | /* |
---|
[1077753b] | 323 | aim_bos_setprofile(owl_global_get_aimsess(&g), |
---|
| 324 | owl_global_get_bosconn(&g), |
---|
| 325 | NULL, NULL, 0, "us-ascii", msg, |
---|
| 326 | strlen(msg), 0); |
---|
[c8735aa] | 327 | */ |
---|
[1077753b] | 328 | return(0); |
---|
[de03334] | 329 | } |
---|
| 330 | |
---|
[e19eb97] | 331 | void owl_aim_chat_join(const char *name, int exchange) |
---|
[d09e5a1] | 332 | { |
---|
[8c92848] | 333 | int ret; |
---|
[2674412] | 334 | aim_conn_t *cur; |
---|
| 335 | /* |
---|
[4d86e06] | 336 | OscarData *od = g->proto_data; |
---|
[e19eb97] | 337 | const char *name, *exchange; |
---|
[2674412] | 338 | */ |
---|
| 339 | |
---|
| 340 | owl_function_debugmsg("Attempting to join chatroom %s exchange %i", name, exchange); |
---|
| 341 | |
---|
| 342 | /* |
---|
| 343 | name = g_hash_table_lookup(data, "room"); |
---|
| 344 | exchange = g_hash_table_lookup(data, "exchange"); |
---|
| 345 | */ |
---|
| 346 | if ((cur = aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV))) { |
---|
| 347 | owl_function_debugmsg("owl_aim_chat_join: chatnav exists, creating room"); |
---|
| 348 | aim_chatnav_createroom(owl_global_get_aimsess(&g), cur, name, exchange); |
---|
| 349 | } else { |
---|
| 350 | /* struct create_room *cr = g_new0(struct create_room, 1); */ |
---|
| 351 | owl_function_debugmsg("owl_aim_chat_join: chatnav does not exist, opening chatnav"); |
---|
| 352 | /* |
---|
| 353 | cr->exchange = atoi(exchange); |
---|
| 354 | cr->name = g_strdup(name); |
---|
| 355 | od->create_rooms = g_slist_append(od->create_rooms, cr); |
---|
| 356 | */ |
---|
[9854278] | 357 | aim_reqservice(owl_global_get_aimsess(&g), |
---|
| 358 | aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV), |
---|
| 359 | AIM_CONN_TYPE_CHATNAV); |
---|
[2674412] | 360 | aim_reqservice(owl_global_get_aimsess(&g), NULL, AIM_CONN_TYPE_CHATNAV); |
---|
| 361 | aim_chatnav_createroom(owl_global_get_aimsess(&g), cur, name, exchange); |
---|
| 362 | ret=aim_chat_join(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), exchange, name, 0x0000); |
---|
| 363 | |
---|
| 364 | } |
---|
| 365 | return; |
---|
| 366 | /******/ |
---|
| 367 | |
---|
[8c92848] | 368 | |
---|
| 369 | /* ret=aim_chat_join(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), exchange, chatroom, 0x0000); */ |
---|
| 370 | /* |
---|
| 371 | ret=aim_chat_join(owl_global_get_aimsess(&g), |
---|
| 372 | aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV), exchange, chatroom, 0x0000); |
---|
| 373 | */ |
---|
| 374 | |
---|
| 375 | aim_reqservice(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), AIM_CONN_TYPE_CHATNAV); |
---|
| 376 | ret = aim_chatnav_createroom(owl_global_get_aimsess(&g), |
---|
[2674412] | 377 | aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_CHATNAV), name, exchange); |
---|
| 378 | ret=aim_chat_join(owl_global_get_aimsess(&g), owl_global_get_bosconn(&g), exchange, name, 0x0000); |
---|
[8c92848] | 379 | |
---|
[d09e5a1] | 380 | } |
---|
| 381 | |
---|
[e19eb97] | 382 | void owl_aim_chat_leave(const char *chatroom) |
---|
[d09e5a1] | 383 | { |
---|
| 384 | } |
---|
| 385 | |
---|
[e19eb97] | 386 | int owl_aim_chat_sendmsg(const char *chatroom, const char *msg) |
---|
[d09e5a1] | 387 | { |
---|
[0ff8fb57] | 388 | return(0); |
---|
[d09e5a1] | 389 | } |
---|
| 390 | |
---|
[651560f] | 391 | /* caller must free the return */ |
---|
[e19eb97] | 392 | char *owl_aim_normalize_screenname(const char *in) |
---|
[8c92848] | 393 | { |
---|
[651560f] | 394 | char *out; |
---|
| 395 | int i, j, k; |
---|
| 396 | |
---|
| 397 | j=strlen(in); |
---|
| 398 | out=owl_malloc(j+30); |
---|
| 399 | k=0; |
---|
| 400 | for (i=0; i<j; i++) { |
---|
| 401 | if (in[i]!=' ') { |
---|
| 402 | out[k]=in[i]; |
---|
| 403 | k++; |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | out[k]='\0'; |
---|
| 407 | return(out); |
---|
| 408 | } |
---|
| 409 | |
---|
[8c92848] | 410 | int owl_aim_process_events() |
---|
| 411 | { |
---|
[d09e5a1] | 412 | aim_session_t *aimsess; |
---|
| 413 | aim_conn_t *waitingconn = NULL; |
---|
| 414 | struct timeval tv; |
---|
| 415 | int selstat = 0; |
---|
| 416 | struct owlfaim_priv *priv; |
---|
| 417 | |
---|
| 418 | aimsess=owl_global_get_aimsess(&g); |
---|
[4d86e06] | 419 | priv = aimsess->aux_data; |
---|
[d09e5a1] | 420 | |
---|
| 421 | /* do a select without blocking */ |
---|
| 422 | tv.tv_sec = 0; |
---|
| 423 | tv.tv_usec = 0; |
---|
| 424 | waitingconn = aim_select(aimsess, &tv, &selstat); |
---|
| 425 | |
---|
[f4d0975] | 426 | if (selstat == -1) { |
---|
[1077753b] | 427 | owl_aim_logged_out(); |
---|
[8c92848] | 428 | } else if (selstat == 0) { |
---|
[f4d0975] | 429 | /* no events pending */ |
---|
[d09e5a1] | 430 | } else if (selstat == 1) { /* outgoing data pending */ |
---|
| 431 | aim_tx_flushqueue(aimsess); |
---|
| 432 | } else if (selstat == 2) { /* incoming data pending */ |
---|
| 433 | /* printf("selstat == 2\n"); */ |
---|
[f4d0975] | 434 | |
---|
| 435 | if (aim_get_command(aimsess, waitingconn) >= 0) { |
---|
| 436 | aim_rxdispatch(aimsess); |
---|
[d09e5a1] | 437 | } else { |
---|
[f4d0975] | 438 | /* printf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); */ |
---|
| 439 | /* we should have callbacks for all these, else the library will do the conn_kill for us. */ |
---|
| 440 | if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
---|
| 441 | if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { |
---|
| 442 | /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */ |
---|
[d09e5a1] | 443 | aim_conn_kill(aimsess, &waitingconn); |
---|
[8c92848] | 444 | owl_aim_logged_out(); |
---|
[d09e5a1] | 445 | } |
---|
[f4d0975] | 446 | } else { |
---|
| 447 | aim_conn_kill(aimsess, &waitingconn); |
---|
[8c92848] | 448 | owl_aim_logged_out(); |
---|
[f4d0975] | 449 | } |
---|
| 450 | if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) { |
---|
| 451 | /* printf("major connection error\n"); */ |
---|
[8c92848] | 452 | owl_aim_logged_out(); |
---|
[f4d0975] | 453 | /* break; */ |
---|
[d09e5a1] | 454 | } |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | /* exit(0); */ |
---|
[0ff8fb57] | 458 | return(0); |
---|
[d09e5a1] | 459 | } |
---|
| 460 | |
---|
| 461 | static void faimtest_debugcb(aim_session_t *sess, int level, const char *format, va_list va) |
---|
| 462 | { |
---|
| 463 | return; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | static int faimtest_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 467 | { |
---|
[4d86e06] | 468 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[03ad7b2] | 469 | struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; |
---|
| 470 | |
---|
[e19eb97] | 471 | const char *key; |
---|
[d09e5a1] | 472 | va_list ap; |
---|
| 473 | |
---|
| 474 | va_start(ap, fr); |
---|
[e19eb97] | 475 | key = va_arg(ap, const char *); |
---|
[d09e5a1] | 476 | va_end(ap); |
---|
| 477 | |
---|
[8c46404] | 478 | owl_function_debugmsg("faimtest_parse_login: %s %s %s", priv->screenname, priv->password, key); |
---|
[8c92848] | 479 | |
---|
[d09e5a1] | 480 | aim_send_login(sess, fr->conn, priv->screenname, priv->password, &info, key); |
---|
[b2b0773] | 481 | |
---|
[8c92848] | 482 | return(1); |
---|
[d09e5a1] | 483 | } |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | static int faimtest_parse_authresp(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 487 | { |
---|
| 488 | va_list ap; |
---|
| 489 | struct aim_authresp_info *info; |
---|
| 490 | aim_conn_t *bosconn; |
---|
| 491 | |
---|
| 492 | va_start(ap, fr); |
---|
| 493 | info = va_arg(ap, struct aim_authresp_info *); |
---|
| 494 | va_end(ap); |
---|
| 495 | |
---|
| 496 | /* printf("Screen name: %s\n", info->sn); */ |
---|
[8c92848] | 497 | owl_function_debugmsg("doing faimtest_parse_authresp"); |
---|
[f4d0975] | 498 | owl_function_debugmsg("faimtest_parse_authresp: %s", info->sn); |
---|
[d09e5a1] | 499 | |
---|
| 500 | /* |
---|
| 501 | * Check for error. |
---|
| 502 | */ |
---|
| 503 | if (info->errorcode || !info->bosip || !info->cookie) { |
---|
| 504 | /* |
---|
| 505 | printf("Login Error Code 0x%04x\n", info->errorcode); |
---|
| 506 | printf("Error URL: %s\n", info->errorurl); |
---|
| 507 | */ |
---|
[a352335c] | 508 | if (info->errorcode==0x05) { |
---|
| 509 | owl_aim_login_error("Incorrect nickname or password."); |
---|
| 510 | } else if (info->errorcode==0x11) { |
---|
| 511 | owl_aim_login_error("Your account is currently suspended."); |
---|
| 512 | } else if (info->errorcode==0x14) { |
---|
| 513 | owl_aim_login_error("The AOL Instant Messenger service is temporarily unavailable."); |
---|
| 514 | } else if (info->errorcode==0x18) { |
---|
| 515 | owl_aim_login_error("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."); |
---|
| 516 | } else if (info->errorcode==0x1c) { |
---|
| 517 | owl_aim_login_error("The client version you are using is too old."); |
---|
| 518 | } else { |
---|
| 519 | owl_aim_login_error(NULL); |
---|
| 520 | } |
---|
| 521 | aim_conn_kill(sess, &fr->conn); |
---|
[8c92848] | 522 | return(1); |
---|
[d09e5a1] | 523 | } |
---|
| 524 | |
---|
| 525 | /* |
---|
| 526 | printf("Reg status: %d\n", info->regstatus); |
---|
| 527 | printf("Email: %s\n", info->email); |
---|
| 528 | printf("BOS IP: %s\n", info->bosip); |
---|
| 529 | */ |
---|
| 530 | |
---|
| 531 | /* printf("Closing auth connection...\n"); */ |
---|
| 532 | aim_conn_kill(sess, &fr->conn); |
---|
| 533 | if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, info->bosip))) { |
---|
| 534 | /* printf("could not connect to BOS: internal error\n"); */ |
---|
[8c92848] | 535 | return(1); |
---|
[d09e5a1] | 536 | } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) { |
---|
| 537 | /* printf("could not connect to BOS\n"); */ |
---|
| 538 | aim_conn_kill(sess, &bosconn); |
---|
[8c92848] | 539 | return(1); |
---|
[d09e5a1] | 540 | } |
---|
[c15bbfb] | 541 | owl_global_set_bossconn(&g, bosconn); |
---|
[a352335c] | 542 | owl_aim_successful_login(info->sn); |
---|
[d09e5a1] | 543 | addcb_bos(sess, bosconn); |
---|
[f4d0975] | 544 | aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
---|
[8c92848] | 545 | return(1); |
---|
[d09e5a1] | 546 | } |
---|
| 547 | |
---|
| 548 | int faimtest_flapversion(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 549 | { |
---|
[8c92848] | 550 | owl_function_debugmsg("doing faimtest_flapversion"); |
---|
| 551 | |
---|
[d09e5a1] | 552 | #if 0 |
---|
| 553 | /* XXX fix libfaim to support this */ |
---|
| 554 | printf("using FLAP version 0x%08x\n", /* aimutil_get32(fr->data)*/ 0xffffffff); |
---|
| 555 | |
---|
| 556 | /* |
---|
| 557 | * This is an alternate location for starting the login process. |
---|
| 558 | */ |
---|
| 559 | /* XXX should do more checking to make sure its really the right AUTH conn */ |
---|
| 560 | if (fr->conn->type == AIM_CONN_TYPE_AUTH) { |
---|
| 561 | /* do NOT send a flapversion, request_login will send it if needed */ |
---|
| 562 | aim_request_login(sess, fr->conn, priv->screenname); |
---|
| 563 | /* printf("faimtest: login request sent\n"); */ |
---|
| 564 | } |
---|
| 565 | #endif |
---|
| 566 | |
---|
| 567 | return 1; |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | |
---|
| 571 | int faimtest_conncomplete(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 572 | { |
---|
[8c92848] | 573 | owl_function_debugmsg("doing faimtest_conncomplete"); |
---|
[a352335c] | 574 | /* owl_aim_successful_login(info->sn); */ |
---|
[d09e5a1] | 575 | return 1; |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | void addcb_bos(aim_session_t *sess, aim_conn_t *bosconn) |
---|
| 579 | { |
---|
[8c92848] | 580 | owl_function_debugmsg("doing addcb_bos"); |
---|
[d09e5a1] | 581 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 582 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
---|
| 583 | |
---|
[aa5f725] | 584 | aim_conn_addhandler(sess, bosconn, 0x0013, 0x0003, ssirights, 0); |
---|
| 585 | aim_conn_addhandler(sess, bosconn, 0x0013, 0x0006, ssidata, 0); |
---|
| 586 | aim_conn_addhandler(sess, bosconn, 0x0013, 0x000f, ssidatanochange, 0); |
---|
| 587 | aim_conn_addhandler(sess, bosconn, 0x0008, 0x0002, handlepopup, 0); |
---|
| 588 | aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, faimtest_bosrights, 0); |
---|
| 589 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, faimtest_handleredirect, 0); |
---|
| 590 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, faimtest_reportinterval, 0); |
---|
| 591 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, faimtest_parse_buddyrights, 0); |
---|
| 592 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, faimtest_parse_motd, 0); |
---|
| 593 | aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, faimtest_icbmparaminfo, 0); |
---|
| 594 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, faimtest_parse_connerr, 0); |
---|
| 595 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, faimtest_locrights, 0); |
---|
| 596 | aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, faimtest_memrequest, 0); |
---|
| 597 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, faimtest_parse_oncoming, 0); |
---|
| 598 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, faimtest_parse_offgoing, 0); |
---|
| 599 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, faimtest_parse_incoming_im, 0); |
---|
| 600 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, faimtest_parse_locerr, 0); |
---|
| 601 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, faimtest_parse_misses, 0); |
---|
| 602 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, faimtest_parse_ratechange, 0); |
---|
| 603 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, faimtest_parse_evilnotify, 0); |
---|
[952bb256] | 604 | |
---|
[aa5f725] | 605 | aim_conn_addhandler(sess, bosconn, 0x000a, 0x0001, faimtest_parse_searcherror, 0); |
---|
| 606 | aim_conn_addhandler(sess, bosconn, 0x000a, 0x0003, faimtest_parse_searchreply, 0); |
---|
[952bb256] | 607 | |
---|
| 608 | /* |
---|
| 609 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, faimtest_parse_searcherror, 0); |
---|
| 610 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, faimtest_parse_searchreply, 0); |
---|
| 611 | */ |
---|
| 612 | |
---|
[aa5f725] | 613 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, faimtest_parse_msgerr, 0); |
---|
| 614 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, faimtest_parse_userinfo, 0); |
---|
| 615 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, faimtest_parse_msgack, 0); |
---|
| 616 | |
---|
| 617 | aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, faimtest_parse_genericerr, 0); |
---|
| 618 | aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, faimtest_parse_genericerr, 0); |
---|
| 619 | aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, faimtest_parse_genericerr, 0); |
---|
| 620 | aim_conn_addhandler(sess, bosconn, 0x0001, 0x000b, serverpause, 0); |
---|
| 621 | aim_conn_addhandler(sess, bosconn, 0x0001, 0x0012, migrate, 0); |
---|
| 622 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, offlinemsg, 0); |
---|
[d09e5a1] | 623 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, offlinemsgdone, 0); |
---|
| 624 | |
---|
[8c46404] | 625 | /* |
---|
[2674412] | 626 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
---|
| 627 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
---|
| 628 | */ |
---|
| 629 | |
---|
| 630 | /* |
---|
[8c46404] | 631 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, faimtest_ssi_parseerr, 0); |
---|
| 632 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, faimtest_ssi_parserights, 0); |
---|
| 633 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, faimtest_ssi_parselist, 0); |
---|
| 634 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, faimtest_ssi_parselist, 0); |
---|
| 635 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, faimtest_ssi_parseack, 0); |
---|
| 636 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, faimtest_ssi_authgiven, 0); |
---|
| 637 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, faimtest_ssi_authrequest, 0); |
---|
| 638 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, faimtest_ssi_authreply, 0); |
---|
| 639 | aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, faimtest_ssi_gotadded, 0); |
---|
| 640 | */ |
---|
| 641 | |
---|
[d09e5a1] | 642 | return; |
---|
| 643 | } |
---|
| 644 | |
---|
[8c92848] | 645 | static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 646 | { |
---|
| 647 | owl_function_debugmsg("doing coninitdone_bos"); |
---|
[d09e5a1] | 648 | |
---|
[8c46404] | 649 | |
---|
| 650 | aim_reqpersonalinfo(sess, fr->conn); |
---|
[f4d0975] | 651 | aim_ssi_reqrights(sess); |
---|
| 652 | aim_ssi_reqdata(sess); |
---|
[8c46404] | 653 | aim_locate_reqrights(sess); |
---|
| 654 | aim_buddylist_reqrights(sess, fr->conn); |
---|
[d09e5a1] | 655 | |
---|
[f4d0975] | 656 | aim_im_reqparams(sess); |
---|
[8c46404] | 657 | /* aim_bos_reqrights(sess, fr->conn); */ /* XXX - Don't call this with ssi */ |
---|
[8c92848] | 658 | |
---|
[8c46404] | 659 | owl_function_debugmsg("conninitdone_bos: requesting rights"); |
---|
| 660 | aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
---|
[d09e5a1] | 661 | aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
---|
[f4d0975] | 662 | aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); |
---|
[d09e5a1] | 663 | |
---|
[8c92848] | 664 | return(1); |
---|
[d09e5a1] | 665 | } |
---|
| 666 | |
---|
| 667 | static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 668 | { |
---|
| 669 | aim_clientready(sess, fr->conn); |
---|
[a0a5179] | 670 | owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection"); |
---|
[d09e5a1] | 671 | return(1); |
---|
| 672 | } |
---|
| 673 | |
---|
| 674 | int logout(aim_session_t *sess) |
---|
| 675 | { |
---|
| 676 | aim_session_kill(sess); |
---|
[fd93b41] | 677 | owl_aim_init(); |
---|
[a0a5179] | 678 | |
---|
| 679 | owl_function_debugmsg("libfaim logout called"); |
---|
| 680 | /* |
---|
[d09e5a1] | 681 | if (faimtest_init() == -1) |
---|
| 682 | printf("faimtest_init failed\n"); |
---|
| 683 | */ |
---|
| 684 | |
---|
| 685 | return(0); |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | /**************************************************************************************************/ |
---|
| 689 | |
---|
| 690 | static int faimtest_parse_connerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 691 | { |
---|
[4d86e06] | 692 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[d09e5a1] | 693 | va_list ap; |
---|
| 694 | fu16_t code; |
---|
[e19eb97] | 695 | const char *msg; |
---|
[d09e5a1] | 696 | |
---|
| 697 | va_start(ap, fr); |
---|
| 698 | code = va_arg(ap, int); |
---|
[e19eb97] | 699 | msg = va_arg(ap, const char *); |
---|
[d09e5a1] | 700 | va_end(ap); |
---|
| 701 | |
---|
[8c46404] | 702 | owl_function_error("faimtest_parse_connerr: Code 0x%04x: %s\n", code, msg); |
---|
[d09e5a1] | 703 | aim_conn_kill(sess, &fr->conn); /* this will break the main loop */ |
---|
| 704 | |
---|
| 705 | priv->connected = 0; |
---|
| 706 | |
---|
| 707 | return 1; |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | static int faimtest_accountconfirm(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 711 | { |
---|
| 712 | int status; |
---|
| 713 | va_list ap; |
---|
| 714 | |
---|
| 715 | va_start(ap, fr); |
---|
| 716 | status = va_arg(ap, int); /* status code of confirmation request */ |
---|
| 717 | va_end(ap); |
---|
[8c46404] | 718 | |
---|
| 719 | /* owl_function_debugmsg("faimtest_accountconfirm: Code 0x%04x: %s\n", code, msg); */ |
---|
| 720 | owl_function_debugmsg("faimtest_accountconfirm: account confirmation returned status 0x%04x (%s)\n", status, (status==0x0000)?"email sent":"unknown"); |
---|
[d09e5a1] | 721 | |
---|
| 722 | return 1; |
---|
| 723 | } |
---|
| 724 | |
---|
| 725 | static int faimtest_infochange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 726 | { |
---|
| 727 | fu16_t change = 0, perms, type; |
---|
| 728 | int length, str; |
---|
[e19eb97] | 729 | const char *val; |
---|
[d09e5a1] | 730 | va_list ap; |
---|
| 731 | |
---|
| 732 | va_start(ap, fr); |
---|
| 733 | change = va_arg(ap, int); |
---|
| 734 | perms = (fu16_t)va_arg(ap, unsigned int); |
---|
| 735 | type = (fu16_t)va_arg(ap, unsigned int); |
---|
| 736 | length = va_arg(ap, int); |
---|
[e19eb97] | 737 | val = va_arg(ap, const char *); |
---|
[d09e5a1] | 738 | str = va_arg(ap, int); |
---|
| 739 | va_end(ap); |
---|
| 740 | |
---|
[8c46404] | 741 | owl_function_debugmsg("faimtest_infochange: info%s: perms = %d, type = %x, length = %d, val = %s", change?" change":"", perms, type, length, str?val:"(not string)"); |
---|
[d09e5a1] | 742 | |
---|
[8c46404] | 743 | return(1); |
---|
[d09e5a1] | 744 | } |
---|
| 745 | |
---|
| 746 | |
---|
| 747 | static int faimtest_handleredirect(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 748 | { |
---|
| 749 | va_list ap; |
---|
| 750 | struct aim_redirect_data *redir; |
---|
[2674412] | 751 | |
---|
| 752 | owl_function_debugmsg("faimtest_handledirect:"); |
---|
[d09e5a1] | 753 | |
---|
| 754 | va_start(ap, fr); |
---|
| 755 | redir = va_arg(ap, struct aim_redirect_data *); |
---|
| 756 | |
---|
| 757 | if (redir->group == 0x0005) { /* Adverts */ |
---|
| 758 | |
---|
| 759 | } else if (redir->group == 0x0007) { /* Authorizer */ |
---|
| 760 | aim_conn_t *tstconn; |
---|
[2674412] | 761 | |
---|
| 762 | owl_function_debugmsg("faimtest_handledirect: autorizer"); |
---|
[d09e5a1] | 763 | |
---|
| 764 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, redir->ip); |
---|
| 765 | if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { |
---|
[8c46404] | 766 | owl_function_error("faimtest_handleredirect: unable to reconnect with authorizer"); |
---|
[d09e5a1] | 767 | } else { |
---|
| 768 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, faimtest_flapversion, 0); |
---|
| 769 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 770 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
---|
| 771 | aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, faimtest_accountconfirm, 0); |
---|
| 772 | aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, faimtest_infochange, 0); |
---|
| 773 | aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0); |
---|
| 774 | /* Send the cookie to the Auth */ |
---|
[f4d0975] | 775 | aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
---|
[8c46404] | 776 | owl_function_debugmsg("faimtest_handleredirect: sent cookie to authorizer host"); |
---|
[d09e5a1] | 777 | } |
---|
| 778 | } else if (redir->group == 0x000d) { /* ChatNav */ |
---|
[2674412] | 779 | owl_function_debugmsg("faimtest_handledirect: chatnav"); |
---|
[d09e5a1] | 780 | chatnav_redirect(sess, redir); |
---|
| 781 | } else if (redir->group == 0x000e) { /* Chat */ |
---|
[2674412] | 782 | owl_function_debugmsg("faimtest_handledirect: chat"); |
---|
[d09e5a1] | 783 | chat_redirect(sess, redir); |
---|
| 784 | } else { |
---|
[8c46404] | 785 | owl_function_debugmsg("faimtest_handleredirect: uh oh... got redirect for unknown service 0x%04x!!", redir->group); |
---|
[d09e5a1] | 786 | } |
---|
| 787 | va_end(ap); |
---|
| 788 | return 1; |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | static int faimtest_icbmparaminfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 792 | { |
---|
| 793 | struct aim_icbmparameters *params; |
---|
| 794 | va_list ap; |
---|
| 795 | |
---|
| 796 | va_start(ap, fr); |
---|
| 797 | params = va_arg(ap, struct aim_icbmparameters *); |
---|
| 798 | va_end(ap); |
---|
| 799 | |
---|
[f278ff3] | 800 | owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08x, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %u", |
---|
[8c46404] | 801 | params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval); |
---|
[d09e5a1] | 802 | |
---|
| 803 | /* |
---|
| 804 | * Set these to your taste, or client medium. Setting minmsginterval |
---|
| 805 | * higher is good for keeping yourself from getting flooded (esp |
---|
| 806 | * if you're on a slow connection or something where that would be |
---|
| 807 | * useful). |
---|
| 808 | */ |
---|
| 809 | params->maxmsglen = 8000; |
---|
| 810 | params->minmsginterval = 0; /* in milliseconds */ |
---|
[f4d0975] | 811 | /* aim_seticbmparam(sess, params); */ |
---|
| 812 | aim_im_setparams(sess, params); |
---|
[d09e5a1] | 813 | |
---|
| 814 | return 1; |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | static int faimtest_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 818 | { |
---|
| 819 | va_list ap; |
---|
| 820 | fu16_t maxbuddies, maxwatchers; |
---|
| 821 | |
---|
| 822 | va_start(ap, fr); |
---|
| 823 | maxbuddies = va_arg(ap, int); |
---|
| 824 | maxwatchers = va_arg(ap, int); |
---|
| 825 | va_end(ap); |
---|
| 826 | |
---|
[8c46404] | 827 | owl_function_debugmsg("faimtest_parse_buddyrights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); |
---|
[d09e5a1] | 828 | |
---|
[f4d0975] | 829 | /* aim_ssi_reqrights(sess, fr->conn); */ |
---|
| 830 | aim_ssi_reqrights(sess); |
---|
[d09e5a1] | 831 | |
---|
| 832 | return 1; |
---|
| 833 | } |
---|
| 834 | |
---|
| 835 | static int faimtest_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 836 | { |
---|
| 837 | va_list ap; |
---|
| 838 | fu16_t maxpermits, maxdenies; |
---|
| 839 | |
---|
| 840 | va_start(ap, fr); |
---|
| 841 | maxpermits = va_arg(ap, int); |
---|
| 842 | maxdenies = va_arg(ap, int); |
---|
| 843 | va_end(ap); |
---|
| 844 | |
---|
[8c46404] | 845 | owl_function_debugmsg("faimtest_bosrights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); |
---|
[d09e5a1] | 846 | aim_clientready(sess, fr->conn); |
---|
[8c92848] | 847 | owl_function_debugmsg("officially connected to BOS."); |
---|
[d09e5a1] | 848 | aim_icq_reqofflinemsgs(sess); |
---|
| 849 | return 1; |
---|
| 850 | } |
---|
| 851 | |
---|
| 852 | static int faimtest_locrights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 853 | { |
---|
| 854 | va_list ap; |
---|
| 855 | fu16_t maxsiglen; |
---|
| 856 | |
---|
| 857 | va_start(ap, fr); |
---|
| 858 | maxsiglen = va_arg(ap, int); |
---|
| 859 | va_end(ap); |
---|
[8c92848] | 860 | |
---|
[8c46404] | 861 | owl_function_debugmsg("faimtest_locrights: rights: max signature length = %d\n", maxsiglen); |
---|
[d09e5a1] | 862 | |
---|
[8c92848] | 863 | return(1); |
---|
[d09e5a1] | 864 | } |
---|
| 865 | |
---|
| 866 | static int faimtest_reportinterval(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 867 | { |
---|
[4d86e06] | 868 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[d09e5a1] | 869 | va_list ap; |
---|
| 870 | fu16_t interval; |
---|
[f4d0975] | 871 | |
---|
[d09e5a1] | 872 | va_start(ap, fr); |
---|
| 873 | interval = va_arg(ap, int); |
---|
| 874 | va_end(ap); |
---|
[f4d0975] | 875 | |
---|
[8c46404] | 876 | owl_function_debugmsg("faimtest_reportinterval: %d (seconds?)\n", interval); |
---|
[f4d0975] | 877 | |
---|
[d09e5a1] | 878 | if (!priv->connected) { |
---|
| 879 | priv->connected++; |
---|
| 880 | } |
---|
[f4d0975] | 881 | /* aim_reqicbmparams(sess); */ |
---|
| 882 | aim_im_reqparams(sess); |
---|
| 883 | /* kretch */ |
---|
[d09e5a1] | 884 | return 1; |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | static int faimtest_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 888 | { |
---|
[e19eb97] | 889 | const char *msg; |
---|
[0ff8fb57] | 890 | fu16_t id; |
---|
| 891 | va_list ap; |
---|
[8c46404] | 892 | static int codeslen = 5; |
---|
[e19eb97] | 893 | static const char *codes[] = { |
---|
[d09e5a1] | 894 | "Unknown", |
---|
| 895 | "Mandatory upgrade", |
---|
| 896 | "Advisory upgrade", |
---|
| 897 | "System bulletin", |
---|
| 898 | "Top o' the world!" |
---|
| 899 | }; |
---|
[0ff8fb57] | 900 | |
---|
[d09e5a1] | 901 | va_start(ap, fr); |
---|
| 902 | id = va_arg(ap, int); |
---|
[e19eb97] | 903 | msg = va_arg(ap, const char *); |
---|
[d09e5a1] | 904 | va_end(ap); |
---|
[8c46404] | 905 | |
---|
| 906 | owl_function_debugmsg("faimtest_parse_motd: %s (%d / %s)\n", msg?msg:"nomsg", id, (id < codeslen)?codes[id]:"unknown"); |
---|
[d09e5a1] | 907 | |
---|
| 908 | return 1; |
---|
| 909 | } |
---|
| 910 | |
---|
| 911 | /* |
---|
| 912 | * This is a little more complicated than it looks. The module |
---|
| 913 | * name (proto, boscore, etc) may or may not be given. If it is |
---|
| 914 | * not given, then use aim.exe. If it is given, put ".ocm" on the |
---|
| 915 | * end of it. |
---|
| 916 | * |
---|
| 917 | * Now, if the offset or length requested would cause a read past |
---|
| 918 | * the end of the file, then the request is considered invalid. Invalid |
---|
| 919 | * requests are processed specially. The value hashed is the |
---|
| 920 | * the request, put into little-endian (eight bytes: offset followed |
---|
| 921 | * by length). |
---|
| 922 | * |
---|
| 923 | * Additionally, if the request is valid, the length is mod 4096. It is |
---|
| 924 | * important that the length is checked for validity first before doing |
---|
| 925 | * the mod. |
---|
| 926 | * |
---|
| 927 | * Note to Bosco's Brigade: if you'd like to break this, put the |
---|
| 928 | * module name on an invalid request. |
---|
| 929 | * |
---|
| 930 | */ |
---|
| 931 | static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname) |
---|
| 932 | { |
---|
[4d86e06] | 933 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[d09e5a1] | 934 | FILE *f; |
---|
| 935 | static const char defaultmod[] = "aim.exe"; |
---|
| 936 | char *filename = NULL; |
---|
| 937 | struct stat st; |
---|
| 938 | unsigned char *buf; |
---|
| 939 | int invalid = 0; |
---|
| 940 | |
---|
| 941 | if (!bufret || !buflenret) |
---|
| 942 | return -1; |
---|
| 943 | |
---|
| 944 | if (modname) { |
---|
[34509d5] | 945 | if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) { |
---|
[d09e5a1] | 946 | /* perror("memrequest: malloc"); */ |
---|
| 947 | return -1; |
---|
| 948 | } |
---|
| 949 | sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname); |
---|
| 950 | } else { |
---|
[34509d5] | 951 | if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) { |
---|
[d09e5a1] | 952 | /* perror("memrequest: malloc"); */ |
---|
| 953 | return -1; |
---|
| 954 | } |
---|
| 955 | sprintf(filename, "%s/%s", priv->aimbinarypath, defaultmod); |
---|
| 956 | } |
---|
| 957 | |
---|
| 958 | if (stat(filename, &st) == -1) { |
---|
| 959 | if (!modname) { |
---|
| 960 | /* perror("memrequest: stat"); */ |
---|
[34509d5] | 961 | owl_free(filename); |
---|
[d09e5a1] | 962 | return -1; |
---|
| 963 | } |
---|
| 964 | invalid = 1; |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | if (!invalid) { |
---|
| 968 | if ((offset > st.st_size) || (len > st.st_size)) |
---|
| 969 | invalid = 1; |
---|
| 970 | else if ((st.st_size - offset) < len) |
---|
| 971 | len = st.st_size - offset; |
---|
| 972 | else if ((st.st_size - len) < len) |
---|
| 973 | len = st.st_size - len; |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | if (!invalid && len) { |
---|
| 977 | len %= 4096; |
---|
| 978 | } |
---|
| 979 | |
---|
| 980 | if (invalid) { |
---|
| 981 | int i; |
---|
| 982 | |
---|
[34509d5] | 983 | owl_free(filename); /* not needed */ |
---|
[8c46404] | 984 | owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname); |
---|
[d09e5a1] | 985 | i = 8; |
---|
| 986 | if (modname) { |
---|
| 987 | i+=strlen(modname); |
---|
| 988 | } |
---|
| 989 | |
---|
[34509d5] | 990 | if (!(buf = owl_malloc(i))) { |
---|
[d09e5a1] | 991 | return -1; |
---|
| 992 | } |
---|
| 993 | |
---|
| 994 | i=0; |
---|
| 995 | |
---|
| 996 | if (modname) { |
---|
| 997 | memcpy(buf, modname, strlen(modname)); |
---|
| 998 | i+=strlen(modname); |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | /* Damn endianness. This must be little (LSB first) endian. */ |
---|
| 1002 | buf[i++] = offset & 0xff; |
---|
| 1003 | buf[i++] = (offset >> 8) & 0xff; |
---|
| 1004 | buf[i++] = (offset >> 16) & 0xff; |
---|
| 1005 | buf[i++] = (offset >> 24) & 0xff; |
---|
| 1006 | buf[i++] = len & 0xff; |
---|
| 1007 | buf[i++] = (len >> 8) & 0xff; |
---|
| 1008 | buf[i++] = (len >> 16) & 0xff; |
---|
| 1009 | buf[i++] = (len >> 24) & 0xff; |
---|
| 1010 | |
---|
| 1011 | *bufret = buf; |
---|
| 1012 | *buflenret = i; |
---|
| 1013 | } else { |
---|
[34509d5] | 1014 | if (!(buf = owl_malloc(len))) { |
---|
| 1015 | owl_free(filename); |
---|
[d09e5a1] | 1016 | return -1; |
---|
| 1017 | } |
---|
| 1018 | /* printf("memrequest: loading %ld bytes from 0x%08lx in \"%s\"...\n", len, offset, filename); */ |
---|
| 1019 | if (!(f = fopen(filename, "r"))) { |
---|
| 1020 | /* perror("memrequest: fopen"); */ |
---|
[34509d5] | 1021 | owl_free(filename); |
---|
| 1022 | owl_free(buf); |
---|
[d09e5a1] | 1023 | return -1; |
---|
| 1024 | } |
---|
| 1025 | |
---|
[34509d5] | 1026 | owl_free(filename); |
---|
[d09e5a1] | 1027 | |
---|
| 1028 | if (fseek(f, offset, SEEK_SET) == -1) { |
---|
| 1029 | /* perror("memrequest: fseek"); */ |
---|
| 1030 | fclose(f); |
---|
[34509d5] | 1031 | owl_free(buf); |
---|
[d09e5a1] | 1032 | return -1; |
---|
| 1033 | } |
---|
| 1034 | |
---|
| 1035 | if (fread(buf, len, 1, f) != 1) { |
---|
| 1036 | /* perror("memrequest: fread"); */ |
---|
| 1037 | fclose(f); |
---|
[34509d5] | 1038 | owl_free(buf); |
---|
[d09e5a1] | 1039 | return -1; |
---|
| 1040 | } |
---|
| 1041 | |
---|
| 1042 | fclose(f); |
---|
| 1043 | *bufret = buf; |
---|
| 1044 | *buflenret = len; |
---|
| 1045 | } |
---|
| 1046 | return 0; /* success! */ |
---|
| 1047 | } |
---|
| 1048 | |
---|
| 1049 | /* |
---|
| 1050 | * This will get an offset and a length. The client should read this |
---|
| 1051 | * data out of whatever AIM.EXE binary the user has provided (hopefully |
---|
| 1052 | * it matches the client information thats sent at login) and pass a |
---|
| 1053 | * buffer back to libfaim so it can hash the data and send it to AOL for |
---|
| 1054 | * inspection by the client police. |
---|
| 1055 | */ |
---|
| 1056 | static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1057 | { |
---|
[4d86e06] | 1058 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[d09e5a1] | 1059 | va_list ap; |
---|
| 1060 | fu32_t offset, len; |
---|
[e19eb97] | 1061 | const char *modname; |
---|
[d09e5a1] | 1062 | unsigned char *buf; |
---|
| 1063 | int buflen; |
---|
| 1064 | |
---|
| 1065 | va_start(ap, fr); |
---|
| 1066 | offset = va_arg(ap, fu32_t); |
---|
| 1067 | len = va_arg(ap, fu32_t); |
---|
[e19eb97] | 1068 | modname = va_arg(ap, const char *); |
---|
[d09e5a1] | 1069 | va_end(ap); |
---|
| 1070 | |
---|
| 1071 | if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) { |
---|
| 1072 | aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
---|
[34509d5] | 1073 | owl_free(buf); |
---|
[d09e5a1] | 1074 | } else { |
---|
[8c46404] | 1075 | owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname); |
---|
[d09e5a1] | 1076 | aim_sendmemblock(sess, fr->conn, offset, len, NULL, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
---|
| 1077 | } |
---|
| 1078 | return 1; |
---|
| 1079 | } |
---|
| 1080 | |
---|
[8c46404] | 1081 | /* |
---|
[d09e5a1] | 1082 | static void printuserflags(fu16_t flags) |
---|
| 1083 | { |
---|
[8c46404] | 1084 | if (flags & AIM_FLAG_UNCONFIRMED) printf("UNCONFIRMED "); |
---|
| 1085 | if (flags & AIM_FLAG_ADMINISTRATOR) printf("ADMINISTRATOR "); |
---|
| 1086 | if (flags & AIM_FLAG_AOL) printf("AOL "); |
---|
| 1087 | if (flags & AIM_FLAG_OSCAR_PAY) printf("OSCAR_PAY "); |
---|
| 1088 | if (flags & AIM_FLAG_FREE) printf("FREE "); |
---|
| 1089 | if (flags & AIM_FLAG_AWAY) printf("AWAY "); |
---|
| 1090 | if (flags & AIM_FLAG_ICQ) printf("ICQ "); |
---|
| 1091 | if (flags & AIM_FLAG_WIRELESS) printf("WIRELESS "); |
---|
| 1092 | if (flags & AIM_FLAG_ACTIVEBUDDY) printf("ACTIVEBUDDY "); |
---|
[d09e5a1] | 1093 | |
---|
| 1094 | return; |
---|
| 1095 | } |
---|
[8c46404] | 1096 | */ |
---|
[d09e5a1] | 1097 | |
---|
| 1098 | static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1099 | { |
---|
| 1100 | aim_userinfo_t *userinfo; |
---|
[e19eb97] | 1101 | const char *prof_encoding = NULL; |
---|
| 1102 | const char *prof = NULL; |
---|
[d09e5a1] | 1103 | fu16_t inforeq = 0; |
---|
[f4d0975] | 1104 | owl_buddy *b; |
---|
[d09e5a1] | 1105 | va_list ap; |
---|
| 1106 | va_start(ap, fr); |
---|
| 1107 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1108 | inforeq = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1109 | prof_encoding = va_arg(ap, const char *); |
---|
| 1110 | prof = va_arg(ap, const char *); |
---|
[d09e5a1] | 1111 | va_end(ap); |
---|
| 1112 | |
---|
[de03334] | 1113 | /* right now the only reason we call this is for idle times */ |
---|
[f4d0975] | 1114 | owl_function_debugmsg("parse_userinfo sn: %s idle: %i", userinfo->sn, userinfo->idletime); |
---|
| 1115 | b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), |
---|
| 1116 | userinfo->sn); |
---|
| 1117 | if (!b) return(1); |
---|
| 1118 | owl_buddy_set_idle_since(b, userinfo->idletime); |
---|
[de03334] | 1119 | return(1); |
---|
[d09e5a1] | 1120 | |
---|
[8c92848] | 1121 | /* |
---|
[d09e5a1] | 1122 | printf("userinfo: sn: %s\n", userinfo->sn); |
---|
| 1123 | printf("userinfo: warnlevel: %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1124 | printf("userinfo: flags: 0x%04x = ", userinfo->flags); |
---|
| 1125 | printuserflags(userinfo->flags); |
---|
| 1126 | printf("\n"); |
---|
[8c92848] | 1127 | */ |
---|
[f4d0975] | 1128 | |
---|
| 1129 | /* |
---|
[d09e5a1] | 1130 | printf("userinfo: membersince: %lu\n", userinfo->membersince); |
---|
| 1131 | printf("userinfo: onlinesince: %lu\n", userinfo->onlinesince); |
---|
| 1132 | printf("userinfo: idletime: 0x%04x\n", userinfo->idletime); |
---|
| 1133 | printf("userinfo: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities); |
---|
[f4d0975] | 1134 | */ |
---|
[8c46404] | 1135 | |
---|
| 1136 | /* |
---|
[d09e5a1] | 1137 | if (inforeq == AIM_GETINFO_GENERALINFO) { |
---|
[8c92848] | 1138 | owl_function_debugmsg("userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); |
---|
| 1139 | owl_function_debugmsg("userinfo: prof: %s\n", prof ? prof : "[none]"); |
---|
[d09e5a1] | 1140 | } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) { |
---|
[8c92848] | 1141 | owl_function_debugmsg("userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); |
---|
| 1142 | owl_function_debugmsg("userinfo: awaymsg: %s\n", prof ? prof : "[none]"); |
---|
[d09e5a1] | 1143 | } else if (inforeq == AIM_GETINFO_CAPABILITIES) { |
---|
[8c92848] | 1144 | owl_function_debugmsg("userinfo: capabilities: see above\n"); |
---|
[d09e5a1] | 1145 | } else { |
---|
[8c92848] | 1146 | owl_function_debugmsg("userinfo: unknown info request\n"); |
---|
[d09e5a1] | 1147 | } |
---|
[8c46404] | 1148 | */ |
---|
[8c92848] | 1149 | return(1); |
---|
[d09e5a1] | 1150 | } |
---|
| 1151 | |
---|
| 1152 | /* |
---|
| 1153 | * Channel 1: Standard Message |
---|
| 1154 | */ |
---|
| 1155 | static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) |
---|
| 1156 | { |
---|
| 1157 | owl_message *m; |
---|
[ab31454] | 1158 | char *stripmsg, *nz_screenname, *wrapmsg; |
---|
[2646676] | 1159 | char realmsg[8192+1] = ""; |
---|
[f4d0975] | 1160 | /* int clienttype = AIM_CLIENTTYPE_UNKNOWN; */ |
---|
| 1161 | |
---|
| 1162 | /* clienttype = aim_fingerprintclient(args->features, args->featureslen); */ |
---|
[d09e5a1] | 1163 | |
---|
| 1164 | /* |
---|
| 1165 | printf("icbm: sn = \"%s\"\n", userinfo->sn); |
---|
| 1166 | printf("icbm: probable client type: %d\n", clienttype); |
---|
| 1167 | printf("icbm: warnlevel = %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1168 | printf("icbm: flags = 0x%04x = ", userinfo->flags); |
---|
| 1169 | printuserflags(userinfo->flags); |
---|
| 1170 | printf("\n"); |
---|
| 1171 | */ |
---|
| 1172 | |
---|
| 1173 | /* |
---|
| 1174 | printf("icbm: membersince = %lu\n", userinfo->membersince); |
---|
| 1175 | printf("icbm: onlinesince = %lu\n", userinfo->onlinesince); |
---|
| 1176 | printf("icbm: idletime = 0x%04x\n", userinfo->idletime); |
---|
| 1177 | printf("icbm: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities); |
---|
| 1178 | */ |
---|
| 1179 | |
---|
| 1180 | /* |
---|
| 1181 | printf("icbm: icbmflags = "); |
---|
| 1182 | if (args->icbmflags & AIM_IMFLAGS_AWAY) printf("away "); |
---|
| 1183 | if (args->icbmflags & AIM_IMFLAGS_ACK) printf("ackrequest "); |
---|
| 1184 | if (args->icbmflags & AIM_IMFLAGS_OFFLINE) printf("offline "); |
---|
| 1185 | if (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) printf("buddyreq "); |
---|
| 1186 | if (args->icbmflags & AIM_IMFLAGS_HASICON) printf("hasicon "); |
---|
| 1187 | printf("\n"); |
---|
| 1188 | */ |
---|
| 1189 | |
---|
[f4d0975] | 1190 | /* |
---|
[d09e5a1] | 1191 | if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) { |
---|
[f4d0975] | 1192 | printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset); |
---|
[d09e5a1] | 1193 | } |
---|
[f4d0975] | 1194 | */ |
---|
[d09e5a1] | 1195 | |
---|
| 1196 | /* |
---|
| 1197 | * Quickly convert it to eight bit format, replacing non-ASCII UNICODE |
---|
| 1198 | * characters with their equivelent HTML entity. |
---|
| 1199 | */ |
---|
| 1200 | if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
---|
| 1201 | int i; |
---|
| 1202 | |
---|
[ae4cd12] | 1203 | for (i=0; i<args->msglen; i+=2) { |
---|
[d09e5a1] | 1204 | fu16_t uni; |
---|
| 1205 | |
---|
| 1206 | uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); |
---|
| 1207 | if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ |
---|
| 1208 | snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "%c", uni); |
---|
| 1209 | } else { /* something else, do UNICODE entity */ |
---|
| 1210 | snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "&#%04x;", uni); |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | } else { |
---|
| 1214 | /* |
---|
| 1215 | * For non-UNICODE encodings (ASCII and ISO 8859-1), there is |
---|
| 1216 | * no need to do anything special here. Most |
---|
| 1217 | * terminals/whatever will be able to display such characters |
---|
| 1218 | * unmodified. |
---|
| 1219 | * |
---|
| 1220 | * Beware that PC-ASCII 128 through 159 are _not_ actually |
---|
| 1221 | * defined in ASCII or ISO 8859-1, and you should send them as |
---|
| 1222 | * UNICODE. WinAIM will send these characters in a UNICODE |
---|
| 1223 | * message, so you need to do so as well. |
---|
| 1224 | * |
---|
| 1225 | * You may not think it necessary to handle UNICODE messages. |
---|
| 1226 | * You're probably wrong. For one thing, Microsoft "Smart |
---|
| 1227 | * Quotes" will be sent by WinAIM as UNICODE (not HTML UNICODE, |
---|
| 1228 | * but real UNICODE). If you don't parse UNICODE at all, your |
---|
| 1229 | * users will get a blank message instead of the message |
---|
| 1230 | * containing Smart Quotes. |
---|
| 1231 | * |
---|
| 1232 | */ |
---|
[e3e6cff] | 1233 | if (args->msg && args->msglen) |
---|
| 1234 | strncpy(realmsg, args->msg, sizeof(realmsg)); |
---|
[d09e5a1] | 1235 | } |
---|
| 1236 | |
---|
[8c46404] | 1237 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: message from: %s", userinfo->sn?userinfo->sn:""); |
---|
[d09e5a1] | 1238 | /* create a message, and put it on the message queue */ |
---|
[3abf28b] | 1239 | stripmsg=owl_text_htmlstrip(realmsg); |
---|
[ab31454] | 1240 | wrapmsg=owl_text_wordwrap(stripmsg, 70); |
---|
[ae4cd12] | 1241 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
[d09e5a1] | 1242 | m=owl_malloc(sizeof(owl_message)); |
---|
[d559df9] | 1243 | owl_message_create_aim(m, |
---|
| 1244 | nz_screenname, |
---|
| 1245 | owl_global_get_aim_screenname(&g), |
---|
[ab31454] | 1246 | wrapmsg, |
---|
[d559df9] | 1247 | OWL_MESSAGE_DIRECTION_IN, |
---|
| 1248 | 0); |
---|
[9854278] | 1249 | if (args->icbmflags & AIM_IMFLAGS_AWAY) owl_message_set_attribute(m, "isauto", ""); |
---|
[d09e5a1] | 1250 | owl_global_messagequeue_addmsg(&g, m); |
---|
[3abf28b] | 1251 | owl_free(stripmsg); |
---|
[ab31454] | 1252 | owl_free(wrapmsg); |
---|
[ae4cd12] | 1253 | owl_free(nz_screenname); |
---|
[fd93b41] | 1254 | |
---|
| 1255 | return(1); |
---|
[8c46404] | 1256 | |
---|
| 1257 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg); |
---|
[d09e5a1] | 1258 | |
---|
| 1259 | if (args->icbmflags & AIM_IMFLAGS_MULTIPART) { |
---|
| 1260 | aim_mpmsg_section_t *sec; |
---|
| 1261 | int z; |
---|
| 1262 | |
---|
[8c46404] | 1263 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts); |
---|
[d09e5a1] | 1264 | |
---|
| 1265 | for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) { |
---|
| 1266 | if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) { |
---|
[8c46404] | 1267 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data); |
---|
[d09e5a1] | 1268 | } else { |
---|
[8c46404] | 1269 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset); |
---|
[d09e5a1] | 1270 | } |
---|
| 1271 | } |
---|
| 1272 | } |
---|
| 1273 | |
---|
| 1274 | if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
---|
[651560f] | 1275 | /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */ |
---|
[f278ff3] | 1276 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: their icon: iconstamp = %ld, iconlen = 0x%08x, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum); |
---|
[d09e5a1] | 1277 | } |
---|
[fd93b41] | 1278 | |
---|
| 1279 | /* |
---|
[d09e5a1] | 1280 | if (realmsg) { |
---|
| 1281 | int i = 0; |
---|
| 1282 | while (realmsg[i] == '<') { |
---|
| 1283 | if (realmsg[i] == '<') { |
---|
| 1284 | while (realmsg[i] != '>') |
---|
| 1285 | i++; |
---|
| 1286 | i++; |
---|
| 1287 | } |
---|
| 1288 | } |
---|
| 1289 | tmpstr = realmsg+i; |
---|
| 1290 | faimtest_handlecmd(sess, conn, userinfo, tmpstr); |
---|
| 1291 | } |
---|
[fd93b41] | 1292 | */ |
---|
[d09e5a1] | 1293 | |
---|
[8c92848] | 1294 | return(1); |
---|
[d09e5a1] | 1295 | } |
---|
| 1296 | |
---|
| 1297 | /* |
---|
| 1298 | * Channel 2: Rendevous Request |
---|
| 1299 | */ |
---|
| 1300 | static int faimtest_parse_incoming_im_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) |
---|
| 1301 | { |
---|
| 1302 | /* |
---|
| 1303 | printf("rendezvous: source sn = %s\n", userinfo->sn); |
---|
| 1304 | printf("rendezvous: \twarnlevel = %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1305 | printf("rendezvous: \tclass = 0x%04x = ", userinfo->flags); |
---|
| 1306 | printuserflags(userinfo->flags); |
---|
| 1307 | printf("\n"); |
---|
| 1308 | |
---|
| 1309 | printf("rendezvous: \tonlinesince = %lu\n", userinfo->onlinesince); |
---|
| 1310 | printf("rendezvous: \tidletime = 0x%04x\n", userinfo->idletime); |
---|
| 1311 | |
---|
| 1312 | printf("rendezvous: message/description = %s\n", args->msg); |
---|
| 1313 | printf("rendezvous: encoding = %s\n", args->encoding); |
---|
| 1314 | printf("rendezvous: language = %s\n", args->language); |
---|
| 1315 | */ |
---|
| 1316 | |
---|
[f4d0975] | 1317 | if (args->reqclass == AIM_CAPS_SENDFILE) { |
---|
[8c46404] | 1318 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: send file!"); |
---|
[d09e5a1] | 1319 | } else if (args->reqclass == AIM_CAPS_CHAT) { |
---|
[8c46404] | 1320 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: chat invite: %s, %i, %i", args->info.chat.roominfo.name, args->info.chat.roominfo.exchange, args->info.chat.roominfo.instance); |
---|
[d09e5a1] | 1321 | /* |
---|
| 1322 | printf("chat invitation: room name = %s\n", args->info.chat.roominfo.name); |
---|
| 1323 | printf("chat invitation: exchange = 0x%04x\n", args->info.chat.roominfo.exchange); |
---|
| 1324 | printf("chat invitation: instance = 0x%04x\n", args->info.chat.roominfo.instance); |
---|
| 1325 | */ |
---|
| 1326 | /* Automatically join room... */ |
---|
| 1327 | /* printf("chat invitiation: autojoining %s...\n", args->info.chat.roominfo.name); */ |
---|
[fd93b41] | 1328 | |
---|
| 1329 | /* aim_chat_join(sess, conn, args->info.chat.roominfo.exchange, args->info.chat.roominfo.name, args->info.chat.roominfo.instance); */ |
---|
[d09e5a1] | 1330 | } else if (args->reqclass == AIM_CAPS_BUDDYICON) { |
---|
[f278ff3] | 1331 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: Buddy Icon from %s, length = %u\n", |
---|
[8c46404] | 1332 | userinfo->sn, args->info.icon.length); |
---|
[d09e5a1] | 1333 | } else if (args->reqclass == AIM_CAPS_ICQRTF) { |
---|
[f278ff3] | 1334 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: RTF message from %s: (fgcolor = 0x%08x, bgcolor = 0x%08x) %s\n", |
---|
[8c46404] | 1335 | userinfo->sn, args->info.rtfmsg.fgcolor, args->info.rtfmsg.bgcolor, args->info.rtfmsg.rtfmsg); |
---|
[d09e5a1] | 1336 | } else { |
---|
[8c46404] | 1337 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: icbm: unknown reqclass (%d)\n", args->reqclass); |
---|
[d09e5a1] | 1338 | } |
---|
| 1339 | return 1; |
---|
| 1340 | } |
---|
| 1341 | |
---|
| 1342 | static int faimtest_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1343 | { |
---|
| 1344 | fu16_t channel; |
---|
| 1345 | aim_userinfo_t *userinfo; |
---|
| 1346 | va_list ap; |
---|
| 1347 | int ret = 0; |
---|
| 1348 | |
---|
| 1349 | va_start(ap, fr); |
---|
| 1350 | channel = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1351 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1352 | |
---|
| 1353 | if (channel == 1) { |
---|
| 1354 | struct aim_incomingim_ch1_args *args; |
---|
| 1355 | args = va_arg(ap, struct aim_incomingim_ch1_args *); |
---|
| 1356 | ret = faimtest_parse_incoming_im_chan1(sess, fr->conn, userinfo, args); |
---|
| 1357 | } else if (channel == 2) { |
---|
| 1358 | struct aim_incomingim_ch2_args *args; |
---|
| 1359 | args = va_arg(ap, struct aim_incomingim_ch2_args *); |
---|
| 1360 | ret = faimtest_parse_incoming_im_chan2(sess, fr->conn, userinfo, args); |
---|
| 1361 | } else { |
---|
[8c46404] | 1362 | owl_function_debugmsg("faimtest_parse_incoming_im: unsupported channel 0x%04x\n", channel); |
---|
[d09e5a1] | 1363 | } |
---|
| 1364 | va_end(ap); |
---|
[8c46404] | 1365 | owl_function_debugmsg("faimtest_parse_incoming_im: done with ICBM handling (ret = %d)\n", ret); |
---|
[d09e5a1] | 1366 | return 1; |
---|
| 1367 | } |
---|
| 1368 | |
---|
| 1369 | static int faimtest_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1370 | { |
---|
| 1371 | aim_userinfo_t *userinfo; |
---|
[ae4cd12] | 1372 | char *nz_screenname; |
---|
[f4d0975] | 1373 | owl_buddy *b; |
---|
[d09e5a1] | 1374 | va_list ap; |
---|
| 1375 | va_start(ap, fr); |
---|
| 1376 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1377 | va_end(ap); |
---|
[aa5f725] | 1378 | |
---|
[ae4cd12] | 1379 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
[f4d0975] | 1380 | |
---|
[ae4cd12] | 1381 | owl_buddylist_oncoming(owl_global_get_buddylist(&g), nz_screenname); |
---|
[f4d0975] | 1382 | |
---|
| 1383 | if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
---|
[8c46404] | 1384 | owl_function_debugmsg("faimtest_parseoncoming: in empty part of userinfo present and present idle"); |
---|
[f4d0975] | 1385 | } |
---|
| 1386 | |
---|
| 1387 | b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), nz_screenname); |
---|
| 1388 | if (!b) { |
---|
| 1389 | owl_function_debugmsg("Error: parse_oncoming setting idle time with no buddy present."); |
---|
| 1390 | return(1); |
---|
| 1391 | } |
---|
| 1392 | if (userinfo->idletime==0) { |
---|
| 1393 | owl_buddy_set_unidle(b); |
---|
| 1394 | } else { |
---|
| 1395 | owl_buddy_set_idle(b); |
---|
| 1396 | owl_buddy_set_idle_since(b, userinfo->idletime); |
---|
| 1397 | } |
---|
[8c92848] | 1398 | |
---|
| 1399 | if (userinfo->flags & AIM_FLAG_AWAY) { |
---|
| 1400 | owl_function_debugmsg("parse_oncoming sn: %s away flag!", userinfo->sn); |
---|
| 1401 | } |
---|
| 1402 | |
---|
[f4d0975] | 1403 | owl_function_debugmsg("parse_oncoming sn: %s idle: %i", userinfo->sn, userinfo->idletime); |
---|
| 1404 | |
---|
[ae4cd12] | 1405 | owl_free(nz_screenname); |
---|
[aa5f725] | 1406 | |
---|
[d09e5a1] | 1407 | /* |
---|
| 1408 | printf("%ld %s is now online (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n", |
---|
| 1409 | time(NULL), |
---|
| 1410 | userinfo->sn, userinfo->flags, |
---|
| 1411 | (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"", |
---|
| 1412 | (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"", |
---|
| 1413 | (userinfo->flags&AIM_FLAG_AOL)?" AOL":"", |
---|
| 1414 | (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"", |
---|
| 1415 | (userinfo->flags&AIM_FLAG_FREE)?" FREE":"", |
---|
| 1416 | (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"", |
---|
| 1417 | (userinfo->flags&AIM_FLAG_ICQ)?" ICQ":"", |
---|
| 1418 | (userinfo->flags&AIM_FLAG_WIRELESS)?" WIRELESS":"", |
---|
| 1419 | (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", |
---|
| 1420 | userinfo->capabilities); |
---|
| 1421 | */ |
---|
[aa5f725] | 1422 | return(1); |
---|
[d09e5a1] | 1423 | } |
---|
| 1424 | |
---|
| 1425 | static int faimtest_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1426 | { |
---|
| 1427 | aim_userinfo_t *userinfo; |
---|
[ae4cd12] | 1428 | char *nz_screenname; |
---|
[d09e5a1] | 1429 | va_list ap; |
---|
| 1430 | |
---|
| 1431 | va_start(ap, fr); |
---|
| 1432 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1433 | va_end(ap); |
---|
| 1434 | |
---|
[ae4cd12] | 1435 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
| 1436 | owl_buddylist_offgoing(owl_global_get_buddylist(&g), nz_screenname); |
---|
| 1437 | owl_free(nz_screenname); |
---|
[aa5f725] | 1438 | |
---|
[f4d0975] | 1439 | if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
---|
| 1440 | owl_function_debugmsg("parse_offgoing sn: %s idle time %i", userinfo->sn, userinfo->idletime); |
---|
| 1441 | } |
---|
| 1442 | |
---|
[d09e5a1] | 1443 | /* |
---|
| 1444 | printf("%ld %s is now offline (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n", |
---|
| 1445 | time(NULL), |
---|
| 1446 | userinfo->sn, userinfo->flags, |
---|
| 1447 | (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"", |
---|
| 1448 | (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"", |
---|
| 1449 | (userinfo->flags&AIM_FLAG_AOL)?" AOL":"", |
---|
| 1450 | (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"", |
---|
| 1451 | (userinfo->flags&AIM_FLAG_FREE)?" FREE":"", |
---|
| 1452 | (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"", |
---|
| 1453 | (userinfo->flags&AIM_FLAG_ICQ)?" ICQ":"", |
---|
| 1454 | (userinfo->flags&AIM_FLAG_WIRELESS)?" WIRELESS":"", |
---|
| 1455 | (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", |
---|
| 1456 | userinfo->capabilities); |
---|
| 1457 | */ |
---|
| 1458 | |
---|
| 1459 | return 1; |
---|
| 1460 | } |
---|
| 1461 | |
---|
| 1462 | /* Used by chat as well. */ |
---|
| 1463 | int faimtest_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1464 | { |
---|
| 1465 | va_list ap; |
---|
| 1466 | fu16_t reason; |
---|
| 1467 | |
---|
| 1468 | va_start(ap, fr); |
---|
| 1469 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1470 | va_end(ap); |
---|
| 1471 | |
---|
| 1472 | /* printf("snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1473 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[d09e5a1] | 1474 | |
---|
| 1475 | return 1; |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | static int faimtest_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1479 | { |
---|
| 1480 | va_list ap; |
---|
[e19eb97] | 1481 | const char *destsn; |
---|
[d09e5a1] | 1482 | fu16_t reason; |
---|
| 1483 | |
---|
| 1484 | va_start(ap, fr); |
---|
| 1485 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1486 | destsn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1487 | va_end(ap); |
---|
| 1488 | |
---|
| 1489 | /* printf("message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1490 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[a836200] | 1491 | |
---|
| 1492 | if (reason==4) { |
---|
| 1493 | owl_function_adminmsg("", "Could not send AIM message, user not logged on"); |
---|
| 1494 | } |
---|
[d09e5a1] | 1495 | |
---|
| 1496 | return 1; |
---|
| 1497 | } |
---|
| 1498 | |
---|
| 1499 | static int faimtest_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1500 | { |
---|
| 1501 | va_list ap; |
---|
[e19eb97] | 1502 | const char *destsn; |
---|
[d09e5a1] | 1503 | fu16_t reason; |
---|
| 1504 | |
---|
| 1505 | va_start(ap, fr); |
---|
| 1506 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1507 | destsn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1508 | va_end(ap); |
---|
| 1509 | |
---|
| 1510 | /* printf("user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1511 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[d09e5a1] | 1512 | |
---|
| 1513 | return 1; |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | static int faimtest_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1517 | { |
---|
[e19eb97] | 1518 | static const char *missedreasons[] = { |
---|
[d09e5a1] | 1519 | "Invalid (0)", |
---|
| 1520 | "Message too large", |
---|
| 1521 | "Rate exceeded", |
---|
| 1522 | "Evil Sender", |
---|
| 1523 | "Evil Receiver" |
---|
| 1524 | }; |
---|
[8c46404] | 1525 | static int missedreasonslen = 5; |
---|
[d09e5a1] | 1526 | |
---|
| 1527 | va_list ap; |
---|
| 1528 | fu16_t chan, nummissed, reason; |
---|
| 1529 | aim_userinfo_t *userinfo; |
---|
| 1530 | |
---|
| 1531 | va_start(ap, fr); |
---|
| 1532 | chan = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1533 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1534 | nummissed = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1535 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1536 | va_end(ap); |
---|
| 1537 | |
---|
[8c46404] | 1538 | owl_function_debugmsg("faimtest_parse_misses: missed %d messages from %s on channel %d (reason %d: %s)\n", nummissed, userinfo->sn, chan, reason, (reason<missedreasonslen)?missedreasons[reason]:"unknown"); |
---|
[d09e5a1] | 1539 | |
---|
| 1540 | return 1; |
---|
| 1541 | } |
---|
| 1542 | |
---|
| 1543 | /* |
---|
| 1544 | * Received in response to an IM sent with the AIM_IMFLAGS_ACK option. |
---|
| 1545 | */ |
---|
| 1546 | static int faimtest_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1547 | { |
---|
| 1548 | va_list ap; |
---|
| 1549 | fu16_t type; |
---|
[e19eb97] | 1550 | const char *sn = NULL; |
---|
[d09e5a1] | 1551 | |
---|
| 1552 | va_start(ap, fr); |
---|
| 1553 | type = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1554 | sn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1555 | va_end(ap); |
---|
| 1556 | |
---|
[8c46404] | 1557 | owl_function_debugmsg("faimtest_parse_msgack: 0x%04x / %s\n", type, sn); |
---|
[d09e5a1] | 1558 | |
---|
| 1559 | return 1; |
---|
| 1560 | } |
---|
| 1561 | |
---|
| 1562 | static int faimtest_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1563 | { |
---|
[e19eb97] | 1564 | static const char *codes[5] = { |
---|
[d09e5a1] | 1565 | "invalid", |
---|
| 1566 | "change", |
---|
| 1567 | "warning", |
---|
| 1568 | "limit", |
---|
| 1569 | "limit cleared" |
---|
| 1570 | }; |
---|
| 1571 | va_list ap; |
---|
| 1572 | fu16_t code, rateclass; |
---|
| 1573 | fu32_t windowsize, clear, alert, limit, disconnect; |
---|
| 1574 | fu32_t currentavg, maxavg; |
---|
| 1575 | |
---|
| 1576 | va_start(ap, fr); |
---|
| 1577 | |
---|
| 1578 | /* See code explanations below */ |
---|
| 1579 | code = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1580 | |
---|
| 1581 | /* |
---|
| 1582 | * See comments above aim_parse_ratechange_middle() in aim_rxhandlers.c. |
---|
| 1583 | */ |
---|
| 1584 | rateclass = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1585 | |
---|
| 1586 | /* |
---|
| 1587 | * Not sure what this is exactly. I think its the temporal |
---|
| 1588 | * relation factor (ie, how to make the rest of the numbers |
---|
| 1589 | * make sense in the real world). |
---|
| 1590 | */ |
---|
| 1591 | windowsize = va_arg(ap, fu32_t); |
---|
| 1592 | |
---|
| 1593 | /* Explained below */ |
---|
| 1594 | clear = va_arg(ap, fu32_t); |
---|
| 1595 | alert = va_arg(ap, fu32_t); |
---|
| 1596 | limit = va_arg(ap, fu32_t); |
---|
| 1597 | disconnect = va_arg(ap, fu32_t); |
---|
| 1598 | currentavg = va_arg(ap, fu32_t); |
---|
| 1599 | maxavg = va_arg(ap, fu32_t); |
---|
| 1600 | |
---|
| 1601 | va_end(ap); |
---|
| 1602 | |
---|
[f278ff3] | 1603 | owl_function_debugmsg("faimtest_parse_ratechange: rate %s (rate class 0x%04x): curavg = %u, maxavg = %u, alert at %u, clear warning at %u, limit at %u, disconnect at %u (window size = %u)", |
---|
[8c46404] | 1604 | (code < 5)?codes[code]:"invalid", |
---|
| 1605 | rateclass, |
---|
| 1606 | currentavg, maxavg, |
---|
| 1607 | alert, clear, |
---|
| 1608 | limit, disconnect, |
---|
| 1609 | windowsize); |
---|
[d09e5a1] | 1610 | return 1; |
---|
| 1611 | } |
---|
| 1612 | |
---|
| 1613 | static int faimtest_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1614 | { |
---|
| 1615 | va_list ap; |
---|
| 1616 | fu16_t newevil; |
---|
| 1617 | aim_userinfo_t *userinfo; |
---|
| 1618 | |
---|
| 1619 | va_start(ap, fr); |
---|
| 1620 | newevil = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1621 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1622 | va_end(ap); |
---|
| 1623 | |
---|
| 1624 | /* |
---|
| 1625 | * Evil Notifications that are lacking userinfo->sn are anon-warns |
---|
| 1626 | * if they are an evil increases, but are not warnings at all if its |
---|
| 1627 | * a decrease (its the natural backoff happening). |
---|
| 1628 | * |
---|
| 1629 | * newevil is passed as an int representing the new evil value times |
---|
| 1630 | * ten. |
---|
| 1631 | */ |
---|
[8c46404] | 1632 | owl_function_debugmsg("faimtest_parse_evilnotify: new value = %2.1f%% (caused by %s)\n", ((float)newevil)/10, (userinfo && strlen(userinfo->sn))?userinfo->sn:"anonymous"); |
---|
[d09e5a1] | 1633 | |
---|
| 1634 | return 1; |
---|
| 1635 | } |
---|
| 1636 | |
---|
| 1637 | static int faimtest_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1638 | { |
---|
| 1639 | va_list ap; |
---|
[e19eb97] | 1640 | const char *address, *SNs; |
---|
[8c46404] | 1641 | int num, i; |
---|
[952bb256] | 1642 | owl_list list; |
---|
[d09e5a1] | 1643 | |
---|
| 1644 | va_start(ap, fr); |
---|
[e19eb97] | 1645 | address = va_arg(ap, const char *); |
---|
[d09e5a1] | 1646 | num = va_arg(ap, int); |
---|
[e19eb97] | 1647 | SNs = va_arg(ap, const char *); |
---|
[d09e5a1] | 1648 | va_end(ap); |
---|
[952bb256] | 1649 | |
---|
| 1650 | owl_list_create(&list); |
---|
[d09e5a1] | 1651 | |
---|
[8c46404] | 1652 | owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address); |
---|
[952bb256] | 1653 | for (i=0; i<num; i++) { |
---|
[8c46404] | 1654 | owl_function_debugmsg(" %s", &SNs[i*(MAXSNLEN+1)]); |
---|
[fa4562c] | 1655 | owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]); |
---|
[8c46404] | 1656 | } |
---|
[952bb256] | 1657 | owl_function_aimsearch_results(address, &list); |
---|
| 1658 | owl_list_free_simple(&list); |
---|
| 1659 | return(1); |
---|
[d09e5a1] | 1660 | } |
---|
| 1661 | |
---|
| 1662 | static int faimtest_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1663 | { |
---|
| 1664 | va_list ap; |
---|
[e19eb97] | 1665 | const char *address; |
---|
[d09e5a1] | 1666 | |
---|
| 1667 | va_start(ap, fr); |
---|
[e19eb97] | 1668 | address = va_arg(ap, const char *); |
---|
[d09e5a1] | 1669 | va_end(ap); |
---|
[952bb256] | 1670 | |
---|
| 1671 | owl_function_error("No results searching for %s", address); |
---|
[8c46404] | 1672 | owl_function_debugmsg("faimtest_parse_searcherror: E-Mail Search Results for %s: No Results or Invalid Email\n", address); |
---|
[d09e5a1] | 1673 | |
---|
[952bb256] | 1674 | return(1); |
---|
[d09e5a1] | 1675 | } |
---|
| 1676 | |
---|
| 1677 | static int handlepopup(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1678 | { |
---|
| 1679 | va_list ap; |
---|
[e19eb97] | 1680 | const char *msg, *url; |
---|
[d09e5a1] | 1681 | fu16_t width, height, delay; |
---|
| 1682 | |
---|
| 1683 | va_start(ap, fr); |
---|
[e19eb97] | 1684 | msg = va_arg(ap, const char *); |
---|
| 1685 | url = va_arg(ap, const char *); |
---|
[d09e5a1] | 1686 | width = va_arg(ap, unsigned int); |
---|
| 1687 | height = va_arg(ap, unsigned int); |
---|
| 1688 | delay = va_arg(ap, unsigned int); |
---|
| 1689 | va_end(ap); |
---|
| 1690 | |
---|
[8c46404] | 1691 | owl_function_debugmsg("handlepopup: (%dx%x:%d) %s (%s)\n", width, height, delay, msg, url); |
---|
[d09e5a1] | 1692 | |
---|
| 1693 | return 1; |
---|
| 1694 | } |
---|
| 1695 | |
---|
| 1696 | static int serverpause(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1697 | { |
---|
| 1698 | aim_sendpauseack(sess, fr->conn); |
---|
| 1699 | return 1; |
---|
| 1700 | } |
---|
| 1701 | |
---|
| 1702 | static int migrate(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1703 | { |
---|
| 1704 | va_list ap; |
---|
| 1705 | aim_conn_t *bosconn; |
---|
[e19eb97] | 1706 | const char *bosip; |
---|
[d09e5a1] | 1707 | fu8_t *cookie; |
---|
| 1708 | |
---|
| 1709 | va_start(ap, fr); |
---|
[e19eb97] | 1710 | bosip = va_arg(ap, const char *); |
---|
[d09e5a1] | 1711 | cookie = va_arg(ap, fu8_t *); |
---|
| 1712 | va_end(ap); |
---|
| 1713 | |
---|
[8c46404] | 1714 | owl_function_debugmsg("migrate: migration in progress -- new BOS is %s -- disconnecting", bosip); |
---|
[d09e5a1] | 1715 | aim_conn_kill(sess, &fr->conn); |
---|
| 1716 | |
---|
| 1717 | if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip))) { |
---|
[8c46404] | 1718 | owl_function_debugmsg("migrate: could not connect to BOS: internal error"); |
---|
[d09e5a1] | 1719 | return 1; |
---|
| 1720 | } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) { |
---|
[8c46404] | 1721 | owl_function_debugmsg("migrate: could not connect to BOS"); |
---|
[d09e5a1] | 1722 | aim_conn_kill(sess, &bosconn); |
---|
| 1723 | return 1; |
---|
| 1724 | } |
---|
| 1725 | |
---|
| 1726 | /* Login will happen all over again. */ |
---|
| 1727 | addcb_bos(sess, bosconn); |
---|
[8c46404] | 1728 | /* aim_sendcookie(sess, bosconn, cookie); */ /********/ |
---|
[d09e5a1] | 1729 | return 1; |
---|
| 1730 | } |
---|
| 1731 | |
---|
| 1732 | static int ssirights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1733 | { |
---|
[8c46404] | 1734 | owl_function_debugmsg("ssirights: got SSI rights, requesting data\n"); |
---|
[f4d0975] | 1735 | /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */ |
---|
| 1736 | aim_ssi_reqdata(sess); |
---|
[d09e5a1] | 1737 | |
---|
[8c92848] | 1738 | return(1); |
---|
[d09e5a1] | 1739 | } |
---|
| 1740 | |
---|
| 1741 | static int ssidata(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1742 | { |
---|
| 1743 | va_list ap; |
---|
| 1744 | fu8_t fmtver; |
---|
| 1745 | fu16_t itemcount; |
---|
| 1746 | fu32_t stamp; |
---|
[f4d0975] | 1747 | struct aim_ssi_item *list; |
---|
[cdf0ef1] | 1748 | /* |
---|
[f4d0975] | 1749 | struct aim_ssi_item *curitem; |
---|
[8c46404] | 1750 | struct aim_ssi_item *l; |
---|
[cdf0ef1] | 1751 | */ |
---|
[d09e5a1] | 1752 | |
---|
| 1753 | va_start(ap, fr); |
---|
| 1754 | fmtver = va_arg(ap, unsigned int); |
---|
| 1755 | itemcount = va_arg(ap, unsigned int); |
---|
| 1756 | stamp = va_arg(ap, fu32_t); |
---|
| 1757 | list = va_arg(ap, struct aim_ssi_item *); |
---|
| 1758 | va_end(ap); |
---|
| 1759 | |
---|
[f278ff3] | 1760 | owl_function_debugmsg("ssiddata: got SSI data (0x%02x, %d items, %u)", fmtver, itemcount, stamp); |
---|
[8c46404] | 1761 | /* |
---|
[f4d0975] | 1762 | for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
---|
[8c46404] | 1763 | for (l = list; l; l = l->next) { |
---|
| 1764 | owl_function_debugmsg("\t0x%04x (%s) - 0x%04x/0x%04x", l->type, l->name, l->gid, l->bid); |
---|
| 1765 | } |
---|
[d09e5a1] | 1766 | } |
---|
[8c46404] | 1767 | */ |
---|
[f4d0975] | 1768 | aim_ssi_enable(sess); |
---|
[d09e5a1] | 1769 | |
---|
| 1770 | return 1; |
---|
| 1771 | } |
---|
| 1772 | |
---|
| 1773 | static int ssidatanochange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1774 | { |
---|
[8c46404] | 1775 | owl_function_debugmsg("ssidatanochange: server says we have the latest SSI data already"); |
---|
[f4d0975] | 1776 | /* aim_ssi_enable(sess, fr->conn); */ |
---|
| 1777 | aim_ssi_enable(sess); |
---|
[d09e5a1] | 1778 | return 1; |
---|
| 1779 | } |
---|
| 1780 | |
---|
| 1781 | static int offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1782 | { |
---|
| 1783 | va_list ap; |
---|
| 1784 | struct aim_icq_offlinemsg *msg; |
---|
| 1785 | |
---|
| 1786 | va_start(ap, fr); |
---|
| 1787 | msg = va_arg(ap, struct aim_icq_offlinemsg *); |
---|
| 1788 | va_end(ap); |
---|
| 1789 | |
---|
| 1790 | if (msg->type == 0x0001) { |
---|
[f278ff3] | 1791 | owl_function_debugmsg("offlinemsg: from %u at %d/%d/%d %02d:%02d : %s", msg->sender, msg->year, msg->month, msg->day, msg->hour, msg->minute, msg->msg); |
---|
[d09e5a1] | 1792 | } else { |
---|
[8c46404] | 1793 | owl_function_debugmsg("unknown offline message type 0x%04x", msg->type); |
---|
[d09e5a1] | 1794 | } |
---|
| 1795 | return 1; |
---|
| 1796 | } |
---|
| 1797 | |
---|
| 1798 | static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1799 | { |
---|
| 1800 | /* Tell the server to delete them. */ |
---|
[8c46404] | 1801 | owl_function_debugmsg("offlinemsg done: "); |
---|
[d09e5a1] | 1802 | aim_icq_ackofflinemsgs(sess); |
---|
| 1803 | return 1; |
---|
| 1804 | } |
---|
| 1805 | |
---|
| 1806 | |
---|
| 1807 | /******************** chat.c **************************/ |
---|
| 1808 | |
---|
| 1809 | static int faimtest_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1810 | { |
---|
| 1811 | va_list ap; |
---|
| 1812 | aim_userinfo_t *userinfo; |
---|
[0ff8fb57] | 1813 | int count; |
---|
| 1814 | /* int i; */ |
---|
[d09e5a1] | 1815 | |
---|
| 1816 | va_start(ap, fr); |
---|
| 1817 | count = va_arg(ap, int); |
---|
| 1818 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1819 | va_end(ap); |
---|
| 1820 | |
---|
[8c92848] | 1821 | owl_function_debugmsg("In faimtest_chat_join"); |
---|
[d09e5a1] | 1822 | /* |
---|
| 1823 | printf("chat: %s: New occupants have joined:\n", aim_chat_getname(fr->conn)); |
---|
| 1824 | for (i = 0; i < count; i++) |
---|
| 1825 | printf("chat: %s: \t%s\n", aim_chat_getname(fr->conn), userinfo[i].sn); |
---|
| 1826 | */ |
---|
| 1827 | return 1; |
---|
| 1828 | } |
---|
| 1829 | |
---|
| 1830 | static int faimtest_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1831 | { |
---|
| 1832 | aim_userinfo_t *userinfo; |
---|
[0ff8fb57] | 1833 | va_list ap; |
---|
| 1834 | int count; |
---|
| 1835 | /* int i; */ |
---|
| 1836 | |
---|
[d09e5a1] | 1837 | |
---|
| 1838 | va_start(ap, fr); |
---|
| 1839 | count = va_arg(ap, int); |
---|
| 1840 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1841 | va_end(ap); |
---|
| 1842 | |
---|
| 1843 | /* |
---|
| 1844 | printf("chat: %s: Some occupants have left:\n", aim_chat_getname(fr->conn)); |
---|
| 1845 | |
---|
| 1846 | for (i = 0; i < count; i++) |
---|
| 1847 | printf("chat: %s: \t%s\n", aim_chat_getname(fr->conn), userinfo[i].sn); |
---|
| 1848 | */ |
---|
| 1849 | return 1; |
---|
| 1850 | } |
---|
| 1851 | |
---|
| 1852 | static int faimtest_chat_infoupdate(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1853 | { |
---|
| 1854 | va_list ap; |
---|
| 1855 | aim_userinfo_t *userinfo; |
---|
| 1856 | struct aim_chat_roominfo *roominfo; |
---|
[e19eb97] | 1857 | const char *roomname; |
---|
[0ff8fb57] | 1858 | int usercount; |
---|
[e19eb97] | 1859 | const char *roomdesc; |
---|
[d09e5a1] | 1860 | fu16_t flags, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
---|
| 1861 | fu32_t creationtime; |
---|
| 1862 | const char *croomname; |
---|
[0ff8fb57] | 1863 | /* int i; */ |
---|
[d09e5a1] | 1864 | |
---|
| 1865 | croomname = aim_chat_getname(fr->conn); |
---|
| 1866 | |
---|
| 1867 | va_start(ap, fr); |
---|
| 1868 | roominfo = va_arg(ap, struct aim_chat_roominfo *); |
---|
[e19eb97] | 1869 | roomname = va_arg(ap, const char *); |
---|
[d09e5a1] | 1870 | usercount = va_arg(ap, int); |
---|
| 1871 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
[e19eb97] | 1872 | roomdesc = va_arg(ap, const char *); |
---|
[d09e5a1] | 1873 | flags = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1874 | creationtime = va_arg(ap, fu32_t); |
---|
| 1875 | maxmsglen = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1876 | unknown_d2 = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1877 | unknown_d5 = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1878 | maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1879 | va_end(ap); |
---|
| 1880 | |
---|
[8c92848] | 1881 | owl_function_debugmsg("In faimtest_chat_infoupdate"); |
---|
[d09e5a1] | 1882 | /* |
---|
| 1883 | printf("chat: %s: info update:\n", croomname); |
---|
| 1884 | printf("chat: %s: \tRoominfo: {%04x, %s, %04x}\n", croomname, roominfo->exchange, roominfo->name, roominfo->instance); |
---|
| 1885 | printf("chat: %s: \tRoomname: %s\n", croomname, roomname); |
---|
| 1886 | printf("chat: %s: \tRoomdesc: %s\n", croomname, roomdesc); |
---|
| 1887 | printf("chat: %s: \tOccupants: (%d)\n", croomname, usercount); |
---|
| 1888 | |
---|
| 1889 | for (i = 0; i < usercount; i++) |
---|
| 1890 | printf("chat: %s: \t\t%s\n", croomname, userinfo[i].sn); |
---|
| 1891 | |
---|
[8c92848] | 1892 | owl_function_debugmsg("chat: %s: \tRoom flags: 0x%04x (%s%s%s%s)\n", |
---|
[d09e5a1] | 1893 | croomname, flags, |
---|
| 1894 | (flags & AIM_CHATROOM_FLAG_EVILABLE) ? "Evilable, " : "", |
---|
| 1895 | (flags & AIM_CHATROOM_FLAG_NAV_ONLY) ? "Nav Only, " : "", |
---|
| 1896 | (flags & AIM_CHATROOM_FLAG_INSTANCING_ALLOWED) ? "Instancing allowed, " : "", |
---|
| 1897 | (flags & AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED) ? "Occupant peek allowed, " : ""); |
---|
| 1898 | printf("chat: %s: \tCreation time: %lu (time_t)\n", croomname, creationtime); |
---|
| 1899 | printf("chat: %s: \tUnknown_d2: 0x%04x\n", croomname, unknown_d2); |
---|
| 1900 | printf("chat: %s: \tUnknown_d5: 0x%02x\n", croomname, unknown_d5); |
---|
| 1901 | printf("chat: %s: \tMax message length: %d bytes\n", croomname, maxmsglen); |
---|
| 1902 | printf("chat: %s: \tMax visible message length: %d bytes\n", croomname, maxvisiblemsglen); |
---|
| 1903 | */ |
---|
| 1904 | |
---|
[8c92848] | 1905 | return(1); |
---|
[d09e5a1] | 1906 | } |
---|
| 1907 | |
---|
| 1908 | static int faimtest_chat_incomingmsg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1909 | { |
---|
| 1910 | va_list ap; |
---|
| 1911 | aim_userinfo_t *userinfo; |
---|
[e19eb97] | 1912 | const char *msg; |
---|
[d09e5a1] | 1913 | char tmpbuf[1152]; |
---|
| 1914 | |
---|
| 1915 | va_start(ap, fr); |
---|
| 1916 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
[e19eb97] | 1917 | msg = va_arg(ap, const char *); |
---|
[d09e5a1] | 1918 | va_end(ap); |
---|
| 1919 | |
---|
[8c92848] | 1920 | owl_function_debugmsg("in faimtest_chat_incomingmsg"); |
---|
| 1921 | |
---|
[d09e5a1] | 1922 | /* |
---|
| 1923 | printf("chat: %s: incoming msg from %s: %s\n", aim_chat_getname(fr->conn), userinfo->sn, msg); |
---|
| 1924 | */ |
---|
| 1925 | |
---|
| 1926 | /* |
---|
| 1927 | * Do an echo for testing purposes. But not for ourselves ("oops!") |
---|
| 1928 | */ |
---|
| 1929 | if (strcmp(userinfo->sn, sess->sn) != 0) { |
---|
| 1930 | /* sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); */ |
---|
| 1931 | aim_chat_send_im(sess, fr->conn, 0, tmpbuf, strlen(tmpbuf)); |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | return 1; |
---|
| 1935 | } |
---|
| 1936 | |
---|
| 1937 | static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1938 | { |
---|
[2674412] | 1939 | owl_function_debugmsg("faimtest_conninitdone_chat:"); |
---|
[d09e5a1] | 1940 | |
---|
[2674412] | 1941 | aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, faimtest_parse_genericerr, 0); |
---|
| 1942 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0); |
---|
| 1943 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0); |
---|
| 1944 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0); |
---|
| 1945 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0); |
---|
[8c92848] | 1946 | |
---|
[d09e5a1] | 1947 | aim_clientready(sess, fr->conn); |
---|
| 1948 | |
---|
[2674412] | 1949 | owl_function_debugmsg("Chat ready"); |
---|
| 1950 | |
---|
| 1951 | /* |
---|
| 1952 | chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
---|
| 1953 | chatcon->id = id; |
---|
| 1954 | chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); |
---|
| 1955 | */ |
---|
| 1956 | return(1); |
---|
| 1957 | } |
---|
| 1958 | |
---|
[d09e5a1] | 1959 | void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir) |
---|
| 1960 | { |
---|
| 1961 | aim_conn_t *tstconn; |
---|
[8c92848] | 1962 | |
---|
| 1963 | owl_function_debugmsg("in faimtest_chatnav_redirect"); |
---|
[d09e5a1] | 1964 | |
---|
| 1965 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, redir->ip); |
---|
| 1966 | if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { |
---|
| 1967 | /* printf("unable to connect to chat(nav) server\n"); */ |
---|
| 1968 | if (tstconn) |
---|
| 1969 | aim_conn_kill(sess, &tstconn); |
---|
| 1970 | return; |
---|
| 1971 | } |
---|
| 1972 | |
---|
| 1973 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 1974 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
---|
[f4d0975] | 1975 | aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
---|
[d09e5a1] | 1976 | /* printf("chatnav: connected\n"); */ |
---|
| 1977 | return; |
---|
| 1978 | } |
---|
| 1979 | |
---|
| 1980 | /* XXX this needs instance too */ |
---|
| 1981 | void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir) |
---|
| 1982 | { |
---|
| 1983 | aim_conn_t *tstconn; |
---|
[8c92848] | 1984 | |
---|
| 1985 | owl_function_debugmsg("in chat_redirect"); |
---|
[d09e5a1] | 1986 | |
---|
| 1987 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, redir->ip); |
---|
| 1988 | if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { |
---|
| 1989 | /* printf("unable to connect to chat server\n"); */ |
---|
| 1990 | if (tstconn) aim_conn_kill(sess, &tstconn); |
---|
| 1991 | return; |
---|
| 1992 | } |
---|
| 1993 | /* printf("chat: connected to %s instance %d on exchange %d\n", redir->chat.room, redir->chat.instance, redir->chat.exchange); */ |
---|
| 1994 | |
---|
| 1995 | /* |
---|
| 1996 | * We must do this to attach the stored name to the connection! |
---|
| 1997 | */ |
---|
| 1998 | aim_chat_attachname(tstconn, redir->chat.exchange, redir->chat.room, redir->chat.instance); |
---|
| 1999 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 2000 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
---|
[f4d0975] | 2001 | aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
---|
[d09e5a1] | 2002 | return; |
---|
| 2003 | } |
---|
| 2004 | |
---|
[3381399] | 2005 | void owl_process_aim() |
---|
| 2006 | { |
---|
| 2007 | if (owl_global_is_doaimevents(&g)) { |
---|
| 2008 | owl_aim_process_events(); |
---|
| 2009 | } |
---|
| 2010 | } |
---|