Mercurial > pidgin
comparison libpurple/protocols/msn/slplink.c @ 30859:2c2ca0aed68e
Split a little more msn_slplink_process_msg. I think this way is easier to read.
author | masca@cpw.pidgin.im |
---|---|
date | Thu, 29 Jul 2010 20:54:50 +0000 |
parents | 2d00d29a45fd |
children | 5ad928319db0 |
comparison
equal
deleted
inserted
replaced
30858:2d00d29a45fd | 30859:2c2ca0aed68e |
---|---|
566 | 566 |
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 static void | |
572 slpmsg_add_part(MsnSlpMessage *slpmsg, MsnSlpMessagePart *part) | |
573 { | |
574 if (slpmsg->ft) { | |
575 slpmsg->slpcall->u.incoming_data = | |
576 g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)part->buffer, part->size); | |
577 purple_xfer_prpl_ready(slpmsg->slpcall->xfer); | |
578 } | |
579 else if (slpmsg->size && slpmsg->buffer) { | |
580 if (G_MAXSIZE - part->size < part->header->offset | |
581 || (part->header->offset + part->size) > slpmsg->size | |
582 || slpmsg->offset != part->header->offset) { | |
583 purple_debug_error("msn", | |
584 "Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n", | |
585 slpmsg->size, part->header->offset, part->size); | |
586 g_return_if_reached(); | |
587 } else { | |
588 memcpy(slpmsg->buffer + part->header->offset, part->buffer, part->size); | |
589 slpmsg->offset += part->size; | |
590 } | |
591 } | |
592 } | |
593 | |
571 void | 594 void |
572 msn_slplink_process_msg(MsnSlpLink *slplink, MsnSlpMessagePart *part) | 595 msn_slplink_process_msg(MsnSlpLink *slplink, MsnSlpMessagePart *part) |
573 { | 596 { |
574 MsnSlpMessage *slpmsg; | 597 MsnSlpMessage *slpmsg; |
575 MsnP2PHeader *header; | 598 MsnP2PHeader *header; |
598 purple_debug_error("msn", "Couldn't find slpmsg\n"); | 621 purple_debug_error("msn", "Couldn't find slpmsg\n"); |
599 return; | 622 return; |
600 } | 623 } |
601 } | 624 } |
602 | 625 |
603 if (slpmsg->ft) | 626 slpmsg_add_part(slpmsg, part); |
604 { | |
605 slpmsg->slpcall->u.incoming_data = | |
606 g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)part->buffer, part->size); | |
607 purple_xfer_prpl_ready(slpmsg->slpcall->xfer); | |
608 } | |
609 else if (slpmsg->size && slpmsg->buffer) | |
610 { | |
611 if (G_MAXSIZE - part->size < offset | |
612 || (offset + part->size) > slpmsg->size | |
613 || slpmsg->offset != offset) | |
614 { | |
615 purple_debug_error("msn", | |
616 "Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n", | |
617 slpmsg->size, offset, part->size); | |
618 g_return_if_reached(); | |
619 } else { | |
620 memcpy(slpmsg->buffer + offset, part->buffer, part->size); | |
621 slpmsg->offset += part->size; | |
622 } | |
623 } | |
624 | 627 |
625 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || | 628 if ((slpmsg->flags == P2P_MSN_OBJ_DATA || |
626 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || | 629 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) || |
627 slpmsg->flags == P2P_FILE_DATA) && | 630 slpmsg->flags == P2P_FILE_DATA) && |
628 (slpmsg->slpcall != NULL)) | 631 (slpmsg->slpcall != NULL)) |