# HG changeset patch # User Elliott Sales de Andrade # Date 1304996987 0 # Node ID 1e657ff2eacb2b9709799c101fdcac335dbf630c # Parent cf702c6ab9e714391437e3e5f8b775572e9fe5f2 Hide some offset occurrences and define a couple of abstractions in the v2 case. diff -r cf702c6ab9e7 -r 1e657ff2eacb libpurple/protocols/msn/p2p.c --- a/libpurple/protocols/msn/p2p.c Mon May 09 22:56:29 2011 +0000 +++ b/libpurple/protocols/msn/p2p.c Tue May 10 03:09:47 2011 +0000 @@ -349,6 +349,7 @@ case MSN_P2P_VERSION_TWO: /* Nothing to do! */ + valid = TRUE; break; default: @@ -359,6 +360,28 @@ } gboolean +msn_p2p_info_is_first(MsnP2PInfo *info) +{ + gboolean first = FALSE; + + switch (info->version) { + case MSN_P2P_VERSION_ONE: + first = info->header.v1.offset == 0; + break; + + case MSN_P2P_VERSION_TWO: + /* Nothing to do! */ + first = info->header.v2.data_tf & TF_FIRST; + break; + + default: + purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version); + } + + return first; +} + +gboolean msn_p2p_info_is_final(MsnP2PInfo *info) { gboolean final = FALSE; @@ -369,7 +392,7 @@ break; case MSN_P2P_VERSION_TWO: - /* Nothing to do! */ + final = msn_tlv_gettlv(info->header.v2.data_tlv, 0x01, 1) == NULL; break; default: diff -r cf702c6ab9e7 -r 1e657ff2eacb libpurple/protocols/msn/p2p.h --- a/libpurple/protocols/msn/p2p.h Mon May 09 22:56:29 2011 +0000 +++ b/libpurple/protocols/msn/p2p.h Tue May 10 03:09:47 2011 +0000 @@ -189,6 +189,9 @@ msn_p2p_info_is_valid(MsnP2PInfo *info); gboolean +msn_p2p_info_is_first(MsnP2PInfo *info); + +gboolean msn_p2p_info_is_final(MsnP2PInfo *info); void diff -r cf702c6ab9e7 -r 1e657ff2eacb libpurple/protocols/msn/slpcall.h --- a/libpurple/protocols/msn/slpcall.h Mon May 09 22:56:29 2011 +0000 +++ b/libpurple/protocols/msn/slpcall.h Tue May 10 03:09:47 2011 +0000 @@ -65,7 +65,7 @@ gboolean wait_for_socket; void (*progress_cb)(MsnSlpCall *slpcall, - gsize total_length, gsize len, gsize offset); + gsize total_length, gsize len); void (*session_init_cb)(MsnSlpCall *slpcall); /* Can be checksum, or smile */ diff -r cf702c6ab9e7 -r 1e657ff2eacb libpurple/protocols/msn/slplink.c --- a/libpurple/protocols/msn/slplink.c Mon May 09 22:56:29 2011 +0000 +++ b/libpurple/protocols/msn/slplink.c Tue May 10 03:09:47 2011 +0000 @@ -344,7 +344,7 @@ if (slpmsg->slpcall->progress_cb != NULL) { slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size, - len, offset); + len); } } @@ -561,7 +561,6 @@ { MsnSlpMessage *slpmsg; MsnP2PInfo *info; - guint64 offset; info = part->info; @@ -574,9 +573,7 @@ return; } - offset = msn_p2p_info_get_offset(info); - - if (offset == 0) + if (msn_p2p_info_is_first(info)) slpmsg = init_first_msg(slplink, info); else { guint32 session_id, id; @@ -600,7 +597,7 @@ if (slpmsg->slpcall->progress_cb != NULL) { slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size, - part->size, offset); + part->size); } }