Mercurial > pidgin
comparison src/protocols/oscar/txqueue.c @ 13262:b08f8f3c9197
[gaim-migrate @ 15628]
More cleanup. It's dinner time!
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 12 Feb 2006 23:59:30 +0000 |
| parents | 7ead7b8aea63 |
| children |
comparison
equal
deleted
inserted
replaced
| 13261:3b04ab4d96db | 13262:b08f8f3c9197 |
|---|---|
| 79 else | 79 else |
| 80 gaim_debug_misc("oscar", "tx_new: unknown framing\n"); | 80 gaim_debug_misc("oscar", "tx_new: unknown framing\n"); |
| 81 | 81 |
| 82 if (datalen > 0) { | 82 if (datalen > 0) { |
| 83 guint8 *data; | 83 guint8 *data; |
| 84 | 84 data = malloc(datalen); |
| 85 if (!(data = (unsigned char *)malloc(datalen))) { | |
| 86 aim_frame_destroy(fr); | |
| 87 return NULL; | |
| 88 } | |
| 89 | |
| 90 aim_bstream_init(&fr->data, data, datalen); | 85 aim_bstream_init(&fr->data, data, datalen); |
| 91 } | 86 } |
| 92 | 87 |
| 93 return fr; | 88 return fr; |
| 94 } | 89 } |
| 169 guint8 *bs_raw; | 164 guint8 *bs_raw; |
| 170 int payloadlen, err = 0, bslen; | 165 int payloadlen, err = 0, bslen; |
| 171 | 166 |
| 172 payloadlen = aim_bstream_curpos(&fr->data); | 167 payloadlen = aim_bstream_curpos(&fr->data); |
| 173 | 168 |
| 174 if (!(bs_raw = malloc(6 + payloadlen))) | 169 bs_raw = malloc(6 + payloadlen); |
| 175 return -ENOMEM; | |
| 176 | 170 |
| 177 aim_bstream_init(&bs, bs_raw, 6 + payloadlen); | 171 aim_bstream_init(&bs, bs_raw, 6 + payloadlen); |
| 178 | 172 |
| 179 /* FLAP header */ | 173 /* FLAP header */ |
| 180 aimbs_put8(&bs, 0x2a); | 174 aimbs_put8(&bs, 0x2a); |
| 206 guint8 *bs_raw; | 200 guint8 *bs_raw; |
| 207 int payloadlen, err = 0, bslen; | 201 int payloadlen, err = 0, bslen; |
| 208 | 202 |
| 209 payloadlen = aim_bstream_curpos(&fr->data); | 203 payloadlen = aim_bstream_curpos(&fr->data); |
| 210 | 204 |
| 211 if (!(bs_raw = malloc(8 + payloadlen))) | 205 bs_raw = malloc(8 + payloadlen); |
| 212 return -ENOMEM; | |
| 213 | 206 |
| 214 aim_bstream_init(&bs, bs_raw, 8 + payloadlen); | 207 aim_bstream_init(&bs, bs_raw, 8 + payloadlen); |
| 215 | 208 |
| 216 /* Rendezvous header */ | 209 /* Rendezvous header */ |
| 217 aimbs_putraw(&bs, fr->hdr.rend.magic, 4); | 210 aimbs_putraw(&bs, fr->hdr.rend.magic, 4); |
| 244 return sendframe_rendezvous(sess, fr); | 237 return sendframe_rendezvous(sess, fr); |
| 245 | 238 |
| 246 return -1; | 239 return -1; |
| 247 } | 240 } |
| 248 | 241 |
| 249 int | |
| 250 aim_tx_flushqueue(OscarSession *sess) | |
| 251 { | |
| 252 FlapFrame *cur; | |
| 253 | |
| 254 for (cur = sess->queue_outgoing; cur; cur = cur->next) { | |
| 255 | |
| 256 if (cur->handled) | |
| 257 continue; /* already been sent */ | |
| 258 | |
| 259 if (cur->conn && (cur->conn->status & AIM_CONN_STATUS_INPROGRESS)) | |
| 260 continue; | |
| 261 | |
| 262 /* XXX this should call the custom "queuing" function!! */ | |
| 263 aim_tx_sendframe(sess, cur); | |
| 264 } | |
| 265 | |
| 266 /* purge sent commands from queue */ | |
| 267 aim_tx_purgequeue(sess); | |
| 268 | |
| 269 return 0; | |
| 270 } | |
| 271 | |
| 272 /* | 242 /* |
| 273 * This is responsible for removing sent commands from the transmit | 243 * This is responsible for removing sent commands from the transmit |
| 274 * queue. This is not a required operation, but it of course helps | 244 * queue. This is not a required operation, but it of course helps |
| 275 * reduce memory footprint at run time! | 245 * reduce memory footprint at run time! |
| 276 */ | 246 */ |
| 277 void | 247 static void |
| 278 aim_tx_purgequeue(OscarSession *sess) | 248 aim_tx_purgequeue(OscarSession *sess) |
| 279 { | 249 { |
| 280 FlapFrame *cur, **prev; | 250 FlapFrame *cur, **prev; |
| 281 | 251 |
| 282 for (prev = &sess->queue_outgoing; (cur = *prev); ) { | 252 for (prev = &sess->queue_outgoing; (cur = *prev); ) { |
| 286 } else | 256 } else |
| 287 prev = &cur->next; | 257 prev = &cur->next; |
| 288 } | 258 } |
| 289 | 259 |
| 290 return; | 260 return; |
| 261 } | |
| 262 | |
| 263 int | |
| 264 aim_tx_flushqueue(OscarSession *sess) | |
| 265 { | |
| 266 FlapFrame *cur; | |
| 267 | |
| 268 for (cur = sess->queue_outgoing; cur; cur = cur->next) { | |
| 269 | |
| 270 if (cur->handled) | |
| 271 continue; /* already been sent */ | |
| 272 | |
| 273 if (cur->conn && (cur->conn->status & AIM_CONN_STATUS_INPROGRESS)) | |
| 274 continue; | |
| 275 | |
| 276 /* XXX this should call the custom "queuing" function!! */ | |
| 277 aim_tx_sendframe(sess, cur); | |
| 278 } | |
| 279 | |
| 280 /* purge sent commands from queue */ | |
| 281 aim_tx_purgequeue(sess); | |
| 282 | |
| 283 return 0; | |
| 291 } | 284 } |
| 292 | 285 |
| 293 /** | 286 /** |
| 294 * Get rid of packets waiting for tx on a dying conn. For now this | 287 * Get rid of packets waiting for tx on a dying conn. For now this |
| 295 * simply marks all packets as sent and lets them disappear without | 288 * simply marks all packets as sent and lets them disappear without |
