Changeset f4d0975
- Timestamp:
- Oct 10, 2003, 5:12:19 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e374dee
- Parents:
- 12582d3
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rf933403 rf4d0975 1 1 $Id$ 2 3 2.0.8-pre-5 4 Fixed bug with idle times causing broken pipes. 5 New libfaim 2 6 3 7 2.0.8-pre-4 -
Makefile.in
rf1e629d rf4d0975 23 23 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ 24 24 keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \ 25 aim.c buddy list.c timer.c style.c stylefunc.c25 aim.c buddy.c buddylist.c timer.c style.c stylefunc.c 26 26 OWL_SRC = owl.c 27 27 TESTER_SRC = tester.c -
aim.c
ra352335c rf4d0975 77 77 static int faimtest_locrights(aim_session_t *sess, aim_frame_t *fr, ...); 78 78 static int faimtest_reportinterval(aim_session_t *sess, aim_frame_t *fr, ...); 79 /* static int reportinterval(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs); */ 79 80 static int faimtest_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...); 80 81 static int getaimdata(aim_session_t *sess, unsigned char **bufret, int *buflenret, unsigned long offset, unsigned long len, const char *modname); … … 106 107 static int offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...); 107 108 108 static int directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...);109 static int directim_typing(aim_session_t *sess, aim_frame_t *fr, ...);110 static int faimtest_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...);111 static int faimtest_getfile_filereq(aim_session_t *ses, aim_frame_t *fr, ...);112 static int faimtest_getfile_filesend(aim_session_t *sess, aim_frame_t *fr, ...);113 static int faimtest_getfile_complete(aim_session_t *sess, aim_frame_t *fr, ...);114 static int faimtest_getfile_disconnect(aim_session_t *sess, aim_frame_t *fr, ...);115 static int faimtest_getfile_listing(aim_session_t *sess, aim_frame_t *fr, ...);116 static int faimtest_getfile_listingreq(aim_session_t *sess, aim_frame_t *fr, ...);117 static int faimtest_getfile_receive(aim_session_t *sess, aim_frame_t *fr, ...);118 static int faimtest_getfile_state4(aim_session_t *sess, aim_frame_t *fr, ...);119 static int faimtest_getfile_initiate(aim_session_t *sess, aim_frame_t *fr, ...);120 void getfile_start(aim_session_t *sess, aim_conn_t *conn, const char *sn);121 void getfile_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args);122 void directim_start(aim_session_t *sess, const char *sn);123 void directim_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args);124 125 109 void chatnav_redirect(aim_session_t *sess, struct aim_redirect_data *redir); 126 110 void chat_redirect(aim_session_t *sess, struct aim_redirect_data *redir); … … 130 114 void owl_aim_init(void) 131 115 { 132 aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 1);116 aim_session_init(owl_global_get_aimsess(&g), AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); 133 117 aim_setdebuggingcb(owl_global_get_aimsess(&g), faimtest_debugcb); 134 118 } 119 135 120 136 121 int owl_aim_login(char *screenname, char *password) … … 147 132 priv->server = "login.oscar.aol.com"; 148 133 owl_global_get_aimsess(&g)->aux_data = priv; 134 135 aim_tx_setenqueue(owl_global_get_aimsess(&g), AIM_TX_IMMEDIATE, NULL); 149 136 150 137 /* login */ … … 159 146 } 160 147 148 #if 0 149 static void oscar_login(GaimAccount *account) { 150 aim_session_t *sess; 151 aim_conn_t *conn; 152 char buf[256]; 153 GaimConnection *gc = gaim_account_get_connection(account); 154 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); 155 156 gaim_debug(GAIM_DEBUG_MISC, "oscar", "oscar_login: gc = %p\n", gc); 157 158 if (isdigit(*(gaim_account_get_username(account)))) { 159 od->icq = TRUE; 160 } else { 161 gc->flags |= GAIM_CONNECTION_HTML; 162 gc->flags |= GAIM_CONNECTION_AUTO_RESP; 163 } 164 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); 165 166 sess = g_new0(aim_session_t, 1); 167 168 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); 169 aim_setdebuggingcb(sess, oscar_debug); 170 171 /* we need an immediate queue because we don't use a while-loop to 172 * see if things need to be sent. */ 173 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); 174 od->sess = sess; 175 sess->aux_data = gc; 176 177 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); 178 if (conn == NULL) { 179 gaim_debug(GAIM_DEBUG_ERROR, "oscar", 180 "internal connection error\n"); 181 gaim_connection_error(gc, _("Unable to login to AIM")); 182 return; 183 } 184 185 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account)); 186 gaim_connection_update_progress(gc, buf, 2, 5); 187 188 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); 189 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); 190 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); 191 192 conn->status |= AIM_CONN_STATUS_INPROGRESS; 193 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), 194 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), 195 oscar_login_connect, gc) < 0) { 196 gaim_connection_error(gc, _("Couldn't connect to host")); 197 return; 198 } 199 aim_request_login(sess, conn, gaim_account_get_username(account)); 200 } 201 #endif 202 203 161 204 /* stuff to run once login has been successful */ 162 205 void owl_aim_successful_login(char *screenname) … … 171 214 owl_timer_reset_newstart(owl_global_get_aim_login_timer(&g), 172 215 owl_global_get_aim_ignorelogin_timer(&g)); 173 174 216 } 175 217 … … 196 238 int owl_aim_send_im(char *to, char *msg) 197 239 { 198 aim_send_im(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_ACK, msg); 240 int ret; 241 242 ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, NULL, msg); 243 244 /* aim_send_im(owl_global_get_aimsess(&g), to, AIM_IMFLAGS_ACK, msg); */ 199 245 200 246 /* I don't know how to check for an error yet */ … … 204 250 void owl_aim_addbuddy(char *screenname) 205 251 { 206 const char **foo; 207 208 /* 209 aim_bos_setbuddylist(owl_global_get_aimsess(&g), 210 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 211 foo); 212 */ 213 214 /* 215 aim_add_buddy(owl_global_get_aimsess(&g), 216 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 217 screenname); 218 */ 219 220 foo=(char *) owl_malloc(30); 221 foo[0]=screenname; 222 aim_ssi_addbuddies(owl_global_get_aimsess(&g), 223 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 224 "Buddies", foo, 1); 225 owl_free(foo); 226 252 aim_ssi_addbuddy(owl_global_get_aimsess(&g), screenname, "Buddies", NULL, NULL, NULL, 0); 227 253 } 228 254 229 255 void owl_aim_delbuddy(char *screenname) 230 256 { 231 /* 232 aim_remove_buddy(owl_global_get_aimsess(&g), 233 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 234 screenname); 235 */ 236 237 aim_ssi_delbuddies(owl_global_get_aimsess(&g), 238 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 239 "Buddies", &screenname, 1); 240 241 /* for some reason we don't get an offgoing notice, so we'll remove 242 * manually 243 */ 244 257 aim_ssi_delbuddy(owl_global_get_aimsess(&g), screenname, "Buddies"); 245 258 owl_buddylist_offgoing(owl_global_get_buddylist(&g), screenname); 246 247 248 } 249 259 } 260 261 #if 0 250 262 void owl_aim_get_idle(char *screenname) 251 263 { 264 /* 252 265 aim_getinfo(owl_global_get_aimsess(&g), 253 266 aim_getconn_type(owl_global_get_aimsess(&g), AIM_CONN_TYPE_BOS), 254 267 screenname, 255 268 AIM_GETINFO_GENERALINFO); 256 } 269 */ 270 } 271 #endif 257 272 258 273 … … 308 323 } 309 324 310 if (selstat == -1) { /* error */ 311 /* keepgoing = 0; */ /* fall through */ 312 } else if (selstat == 0) { /* no events pending */ 313 /* printf("selstat == 0\n"); */ 325 if (selstat == -1) { 326 owl_function_debugmsg("Error in select"); 327 /* error */ 328 } else if (selstat == 0) { 329 /* no events pending */ 314 330 } else if (selstat == 1) { /* outgoing data pending */ 315 /* printf("selstat == 1\n"); */316 331 aim_tx_flushqueue(aimsess); 317 332 } else if (selstat == 2) { /* incoming data pending */ 318 333 /* printf("selstat == 2\n"); */ 319 if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { 320 if (aim_handlerendconnect(aimsess, waitingconn) < 0) { 321 /* printf("connection error (rend out)\n"); */ 334 335 if (aim_get_command(aimsess, waitingconn) >= 0) { 336 aim_rxdispatch(aimsess); 337 } else { 338 /* printf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); */ 339 /* we should have callbacks for all these, else the library will do the conn_kill for us. */ 340 if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) { 341 if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { 342 /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */ 343 aim_conn_kill(aimsess, &waitingconn); 344 } 345 } else { 322 346 aim_conn_kill(aimsess, &waitingconn); 323 347 } 324 } else { 325 if (aim_get_command(aimsess, waitingconn) >= 0) { 326 aim_rxdispatch(aimsess); 327 } else { 328 /* printf("connection error (type 0x%04x:0x%04x)\n", waitingconn->type, waitingconn->subtype); */ 329 /* we should have callbacks for all these, else the library will do the conn_kill for us. */ 330 if (waitingconn->type == AIM_CONN_TYPE_RENDEZVOUS) { 331 if (waitingconn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { 332 /* printf("disconnected from %s\n", aim_directim_getsn(waitingconn)); */ 333 aim_conn_kill(aimsess, &waitingconn); 334 } 335 } else { 336 aim_conn_kill(aimsess, &waitingconn); 337 } 338 if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) { 339 /* printf("major connection error\n"); */ 340 /* break; */ 341 /* we should probably kill the session */ 342 } 348 if (!aim_getconn_type(aimsess, AIM_CONN_TYPE_BOS)) { 349 /* printf("major connection error\n"); */ 350 /* break; */ 351 /* we should probably kill the session */ 343 352 } 344 353 } … … 354 363 } 355 364 356 357 365 static int faimtest_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) 358 366 { … … 384 392 385 393 /* printf("Screen name: %s\n", info->sn); */ 386 owl_function_debugmsg(" Here with%s", info->sn);394 owl_function_debugmsg("faimtest_parse_authresp: %s", info->sn); 387 395 388 396 /* … … 434 442 owl_aim_successful_login(info->sn); 435 443 addcb_bos(sess, bosconn); 436 aim_sendcookie(sess, bosconn, info->cookie );444 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); 437 445 return 1; 438 446 } … … 513 521 } 514 522 515 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) 516 { 517 char buddies[128]; /* this is the new buddy list */ 518 char profile[256]; /* this is the new profile */ 519 /* char awaymsg[] = {"blah blah blah Ole! blah blah blah"}; */ 520 521 /* Caution: Buddy1 and Buddy2 are real people! (who I don't know) */ 522 /* snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&%s&", priv->ohcaptainmycaptain ? priv->ohcaptainmycaptain : "blah"); 523 snprintf(profile, sizeof(profile), "Hello.<br>My captain is %s. They were dumb enough to leave this message in their client, or they are using faimtest. Shame 524 on them.", priv->ohcaptainmycaptain); 525 */ 526 527 /* 528 snprintf(buddies, sizeof(buddies), "Buddy1&Buddy2&"); 529 snprintf(profile, sizeof(profile), "Hello.<br>This is a test"); 530 */ 531 strcpy(profile, ""); 532 523 524 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { 533 525 aim_reqpersonalinfo(sess, fr->conn); 526 527 #ifndef NOSSI 528 aim_ssi_reqrights(sess); 529 aim_ssi_reqdata(sess); 530 #endif 531 534 532 aim_bos_reqlocaterights(sess, fr->conn); 535 536 /* aim_bos_setprofile(sess, fr->conn, profile, awaymsg, AIM_CAPS_BUDDYICON | AIM_CAPS_CHAT | AIM_CAPS_GETFILE | AIM_CAPS_SENDFILE | AIM_CAPS_IMIMAGE | AIM_CAPS_GAMES | AIM_CAPS_SAVESTOCKS | AIM_CAPS_SENDBUDDYLIST | AIM_CAPS_ICQ | AIM_CAPS_ICQUNKNOWN | AIM_CAPS_ICQRTF | AIM_CAPS_ICQSERVERRELAY | AIM_CAPS_TRILLIANCRYPT); */537 aim_bos_setprofile(sess, fr->conn, "", "", AIM_CAPS_SENDBUDDYLIST );538 533 aim_bos_reqbuddyrights(sess, fr->conn); 539 540 /* send the buddy list and profile (required, even if empty) */ 541 aim_bos_setbuddylist(sess, fr->conn, buddies); 542 543 aim_reqicbmparams(sess); 544 545 aim_bos_reqrights(sess, fr->conn); 546 /* set group permissions -- all user classes */ 534 aim_im_reqparams(sess); 535 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */ 536 537 #ifdef NOSSI 547 538 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); 548 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE); 539 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); 540 #endif 549 541 550 542 return 1; … … 693 685 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, faimtest_infochange, 0); 694 686 /* Send the cookie to the Auth */ 695 aim_sendcookie(sess, tstconn, redir->cookie );687 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); 696 688 /* printf("sent cookie to authorizer host\n"); */ 697 689 } … … 726 718 params->maxmsglen = 8000; 727 719 params->minmsginterval = 0; /* in milliseconds */ 728 aim_seticbmparam(sess, params); 720 /* aim_seticbmparam(sess, params); */ 721 aim_im_setparams(sess, params); 729 722 730 723 return 1; … … 743 736 /* printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); */ 744 737 745 aim_ssi_reqrights(sess, fr->conn); 738 /* aim_ssi_reqrights(sess, fr->conn); */ 739 aim_ssi_reqrights(sess); 746 740 747 741 return 1; … … 784 778 va_list ap; 785 779 fu16_t interval; 786 780 787 781 va_start(ap, fr); 788 782 interval = va_arg(ap, int); 789 783 va_end(ap); 790 784 791 785 /* printf("minimum report interval: %d (seconds?)\n", interval); */ 792 786 793 787 if (!priv->connected) { 794 788 priv->connected++; 795 789 } 796 aim_reqicbmparams(sess); 790 /* aim_reqicbmparams(sess); */ 791 aim_im_reqparams(sess); 792 /* kretch */ 797 793 return 1; 798 794 } … … 1026 1022 char *prof = NULL; 1027 1023 fu16_t inforeq = 0; 1028 1024 owl_buddy *b; 1029 1025 va_list ap; 1030 1026 va_start(ap, fr); … … 1036 1032 1037 1033 /* right now the only reason we call this is for idle times */ 1038 owl_buddylist_set_idletime(owl_global_get_buddylist(&g), userinfo->sn, userinfo->idletime); 1034 owl_function_debugmsg("parse_userinfo sn: %s idle: %i", userinfo->sn, userinfo->idletime); 1035 b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), 1036 userinfo->sn); 1037 if (!b) return(1); 1038 owl_buddy_set_idle_since(b, userinfo->idletime); 1039 1039 return(1); 1040 1040 … … 1044 1044 printuserflags(userinfo->flags); 1045 1045 printf("\n"); 1046 1046 1047 /* 1047 1048 printf("userinfo: membersince: %lu\n", userinfo->membersince); 1048 1049 printf("userinfo: onlinesince: %lu\n", userinfo->onlinesince); 1049 1050 printf("userinfo: idletime: 0x%04x\n", userinfo->idletime); 1050 1051 printf("userinfo: capabilities = %s = 0x%08lx\n", (userinfo->present & AIM_USERINFO_PRESENT_CAPABILITIES) ? "present" : "not present", userinfo->capabilities); 1051 1052 */ 1052 1053 1053 1054 if (inforeq == AIM_GETINFO_GENERALINFO) { … … 1066 1067 } 1067 1068 1069 #if 0 1068 1070 static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, const char *tmpstr) 1069 1071 { … … 1073 1075 logout(sess); 1074 1076 } else if (strstr(tmpstr, "goodday")) { 1075 aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too.");1077 /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); */ 1076 1078 } else if (strstr(tmpstr, "haveicon") && priv->buddyicon) { 1077 1079 struct aim_sendimext_args args; … … 1118 1120 */ 1119 1121 args.destsn = userinfo->sn; 1120 args.flags = AIM_IMFLAGS_CUSTOMCHARSET;1122 /* args.flags = AIM_IMFLAGS_CUSTOMCHARSET; */ 1121 1123 args.charset = args.charsubset = 0x4242; 1122 1124 args.msg = data; 1123 1125 args.msglen = sizeof(data); 1124 aim_send_im_ext(sess, &args);1126 /* aim_send_im_ext(sess, &args); */ 1125 1127 } else if (strstr(tmpstr, "sendmulti")) { 1126 1128 struct aim_sendimext_args args; … … 1148 1150 args.mpmsg = &mpm; 1149 1151 1150 aim_send_im_ext(sess, &args);1152 /* aim_send_im_ext(sess, &args); */ 1151 1153 1152 1154 aim_mpmsg_free(sess, &mpm); … … 1182 1184 args.mpmsg = &mpm; 1183 1185 1184 aim_send_im_ext(sess, &args);1186 /* aim_send_im_ext(sess, &args); */ 1185 1187 aim_mpmsg_free(sess, &mpm); 1186 1188 … … 1197 1199 args.featureslen = sizeof(features); 1198 1200 1199 aim_send_im_ext(sess, &args);1201 /* aim_send_im_ext(sess, &args); */ 1200 1202 } else if (strstr(tmpstr, "sendicon") && priv->buddyicon) { 1201 aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum);1203 /* aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); */ 1202 1204 } else if (strstr(tmpstr, "warnme")) { 1203 1205 /* printf("icbm: sending non-anon warning\n"); */ 1204 aim_send_warning(sess, conn, userinfo->sn, 0);1206 /* aim_send_warning(sess, conn, userinfo->sn, 0); */ 1205 1207 } else if (strstr(tmpstr, "anonwarn")) { 1206 1208 /* printf("icbm: sending anon warning\n"); */ 1207 aim_send_warning(sess, conn, userinfo->sn, AIM_WARN_ANON);1209 /* aim_send_warning(sess, conn, userinfo->sn, AIM_WARN_ANON); */ 1208 1210 } else if (strstr(tmpstr, "setdirectoryinfo")) { 1209 1211 /* printf("icbm: sending backwards profile data\n"); */ … … 1212 1214 /* printf("icbm: setting fun interests\n"); */ 1213 1215 aim_setuserinterests(sess, conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1); 1214 } else if (!strncmp(tmpstr, "getfile", 7)) {1215 if (!priv->ohcaptainmycaptain) {1216 aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "I have no owner!");1217 } else {1218 getfile_start(sess, conn, (strlen(tmpstr) < 8)?priv->ohcaptainmycaptain:tmpstr+8);1219 }1220 1216 } else if (!strncmp(tmpstr, "open chatnav", 12)) { 1221 1217 aim_reqservice(sess, conn, AIM_CONN_TYPE_CHATNAV); … … 1234 1230 aim_getinfo(sess, conn, "midendian", AIM_GETINFO_AWAYMESSAGE); 1235 1231 aim_getinfo(sess, conn, "midendian", AIM_GETINFO_CAPABILITIES); 1236 } else if (strstr(tmpstr, "open directim")) {1237 directim_start(sess, userinfo->sn);1238 1232 } else if(strstr(tmpstr, "lookup")) { 1239 aim_usersearch_address(sess, conn, "mid@auk.cx");1233 /* aim_usersearch_address(sess, conn, "mid@auk.cx"); */ 1240 1234 } else if (!strncmp(tmpstr, "reqsendmsg", 10)) { 1241 aim_send_im(sess, priv->ohcaptainmycaptain, 0, "sendmsg 7900");1235 /* aim_send_im(sess, priv->ohcaptainmycaptain, 0, "sendmsg 7900"); */ 1242 1236 } else if (!strncmp(tmpstr, "reqadmin", 8)) { 1243 1237 aim_reqservice(sess, conn, AIM_CONN_TYPE_AUTH); … … 1264 1258 newbuf[z] = (z % 10)+0x30; 1265 1259 newbuf[i] = '\0'; 1266 aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf);1260 /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */ 1267 1261 free(newbuf); 1268 1262 } 1269 1263 } else if (strstr(tmpstr, "seticqstatus")) { 1270 aim_setextstatus(sess, conn,AIM_ICQ_STATE_DND);1264 aim_setextstatus(sess, AIM_ICQ_STATE_DND); 1271 1265 } else if (strstr(tmpstr, "rtfmsg")) { 1272 1266 static const char rtfmsg[] = {"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\froman\\fprq2\\fcharset0 Georgia;}{\\f2\\fmodern\\fprq1\\fcharset0 MS Mincho;}{\\f3\\froman\\fprq2\\fcharset2 Symbol;}}\\viewkind4\\uc1\\pard\\f0\\fs20 Test\\f1 test\\f2\fs44 test\\f3\\fs20 test\\f0\\par}"}; … … 1278 1272 rtfargs.bgcolor = 0x00000000; 1279 1273 rtfargs.rtfmsg = rtfmsg; 1280 aim_send_rtfmsg(sess, &rtfargs);1274 /* aim_send_rtfmsg(sess, &rtfargs); */ 1281 1275 } else { 1282 1276 /* printf("unknown command.\n"); */ … … 1286 1280 return 0; 1287 1281 } 1282 #endif 1288 1283 1289 1284 /* … … 1293 1288 { 1294 1289 struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data; 1295 int clienttype = AIM_CLIENTTYPE_UNKNOWN;1296 1290 owl_message *m; 1297 1291 char *stripmsg, *nz_screenname, *wrapmsg; 1298 1292 char realmsg[8192+1] = {""}; 1299 clienttype = aim_fingerprintclient(args->features, args->featureslen); 1293 /* int clienttype = AIM_CLIENTTYPE_UNKNOWN; */ 1294 1295 /* clienttype = aim_fingerprintclient(args->features, args->featureslen); */ 1300 1296 1301 1297 /* … … 1325 1321 */ 1326 1322 1323 /* 1327 1324 if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) { 1328 /* printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset); */ 1329 } 1325 printf("icbm: encoding flags = {%04x, %04x}\n", args->charset, args->charsubset); 1326 } 1327 */ 1330 1328 1331 1329 /* … … 1425 1423 1426 1424 if (priv->buddyicon && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { 1427 aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum);1425 /* aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); */ 1428 1426 } 1429 1427 … … 1451 1449 */ 1452 1450 1453 if (args->reqclass == AIM_CAPS_GETFILE) { 1454 getfile_requested(sess, conn, userinfo, args); 1455 } else if (args->reqclass == AIM_CAPS_SENDFILE) { 1451 if (args->reqclass == AIM_CAPS_SENDFILE) { 1456 1452 /* printf("send file!\n"); */ 1457 1453 } else if (args->reqclass == AIM_CAPS_CHAT) { … … 1465 1461 1466 1462 /* aim_chat_join(sess, conn, args->info.chat.roominfo.exchange, args->info.chat.roominfo.name, args->info.chat.roominfo.instance); */ 1467 } else if (args->reqclass == AIM_CAPS_IMIMAGE) {1468 directim_requested(sess, conn, userinfo, args);1469 1463 } else if (args->reqclass == AIM_CAPS_BUDDYICON) { 1470 1464 /* printf("Buddy Icon from %s, length = %lu\n", userinfo->sn, args->info.icon.length); */ … … 1508 1502 aim_userinfo_t *userinfo; 1509 1503 char *nz_screenname; 1510 1504 owl_buddy *b; 1505 owl_buddylist *bl; 1511 1506 va_list ap; 1512 1507 va_start(ap, fr); … … 1515 1510 1516 1511 nz_screenname=owl_aim_normalize_screenname(userinfo->sn); 1512 bl=owl_global_get_buddylist(&g); 1513 1517 1514 owl_buddylist_oncoming(owl_global_get_buddylist(&g), nz_screenname); 1515 1516 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { 1517 /* */ 1518 } 1519 1520 b=owl_buddylist_get_aim_buddy(owl_global_get_buddylist(&g), nz_screenname); 1521 if (!b) { 1522 owl_function_debugmsg("Error: parse_oncoming setting idle time with no buddy present."); 1523 return(1); 1524 } 1525 if (userinfo->idletime==0) { 1526 owl_buddy_set_unidle(b); 1527 } else { 1528 owl_buddy_set_idle(b); 1529 owl_buddy_set_idle_since(b, userinfo->idletime); 1530 } 1531 owl_function_debugmsg("parse_oncoming sn: %s idle: %i", userinfo->sn, userinfo->idletime); 1532 1518 1533 owl_free(nz_screenname); 1519 1534 … … 1550 1565 owl_free(nz_screenname); 1551 1566 1567 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { 1568 owl_function_debugmsg("parse_offgoing sn: %s idle time %i", userinfo->sn, userinfo->idletime); 1569 } 1570 1552 1571 /* 1553 1572 printf("%ld %s is now offline (flags: %04x = %s%s%s%s%s%s%s%s) (caps = %s = 0x%08lx)\n", … … 1830 1849 /* Login will happen all over again. */ 1831 1850 addcb_bos(sess, bosconn); 1832 aim_sendcookie(sess, bosconn, cookie);1851 /* aim_sendcookie(sess, bosconn, cookie); */ 1833 1852 return 1; 1834 1853 } … … 1838 1857 1839 1858 /* printf("got SSI rights, requesting data\n"); */ 1840 aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); 1859 /* aim_ssi_reqdata(sess, fr->conn, 0, 0x0000); */ 1860 aim_ssi_reqdata(sess); 1841 1861 1842 1862 return 1; … … 1849 1869 fu16_t itemcount; 1850 1870 fu32_t stamp; 1851 struct aim_ssi_item *list, *l; 1871 struct aim_ssi_item *list; 1872 struct aim_ssi_item *curitem; 1873 /* struct aim_ssi_item *l; */ 1852 1874 1853 1875 va_start(ap, fr); … … 1859 1881 1860 1882 /* printf("got SSI data: (0x%02x, %d items, %ld)\n", fmtver, itemcount, stamp); */ 1861 for (l = list; l; l = l->next) { 1883 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { 1884 /* for (l = list; l; l = l->next) { */ 1862 1885 /* printf("\t0x%04x (%s) - 0x%04x/0x%04x\n", l->type, l->name, l->gid, l->bid); */ 1863 1886 /* printf("I would have printed data here!\n"); */ 1864 1887 } 1865 1888 1866 aim_ssi_enable(sess , fr->conn);1889 aim_ssi_enable(sess); 1867 1890 1868 1891 return 1; … … 1872 1895 { 1873 1896 /* printf("server says we have the latest SSI data already\n"); */ 1874 aim_ssi_enable(sess, fr->conn); 1897 /* aim_ssi_enable(sess, fr->conn); */ 1898 aim_ssi_enable(sess); 1875 1899 return 1; 1876 1900 } … … 2128 2152 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); 2129 2153 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); 2130 aim_sendcookie(sess, tstconn, redir->cookie );2154 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); 2131 2155 /* printf("chatnav: connected\n"); */ 2132 2156 return; … … 2152 2176 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE, faimtest_conncomplete, 0); 2153 2177 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); 2154 aim_sendcookie(sess, tstconn, redir->cookie );2178 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); 2155 2179 return; 2156 }2157 2158 2159 2160 2161 /******************************************* ft.c ******************************************/2162 2163 2164 static int directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...)2165 {2166 va_list ap;2167 char *sn, *msg;2168 2169 va_start(ap, fr);2170 sn = va_arg(ap, char *);2171 msg = va_arg(ap, char *);2172 va_end(ap);2173 2174 /* printf("Directim from %s: %s\n", sn, msg); */2175 if (strstr(msg, "sendmsg")) {2176 int i;2177 2178 i = atoi(strstr(msg, "sendmsg")+8);2179 if (i < 10000) {2180 char *newbuf;2181 int z;2182 2183 newbuf = malloc(i+1);2184 for (z = 0; z < i; z++)2185 newbuf[z] = (z % 10)+0x30;2186 newbuf[i] = '\0';2187 aim_send_im_direct(sess, fr->conn, newbuf, strlen(newbuf), 0);2188 free(newbuf);2189 }2190 } else if (strstr(msg, "goodday")) {2191 aim_send_im_direct(sess, fr->conn, "Good day to you, too", 18, 0);2192 } else {2193 char newmsg[1024];2194 snprintf(newmsg, sizeof(newmsg), "unknown (%s)\n", msg);2195 aim_send_im_direct(sess, fr->conn, newmsg, strlen(newmsg), 0);2196 }2197 2198 return 1;2199 }2200 2201 static int directim_typing(aim_session_t *sess, aim_frame_t *fr, ...)2202 {2203 va_list ap;2204 char *sn;2205 2206 va_start(ap, fr);2207 sn = va_arg(ap, char *);2208 va_end(ap);2209 /* printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); */2210 return 1;2211 }2212 2213 static int faimtest_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...)2214 {2215 va_list ap;2216 aim_conn_t *newconn, *listenerconn;2217 2218 va_start(ap, fr);2219 newconn = va_arg(ap, aim_conn_t *);2220 listenerconn = va_arg(ap, aim_conn_t *);2221 va_end(ap);2222 2223 aim_conn_close(listenerconn);2224 aim_conn_kill(sess, &listenerconn);2225 2226 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, directim_incoming, 0);2227 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, directim_typing, 0);2228 2229 aim_send_im_direct(sess, newconn, "goodday", 8, 0);2230 2231 /* printf("OFT: DirectIM: connected to %s\n", aim_directim_getsn(newconn)); */2232 2233 return 1;2234 }2235 2236 static int faimtest_getfile_filereq(aim_session_t *ses, aim_frame_t *fr, ...)2237 {2238 va_list ap;2239 aim_conn_t *oftconn;2240 struct aim_fileheader_t *fh;2241 fu8_t *cookie;2242 2243 va_start(ap, fr);2244 oftconn = va_arg(ap, aim_conn_t *);2245 fh = va_arg(ap, struct aim_fileheader_t *);2246 cookie = va_arg(ap, fu8_t *);2247 va_end(ap);2248 2249 /* printf("request for file %s.\n", fh->name); */2250 2251 return 1;2252 }2253 2254 static int faimtest_getfile_filesend(aim_session_t *sess, aim_frame_t *fr, ...)2255 {2256 struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;2257 va_list ap;2258 aim_conn_t *oftconn;2259 struct aim_fileheader_t *fh;2260 char *path;2261 fu8_t *cookie;2262 int pos, bufpos = 0, bufsize = 2048, i;2263 char *buf;2264 FILE *file;2265 2266 va_start(ap, fr);2267 oftconn = va_arg(ap, aim_conn_t *);2268 fh = va_arg(ap, struct aim_fileheader_t *);2269 cookie = va_arg(ap, fu8_t *);2270 va_end(ap);2271 2272 /* printf("sending file %s(%ld).\n", fh->name, fh->size); */2273 2274 if (!(buf = malloc(2048)))2275 return -1;2276 2277 if (!(path = (char *)calloc(1, strlen(priv->listingpath) +strlen(fh->name)+2))) {2278 /* perror("calloc"); */2279 /* printf("error in calloc of path\n"); */2280 2281 return 0; /* XXX: no idea what winaim expects here =) */2282 }2283 2284 snprintf(path, strlen(priv->listingpath)+strlen(fh->name)+2, "%s/%s", priv->listingpath, fh->name);2285 2286 if (!(file = fopen(path, "r"))) {2287 /* printf("getfile_send fopen failed for %s. damn.\n", path); */2288 return 0;2289 }2290 2291 /*2292 * This is a mess. Remember that faimtest is demonstration code2293 * only and for the sake of the gods, don't use this code in any2294 * of your clients. --mid2295 */2296 for(pos = 0; pos < fh->size; pos++) {2297 2298 bufpos = pos % bufsize;2299 2300 if (bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */2301 if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {2302 /* perror("faim: getfile_send: write1"); */2303 /* printf("faim: getfile_send: whoopsy, didn't write it all...\n"); */2304 free(buf);2305 return 0;2306 }2307 }2308 2309 if( (buf[bufpos] = fgetc(file)) == EOF) {2310 if(pos != fh->size) {2311 /* printf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size); */2312 free(buf);2313 return 0;2314 }2315 }2316 /* printf("%c(0x%02x) ", buf[pos], buf[pos]); */2317 }2318 2319 if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {2320 /* perror("faim: getfile_send: write2"); */2321 /* printf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n"); */2322 free(buf);2323 return 0;2324 }2325 2326 free(buf);2327 free(fh);2328 2329 return 1;2330 }2331 2332 static int faimtest_getfile_complete(aim_session_t *sess, aim_frame_t *fr, ...)2333 {2334 va_list ap;2335 aim_conn_t *conn;2336 struct aim_fileheader_t *fh;2337 2338 va_start(ap, fr);2339 conn = va_arg(ap, aim_conn_t *);2340 fh = va_arg(ap, struct aim_fileheader_t *);2341 va_end(ap);2342 2343 /* printf("completed file transfer for %s.\n", fh->name); */2344 2345 aim_conn_close(conn);2346 aim_conn_kill(sess, &conn);2347 2348 return 1;2349 }2350 2351 static int faimtest_getfile_disconnect(aim_session_t *sess, aim_frame_t *fr, ...)2352 {2353 va_list ap;2354 aim_conn_t *conn;2355 char *sn;2356 2357 va_start(ap, fr);2358 conn = va_arg(ap, aim_conn_t *);2359 sn = va_arg(ap, char *);2360 va_end(ap);2361 2362 aim_conn_kill(sess, &conn);2363 2364 /* printf("getfile: disconnected from %s\n", sn); */2365 2366 return 1;2367 }2368 2369 static int faimtest_getfile_listing(aim_session_t *sess, aim_frame_t *fr, ...)2370 {2371 va_list ap;2372 aim_conn_t *conn;2373 char *listing;2374 struct aim_filetransfer_priv *ft;2375 char *filename, *nameend, *sizec;2376 int filesize, namelen;2377 2378 va_start(ap, fr);2379 conn = va_arg(ap, aim_conn_t *);2380 ft = va_arg(ap, struct aim_filetransfer_priv *);2381 listing = va_arg(ap, char *);2382 va_end(ap);2383 2384 /* printf("listing on %d==================\n%s\n===========\n", conn->fd, listing); */2385 2386 nameend = strstr(listing+0x1a, "\r");2387 namelen = nameend - (listing + 0x1a);2388 2389 filename = malloc(namelen + 1);2390 strncpy(filename, listing+0x1a, namelen);2391 filename[namelen] = 0x00;2392 2393 sizec = malloc(8+1);2394 memcpy(sizec, listing + 0x11, 8);2395 sizec[8] = 0x00;2396 2397 filesize = strtol(sizec, (char **)NULL, 10);2398 2399 /* printf("requesting %d %s(%d long)\n", namelen, filename, filesize); */2400 2401 /* aim_oft_getfile_request(sess, conn, filename, filesize); */2402 2403 free(filename);2404 free(sizec);2405 2406 return 0;2407 }2408 2409 static int faimtest_getfile_listingreq(aim_session_t *sess, aim_frame_t *fr, ...)2410 {2411 struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;2412 va_list ap;2413 aim_conn_t *oftconn;2414 struct aim_fileheader_t *fh;2415 int pos, bufpos = 0, bufsize = 2048, i;2416 char *buf;2417 2418 va_start(ap, fr);2419 oftconn = va_arg(ap, aim_conn_t *);2420 fh = va_arg(ap, struct aim_fileheader_t *);2421 va_end(ap);2422 2423 /* printf("sending listing of size %ld\n", fh->size); */2424 2425 if(!(buf = malloc(2048))) return -1;2426 2427 for(pos = 0; pos < fh->size; pos++) {2428 bufpos = pos % bufsize;2429 if(bufpos == 0 && pos > 0) { /* filled our buffer. spit it across the wire */2430 if ( (i = send(oftconn->fd, buf, bufsize, 0)) != bufsize ) {2431 /* perror("faim: getfile_send: write1"); */2432 /* printf("faim: getfile_send: whoopsy, didn't write it all...\n"); */2433 free(buf);2434 return 0;2435 }2436 }2437 if( (buf[bufpos] = fgetc(priv->listingfile)) == EOF) {2438 if(pos != fh->size) {2439 /* printf("faim: getfile_send: hrm... apparent early EOF at pos 0x%x of 0x%lx\n", pos, fh->size); */2440 free(buf);2441 return 0;2442 }2443 }2444 }2445 2446 if( (i = send(oftconn->fd, buf, bufpos+1, 0)) != (bufpos+1)) {2447 /* perror("faim: getfile_send: write2"); */2448 /* printf("faim: getfile_send cleanup: whoopsy, didn't write it all...\n"); */2449 free(buf);2450 return 0;2451 }2452 2453 /* printf("sent listing\n"); */2454 free(buf);2455 2456 return 0;2457 }2458 2459 static int faimtest_getfile_receive(aim_session_t *sess, aim_frame_t *fr, ...)2460 {2461 /* needs ot be fixed --kretch */2462 #if 02463 va_list ap;2464 aim_conn_t *conn;2465 struct aim_filetransfer_priv *ft;2466 unsigned char data;2467 int pos;2468 2469 2470 va_start(ap, fr);2471 conn = va_arg(ap, aim_conn_t *);2472 ft = va_arg(ap, struct aim_filetransfer_priv *);2473 va_end(ap);2474 2475 /* printf("receiving %ld bytes of file data for %s:\n\t", ft->fh.size, ft->fh.name); */2476 2477 for(pos = 0; pos < ft->fh.size; pos++) {2478 read(conn->fd, &data, 1);2479 /* printf("%c(%02x) ", data, data); */2480 }2481 2482 /* printf("\n"); */2483 2484 aim_oft_getfile_end(sess, conn);2485 #endif2486 return 0;2487 }2488 2489 static int faimtest_getfile_state4(aim_session_t *sess, aim_frame_t *fr, ...)2490 {2491 va_list ap;2492 aim_conn_t *conn;2493 2494 va_start(ap, fr);2495 conn = va_arg(ap, aim_conn_t *);2496 va_end(ap);2497 2498 aim_conn_close(conn);2499 aim_conn_kill(sess, &conn);2500 2501 return 0;2502 }2503 2504 static int faimtest_getfile_initiate(aim_session_t *sess, aim_frame_t *fr, ...)2505 {2506 va_list ap;2507 aim_conn_t *conn, *listenerconn;2508 struct aim_filetransfer_priv *priv;2509 2510 va_start(ap, fr);2511 conn = va_arg(ap, aim_conn_t *);2512 listenerconn = va_arg(ap, aim_conn_t *);2513 va_end(ap);2514 2515 aim_conn_close(listenerconn);2516 aim_conn_kill(sess, &listenerconn);2517 2518 /* This doesn't work with the new libfaim */2519 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ, faimtest_getfile_filereq, 0);2520 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);2521 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);2522 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);2523 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTING, faimtest_getfile_listing, 0);2524 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);2525 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILERECEIVE, faimtest_getfile_receive, 0);2526 aim_conn_addhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILESTATE4, faimtest_getfile_state4, 0);2527 2528 priv = (struct aim_filetransfer_priv *)conn->priv;2529 2530 /* printf("getfile: %s (%s) connected to us on %d\n", priv->sn, priv->ip, conn->fd); */2531 2532 return 1;2533 }2534 2535 void getfile_start(aim_session_t *sess, aim_conn_t *conn, const char *sn)2536 {2537 aim_conn_t *newconn;2538 2539 newconn = aim_getfile_initiate(sess, conn, sn);2540 /* printf("getting file listing from %s\n", sn); */2541 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEINITIATE, faimtest_getfile_initiate,0);2542 2543 return;2544 }2545 2546 void getfile_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args)2547 {2548 struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;2549 aim_conn_t *newconn;2550 struct aim_fileheader_t *fh;2551 2552 printf("get file request from %s (at %s/%s/%s) %x\n", userinfo->sn, args->clientip, args->clientip2, args->verifiedip, args->reqclass);2553 fh = aim_getlisting(sess, priv->listingfile);2554 newconn = aim_accepttransfer(sess, conn, userinfo->sn, args->cookie, args->clientip, fh->totfiles, fh->totsize, fh->size, fh->checksum, args->reqclass);2555 free(fh);2556 2557 if ( (!newconn) || (newconn->fd == -1) ) {2558 printf("getfile: requestconn: apparent error in accepttransfer\n");2559 if (newconn) aim_conn_kill(sess, &newconn);2560 return;2561 }2562 2563 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILELISTINGREQ, faimtest_getfile_listingreq, 0);2564 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILEREQ, faimtest_getfile_filereq, 0);2565 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEFILESEND, faimtest_getfile_filesend, 0);2566 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILECOMPLETE, faimtest_getfile_complete, 0);2567 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_GETFILEDISCONNECT, faimtest_getfile_disconnect, 0);2568 2569 /* printf("getfile connect succeeded, handlers added.\n"); */2570 2571 return;2572 }2573 2574 void directim_start(aim_session_t *sess, const char *sn)2575 {2576 aim_conn_t *newconn;2577 2578 /* printf("opening directim to %s\n", sn); */2579 newconn = aim_directim_initiate(sess, sn);2580 if (!newconn || (newconn->fd == -1)) {2581 /* printf("connection failed!\n"); */2582 if (newconn) aim_conn_kill(sess, &newconn);2583 } else {2584 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, faimtest_directim_initiate, 0);2585 }2586 return;2587 }2588 2589 void directim_requested(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args)2590 {2591 aim_conn_t *newconn;2592 2593 /* printf("OFT: DirectIM: request from %s (%s/%s/%s)\n", userinfo->sn, args->clientip, args->clientip2, args->verifiedip); */2594 2595 newconn = aim_directim_connect(sess, userinfo->sn, args->clientip, args->cookie);2596 if (!newconn || (newconn->fd == -1)) {2597 /* printf("icbm: imimage: could not connect\n"); */2598 if (newconn) aim_conn_kill(sess, &newconn);2599 } else {2600 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, directim_incoming, 0);2601 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, directim_typing, 0);2602 /* printf("OFT: DirectIM: connected to %s\n", userinfo->sn); */2603 aim_send_im_direct(sess, newconn, "goodday", 7, 0);2604 }2605 2180 } 2606 2181 -
buddylist.c
r2404c3a rf4d0975 3 3 static const char fileIdent[] = "$Id$"; 4 4 5 void owl_buddylist_init(owl_buddylist *b )5 void owl_buddylist_init(owl_buddylist *bl) 6 6 { 7 owl_list_create(&(b->buddies)); 8 owl_list_create(&(b->idletimes)); 9 /* owl_list_create(&(g->buddymsg_queue)); */ 7 owl_list_create(&(bl->buddies)); 8 } 9 10 /* add a (logged-in) AIM buddy to the buddy list 11 */ 12 void owl_buddylist_add_aim_buddy(owl_buddylist *bl, char *screenname) 13 { 14 owl_buddy *b; 15 b=owl_malloc(sizeof(owl_buddy)); 16 17 owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname); 18 owl_list_append_element(&(bl->buddies), b); 19 } 20 21 /* remove an AIM buddy from the buddy list 22 */ 23 int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, char *name) 24 { 25 int i, j; 26 owl_buddy *b; 27 28 j=owl_list_get_size(&(bl->buddies)); 29 for (i=0; i<j; i++) { 30 b=owl_list_get_element(&(bl->buddies), i); 31 if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) { 32 owl_list_remove_element(&(bl->buddies), i); 33 owl_buddy_free(b); 34 return(0); 35 } 36 } 37 return(1); 10 38 } 11 39 … … 14 42 * logged in. 15 43 */ 16 void owl_buddylist_oncoming(owl_buddylist *b , char *screenname)44 void owl_buddylist_oncoming(owl_buddylist *bl, char *screenname) 17 45 { 18 int *zero;19 46 owl_message *m; 20 47 21 if (!owl_buddylist_is_ buddy_loggedin(b, screenname)) {48 if (!owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) { 22 49 23 /* add the buddy */ 24 owl_list_append_element(&(b->buddies), owl_strdup(screenname)); 25 zero=owl_malloc(sizeof(int)); 26 *zero=0; 27 owl_list_append_element(&(b->idletimes), zero); 50 owl_buddylist_add_aim_buddy(bl, screenname); 28 51 29 /* do a request for idle time */30 owl_buddylist_request_idletime(b, screenname);31 32 52 /* are we ingoring login messages for a while? */ 33 53 if (!owl_timer_is_expired(owl_global_get_aim_login_timer(&g))) return; … … 48 68 * has logged out, and sending a message if they were logged in. 49 69 */ 50 void owl_buddylist_offgoing(owl_buddylist *b , char *screenname)70 void owl_buddylist_offgoing(owl_buddylist *bl, char *screenname) 51 71 { 52 int index;53 72 owl_message *m; 54 73 55 index=owl_buddylist_get_buddy_index(b, screenname); 56 if (index==-1) return; 57 58 owl_free(owl_list_get_element(&(b->buddies), index)); 59 owl_free(owl_list_get_element(&(b->idletimes), index)); 60 owl_list_remove_element(&(b->buddies), index); 61 owl_list_remove_element(&(b->idletimes), index); 62 74 owl_buddylist_remove_aim_buddy(bl, screenname); 75 63 76 m=owl_malloc(sizeof(owl_message)); 64 77 owl_message_create_aim(m, … … 71 84 } 72 85 73 /* send requests to the AIM server to retrieve info 74 * on all buddies. The AIM callback then fills in the 75 * values when the responses are received 86 /* return the number of logged in buddies */ 87 int owl_buddylist_get_size(owl_buddylist *bl) 88 { 89 return(owl_list_get_size(&(bl->buddies))); 90 } 91 92 /* return the buddy with index N. If out of range, return NULL 76 93 */ 77 void owl_buddylist_request_idletimes(owl_buddylist *b) 94 owl_buddy *owl_buddylist_get_buddy_n(owl_buddylist *bl, int index) 95 { 96 if (index<0) return(NULL); 97 if (index>(owl_buddylist_get_size(bl)-1)) return(NULL); 98 99 return(owl_list_get_element(&(bl->buddies), index)); 100 } 101 102 /* return the AIM buddy with screenname 'name'. If 103 * no such buddy is logged in, return NULL. 104 */ 105 owl_buddy *owl_buddylist_get_aim_buddy(owl_buddylist *bl, char *name) 78 106 { 79 107 int i, j; 108 owl_buddy *b; 80 109 81 j=owl_ buddylist_get_size(b);110 j=owl_list_get_size(&(bl->buddies)); 82 111 for (i=0; i<j; i++) { 83 owl_aim_get_idle(owl_buddylist_get_buddy(b, i)); 112 b=owl_list_get_element(&(bl->buddies), i); 113 if (!strcasecmp(name, owl_buddy_get_name(b))) return(b); 84 114 } 85 } 86 87 /* send request to the AIM server to retrieve info on one buddy. The 88 * AIM callback then fills in the values when the responses are 89 * received. The buddy must be logged in or no request will be 90 * performed. 91 */ 92 void owl_buddylist_request_idletime(owl_buddylist *b, char *screenname) 93 { 94 if (!owl_buddylist_is_buddy_loggedin(b, screenname)) return; 95 96 owl_aim_get_idle(screenname); 97 } 98 99 /* return the number of logged in buddies */ 100 int owl_buddylist_get_size(owl_buddylist *b) 101 { 102 return(owl_list_get_size(&(b->buddies))); 103 } 104 105 /* get buddy number 'n' */ 106 char *owl_buddylist_get_buddy(owl_buddylist *b, int n) 107 { 108 if (n > owl_buddylist_get_size(b)-1) return(""); 109 return(owl_list_get_element(&(b->buddies), n)); 110 } 111 112 /* Return the index of the buddy 'screename' or -1 113 * if the buddy is not logged in. 114 */ 115 int owl_buddylist_get_buddy_index(owl_buddylist *b, char *screenname) 116 { 117 int i, j; 118 119 j=owl_list_get_size(&(b->buddies)); 120 for (i=0; i<j; i++) { 121 if (!strcasecmp(owl_list_get_element(&(b->buddies), i), screenname)) { 122 return(i); 123 } 124 } 125 return(-1); 115 return(NULL); 126 116 } 127 117 … … 129 119 * otherwise return 0 130 120 */ 131 int owl_buddylist_is_ buddy_loggedin(owl_buddylist *b, char *screenname)121 int owl_buddylist_is_aim_buddy_loggedin(owl_buddylist *bl, char *screenname) 132 122 { 133 if (owl_buddylist_get_buddy_index(b, screenname)!=-1) return(1); 134 return(0); 135 } 123 owl_buddy *b; 136 124 137 /* get the idle time for buddy number 'n' */ 138 int owl_buddylist_get_idletime(owl_buddylist *b, int n) 139 { 140 int *foo; 141 142 foo=owl_list_get_element(&(b->idletimes), n); 143 return(*foo); 144 } 145 146 /* Set the idle time for user 'screenname'. If the given screenname 147 * is not on the buddy list do nothing. If there is a queued request 148 * for this screename, remove it from the queue. 149 */ 150 void owl_buddylist_set_idletime(owl_buddylist *b, char *screenname, int minutes) 151 { 152 int index, *idle; 153 154 index=owl_buddylist_get_buddy_index(b, screenname); 155 if (index==-1) return; 156 157 owl_free(owl_list_get_element(&(b->idletimes), index)); 158 idle=owl_malloc(sizeof(int)); 159 *idle=minutes; 160 owl_list_replace_element(&(b->idletimes), index, idle); 125 b=owl_buddylist_get_aim_buddy(bl, screenname); 126 if (b==NULL) return(0); 127 return(1); 161 128 } 162 129 163 130 /* remove all buddies from the list */ 164 void owl_buddylist_clear(owl_buddylist *b) { 165 owl_list_free_all(&(b->buddies), owl_free); 166 owl_list_free_all(&(b->idletimes), owl_free); 167 owl_list_create(&(b->buddies)); 168 owl_list_create(&(b->idletimes)); 131 void owl_buddylist_clear(owl_buddylist *bl) 132 { 133 owl_list_free_all(&(bl->buddies), (void(*)(void*))owl_buddy_free); 134 owl_list_create(&(bl->buddies)); 169 135 } 136 137 void owl_buddylist_free(owl_buddylist *bl) 138 { 139 owl_list_free_all(&(bl->buddies), (void(*)(void*))owl_buddy_free); 140 } -
functions.c
rf933403 rf4d0975 2875 2875 int i, j, idle; 2876 2876 owl_fmtext fm; 2877 owl_buddylist *b; 2877 owl_buddylist *bl; 2878 owl_buddy *b; 2878 2879 char *foo, *timestr; 2879 2880 #ifdef HAVE_LIBZEPHYR … … 2887 2888 2888 2889 if (aim && owl_global_is_aimloggedin(&g)) { 2889 b =owl_global_get_buddylist(&g);2890 bl=owl_global_get_buddylist(&g); 2890 2891 2891 2892 owl_fmtext_append_bold(&fm, "AIM users logged in:\n"); 2892 j=owl_buddylist_get_size(b); 2893 /* we're assuming AIM for now */ 2894 j=owl_buddylist_get_size(bl); 2893 2895 for (i=0; i<j; i++) { 2894 idle=owl_buddylist_get_idletime(b, i); 2896 b=owl_buddylist_get_buddy_n(bl, i); 2897 idle=owl_buddy_get_idle_time(b); 2895 2898 if (idle!=0) { 2896 2899 timestr=owl_util_minutes_to_timestr(idle); … … 2899 2902 } 2900 2903 foo=owl_sprintf(" %-15.15s %-12.12s\n", 2901 owl_buddy list_get_buddy(b, i),2904 owl_buddy_get_name(b), 2902 2905 timestr); 2903 2906 owl_fmtext_append_normal(&fm, foo); -
message.c
rf1e629d rf4d0975 75 75 } 76 76 } 77 owl_function_debugmsg("No attribute %s found", attrname); 77 78 /* 79 owl_function_debugmsg("No attribute %s found for message %i", 80 attrname, 81 owl_message_get_id(m)); 82 */ 78 83 return(NULL); 79 84 } … … 848 853 owl_fmtext_free(&(m->fmtext)); 849 854 } 850 851 -
owl.c
r12582d3 rf4d0975 329 329 if (owl_global_is_aimloggedin(&g)) { 330 330 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) { 331 owl_buddylist_request_idletimes(owl_global_get_buddylist(&g));331 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */ 332 332 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g)); 333 333 } -
owl.h
r2404c3a rf4d0975 21 21 static const char owl_h_fileIdent[] = "$Id$"; 22 22 23 #define OWL_VERSION 2.0.8-pre- 424 #define OWL_VERSION_STRING "2.0.8-pre- 4"23 #define OWL_VERSION 2.0.8-pre-5 24 #define OWL_VERSION_STRING "2.0.8-pre-5" 25 25 26 26 #define OWL_DEBUG 0 … … 47 47 #define OWL_EDITWIN_STYLE_MULTILINE 0 48 48 #define OWL_EDITWIN_STYLE_ONELINE 1 49 50 #define OWL_PROTOCOL_ZEPHYR 0 51 #define OWL_PROTOCOL_AIM 1 52 #define OWL_PROTOCOL_JABBER 2 53 #define OWL_PROTOCOL_ICQ 3 54 #define OWL_PROTOCOL_YAHOO 4 55 #define OWL_PROTOCOL_MSN 5 49 56 50 57 #define OWL_MESSAGE_TYPE_ADMIN 0 … … 384 391 } owl_keyhandler; 385 392 393 typedef struct _owl_buddy { 394 int proto; 395 char *name; 396 int isidle; 397 int idlesince; 398 } owl_buddy; 399 386 400 typedef struct _owl_buddylist { 387 401 owl_list buddies; 388 owl_list idletimes;389 402 } owl_buddylist; 390 403
Note: See TracChangeset
for help on using the changeset viewer.