Changeset 862371b for libfaim/txqueue.c
- Timestamp:
- Jun 29, 2003, 1:47:04 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:
- e016fc2
- Parents:
- 03ad7b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/txqueue.c
r5e53c4a r862371b 1 1 /* 2 * aim_txqueue.c2 * txqueue.c 3 3 * 4 4 * Herein lies all the mangement routines for the transmit (Tx) queue. … … 11 11 #ifndef _WIN32 12 12 #include <sys/socket.h> 13 #else 14 #include "win32dep.h" 13 15 #endif 14 16 … … 25 27 * 26 28 */ 27 faim_internal aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, fu8_t framing, fu 8_t chan, int datalen)29 faim_internal aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, fu8_t framing, fu16_t chan, int datalen) 28 30 { 29 31 aim_frame_t *fr; … … 62 64 } else if (fr->hdrtype == AIM_FRAMETYPE_OFT) { 63 65 64 fr->hdr.oft.type = chan; 65 fr->hdr.oft.hdr2len = 0; /* this will get setup by caller */ 66 fr->hdr.rend.type = chan; 66 67 67 68 } else … … 231 232 { 232 233 int wrote = 0; 233 234 234 if (!bs || !conn || (count < 0)) 235 235 return -EINVAL; … … 238 238 count = aim_bstream_empty(bs); /* truncate to remaining space */ 239 239 240 if (count) 241 wrote = aim_send(conn->fd, bs->data + bs->offset, count); 240 if (count) { 241 if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) && 242 (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { 243 /* I strongly suspect that this is a horrible thing to do 244 * and I feel really guilty doing it. */ 245 const char *sn = aim_directim_getsn(conn); 246 aim_rxcallback_t userfunc; 247 while (count - wrote > 1024) { 248 wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, 1024); 249 if ((userfunc=aim_callhandler(conn->sessv, conn, 250 AIM_CB_FAM_SPECIAL, 251 AIM_CB_SPECIAL_IMAGETRANSFER))) 252 userfunc(conn->sessv, NULL, sn, 253 count-wrote>1024 ? ((double)wrote / count) : 1); 254 } 255 } 256 if (count - wrote) { 257 wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, count - wrote); 258 } 259 260 } 261 242 262 243 263 if (((aim_session_t *)conn->sessv)->debug >= 2) { … … 285 305 obslen = aim_bstream_curpos(&obs); 286 306 aim_bstream_rewind(&obs); 287 288 307 if (aim_bstream_send(&obs, fr->conn, obslen) != obslen) 289 308 err = -errno; … … 297 316 } 298 317 299 static int sendframe_oft(aim_session_t *sess, aim_frame_t *fr) 300 { 301 aim_bstream_t hbs; 302 fu8_t *hbs_raw; 303 int hbslen; 318 static int sendframe_rendezvous(aim_session_t *sess, aim_frame_t *fr) 319 { 320 aim_bstream_t bs; 321 fu8_t *bs_raw; 304 322 int err = 0; 305 306 hbslen = 8 + fr->hdr.oft.hdr2len; 307 308 if (!(hbs_raw = malloc(hbslen))) 323 int totlen = 8 + aim_bstream_curpos(&fr->data); 324 325 if (!(bs_raw = malloc(totlen))) 309 326 return -1; 310 327 311 aim_bstream_init(&hbs, hbs_raw, hbslen); 312 313 aimbs_putraw(&hbs, fr->hdr.oft.magic, 4); 314 aimbs_put16(&hbs, fr->hdr.oft.hdr2len + 8); 315 aimbs_put16(&hbs, fr->hdr.oft.type); 316 aimbs_putraw(&hbs, fr->hdr.oft.hdr2, fr->hdr.oft.hdr2len); 317 318 aim_bstream_rewind(&hbs); 319 320 if (aim_bstream_send(&hbs, fr->conn, hbslen) != hbslen) { 321 328 aim_bstream_init(&bs, bs_raw, totlen); 329 330 aimbs_putraw(&bs, fr->hdr.rend.magic, 4); 331 aimbs_put16(&bs, 8 + fr->hdr.rend.hdrlen); 332 aimbs_put16(&bs, fr->hdr.rend.type); 333 334 /* payload */ 335 aim_bstream_rewind(&fr->data); 336 aimbs_putbs(&bs, &fr->data, totlen - 8); 337 338 aim_bstream_rewind(&bs); 339 340 if (aim_bstream_send(&bs, fr->conn, totlen) != totlen) 322 341 err = -errno; 323 324 } else if (aim_bstream_curpos(&fr->data)) { 325 int len; 326 327 len = aim_bstream_curpos(&fr->data); 328 aim_bstream_rewind(&fr->data); 329 330 if (aim_bstream_send(&fr->data, fr->conn, len) != len) 331 err = -errno; 332 } 333 334 free(hbs_raw); /* XXX aim_bstream_free */ 342 343 free(bs_raw); /* XXX aim_bstream_free */ 335 344 336 345 fr->handled = 1; 337 346 fr->conn->lastactivity = time(NULL); 338 339 347 340 348 return err; … … 346 354 return sendframe_flap(sess, fr); 347 355 else if (fr->hdrtype == AIM_FRAMETYPE_OFT) 348 return sendframe_ oft(sess, fr);356 return sendframe_rendezvous(sess, fr); 349 357 return -1; 350 358 } … … 422 430 * 423 431 */ 424 faim_ exportvoid aim_tx_cleanqueue(aim_session_t *sess, aim_conn_t *conn)432 faim_internal void aim_tx_cleanqueue(aim_session_t *sess, aim_conn_t *conn) 425 433 { 426 434 aim_frame_t *cur; … … 433 441 return; 434 442 } 435 436
Note: See TracChangeset
for help on using the changeset viewer.