Mercurial > pidgin
comparison libpurple/protocols/msn/slplink.c @ 30858:2d00d29a45fd
Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
author | masca@cpw.pidgin.im |
---|---|
date | Thu, 29 Jul 2010 00:12:54 +0000 |
parents | 1ded0bc5c911 |
children | 2c2ca0aed68e |
comparison
equal
deleted
inserted
replaced
30857:1ded0bc5c911 | 30858:2d00d29a45fd |
---|---|
567 if (!slpcall->wait_for_socket && slpcall->wasted) | 567 if (!slpcall->wait_for_socket && slpcall->wasted) |
568 msn_slpcall_destroy(slpcall); | 568 msn_slpcall_destroy(slpcall); |
569 } | 569 } |
570 | 570 |
571 void | 571 void |
572 msn_slplink_process_msg(MsnSlpLink *slplink, MsnP2PHeader *header, const char *data, gsize len) | 572 msn_slplink_process_msg(MsnSlpLink *slplink, MsnSlpMessagePart *part) |
573 { | 573 { |
574 MsnSlpMessage *slpmsg; | 574 MsnSlpMessage *slpmsg; |
575 MsnP2PHeader *header; | |
575 guint64 offset; | 576 guint64 offset; |
577 | |
578 header = part->header; | |
576 | 579 |
577 if (header->total_size < header->length) | 580 if (header->total_size < header->length) |
578 { | 581 { |
579 /* We seem to have received a bad header */ | 582 /* We seem to have received a bad header */ |
580 purple_debug_warning("msn", "Total size listed in SLP binary header " | 583 purple_debug_warning("msn", "Total size listed in SLP binary header " |
598 } | 601 } |
599 | 602 |
600 if (slpmsg->ft) | 603 if (slpmsg->ft) |
601 { | 604 { |
602 slpmsg->slpcall->u.incoming_data = | 605 slpmsg->slpcall->u.incoming_data = |
603 g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)data, len); | 606 g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)part->buffer, part->size); |
604 purple_xfer_prpl_ready(slpmsg->slpcall->xfer); | 607 purple_xfer_prpl_ready(slpmsg->slpcall->xfer); |
605 } | 608 } |
606 else if (slpmsg->size && slpmsg->buffer) | 609 else if (slpmsg->size && slpmsg->buffer) |
607 { | 610 { |
608 if (G_MAXSIZE - len < offset || (offset + len) > slpmsg->size || slpmsg->offset != offset) | 611 if (G_MAXSIZE - part->size < offset |
612 || (offset + part->size) > slpmsg->size | |
613 || slpmsg->offset != offset) | |
609 { | 614 { |
610 purple_debug_error("msn", | 615 purple_debug_error("msn", |
611 "Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n", | 616 "Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n", |
612 slpmsg->size, offset, len); | 617 slpmsg->size, offset, part->size); |
613 g_return_if_reached(); | 618 g_return_if_reached(); |
614 } else { | 619 } else { |
615 memcpy(slpmsg->buffer + offset, data, len); | 620 memcpy(slpmsg->buffer + offset, part->buffer, part->size); |
616 slpmsg->offset += len; | 621 slpmsg->offset += part->size; |
617 } | 622 } |
618 } | 623 } |
619 | 624 |
620 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || | 625 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || |
621 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || | 626 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || |
625 slpmsg->slpcall->progress = TRUE; | 630 slpmsg->slpcall->progress = TRUE; |
626 | 631 |
627 if (slpmsg->slpcall->progress_cb != NULL) | 632 if (slpmsg->slpcall->progress_cb != NULL) |
628 { | 633 { |
629 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size, | 634 slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size, |
630 len, offset); | 635 part->size, offset); |
631 } | 636 } |
632 } | 637 } |
633 | 638 |
634 #if 0 | 639 #if 0 |
635 if (slpmsg->buffer == NULL) | 640 if (slpmsg->buffer == NULL) |