[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) { |
---|
[36486be] | 945 | filename = owl_sprintf("%s/%s.ocm", priv->aimbinarypath, modname); |
---|
[d09e5a1] | 946 | } else { |
---|
[36486be] | 947 | filename = owl_sprintf("%s/%s", priv->aimbinarypath, defaultmod); |
---|
[d09e5a1] | 948 | } |
---|
| 949 | |
---|
| 950 | if (stat(filename, &st) == -1) { |
---|
| 951 | if (!modname) { |
---|
| 952 | /* perror("memrequest: stat"); */ |
---|
[34509d5] | 953 | owl_free(filename); |
---|
[d09e5a1] | 954 | return -1; |
---|
| 955 | } |
---|
| 956 | invalid = 1; |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | if (!invalid) { |
---|
| 960 | if ((offset > st.st_size) || (len > st.st_size)) |
---|
| 961 | invalid = 1; |
---|
| 962 | else if ((st.st_size - offset) < len) |
---|
| 963 | len = st.st_size - offset; |
---|
| 964 | else if ((st.st_size - len) < len) |
---|
| 965 | len = st.st_size - len; |
---|
| 966 | } |
---|
| 967 | |
---|
| 968 | if (!invalid && len) { |
---|
| 969 | len %= 4096; |
---|
| 970 | } |
---|
| 971 | |
---|
| 972 | if (invalid) { |
---|
| 973 | int i; |
---|
| 974 | |
---|
[34509d5] | 975 | owl_free(filename); /* not needed */ |
---|
[8c46404] | 976 | owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname); |
---|
[d09e5a1] | 977 | i = 8; |
---|
| 978 | if (modname) { |
---|
| 979 | i+=strlen(modname); |
---|
| 980 | } |
---|
| 981 | |
---|
[34509d5] | 982 | if (!(buf = owl_malloc(i))) { |
---|
[d09e5a1] | 983 | return -1; |
---|
| 984 | } |
---|
| 985 | |
---|
| 986 | i=0; |
---|
| 987 | |
---|
| 988 | if (modname) { |
---|
| 989 | memcpy(buf, modname, strlen(modname)); |
---|
| 990 | i+=strlen(modname); |
---|
| 991 | } |
---|
| 992 | |
---|
| 993 | /* Damn endianness. This must be little (LSB first) endian. */ |
---|
| 994 | buf[i++] = offset & 0xff; |
---|
| 995 | buf[i++] = (offset >> 8) & 0xff; |
---|
| 996 | buf[i++] = (offset >> 16) & 0xff; |
---|
| 997 | buf[i++] = (offset >> 24) & 0xff; |
---|
| 998 | buf[i++] = len & 0xff; |
---|
| 999 | buf[i++] = (len >> 8) & 0xff; |
---|
| 1000 | buf[i++] = (len >> 16) & 0xff; |
---|
| 1001 | buf[i++] = (len >> 24) & 0xff; |
---|
| 1002 | |
---|
| 1003 | *bufret = buf; |
---|
| 1004 | *buflenret = i; |
---|
| 1005 | } else { |
---|
[34509d5] | 1006 | if (!(buf = owl_malloc(len))) { |
---|
| 1007 | owl_free(filename); |
---|
[d09e5a1] | 1008 | return -1; |
---|
| 1009 | } |
---|
| 1010 | /* printf("memrequest: loading %ld bytes from 0x%08lx in \"%s\"...\n", len, offset, filename); */ |
---|
| 1011 | if (!(f = fopen(filename, "r"))) { |
---|
| 1012 | /* perror("memrequest: fopen"); */ |
---|
[34509d5] | 1013 | owl_free(filename); |
---|
| 1014 | owl_free(buf); |
---|
[d09e5a1] | 1015 | return -1; |
---|
| 1016 | } |
---|
| 1017 | |
---|
[34509d5] | 1018 | owl_free(filename); |
---|
[d09e5a1] | 1019 | |
---|
| 1020 | if (fseek(f, offset, SEEK_SET) == -1) { |
---|
| 1021 | /* perror("memrequest: fseek"); */ |
---|
| 1022 | fclose(f); |
---|
[34509d5] | 1023 | owl_free(buf); |
---|
[d09e5a1] | 1024 | return -1; |
---|
| 1025 | } |
---|
| 1026 | |
---|
| 1027 | if (fread(buf, len, 1, f) != 1) { |
---|
| 1028 | /* perror("memrequest: fread"); */ |
---|
| 1029 | fclose(f); |
---|
[34509d5] | 1030 | owl_free(buf); |
---|
[d09e5a1] | 1031 | return -1; |
---|
| 1032 | } |
---|
| 1033 | |
---|
| 1034 | fclose(f); |
---|
| 1035 | *bufret = buf; |
---|
| 1036 | *buflenret = len; |
---|
| 1037 | } |
---|
| 1038 | return 0; /* success! */ |
---|
| 1039 | } |
---|
| 1040 | |
---|
| 1041 | /* |
---|
| 1042 | * This will get an offset and a length. The client should read this |
---|
| 1043 | * data out of whatever AIM.EXE binary the user has provided (hopefully |
---|
| 1044 | * it matches the client information thats sent at login) and pass a |
---|
| 1045 | * buffer back to libfaim so it can hash the data and send it to AOL for |
---|
| 1046 | * inspection by the client police. |
---|
| 1047 | */ |
---|
| 1048 | static int faimtest_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1049 | { |
---|
[4d86e06] | 1050 | struct owlfaim_priv *priv = sess->aux_data; |
---|
[d09e5a1] | 1051 | va_list ap; |
---|
| 1052 | fu32_t offset, len; |
---|
[e19eb97] | 1053 | const char *modname; |
---|
[d09e5a1] | 1054 | unsigned char *buf; |
---|
| 1055 | int buflen; |
---|
| 1056 | |
---|
| 1057 | va_start(ap, fr); |
---|
| 1058 | offset = va_arg(ap, fu32_t); |
---|
| 1059 | len = va_arg(ap, fu32_t); |
---|
[e19eb97] | 1060 | modname = va_arg(ap, const char *); |
---|
[d09e5a1] | 1061 | va_end(ap); |
---|
| 1062 | |
---|
| 1063 | if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) { |
---|
| 1064 | aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
---|
[34509d5] | 1065 | owl_free(buf); |
---|
[d09e5a1] | 1066 | } else { |
---|
[8c46404] | 1067 | owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname); |
---|
[d09e5a1] | 1068 | aim_sendmemblock(sess, fr->conn, offset, len, NULL, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
---|
| 1069 | } |
---|
| 1070 | return 1; |
---|
| 1071 | } |
---|
| 1072 | |
---|
[8c46404] | 1073 | /* |
---|
[d09e5a1] | 1074 | static void printuserflags(fu16_t flags) |
---|
| 1075 | { |
---|
[8c46404] | 1076 | if (flags & AIM_FLAG_UNCONFIRMED) printf("UNCONFIRMED "); |
---|
| 1077 | if (flags & AIM_FLAG_ADMINISTRATOR) printf("ADMINISTRATOR "); |
---|
| 1078 | if (flags & AIM_FLAG_AOL) printf("AOL "); |
---|
| 1079 | if (flags & AIM_FLAG_OSCAR_PAY) printf("OSCAR_PAY "); |
---|
| 1080 | if (flags & AIM_FLAG_FREE) printf("FREE "); |
---|
| 1081 | if (flags & AIM_FLAG_AWAY) printf("AWAY "); |
---|
| 1082 | if (flags & AIM_FLAG_ICQ) printf("ICQ "); |
---|
| 1083 | if (flags & AIM_FLAG_WIRELESS) printf("WIRELESS "); |
---|
| 1084 | if (flags & AIM_FLAG_ACTIVEBUDDY) printf("ACTIVEBUDDY "); |
---|
[d09e5a1] | 1085 | |
---|
| 1086 | return; |
---|
| 1087 | } |
---|
[8c46404] | 1088 | */ |
---|
[d09e5a1] | 1089 | |
---|
| 1090 | static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1091 | { |
---|
| 1092 | aim_userinfo_t *userinfo; |
---|
[e19eb97] | 1093 | const char *prof_encoding = NULL; |
---|
| 1094 | const char *prof = NULL; |
---|
[d09e5a1] | 1095 | fu16_t inforeq = 0; |
---|
[f4d0975] | 1096 | owl_buddy *b; |
---|
[d09e5a1] | 1097 | va_list ap; |
---|
| 1098 | va_start(ap, fr); |
---|
| 1099 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1100 | inforeq = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1101 | prof_encoding = va_arg(ap, const char *); |
---|
| 1102 | prof = va_arg(ap, const char *); |
---|
[d09e5a1] | 1103 | va_end(ap); |
---|
| 1104 | |
---|
[de03334] | 1105 | /* right now the only reason we call this is for idle times */ |
---|
[f4d0975] | 1106 | owl_function_debugmsg("parse_userinfo sn: %s idle: %i", userinfo->sn, userinfo->idletime); |
---|
| 1107 | b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), |
---|
| 1108 | userinfo->sn); |
---|
| 1109 | if (!b) return(1); |
---|
| 1110 | owl_buddy_set_idle_since(b, userinfo->idletime); |
---|
[de03334] | 1111 | return(1); |
---|
[d09e5a1] | 1112 | |
---|
[8c92848] | 1113 | /* |
---|
[d09e5a1] | 1114 | printf("userinfo: sn: %s\n", userinfo->sn); |
---|
| 1115 | printf("userinfo: warnlevel: %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1116 | printf("userinfo: flags: 0x%04x = ", userinfo->flags); |
---|
| 1117 | printuserflags(userinfo->flags); |
---|
| 1118 | printf("\n"); |
---|
[8c92848] | 1119 | */ |
---|
[f4d0975] | 1120 | |
---|
| 1121 | /* |
---|
[d09e5a1] | 1122 | printf("userinfo: membersince: %lu\n", userinfo->membersince); |
---|
| 1123 | printf("userinfo: onlinesince: %lu\n", userinfo->onlinesince); |
---|
| 1124 | printf("userinfo: idletime: 0x%04x\n", userinfo->idletime); |
---|
| 1125 | printf("userinfo: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities); |
---|
[f4d0975] | 1126 | */ |
---|
[8c46404] | 1127 | |
---|
| 1128 | /* |
---|
[d09e5a1] | 1129 | if (inforeq == AIM_GETINFO_GENERALINFO) { |
---|
[8c92848] | 1130 | owl_function_debugmsg("userinfo: profile_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); |
---|
| 1131 | owl_function_debugmsg("userinfo: prof: %s\n", prof ? prof : "[none]"); |
---|
[d09e5a1] | 1132 | } else if (inforeq == AIM_GETINFO_AWAYMESSAGE) { |
---|
[8c92848] | 1133 | owl_function_debugmsg("userinfo: awaymsg_encoding: %s\n", prof_encoding ? prof_encoding : "[none]"); |
---|
| 1134 | owl_function_debugmsg("userinfo: awaymsg: %s\n", prof ? prof : "[none]"); |
---|
[d09e5a1] | 1135 | } else if (inforeq == AIM_GETINFO_CAPABILITIES) { |
---|
[8c92848] | 1136 | owl_function_debugmsg("userinfo: capabilities: see above\n"); |
---|
[d09e5a1] | 1137 | } else { |
---|
[8c92848] | 1138 | owl_function_debugmsg("userinfo: unknown info request\n"); |
---|
[d09e5a1] | 1139 | } |
---|
[8c46404] | 1140 | */ |
---|
[8c92848] | 1141 | return(1); |
---|
[d09e5a1] | 1142 | } |
---|
| 1143 | |
---|
| 1144 | /* |
---|
| 1145 | * Channel 1: Standard Message |
---|
| 1146 | */ |
---|
| 1147 | 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) |
---|
| 1148 | { |
---|
| 1149 | owl_message *m; |
---|
[ab31454] | 1150 | char *stripmsg, *nz_screenname, *wrapmsg; |
---|
[2646676] | 1151 | char realmsg[8192+1] = ""; |
---|
[f4d0975] | 1152 | /* int clienttype = AIM_CLIENTTYPE_UNKNOWN; */ |
---|
| 1153 | |
---|
| 1154 | /* clienttype = aim_fingerprintclient(args->features, args->featureslen); */ |
---|
[d09e5a1] | 1155 | |
---|
| 1156 | /* |
---|
| 1157 | printf("icbm: sn = \"%s\"\n", userinfo->sn); |
---|
| 1158 | printf("icbm: probable client type: %d\n", clienttype); |
---|
| 1159 | printf("icbm: warnlevel = %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1160 | printf("icbm: flags = 0x%04x = ", userinfo->flags); |
---|
| 1161 | printuserflags(userinfo->flags); |
---|
| 1162 | printf("\n"); |
---|
| 1163 | */ |
---|
| 1164 | |
---|
| 1165 | /* |
---|
| 1166 | printf("icbm: membersince = %lu\n", userinfo->membersince); |
---|
| 1167 | printf("icbm: onlinesince = %lu\n", userinfo->onlinesince); |
---|
| 1168 | printf("icbm: idletime = 0x%04x\n", userinfo->idletime); |
---|
| 1169 | printf("icbm: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities); |
---|
| 1170 | */ |
---|
| 1171 | |
---|
| 1172 | /* |
---|
| 1173 | printf("icbm: icbmflags = "); |
---|
| 1174 | if (args->icbmflags & AIM_IMFLAGS_AWAY) printf("away "); |
---|
| 1175 | if (args->icbmflags & AIM_IMFLAGS_ACK) printf("ackrequest "); |
---|
| 1176 | if (args->icbmflags & AIM_IMFLAGS_OFFLINE) printf("offline "); |
---|
| 1177 | if (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) printf("buddyreq "); |
---|
| 1178 | if (args->icbmflags & AIM_IMFLAGS_HASICON) printf("hasicon "); |
---|
| 1179 | printf("\n"); |
---|
| 1180 | */ |
---|
| 1181 | |
---|
[f4d0975] | 1182 | /* |
---|
[d09e5a1] | 1183 | if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) { |
---|
[f4d0975] | 1184 | printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset); |
---|
[d09e5a1] | 1185 | } |
---|
[f4d0975] | 1186 | */ |
---|
[d09e5a1] | 1187 | |
---|
| 1188 | /* |
---|
| 1189 | * Quickly convert it to eight bit format, replacing non-ASCII UNICODE |
---|
| 1190 | * characters with their equivelent HTML entity. |
---|
| 1191 | */ |
---|
| 1192 | if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
---|
| 1193 | int i; |
---|
| 1194 | |
---|
[ae4cd12] | 1195 | for (i=0; i<args->msglen; i+=2) { |
---|
[d09e5a1] | 1196 | fu16_t uni; |
---|
| 1197 | |
---|
| 1198 | uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); |
---|
| 1199 | if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ |
---|
| 1200 | snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "%c", uni); |
---|
| 1201 | } else { /* something else, do UNICODE entity */ |
---|
| 1202 | snprintf(realmsg+strlen(realmsg), sizeof(realmsg)-strlen(realmsg), "&#%04x;", uni); |
---|
| 1203 | } |
---|
| 1204 | } |
---|
| 1205 | } else { |
---|
| 1206 | /* |
---|
| 1207 | * For non-UNICODE encodings (ASCII and ISO 8859-1), there is |
---|
| 1208 | * no need to do anything special here. Most |
---|
| 1209 | * terminals/whatever will be able to display such characters |
---|
| 1210 | * unmodified. |
---|
| 1211 | * |
---|
| 1212 | * Beware that PC-ASCII 128 through 159 are _not_ actually |
---|
| 1213 | * defined in ASCII or ISO 8859-1, and you should send them as |
---|
| 1214 | * UNICODE. WinAIM will send these characters in a UNICODE |
---|
| 1215 | * message, so you need to do so as well. |
---|
| 1216 | * |
---|
| 1217 | * You may not think it necessary to handle UNICODE messages. |
---|
| 1218 | * You're probably wrong. For one thing, Microsoft "Smart |
---|
| 1219 | * Quotes" will be sent by WinAIM as UNICODE (not HTML UNICODE, |
---|
| 1220 | * but real UNICODE). If you don't parse UNICODE at all, your |
---|
| 1221 | * users will get a blank message instead of the message |
---|
| 1222 | * containing Smart Quotes. |
---|
| 1223 | * |
---|
| 1224 | */ |
---|
[e3e6cff] | 1225 | if (args->msg && args->msglen) |
---|
| 1226 | strncpy(realmsg, args->msg, sizeof(realmsg)); |
---|
[d09e5a1] | 1227 | } |
---|
| 1228 | |
---|
[8c46404] | 1229 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: message from: %s", userinfo->sn?userinfo->sn:""); |
---|
[d09e5a1] | 1230 | /* create a message, and put it on the message queue */ |
---|
[3abf28b] | 1231 | stripmsg=owl_text_htmlstrip(realmsg); |
---|
[ab31454] | 1232 | wrapmsg=owl_text_wordwrap(stripmsg, 70); |
---|
[ae4cd12] | 1233 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
[d09e5a1] | 1234 | m=owl_malloc(sizeof(owl_message)); |
---|
[d559df9] | 1235 | owl_message_create_aim(m, |
---|
| 1236 | nz_screenname, |
---|
| 1237 | owl_global_get_aim_screenname(&g), |
---|
[ab31454] | 1238 | wrapmsg, |
---|
[d559df9] | 1239 | OWL_MESSAGE_DIRECTION_IN, |
---|
| 1240 | 0); |
---|
[9854278] | 1241 | if (args->icbmflags & AIM_IMFLAGS_AWAY) owl_message_set_attribute(m, "isauto", ""); |
---|
[d09e5a1] | 1242 | owl_global_messagequeue_addmsg(&g, m); |
---|
[3abf28b] | 1243 | owl_free(stripmsg); |
---|
[ab31454] | 1244 | owl_free(wrapmsg); |
---|
[ae4cd12] | 1245 | owl_free(nz_screenname); |
---|
[fd93b41] | 1246 | |
---|
| 1247 | return(1); |
---|
[8c46404] | 1248 | |
---|
| 1249 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg); |
---|
[d09e5a1] | 1250 | |
---|
| 1251 | if (args->icbmflags & AIM_IMFLAGS_MULTIPART) { |
---|
| 1252 | aim_mpmsg_section_t *sec; |
---|
| 1253 | int z; |
---|
| 1254 | |
---|
[8c46404] | 1255 | owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts); |
---|
[d09e5a1] | 1256 | |
---|
| 1257 | for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) { |
---|
| 1258 | if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) { |
---|
[8c46404] | 1259 | 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] | 1260 | } else { |
---|
[8c46404] | 1261 | 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] | 1262 | } |
---|
| 1263 | } |
---|
| 1264 | } |
---|
| 1265 | |
---|
| 1266 | if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
---|
[651560f] | 1267 | /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */ |
---|
[f278ff3] | 1268 | 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] | 1269 | } |
---|
[fd93b41] | 1270 | |
---|
| 1271 | /* |
---|
[d09e5a1] | 1272 | if (realmsg) { |
---|
| 1273 | int i = 0; |
---|
| 1274 | while (realmsg[i] == '<') { |
---|
| 1275 | if (realmsg[i] == '<') { |
---|
| 1276 | while (realmsg[i] != '>') |
---|
| 1277 | i++; |
---|
| 1278 | i++; |
---|
| 1279 | } |
---|
| 1280 | } |
---|
| 1281 | tmpstr = realmsg+i; |
---|
| 1282 | faimtest_handlecmd(sess, conn, userinfo, tmpstr); |
---|
| 1283 | } |
---|
[fd93b41] | 1284 | */ |
---|
[d09e5a1] | 1285 | |
---|
[8c92848] | 1286 | return(1); |
---|
[d09e5a1] | 1287 | } |
---|
| 1288 | |
---|
| 1289 | /* |
---|
| 1290 | * Channel 2: Rendevous Request |
---|
| 1291 | */ |
---|
| 1292 | 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) |
---|
| 1293 | { |
---|
| 1294 | /* |
---|
| 1295 | printf("rendezvous: source sn = %s\n", userinfo->sn); |
---|
| 1296 | printf("rendezvous: \twarnlevel = %f\n", aim_userinfo_warnlevel(userinfo)); |
---|
| 1297 | printf("rendezvous: \tclass = 0x%04x = ", userinfo->flags); |
---|
| 1298 | printuserflags(userinfo->flags); |
---|
| 1299 | printf("\n"); |
---|
| 1300 | |
---|
| 1301 | printf("rendezvous: \tonlinesince = %lu\n", userinfo->onlinesince); |
---|
| 1302 | printf("rendezvous: \tidletime = 0x%04x\n", userinfo->idletime); |
---|
| 1303 | |
---|
| 1304 | printf("rendezvous: message/description = %s\n", args->msg); |
---|
| 1305 | printf("rendezvous: encoding = %s\n", args->encoding); |
---|
| 1306 | printf("rendezvous: language = %s\n", args->language); |
---|
| 1307 | */ |
---|
| 1308 | |
---|
[f4d0975] | 1309 | if (args->reqclass == AIM_CAPS_SENDFILE) { |
---|
[8c46404] | 1310 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: send file!"); |
---|
[d09e5a1] | 1311 | } else if (args->reqclass == AIM_CAPS_CHAT) { |
---|
[8c46404] | 1312 | 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] | 1313 | /* |
---|
| 1314 | printf("chat invitation: room name = %s\n", args->info.chat.roominfo.name); |
---|
| 1315 | printf("chat invitation: exchange = 0x%04x\n", args->info.chat.roominfo.exchange); |
---|
| 1316 | printf("chat invitation: instance = 0x%04x\n", args->info.chat.roominfo.instance); |
---|
| 1317 | */ |
---|
| 1318 | /* Automatically join room... */ |
---|
| 1319 | /* printf("chat invitiation: autojoining %s...\n", args->info.chat.roominfo.name); */ |
---|
[fd93b41] | 1320 | |
---|
| 1321 | /* aim_chat_join(sess, conn, args->info.chat.roominfo.exchange, args->info.chat.roominfo.name, args->info.chat.roominfo.instance); */ |
---|
[d09e5a1] | 1322 | } else if (args->reqclass == AIM_CAPS_BUDDYICON) { |
---|
[f278ff3] | 1323 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: Buddy Icon from %s, length = %u\n", |
---|
[8c46404] | 1324 | userinfo->sn, args->info.icon.length); |
---|
[d09e5a1] | 1325 | } else if (args->reqclass == AIM_CAPS_ICQRTF) { |
---|
[f278ff3] | 1326 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: RTF message from %s: (fgcolor = 0x%08x, bgcolor = 0x%08x) %s\n", |
---|
[8c46404] | 1327 | userinfo->sn, args->info.rtfmsg.fgcolor, args->info.rtfmsg.bgcolor, args->info.rtfmsg.rtfmsg); |
---|
[d09e5a1] | 1328 | } else { |
---|
[8c46404] | 1329 | owl_function_debugmsg("faimtest_parse_incoming_im_chan2: icbm: unknown reqclass (%d)\n", args->reqclass); |
---|
[d09e5a1] | 1330 | } |
---|
| 1331 | return 1; |
---|
| 1332 | } |
---|
| 1333 | |
---|
| 1334 | static int faimtest_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1335 | { |
---|
| 1336 | fu16_t channel; |
---|
| 1337 | aim_userinfo_t *userinfo; |
---|
| 1338 | va_list ap; |
---|
| 1339 | int ret = 0; |
---|
| 1340 | |
---|
| 1341 | va_start(ap, fr); |
---|
| 1342 | channel = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1343 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1344 | |
---|
| 1345 | if (channel == 1) { |
---|
| 1346 | struct aim_incomingim_ch1_args *args; |
---|
| 1347 | args = va_arg(ap, struct aim_incomingim_ch1_args *); |
---|
| 1348 | ret = faimtest_parse_incoming_im_chan1(sess, fr->conn, userinfo, args); |
---|
| 1349 | } else if (channel == 2) { |
---|
| 1350 | struct aim_incomingim_ch2_args *args; |
---|
| 1351 | args = va_arg(ap, struct aim_incomingim_ch2_args *); |
---|
| 1352 | ret = faimtest_parse_incoming_im_chan2(sess, fr->conn, userinfo, args); |
---|
| 1353 | } else { |
---|
[8c46404] | 1354 | owl_function_debugmsg("faimtest_parse_incoming_im: unsupported channel 0x%04x\n", channel); |
---|
[d09e5a1] | 1355 | } |
---|
| 1356 | va_end(ap); |
---|
[8c46404] | 1357 | owl_function_debugmsg("faimtest_parse_incoming_im: done with ICBM handling (ret = %d)\n", ret); |
---|
[d09e5a1] | 1358 | return 1; |
---|
| 1359 | } |
---|
| 1360 | |
---|
| 1361 | static int faimtest_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1362 | { |
---|
| 1363 | aim_userinfo_t *userinfo; |
---|
[ae4cd12] | 1364 | char *nz_screenname; |
---|
[f4d0975] | 1365 | owl_buddy *b; |
---|
[d09e5a1] | 1366 | va_list ap; |
---|
| 1367 | va_start(ap, fr); |
---|
| 1368 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1369 | va_end(ap); |
---|
[aa5f725] | 1370 | |
---|
[ae4cd12] | 1371 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
[f4d0975] | 1372 | |
---|
[ae4cd12] | 1373 | owl_buddylist_oncoming(owl_global_get_buddylist(&g), nz_screenname); |
---|
[f4d0975] | 1374 | |
---|
| 1375 | if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
---|
[8c46404] | 1376 | owl_function_debugmsg("faimtest_parseoncoming: in empty part of userinfo present and present idle"); |
---|
[f4d0975] | 1377 | } |
---|
| 1378 | |
---|
| 1379 | b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), nz_screenname); |
---|
| 1380 | if (!b) { |
---|
| 1381 | owl_function_debugmsg("Error: parse_oncoming setting idle time with no buddy present."); |
---|
| 1382 | return(1); |
---|
| 1383 | } |
---|
| 1384 | if (userinfo->idletime==0) { |
---|
| 1385 | owl_buddy_set_unidle(b); |
---|
| 1386 | } else { |
---|
| 1387 | owl_buddy_set_idle(b); |
---|
| 1388 | owl_buddy_set_idle_since(b, userinfo->idletime); |
---|
| 1389 | } |
---|
[8c92848] | 1390 | |
---|
| 1391 | if (userinfo->flags & AIM_FLAG_AWAY) { |
---|
| 1392 | owl_function_debugmsg("parse_oncoming sn: %s away flag!", userinfo->sn); |
---|
| 1393 | } |
---|
| 1394 | |
---|
[f4d0975] | 1395 | owl_function_debugmsg("parse_oncoming sn: %s idle: %i", userinfo->sn, userinfo->idletime); |
---|
| 1396 | |
---|
[ae4cd12] | 1397 | owl_free(nz_screenname); |
---|
[aa5f725] | 1398 | |
---|
[d09e5a1] | 1399 | /* |
---|
| 1400 | printf("%ld %s is now online (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n", |
---|
| 1401 | time(NULL), |
---|
| 1402 | userinfo->sn, userinfo->flags, |
---|
| 1403 | (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"", |
---|
| 1404 | (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"", |
---|
| 1405 | (userinfo->flags&AIM_FLAG_AOL)?" AOL":"", |
---|
| 1406 | (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"", |
---|
| 1407 | (userinfo->flags&AIM_FLAG_FREE)?" FREE":"", |
---|
| 1408 | (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"", |
---|
| 1409 | (userinfo->flags&AIM_FLAG_ICQ)?" ICQ":"", |
---|
| 1410 | (userinfo->flags&AIM_FLAG_WIRELESS)?" WIRELESS":"", |
---|
| 1411 | (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", |
---|
| 1412 | userinfo->capabilities); |
---|
| 1413 | */ |
---|
[aa5f725] | 1414 | return(1); |
---|
[d09e5a1] | 1415 | } |
---|
| 1416 | |
---|
| 1417 | static int faimtest_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1418 | { |
---|
| 1419 | aim_userinfo_t *userinfo; |
---|
[ae4cd12] | 1420 | char *nz_screenname; |
---|
[d09e5a1] | 1421 | va_list ap; |
---|
| 1422 | |
---|
| 1423 | va_start(ap, fr); |
---|
| 1424 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1425 | va_end(ap); |
---|
| 1426 | |
---|
[ae4cd12] | 1427 | nz_screenname=owl_aim_normalize_screenname(userinfo->sn); |
---|
| 1428 | owl_buddylist_offgoing(owl_global_get_buddylist(&g), nz_screenname); |
---|
| 1429 | owl_free(nz_screenname); |
---|
[aa5f725] | 1430 | |
---|
[f4d0975] | 1431 | if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
---|
| 1432 | owl_function_debugmsg("parse_offgoing sn: %s idle time %i", userinfo->sn, userinfo->idletime); |
---|
| 1433 | } |
---|
| 1434 | |
---|
[d09e5a1] | 1435 | /* |
---|
| 1436 | printf("%ld %s is now offline (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n", |
---|
| 1437 | time(NULL), |
---|
| 1438 | userinfo->sn, userinfo->flags, |
---|
| 1439 | (userinfo->flags&AIM_FLAG_UNCONFIRMED)?" UNCONFIRMED":"", |
---|
| 1440 | (userinfo->flags&AIM_FLAG_ADMINISTRATOR)?" ADMINISTRATOR":"", |
---|
| 1441 | (userinfo->flags&AIM_FLAG_AOL)?" AOL":"", |
---|
| 1442 | (userinfo->flags&AIM_FLAG_OSCAR_PAY)?" OSCAR_PAY":"", |
---|
| 1443 | (userinfo->flags&AIM_FLAG_FREE)?" FREE":"", |
---|
| 1444 | (userinfo->flags&AIM_FLAG_AWAY)?" AWAY":"", |
---|
| 1445 | (userinfo->flags&AIM_FLAG_ICQ)?" ICQ":"", |
---|
| 1446 | (userinfo->flags&AIM_FLAG_WIRELESS)?" WIRELESS":"", |
---|
| 1447 | (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", |
---|
| 1448 | userinfo->capabilities); |
---|
| 1449 | */ |
---|
| 1450 | |
---|
| 1451 | return 1; |
---|
| 1452 | } |
---|
| 1453 | |
---|
| 1454 | /* Used by chat as well. */ |
---|
| 1455 | int faimtest_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1456 | { |
---|
| 1457 | va_list ap; |
---|
| 1458 | fu16_t reason; |
---|
| 1459 | |
---|
| 1460 | va_start(ap, fr); |
---|
| 1461 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1462 | va_end(ap); |
---|
| 1463 | |
---|
| 1464 | /* printf("snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1465 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[d09e5a1] | 1466 | |
---|
| 1467 | return 1; |
---|
| 1468 | } |
---|
| 1469 | |
---|
| 1470 | static int faimtest_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1471 | { |
---|
| 1472 | va_list ap; |
---|
[e19eb97] | 1473 | const char *destsn; |
---|
[d09e5a1] | 1474 | fu16_t reason; |
---|
| 1475 | |
---|
| 1476 | va_start(ap, fr); |
---|
| 1477 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1478 | destsn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1479 | va_end(ap); |
---|
| 1480 | |
---|
| 1481 | /* printf("message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1482 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[a836200] | 1483 | |
---|
| 1484 | if (reason==4) { |
---|
| 1485 | owl_function_adminmsg("", "Could not send AIM message, user not logged on"); |
---|
| 1486 | } |
---|
[d09e5a1] | 1487 | |
---|
| 1488 | return 1; |
---|
| 1489 | } |
---|
| 1490 | |
---|
| 1491 | static int faimtest_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1492 | { |
---|
| 1493 | va_list ap; |
---|
[e19eb97] | 1494 | const char *destsn; |
---|
[d09e5a1] | 1495 | fu16_t reason; |
---|
| 1496 | |
---|
| 1497 | va_start(ap, fr); |
---|
| 1498 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1499 | destsn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1500 | va_end(ap); |
---|
| 1501 | |
---|
| 1502 | /* printf("user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ |
---|
[554a2b8] | 1503 | if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]); |
---|
[d09e5a1] | 1504 | |
---|
| 1505 | return 1; |
---|
| 1506 | } |
---|
| 1507 | |
---|
| 1508 | static int faimtest_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1509 | { |
---|
[e19eb97] | 1510 | static const char *missedreasons[] = { |
---|
[d09e5a1] | 1511 | "Invalid (0)", |
---|
| 1512 | "Message too large", |
---|
| 1513 | "Rate exceeded", |
---|
| 1514 | "Evil Sender", |
---|
| 1515 | "Evil Receiver" |
---|
| 1516 | }; |
---|
[8c46404] | 1517 | static int missedreasonslen = 5; |
---|
[d09e5a1] | 1518 | |
---|
| 1519 | va_list ap; |
---|
| 1520 | fu16_t chan, nummissed, reason; |
---|
| 1521 | aim_userinfo_t *userinfo; |
---|
| 1522 | |
---|
| 1523 | va_start(ap, fr); |
---|
| 1524 | chan = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1525 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1526 | nummissed = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1527 | reason = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1528 | va_end(ap); |
---|
| 1529 | |
---|
[8c46404] | 1530 | 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] | 1531 | |
---|
| 1532 | return 1; |
---|
| 1533 | } |
---|
| 1534 | |
---|
| 1535 | /* |
---|
| 1536 | * Received in response to an IM sent with the AIM_IMFLAGS_ACK option. |
---|
| 1537 | */ |
---|
| 1538 | static int faimtest_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1539 | { |
---|
| 1540 | va_list ap; |
---|
| 1541 | fu16_t type; |
---|
[e19eb97] | 1542 | const char *sn = NULL; |
---|
[d09e5a1] | 1543 | |
---|
| 1544 | va_start(ap, fr); |
---|
| 1545 | type = (fu16_t)va_arg(ap, unsigned int); |
---|
[e19eb97] | 1546 | sn = va_arg(ap, const char *); |
---|
[d09e5a1] | 1547 | va_end(ap); |
---|
| 1548 | |
---|
[8c46404] | 1549 | owl_function_debugmsg("faimtest_parse_msgack: 0x%04x / %s\n", type, sn); |
---|
[d09e5a1] | 1550 | |
---|
| 1551 | return 1; |
---|
| 1552 | } |
---|
| 1553 | |
---|
| 1554 | static int faimtest_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1555 | { |
---|
[e19eb97] | 1556 | static const char *codes[5] = { |
---|
[d09e5a1] | 1557 | "invalid", |
---|
| 1558 | "change", |
---|
| 1559 | "warning", |
---|
| 1560 | "limit", |
---|
| 1561 | "limit cleared" |
---|
| 1562 | }; |
---|
| 1563 | va_list ap; |
---|
| 1564 | fu16_t code, rateclass; |
---|
| 1565 | fu32_t windowsize, clear, alert, limit, disconnect; |
---|
| 1566 | fu32_t currentavg, maxavg; |
---|
| 1567 | |
---|
| 1568 | va_start(ap, fr); |
---|
| 1569 | |
---|
| 1570 | /* See code explanations below */ |
---|
| 1571 | code = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1572 | |
---|
| 1573 | /* |
---|
| 1574 | * See comments above aim_parse_ratechange_middle() in aim_rxhandlers.c. |
---|
| 1575 | */ |
---|
| 1576 | rateclass = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1577 | |
---|
| 1578 | /* |
---|
| 1579 | * Not sure what this is exactly. I think its the temporal |
---|
| 1580 | * relation factor (ie, how to make the rest of the numbers |
---|
| 1581 | * make sense in the real world). |
---|
| 1582 | */ |
---|
| 1583 | windowsize = va_arg(ap, fu32_t); |
---|
| 1584 | |
---|
| 1585 | /* Explained below */ |
---|
| 1586 | clear = va_arg(ap, fu32_t); |
---|
| 1587 | alert = va_arg(ap, fu32_t); |
---|
| 1588 | limit = va_arg(ap, fu32_t); |
---|
| 1589 | disconnect = va_arg(ap, fu32_t); |
---|
| 1590 | currentavg = va_arg(ap, fu32_t); |
---|
| 1591 | maxavg = va_arg(ap, fu32_t); |
---|
| 1592 | |
---|
| 1593 | va_end(ap); |
---|
| 1594 | |
---|
[f278ff3] | 1595 | 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] | 1596 | (code < 5)?codes[code]:"invalid", |
---|
| 1597 | rateclass, |
---|
| 1598 | currentavg, maxavg, |
---|
| 1599 | alert, clear, |
---|
| 1600 | limit, disconnect, |
---|
| 1601 | windowsize); |
---|
[d09e5a1] | 1602 | return 1; |
---|
| 1603 | } |
---|
| 1604 | |
---|
| 1605 | static int faimtest_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1606 | { |
---|
| 1607 | va_list ap; |
---|
| 1608 | fu16_t newevil; |
---|
| 1609 | aim_userinfo_t *userinfo; |
---|
| 1610 | |
---|
| 1611 | va_start(ap, fr); |
---|
| 1612 | newevil = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1613 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1614 | va_end(ap); |
---|
| 1615 | |
---|
| 1616 | /* |
---|
| 1617 | * Evil Notifications that are lacking userinfo->sn are anon-warns |
---|
| 1618 | * if they are an evil increases, but are not warnings at all if its |
---|
| 1619 | * a decrease (its the natural backoff happening). |
---|
| 1620 | * |
---|
| 1621 | * newevil is passed as an int representing the new evil value times |
---|
| 1622 | * ten. |
---|
| 1623 | */ |
---|
[8c46404] | 1624 | 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] | 1625 | |
---|
| 1626 | return 1; |
---|
| 1627 | } |
---|
| 1628 | |
---|
| 1629 | static int faimtest_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1630 | { |
---|
| 1631 | va_list ap; |
---|
[e19eb97] | 1632 | const char *address, *SNs; |
---|
[8c46404] | 1633 | int num, i; |
---|
[952bb256] | 1634 | owl_list list; |
---|
[d09e5a1] | 1635 | |
---|
| 1636 | va_start(ap, fr); |
---|
[e19eb97] | 1637 | address = va_arg(ap, const char *); |
---|
[d09e5a1] | 1638 | num = va_arg(ap, int); |
---|
[e19eb97] | 1639 | SNs = va_arg(ap, const char *); |
---|
[d09e5a1] | 1640 | va_end(ap); |
---|
[952bb256] | 1641 | |
---|
| 1642 | owl_list_create(&list); |
---|
[d09e5a1] | 1643 | |
---|
[8c46404] | 1644 | owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address); |
---|
[952bb256] | 1645 | for (i=0; i<num; i++) { |
---|
[8c46404] | 1646 | owl_function_debugmsg(" %s", &SNs[i*(MAXSNLEN+1)]); |
---|
[fa4562c] | 1647 | owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]); |
---|
[8c46404] | 1648 | } |
---|
[952bb256] | 1649 | owl_function_aimsearch_results(address, &list); |
---|
| 1650 | owl_list_free_simple(&list); |
---|
| 1651 | return(1); |
---|
[d09e5a1] | 1652 | } |
---|
| 1653 | |
---|
| 1654 | static int faimtest_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1655 | { |
---|
| 1656 | va_list ap; |
---|
[e19eb97] | 1657 | const char *address; |
---|
[d09e5a1] | 1658 | |
---|
| 1659 | va_start(ap, fr); |
---|
[e19eb97] | 1660 | address = va_arg(ap, const char *); |
---|
[d09e5a1] | 1661 | va_end(ap); |
---|
[952bb256] | 1662 | |
---|
| 1663 | owl_function_error("No results searching for %s", address); |
---|
[8c46404] | 1664 | owl_function_debugmsg("faimtest_parse_searcherror: E-Mail Search Results for %s: No Results or Invalid Email\n", address); |
---|
[d09e5a1] | 1665 | |
---|
[952bb256] | 1666 | return(1); |
---|
[d09e5a1] | 1667 | } |
---|
| 1668 | |
---|
| 1669 | static int handlepopup(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1670 | { |
---|
| 1671 | va_list ap; |
---|
[e19eb97] | 1672 | const char *msg, *url; |
---|
[d09e5a1] | 1673 | fu16_t width, height, delay; |
---|
| 1674 | |
---|
| 1675 | va_start(ap, fr); |
---|
[e19eb97] | 1676 | msg = va_arg(ap, const char *); |
---|
| 1677 | url = va_arg(ap, const char *); |
---|
[d09e5a1] | 1678 | width = va_arg(ap, unsigned int); |
---|
| 1679 | height = va_arg(ap, unsigned int); |
---|
| 1680 | delay = va_arg(ap, unsigned int); |
---|
| 1681 | va_end(ap); |
---|
| 1682 | |
---|
[8c46404] | 1683 | owl_function_debugmsg("handlepopup: (%dx%x:%d) %s (%s)\n", width, height, delay, msg, url); |
---|
[d09e5a1] | 1684 | |
---|
| 1685 | return 1; |
---|
| 1686 | } |
---|
| 1687 | |
---|
| 1688 | static int serverpause(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1689 | { |
---|
| 1690 | aim_sendpauseack(sess, fr->conn); |
---|
| 1691 | return 1; |
---|
| 1692 | } |
---|
| 1693 | |
---|
| 1694 | static int migrate(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1695 | { |
---|
| 1696 | va_list ap; |
---|
| 1697 | aim_conn_t *bosconn; |
---|
[e19eb97] | 1698 | const char *bosip; |
---|
[d09e5a1] | 1699 | fu8_t *cookie; |
---|
| 1700 | |
---|
| 1701 | va_start(ap, fr); |
---|
[e19eb97] | 1702 | bosip = va_arg(ap, const char *); |
---|
[d09e5a1] | 1703 | cookie = va_arg(ap, fu8_t *); |
---|
| 1704 | va_end(ap); |
---|
| 1705 | |
---|
[8c46404] | 1706 | owl_function_debugmsg("migrate: migration in progress -- new BOS is %s -- disconnecting", bosip); |
---|
[d09e5a1] | 1707 | aim_conn_kill(sess, &fr->conn); |
---|
| 1708 | |
---|
| 1709 | if (!(bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, bosip))) { |
---|
[8c46404] | 1710 | owl_function_debugmsg("migrate: could not connect to BOS: internal error"); |
---|
[d09e5a1] | 1711 | return 1; |
---|
| 1712 | } else if (bosconn->status & AIM_CONN_STATUS_CONNERR) { |
---|
[8c46404] | 1713 | owl_function_debugmsg("migrate: could not connect to BOS"); |
---|
[d09e5a1] | 1714 | aim_conn_kill(sess, &bosconn); |
---|
| 1715 | return 1; |
---|
| 1716 | } |
---|
| 1717 | |
---|
| 1718 | /* Login will happen all over again. */ |
---|
| 1719 | addcb_bos(sess, bosconn); |
---|
[8c46404] | 1720 | /* aim_sendcookie(sess, bosconn, cookie); */ /********/ |
---|
[d09e5a1] | 1721 | return 1; |
---|
| 1722 | } |
---|
| 1723 | |
---|
| 1724 | static int ssirights(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1725 | { |
---|
[8c46404] | 1726 | owl_function_debugmsg("ssirights: got SSI rights, requesting data\n"); |
---|
[f4d0975] | 1727 | /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */ |
---|
| 1728 | aim_ssi_reqdata(sess); |
---|
[d09e5a1] | 1729 | |
---|
[8c92848] | 1730 | return(1); |
---|
[d09e5a1] | 1731 | } |
---|
| 1732 | |
---|
| 1733 | static int ssidata(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1734 | { |
---|
| 1735 | va_list ap; |
---|
| 1736 | fu8_t fmtver; |
---|
| 1737 | fu16_t itemcount; |
---|
| 1738 | fu32_t stamp; |
---|
[f4d0975] | 1739 | struct aim_ssi_item *list; |
---|
[cdf0ef1] | 1740 | /* |
---|
[f4d0975] | 1741 | struct aim_ssi_item *curitem; |
---|
[8c46404] | 1742 | struct aim_ssi_item *l; |
---|
[cdf0ef1] | 1743 | */ |
---|
[d09e5a1] | 1744 | |
---|
| 1745 | va_start(ap, fr); |
---|
| 1746 | fmtver = va_arg(ap, unsigned int); |
---|
| 1747 | itemcount = va_arg(ap, unsigned int); |
---|
| 1748 | stamp = va_arg(ap, fu32_t); |
---|
| 1749 | list = va_arg(ap, struct aim_ssi_item *); |
---|
| 1750 | va_end(ap); |
---|
| 1751 | |
---|
[f278ff3] | 1752 | owl_function_debugmsg("ssiddata: got SSI data (0x%02x, %d items, %u)", fmtver, itemcount, stamp); |
---|
[8c46404] | 1753 | /* |
---|
[f4d0975] | 1754 | for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
---|
[8c46404] | 1755 | for (l = list; l; l = l->next) { |
---|
| 1756 | owl_function_debugmsg("\t0x%04x (%s) - 0x%04x/0x%04x", l->type, l->name, l->gid, l->bid); |
---|
| 1757 | } |
---|
[d09e5a1] | 1758 | } |
---|
[8c46404] | 1759 | */ |
---|
[f4d0975] | 1760 | aim_ssi_enable(sess); |
---|
[d09e5a1] | 1761 | |
---|
| 1762 | return 1; |
---|
| 1763 | } |
---|
| 1764 | |
---|
| 1765 | static int ssidatanochange(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1766 | { |
---|
[8c46404] | 1767 | owl_function_debugmsg("ssidatanochange: server says we have the latest SSI data already"); |
---|
[f4d0975] | 1768 | /* aim_ssi_enable(sess, fr->conn); */ |
---|
| 1769 | aim_ssi_enable(sess); |
---|
[d09e5a1] | 1770 | return 1; |
---|
| 1771 | } |
---|
| 1772 | |
---|
| 1773 | static int offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1774 | { |
---|
| 1775 | va_list ap; |
---|
| 1776 | struct aim_icq_offlinemsg *msg; |
---|
| 1777 | |
---|
| 1778 | va_start(ap, fr); |
---|
| 1779 | msg = va_arg(ap, struct aim_icq_offlinemsg *); |
---|
| 1780 | va_end(ap); |
---|
| 1781 | |
---|
| 1782 | if (msg->type == 0x0001) { |
---|
[f278ff3] | 1783 | 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] | 1784 | } else { |
---|
[8c46404] | 1785 | owl_function_debugmsg("unknown offline message type 0x%04x", msg->type); |
---|
[d09e5a1] | 1786 | } |
---|
| 1787 | return 1; |
---|
| 1788 | } |
---|
| 1789 | |
---|
| 1790 | static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1791 | { |
---|
| 1792 | /* Tell the server to delete them. */ |
---|
[8c46404] | 1793 | owl_function_debugmsg("offlinemsg done: "); |
---|
[d09e5a1] | 1794 | aim_icq_ackofflinemsgs(sess); |
---|
| 1795 | return 1; |
---|
| 1796 | } |
---|
| 1797 | |
---|
| 1798 | |
---|
| 1799 | /******************** chat.c **************************/ |
---|
| 1800 | |
---|
| 1801 | static int faimtest_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1802 | { |
---|
| 1803 | va_list ap; |
---|
| 1804 | aim_userinfo_t *userinfo; |
---|
[0ff8fb57] | 1805 | int count; |
---|
| 1806 | /* int i; */ |
---|
[d09e5a1] | 1807 | |
---|
| 1808 | va_start(ap, fr); |
---|
| 1809 | count = va_arg(ap, int); |
---|
| 1810 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1811 | va_end(ap); |
---|
| 1812 | |
---|
[8c92848] | 1813 | owl_function_debugmsg("In faimtest_chat_join"); |
---|
[d09e5a1] | 1814 | /* |
---|
| 1815 | printf("chat: %s: New occupants have joined:\n", aim_chat_getname(fr->conn)); |
---|
| 1816 | for (i = 0; i < count; i++) |
---|
| 1817 | printf("chat: %s: \t%s\n", aim_chat_getname(fr->conn), userinfo[i].sn); |
---|
| 1818 | */ |
---|
| 1819 | return 1; |
---|
| 1820 | } |
---|
| 1821 | |
---|
| 1822 | static int faimtest_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1823 | { |
---|
| 1824 | aim_userinfo_t *userinfo; |
---|
[0ff8fb57] | 1825 | va_list ap; |
---|
| 1826 | int count; |
---|
| 1827 | /* int i; */ |
---|
| 1828 | |
---|
[d09e5a1] | 1829 | |
---|
| 1830 | va_start(ap, fr); |
---|
| 1831 | count = va_arg(ap, int); |
---|
| 1832 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
| 1833 | va_end(ap); |
---|
| 1834 | |
---|
| 1835 | /* |
---|
| 1836 | printf("chat: %s: Some occupants have left:\n", aim_chat_getname(fr->conn)); |
---|
| 1837 | |
---|
| 1838 | for (i = 0; i < count; i++) |
---|
| 1839 | printf("chat: %s: \t%s\n", aim_chat_getname(fr->conn), userinfo[i].sn); |
---|
| 1840 | */ |
---|
| 1841 | return 1; |
---|
| 1842 | } |
---|
| 1843 | |
---|
| 1844 | static int faimtest_chat_infoupdate(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1845 | { |
---|
| 1846 | va_list ap; |
---|
| 1847 | aim_userinfo_t *userinfo; |
---|
| 1848 | struct aim_chat_roominfo *roominfo; |
---|
[e19eb97] | 1849 | const char *roomname; |
---|
[0ff8fb57] | 1850 | int usercount; |
---|
[e19eb97] | 1851 | const char *roomdesc; |
---|
[d09e5a1] | 1852 | fu16_t flags, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
---|
| 1853 | fu32_t creationtime; |
---|
| 1854 | const char *croomname; |
---|
[0ff8fb57] | 1855 | /* int i; */ |
---|
[d09e5a1] | 1856 | |
---|
| 1857 | croomname = aim_chat_getname(fr->conn); |
---|
| 1858 | |
---|
| 1859 | va_start(ap, fr); |
---|
| 1860 | roominfo = va_arg(ap, struct aim_chat_roominfo *); |
---|
[e19eb97] | 1861 | roomname = va_arg(ap, const char *); |
---|
[d09e5a1] | 1862 | usercount = va_arg(ap, int); |
---|
| 1863 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
[e19eb97] | 1864 | roomdesc = va_arg(ap, const char *); |
---|
[d09e5a1] | 1865 | flags = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1866 | creationtime = va_arg(ap, fu32_t); |
---|
| 1867 | maxmsglen = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1868 | unknown_d2 = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1869 | unknown_d5 = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1870 | maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); |
---|
| 1871 | va_end(ap); |
---|
| 1872 | |
---|
[8c92848] | 1873 | owl_function_debugmsg("In faimtest_chat_infoupdate"); |
---|
[d09e5a1] | 1874 | /* |
---|
| 1875 | printf("chat: %s: info update:\n", croomname); |
---|
| 1876 | printf("chat: %s: \tRoominfo: {%04x, %s, %04x}\n", croomname, roominfo->exchange, roominfo->name, roominfo->instance); |
---|
| 1877 | printf("chat: %s: \tRoomname: %s\n", croomname, roomname); |
---|
| 1878 | printf("chat: %s: \tRoomdesc: %s\n", croomname, roomdesc); |
---|
| 1879 | printf("chat: %s: \tOccupants: (%d)\n", croomname, usercount); |
---|
| 1880 | |
---|
| 1881 | for (i = 0; i < usercount; i++) |
---|
| 1882 | printf("chat: %s: \t\t%s\n", croomname, userinfo[i].sn); |
---|
| 1883 | |
---|
[8c92848] | 1884 | owl_function_debugmsg("chat: %s: \tRoom flags: 0x%04x (%s%s%s%s)\n", |
---|
[d09e5a1] | 1885 | croomname, flags, |
---|
| 1886 | (flags & AIM_CHATROOM_FLAG_EVILABLE) ? "Evilable, " : "", |
---|
| 1887 | (flags & AIM_CHATROOM_FLAG_NAV_ONLY) ? "Nav Only, " : "", |
---|
| 1888 | (flags & AIM_CHATROOM_FLAG_INSTANCING_ALLOWED) ? "Instancing allowed, " : "", |
---|
| 1889 | (flags & AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED) ? "Occupant peek allowed, " : ""); |
---|
| 1890 | printf("chat: %s: \tCreation time: %lu (time_t)\n", croomname, creationtime); |
---|
| 1891 | printf("chat: %s: \tUnknown_d2: 0x%04x\n", croomname, unknown_d2); |
---|
| 1892 | printf("chat: %s: \tUnknown_d5: 0x%02x\n", croomname, unknown_d5); |
---|
| 1893 | printf("chat: %s: \tMax message length: %d bytes\n", croomname, maxmsglen); |
---|
| 1894 | printf("chat: %s: \tMax visible message length: %d bytes\n", croomname, maxvisiblemsglen); |
---|
| 1895 | */ |
---|
| 1896 | |
---|
[8c92848] | 1897 | return(1); |
---|
[d09e5a1] | 1898 | } |
---|
| 1899 | |
---|
| 1900 | static int faimtest_chat_incomingmsg(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1901 | { |
---|
| 1902 | va_list ap; |
---|
| 1903 | aim_userinfo_t *userinfo; |
---|
[e19eb97] | 1904 | const char *msg; |
---|
[d09e5a1] | 1905 | char tmpbuf[1152]; |
---|
| 1906 | |
---|
| 1907 | va_start(ap, fr); |
---|
| 1908 | userinfo = va_arg(ap, aim_userinfo_t *); |
---|
[e19eb97] | 1909 | msg = va_arg(ap, const char *); |
---|
[d09e5a1] | 1910 | va_end(ap); |
---|
| 1911 | |
---|
[8c92848] | 1912 | owl_function_debugmsg("in faimtest_chat_incomingmsg"); |
---|
| 1913 | |
---|
[d09e5a1] | 1914 | /* |
---|
| 1915 | printf("chat: %s: incoming msg from %s: %s\n", aim_chat_getname(fr->conn), userinfo->sn, msg); |
---|
| 1916 | */ |
---|
| 1917 | |
---|
| 1918 | /* |
---|
| 1919 | * Do an echo for testing purposes. But not for ourselves ("oops!") |
---|
| 1920 | */ |
---|
| 1921 | if (strcmp(userinfo->sn, sess->sn) != 0) { |
---|
| 1922 | /* sprintf(tmpbuf, "(%s said \"%s\")", userinfo->sn, msg); */ |
---|
| 1923 | aim_chat_send_im(sess, fr->conn, 0, tmpbuf, strlen(tmpbuf)); |
---|
| 1924 | } |
---|
| 1925 | |
---|
| 1926 | return 1; |
---|
| 1927 | } |
---|
| 1928 | |
---|
| 1929 | static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) |
---|
| 1930 | { |
---|
[2674412] | 1931 | owl_function_debugmsg("faimtest_conninitdone_chat:"); |
---|
[d09e5a1] | 1932 | |
---|
[2674412] | 1933 | aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, faimtest_parse_genericerr, 0); |
---|
| 1934 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, faimtest_chat_join, 0); |
---|
| 1935 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, faimtest_chat_leave, 0); |
---|
| 1936 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, faimtest_chat_infoupdate, 0); |
---|
| 1937 | aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, faimtest_chat_incomingmsg, 0); |
---|
[8c92848] | 1938 | |
---|
[d09e5a1] | 1939 | aim_clientready(sess, fr->conn); |
---|
| 1940 | |
---|
[2674412] | 1941 | owl_function_debugmsg("Chat ready"); |
---|
| 1942 | |
---|
| 1943 | /* |
---|
| 1944 | chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
---|
| 1945 | chatcon->id = id; |
---|
| 1946 | chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); |
---|
| 1947 | */ |
---|
| 1948 | return(1); |
---|
| 1949 | } |
---|
| 1950 | |
---|
[d09e5a1] | 1951 | void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir) |
---|
| 1952 | { |
---|
| 1953 | aim_conn_t *tstconn; |
---|
[8c92848] | 1954 | |
---|
| 1955 | owl_function_debugmsg("in faimtest_chatnav_redirect"); |
---|
[d09e5a1] | 1956 | |
---|
| 1957 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, redir->ip); |
---|
| 1958 | if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { |
---|
| 1959 | /* printf("unable to connect to chat(nav) server\n"); */ |
---|
| 1960 | if (tstconn) |
---|
| 1961 | aim_conn_kill(sess, &tstconn); |
---|
| 1962 | return; |
---|
| 1963 | } |
---|
| 1964 | |
---|
| 1965 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 1966 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
---|
[f4d0975] | 1967 | aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
---|
[d09e5a1] | 1968 | /* printf("chatnav: connected\n"); */ |
---|
| 1969 | return; |
---|
| 1970 | } |
---|
| 1971 | |
---|
| 1972 | /* XXX this needs instance too */ |
---|
| 1973 | void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir) |
---|
| 1974 | { |
---|
| 1975 | aim_conn_t *tstconn; |
---|
[8c92848] | 1976 | |
---|
| 1977 | owl_function_debugmsg("in chat_redirect"); |
---|
[d09e5a1] | 1978 | |
---|
| 1979 | tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, redir->ip); |
---|
| 1980 | if (!tstconn || (tstconn->status & AIM_CONN_STATUS_RESOLVERR)) { |
---|
| 1981 | /* printf("unable to connect to chat server\n"); */ |
---|
| 1982 | if (tstconn) aim_conn_kill(sess, &tstconn); |
---|
| 1983 | return; |
---|
| 1984 | } |
---|
| 1985 | /* printf("chat: connected to %s instance %d on exchange %d\n", redir->chat.room, redir->chat.instance, redir->chat.exchange); */ |
---|
| 1986 | |
---|
| 1987 | /* |
---|
| 1988 | * We must do this to attach the stored name to the connection! |
---|
| 1989 | */ |
---|
| 1990 | aim_chat_attachname(tstconn, redir->chat.exchange, redir->chat.room, redir->chat.instance); |
---|
| 1991 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); |
---|
| 1992 | aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
---|
[f4d0975] | 1993 | aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
---|
[d09e5a1] | 1994 | return; |
---|
| 1995 | } |
---|
| 1996 | |
---|
[3381399] | 1997 | void owl_process_aim() |
---|
| 1998 | { |
---|
| 1999 | if (owl_global_is_doaimevents(&g)) { |
---|
| 2000 | owl_aim_process_events(); |
---|
| 2001 | } |
---|
| 2002 | } |
---|