Mercurial > pidgin
comparison libpurple/protocols/msn/slplink.c @ 30802:0f26d510af1b
SlpLink must not use MsnMessages but SlpMessageParts, so migrate code to use SlpMessagePart API.
author | masca@cpw.pidgin.im |
---|---|
date | Wed, 16 Jun 2010 22:17:28 +0000 |
parents | 22f26c372797 |
children | dfada77da5cb |
comparison
equal
deleted
inserted
replaced
30801:fd8abea40a0d | 30802:0f26d510af1b |
---|---|
25 #include "internal.h" | 25 #include "internal.h" |
26 #include "debug.h" | 26 #include "debug.h" |
27 | 27 |
28 #include "msn.h" | 28 #include "msn.h" |
29 #include "slplink.h" | 29 #include "slplink.h" |
30 #include "slpmsg_part.h" | |
30 | 31 |
31 #include "sbconn.h" | 32 #include "sbconn.h" |
32 #include "switchboard.h" | 33 #include "switchboard.h" |
33 #include "slp.h" | 34 #include "slp.h" |
34 #include "p2p.h" | 35 #include "p2p.h" |
264 | 265 |
265 return NULL; | 266 return NULL; |
266 } | 267 } |
267 | 268 |
268 void | 269 void |
270 msn_slplink_send_part(MsnSlpLink *slplink, MsnSlpMessagePart *part) | |
271 { | |
272 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED) | |
273 { | |
274 msn_dc_enqueue_part(slplink->dc, part); | |
275 } | |
276 else | |
277 { | |
278 msn_sbconn_send_part(slplink, part); | |
279 } | |
280 } | |
281 void | |
269 msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg) | 282 msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg) |
270 { | 283 { |
271 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED) | 284 if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED) |
272 { | 285 { |
273 msn_dc_enqueue_msg(slplink->dc, msg); | 286 msn_dc_enqueue_msg(slplink->dc, msg); |
279 } | 292 } |
280 | 293 |
281 void | 294 void |
282 msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) | 295 msn_slplink_send_msgpart(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) |
283 { | 296 { |
284 MsnMessage *msg; | 297 MsnSlpMessagePart *part; |
285 long long real_size; | 298 long long real_size; |
286 size_t len = 0; | 299 size_t len = 0; |
287 | 300 |
288 /* Maybe we will want to create a new msg for this slpmsg instead of | 301 /* Maybe we will want to create a new msg for this slpmsg instead of |
289 * reusing the same one all the time. */ | 302 * reusing the same one all the time. */ |
290 msg = slpmsg->msg; | 303 part = msn_slpmsgpart_new(slpmsg->header, slpmsg->footer); |
291 | 304 |
292 real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size; | 305 real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size; |
293 | 306 |
294 if (slpmsg->offset < real_size) | 307 if (slpmsg->offset < real_size) |
295 { | 308 { |
296 if (slpmsg->slpcall && slpmsg->slpcall->xfer && purple_xfer_get_type(slpmsg->slpcall->xfer) == PURPLE_XFER_SEND && | 309 if (slpmsg->slpcall && slpmsg->slpcall->xfer && purple_xfer_get_type(slpmsg->slpcall->xfer) == PURPLE_XFER_SEND && |
297 purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED) | 310 purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED) |
298 { | 311 { |
299 len = MIN(MSN_SBCONN_MAX_SIZE, slpmsg->slpcall->u.outgoing.len); | 312 len = MIN(MSN_SBCONN_MAX_SIZE, slpmsg->slpcall->u.outgoing.len); |
300 msn_message_set_bin_data(msg, slpmsg->slpcall->u.outgoing.data, len); | 313 msn_slpmsgpart_set_bin_data(part, slpmsg->slpcall->u.outgoing.data, len); |
301 } | 314 } |
302 else | 315 else |
303 { | 316 { |
304 len = slpmsg->size - slpmsg->offset; | 317 len = slpmsg->size - slpmsg->offset; |
305 | 318 |
306 if (len > MSN_SBCONN_MAX_SIZE) | 319 if (len > MSN_SBCONN_MAX_SIZE) |
307 len = MSN_SBCONN_MAX_SIZE; | 320 len = MSN_SBCONN_MAX_SIZE; |
308 | 321 |
309 msn_message_set_bin_data(msg, slpmsg->buffer + slpmsg->offset, len); | 322 msn_slpmsgpart_set_bin_data(part, slpmsg->slpcall->u.outgoing.data, len); |
310 } | 323 } |
311 | 324 |
312 slpmsg->header->offset = slpmsg->offset; | 325 slpmsg->header->offset = slpmsg->offset; |
313 slpmsg->header->length = len; | 326 slpmsg->header->length = len; |
314 } | 327 } |
315 | 328 |
329 #if 0 | |
330 /* TODO: port this function to SlpMessageParts */ | |
316 if (purple_debug_is_verbose()) | 331 if (purple_debug_is_verbose()) |
317 msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body); | 332 msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body); |
333 #endif | |
318 | 334 |
319 #ifdef MSN_DEBUG_SLP_FILES | 335 #ifdef MSN_DEBUG_SLP_FILES |
320 debug_msg_to_file(msg, TRUE); | 336 debug_msg_to_file(msg, TRUE); |
321 #endif | 337 #endif |
322 | 338 |
323 slpmsg->msgs = | 339 slpmsg->parts = g_list_append(slpmsg->parts, part); |
324 g_list_append(slpmsg->msgs, msn_message_ref(msg)); | 340 msn_slplink_send_part(slplink, part); |
325 msn_slplink_send_msg(slplink, msg); | |
326 | 341 |
327 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || | 342 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || |
328 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || | 343 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || |
329 slpmsg->flags == P2P_FILE_DATA) && | 344 slpmsg->flags == P2P_FILE_DATA) && |
330 (slpmsg->slpcall != NULL)) | 345 (slpmsg->slpcall != NULL)) |