comparison src/protocols/oscar/txqueue.c @ 13239:f260d319bbbc

[gaim-migrate @ 15605] Renaming a bunch of structs and typedefs to use the same naming scheme as the rest of Gaim committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Feb 2006 16:02:05 +0000
parents f2431a7e33aa
children 87a7c3077c19
comparison
equal deleted inserted replaced
13238:1e855032d7bc 13239:f260d319bbbc
44 * 44 *
45 * framing = AIM_FRAMETYPE_OFT/FLAP 45 * framing = AIM_FRAMETYPE_OFT/FLAP
46 * chan = channel for FLAP, hdrtype for OFT 46 * chan = channel for FLAP, hdrtype for OFT
47 * 47 *
48 */ 48 */
49 faim_internal aim_frame_t *aim_tx_new(aim_session_t *sess, aim_conn_t *conn, guint8 framing, guint16 chan, int datalen) 49 faim_internal FlapFrame *aim_tx_new(OscarSession *sess, OscarConnection *conn, guint8 framing, guint16 chan, int datalen)
50 { 50 {
51 aim_frame_t *fr; 51 FlapFrame *fr;
52 52
53 if (!sess || !conn) { 53 if (!sess || !conn) {
54 gaim_debug_misc("oscar", "aim_tx_new: No session or no connection specified!\n"); 54 gaim_debug_misc("oscar", "aim_tx_new: No session or no connection specified!\n");
55 return NULL; 55 return NULL;
56 } 56 }
66 gaim_debug_misc("oscar", "aim_tx_new: attempted to allocate inappropriate frame type for FLAP connection\n"); 66 gaim_debug_misc("oscar", "aim_tx_new: attempted to allocate inappropriate frame type for FLAP connection\n");
67 return NULL; 67 return NULL;
68 } 68 }
69 } 69 }
70 70
71 if (!(fr = (aim_frame_t *)calloc(1, sizeof(aim_frame_t)))) 71 if (!(fr = (FlapFrame *)calloc(1, sizeof(FlapFrame))))
72 return NULL; 72 return NULL;
73 73
74 fr->conn = conn; 74 fr->conn = conn;
75 fr->hdrtype = framing; 75 fr->hdrtype = framing;
76 if (fr->hdrtype == AIM_FRAMETYPE_FLAP) 76 if (fr->hdrtype == AIM_FRAMETYPE_FLAP)
98 * This increments the tx command count, and returns the seqnum 98 * This increments the tx command count, and returns the seqnum
99 * that should be stamped on the next FLAP packet sent. This is 99 * that should be stamped on the next FLAP packet sent. This is
100 * normally called during the final step of packet preparation 100 * normally called during the final step of packet preparation
101 * before enqueuement (in aim_tx_enqueue()). 101 * before enqueuement (in aim_tx_enqueue()).
102 */ 102 */
103 static flap_seqnum_t aim_get_next_txseqnum(aim_conn_t *conn) 103 static flap_seqnum_t aim_get_next_txseqnum(OscarConnection *conn)
104 { 104 {
105 flap_seqnum_t ret; 105 flap_seqnum_t ret;
106 106
107 ret = ++conn->seqnum; 107 ret = ++conn->seqnum;
108 108
119 * 119 *
120 * Note that this is only used when doing queue-based transmitting; 120 * Note that this is only used when doing queue-based transmitting;
121 * that is, when sess->tx_enqueue is set to &aim_tx_enqueue__queuebased. 121 * that is, when sess->tx_enqueue is set to &aim_tx_enqueue__queuebased.
122 * 122 *
123 */ 123 */
124 static int aim_tx_enqueue__queuebased(aim_session_t *sess, aim_frame_t *fr) 124 static int aim_tx_enqueue__queuebased(OscarSession *sess, FlapFrame *fr)
125 { 125 {
126 126
127 if (!fr->conn) { 127 if (!fr->conn) {
128 gaim_debug_warning("oscar", "aim_tx_enqueue: enqueueing packet with no connecetion\n"); 128 gaim_debug_warning("oscar", "aim_tx_enqueue: enqueueing packet with no connecetion\n");
129 fr->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); 129 fr->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
138 138
139 /* see overhead note in aim_rxqueue counterpart */ 139 /* see overhead note in aim_rxqueue counterpart */
140 if (!sess->queue_outgoing) 140 if (!sess->queue_outgoing)
141 sess->queue_outgoing = fr; 141 sess->queue_outgoing = fr;
142 else { 142 else {
143 aim_frame_t *cur; 143 FlapFrame *cur;
144 for (cur = sess->queue_outgoing; cur->next; cur = cur->next); 144 for (cur = sess->queue_outgoing; cur->next; cur = cur->next);
145 cur->next = fr; 145 cur->next = fr;
146 } 146 }
147 147
148 return 0; 148 return 0;
155 * Basically the same as its __queuebased couterpart, however 155 * Basically the same as its __queuebased couterpart, however
156 * instead of doing a list append, it just calls aim_tx_sendframe() 156 * instead of doing a list append, it just calls aim_tx_sendframe()
157 * right here. 157 * right here.
158 * 158 *
159 */ 159 */
160 static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr) 160 static int aim_tx_enqueue__immediate(OscarSession *sess, FlapFrame *fr)
161 { 161 {
162 int ret; 162 int ret;
163 163
164 if (!fr->conn) { 164 if (!fr->conn) {
165 gaim_debug_error("oscar", "aim_tx_enqueue: packet has no connection\n"); 165 gaim_debug_error("oscar", "aim_tx_enqueue: packet has no connection\n");
177 aim_frame_destroy(fr); 177 aim_frame_destroy(fr);
178 178
179 return ret; 179 return ret;
180 } 180 }
181 181
182 faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)) 182 faim_export int aim_tx_setenqueue(OscarSession *sess, int what, int (*func)(OscarSession *, FlapFrame *))
183 { 183 {
184 184
185 if (what == AIM_TX_QUEUED) 185 if (what == AIM_TX_QUEUED)
186 sess->tx_enqueue = &aim_tx_enqueue__queuebased; 186 sess->tx_enqueue = &aim_tx_enqueue__queuebased;
187 else if (what == AIM_TX_IMMEDIATE) 187 else if (what == AIM_TX_IMMEDIATE)
194 return -EINVAL; /* unknown action */ 194 return -EINVAL; /* unknown action */
195 195
196 return 0; 196 return 0;
197 } 197 }
198 198
199 faim_internal int aim_tx_enqueue(aim_session_t *sess, aim_frame_t *fr) 199 faim_internal int aim_tx_enqueue(OscarSession *sess, FlapFrame *fr)
200 { 200 {
201 201
202 /* 202 /*
203 * If we want to send on a connection that is in progress, we have to force 203 * If we want to send on a connection that is in progress, we have to force
204 * them to use the queue based version. Otherwise, use whatever they 204 * them to use the queue based version. Otherwise, use whatever they
231 } 231 }
232 232
233 return cur; 233 return cur;
234 } 234 }
235 235
236 faim_internal int aim_bstream_send(aim_bstream_t *bs, aim_conn_t *conn, size_t count) 236 faim_internal int aim_bstream_send(ByteStream *bs, OscarConnection *conn, size_t count)
237 { 237 {
238 int wrote = 0; 238 int wrote = 0;
239 239
240 if (!bs || !conn) 240 if (!bs || !conn)
241 return -EINVAL; 241 return -EINVAL;
277 bs->offset += wrote; 277 bs->offset += wrote;
278 278
279 return wrote; 279 return wrote;
280 } 280 }
281 281
282 static int sendframe_flap(aim_session_t *sess, aim_frame_t *fr) 282 static int sendframe_flap(OscarSession *sess, FlapFrame *fr)
283 { 283 {
284 aim_bstream_t bs; 284 ByteStream bs;
285 guint8 *bs_raw; 285 guint8 *bs_raw;
286 int payloadlen, err = 0, bslen; 286 int payloadlen, err = 0, bslen;
287 287
288 payloadlen = aim_bstream_curpos(&fr->data); 288 payloadlen = aim_bstream_curpos(&fr->data);
289 289
313 fr->conn->lastactivity = time(NULL); 313 fr->conn->lastactivity = time(NULL);
314 314
315 return err; 315 return err;
316 } 316 }
317 317
318 static int sendframe_rendezvous(aim_session_t *sess, aim_frame_t *fr) 318 static int sendframe_rendezvous(OscarSession *sess, FlapFrame *fr)
319 { 319 {
320 aim_bstream_t bs; 320 ByteStream bs;
321 guint8 *bs_raw; 321 guint8 *bs_raw;
322 int payloadlen, err = 0, bslen; 322 int payloadlen, err = 0, bslen;
323 323
324 payloadlen = aim_bstream_curpos(&fr->data); 324 payloadlen = aim_bstream_curpos(&fr->data);
325 325
348 fr->conn->lastactivity = time(NULL); 348 fr->conn->lastactivity = time(NULL);
349 349
350 return err; 350 return err;
351 } 351 }
352 352
353 faim_internal int aim_tx_sendframe(aim_session_t *sess, aim_frame_t *fr) 353 faim_internal int aim_tx_sendframe(OscarSession *sess, FlapFrame *fr)
354 { 354 {
355 if (fr->hdrtype == AIM_FRAMETYPE_FLAP) 355 if (fr->hdrtype == AIM_FRAMETYPE_FLAP)
356 return sendframe_flap(sess, fr); 356 return sendframe_flap(sess, fr);
357 else if (fr->hdrtype == AIM_FRAMETYPE_OFT) 357 else if (fr->hdrtype == AIM_FRAMETYPE_OFT)
358 return sendframe_rendezvous(sess, fr); 358 return sendframe_rendezvous(sess, fr);
359 359
360 return -1; 360 return -1;
361 } 361 }
362 362
363 faim_export int aim_tx_flushqueue(aim_session_t *sess) 363 faim_export int aim_tx_flushqueue(OscarSession *sess)
364 { 364 {
365 aim_frame_t *cur; 365 FlapFrame *cur;
366 366
367 for (cur = sess->queue_outgoing; cur; cur = cur->next) { 367 for (cur = sess->queue_outgoing; cur; cur = cur->next) {
368 368
369 if (cur->handled) 369 if (cur->handled)
370 continue; /* already been sent */ 370 continue; /* already been sent */
400 /* 400 /*
401 * This is responsible for removing sent commands from the transmit 401 * This is responsible for removing sent commands from the transmit
402 * queue. This is not a required operation, but it of course helps 402 * queue. This is not a required operation, but it of course helps
403 * reduce memory footprint at run time! 403 * reduce memory footprint at run time!
404 */ 404 */
405 faim_export void aim_tx_purgequeue(aim_session_t *sess) 405 faim_export void aim_tx_purgequeue(OscarSession *sess)
406 { 406 {
407 aim_frame_t *cur, **prev; 407 FlapFrame *cur, **prev;
408 408
409 for (prev = &sess->queue_outgoing; (cur = *prev); ) { 409 for (prev = &sess->queue_outgoing; (cur = *prev); ) {
410 if (cur->handled) { 410 if (cur->handled) {
411 *prev = cur->next; 411 *prev = cur->next;
412 aim_frame_destroy(cur); 412 aim_frame_destroy(cur);
423 * warning. 423 * warning.
424 * 424 *
425 * @param sess A session. 425 * @param sess A session.
426 * @param conn Connection that's dying. 426 * @param conn Connection that's dying.
427 */ 427 */
428 faim_internal void aim_tx_cleanqueue(aim_session_t *sess, aim_conn_t *conn) 428 faim_internal void aim_tx_cleanqueue(OscarSession *sess, OscarConnection *conn)
429 { 429 {
430 aim_frame_t *cur; 430 FlapFrame *cur;
431 431
432 for (cur = sess->queue_outgoing; cur; cur = cur->next) { 432 for (cur = sess->queue_outgoing; cur; cur = cur->next) {
433 if (cur->conn == conn) 433 if (cur->conn == conn)
434 cur->handled = 1; 434 cur->handled = 1;
435 } 435 }