libpurple/protocols/msn/p2p.c

Wed, 21 Aug 2013 14:59:29 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Wed, 21 Aug 2013 14:59:29 +0200
changeset 34304
faf0414a8b51
parent 31792
ebe13c307f60
child 35676
d9fdd45925ec
permissions
-rw-r--r--

Fix most of libpurple warnings about -Wsign-compare

31180
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
1 /**
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
2 * @file p2p.c MSN P2P functions
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
3 *
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
4 * purple
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
5 *
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
8 * source distribution.
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
9 *
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
11 * it under the terms of the GNU General Public License as published by
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
13 * (at your option) any later version.
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
14 *
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
15 * This program is distributed in the hope that it will be useful,
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
18 * GNU General Public License for more details.
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
19 *
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
20 * You should have received a copy of the GNU General Public License
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
21 * along with this program; if not, write to the Free Software
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
23 */
3f527ea0d2ea These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31070
diff changeset
24
30975
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
25 #include "internal.h"
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
26 #include "debug.h"
30975
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
27
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
28 #include "p2p.h"
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
29 #include "tlv.h"
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
30 #include "msnutils.h"
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
31
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
32 MsnP2PInfo *
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
33 msn_p2p_info_new(MsnP2PVersion version)
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
34 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
35 MsnP2PInfo *info = g_new0(MsnP2PInfo, 1);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
36 info->version = version;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
37
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
38 switch (version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
39 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
40 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
41 /* Nothing to do */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
42 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
43
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
44 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
45 purple_debug_error("msn", "Invalid P2P Info version: %d\n", version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
46 g_free(info);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
47 info = NULL;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
48 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
49
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
50 return info;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
51 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
52
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
53 MsnP2PInfo *
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
54 msn_p2p_info_dup(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
55 {
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
56 MsnP2PInfo *new_info = g_new0(MsnP2PInfo, 1);
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
57
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
58 new_info->version = info->version;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
59
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
60 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
61 case MSN_P2P_VERSION_ONE:
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
62 *new_info = *info;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
63 break;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
64
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
65 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
66 *new_info = *info;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
67 new_info->header.v2.header_tlv = msn_tlvlist_copy(info->header.v2.header_tlv);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
68 new_info->header.v2.data_tlv = msn_tlvlist_copy(info->header.v2.data_tlv);
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
69 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
70
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
71 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
72 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
73 g_free(new_info);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
74 new_info = NULL;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
75 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
76
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
77 return new_info;
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
78 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
79
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
80 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
81 msn_p2p_info_free(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
82 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
83 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
84 case MSN_P2P_VERSION_ONE:
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
85 /* Nothing to do! */
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
86 break;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
87
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
88 case MSN_P2P_VERSION_TWO:
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
89 msn_tlvlist_free(info->header.v2.header_tlv);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
90 msn_tlvlist_free(info->header.v2.data_tlv);
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
91 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
92
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
93 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
94 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
95 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
96
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
97 g_free(info);
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
98 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
99
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
100 size_t
31520
c557ab744010 Add a maximum length when parsing the P2P wire data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31475
diff changeset
101 msn_p2p_header_from_wire(MsnP2PInfo *info, const char *wire, size_t max_len)
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
102 {
31521
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
103 size_t len = 0;
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
104
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
105 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
106 case MSN_P2P_VERSION_ONE: {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
107 MsnP2PHeader *header = &info->header.v1;
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
108
31521
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
109 if (max_len < P2P_PACKET_HEADER_SIZE) {
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
110 /* Invalid packet length */
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
111 len = 0;
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
112 break;
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
113 }
06233b79d75e Oops, I forgot to move the size check to the new location.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31520
diff changeset
114
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
115 header->session_id = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
116 header->id = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
117 header->offset = msn_pop64le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
118 header->total_size = msn_pop64le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
119 header->length = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
120 header->flags = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
121 header->ack_id = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
122 header->ack_sub_id = msn_pop32le(wire);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
123 header->ack_size = msn_pop64le(wire);
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
124
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
125 len = P2P_PACKET_HEADER_SIZE;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
126 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
127 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
128
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
129 case MSN_P2P_VERSION_TWO: {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
130 MsnP2Pv2Header *header = &info->header.v2;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
131
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
132 header->header_len = msn_pop8(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
133 header->opcode = msn_pop8(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
134 header->message_len = msn_pop16be(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
135 header->base_id = msn_pop32be(wire);
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31792
diff changeset
136 if ((gsize)header->header_len + header->message_len +
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31792
diff changeset
137 P2P_PACKET_FOOTER_SIZE > max_len)
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31792
diff changeset
138 {
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
139 /* Invalid header and data length */
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
140 len = 0;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
141 break;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
142 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
143
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
144 if (header->header_len > 8) {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
145 header->header_tlv = msn_tlvlist_read(wire, header->header_len - 8);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
146 wire += header->header_len - 8;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
147 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
148
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
149 if (header->message_len > 0) {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
150 /* Parse Data packet */
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
151
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
152 header->data_header_len = msn_pop8(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
153 if (header->data_header_len > header->message_len) {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
154 /* Invalid data header length */
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
155 len = 0;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
156 break;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
157 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
158 header->data_tf = msn_pop8(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
159 header->package_number = msn_pop16be(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
160 header->session_id = msn_pop32be(wire);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
161
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
162 if (header->data_header_len > 8) {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
163 header->data_tlv = msn_tlvlist_read(wire, header->data_header_len - 8);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
164 wire += header->data_header_len - 8;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
165 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
166 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
167
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
168 len = header->header_len + header->message_len;
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
169
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
170 break;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
171 }
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
172
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
173 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
174 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
175 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
176
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
177 return len;
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
178 }
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
179
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
180 char *
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
181 msn_p2p_header_to_wire(MsnP2PInfo *info, size_t *len)
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
182 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
183 char *wire = NULL;
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
184 char *tmp;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31247
diff changeset
185
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
186 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
187 case MSN_P2P_VERSION_ONE: {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
188 MsnP2PHeader *header = &info->header.v1;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
189 tmp = wire = g_new(char, P2P_PACKET_HEADER_SIZE);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
190
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
191 msn_push32le(tmp, header->session_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
192 msn_push32le(tmp, header->id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
193 msn_push64le(tmp, header->offset);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
194 msn_push64le(tmp, header->total_size);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
195 msn_push32le(tmp, header->length);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
196 msn_push32le(tmp, header->flags);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
197 msn_push32le(tmp, header->ack_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
198 msn_push32le(tmp, header->ack_sub_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
199 msn_push64le(tmp, header->ack_size);
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
200
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
201 if (len)
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
202 *len = P2P_PACKET_HEADER_SIZE;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
203
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
204 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
205 }
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
206
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
207 case MSN_P2P_VERSION_TWO: {
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
208 MsnP2Pv2Header *header = &info->header.v2;
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
209 char *header_wire = NULL;
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
210 char *data_header_wire = NULL;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
211
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
212 if (header->header_tlv != NULL)
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
213 header_wire = msn_tlvlist_write(header->header_tlv, (size_t *)&header->header_len);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
214 else
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
215 header->header_len = 0;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
216
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
217 if (header->data_tlv != NULL)
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
218 data_header_wire = msn_tlvlist_write(header->data_tlv, (size_t *)&header->data_header_len);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
219 else
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
220 header->data_header_len = 0;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
221
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
222 tmp = wire = g_new(char, 16 + header->header_len + header->data_header_len);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
223
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
224 msn_push8(tmp, header->header_len + 8);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
225 msn_push8(tmp, header->opcode);
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
226 msn_push16be(tmp, header->data_header_len + 8 + header->message_len);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
227 msn_push32be(tmp, header->base_id);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
228
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
229 if (header_wire != NULL) {
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
230 memcpy(tmp, header_wire, header->header_len);
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
231 tmp += header->header_len;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
232 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
233
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
234 msn_push8(tmp, header->data_header_len + 8);
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
235 msn_push8(tmp, header->data_tf);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
236 msn_push16be(tmp, header->package_number);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
237 msn_push32be(tmp, header->session_id);
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
238
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
239 if (data_header_wire != NULL) {
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
240 memcpy(tmp, data_header_wire, header->data_header_len);
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
241 tmp += header->data_header_len;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
242 }
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
243
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
244 if (len)
31759
23d8a2af70d7 This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31523
diff changeset
245 *len = header->header_len + header->data_header_len + 16;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
246
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
247 break;
31523
3a58442e7b62 Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31521
diff changeset
248 }
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
249
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
250 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
251 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
252 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
253
30975
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
254 return wire;
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
255 }
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
256
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
257 size_t
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
258 msn_p2p_footer_from_wire(MsnP2PInfo *info, const char *wire)
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
259 {
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
260 MsnP2PFooter *footer;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
261
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
262 footer = &info->footer;
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
263
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
264 footer->value = msn_pop32be(wire);
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
265
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
266 return P2P_PACKET_FOOTER_SIZE;
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
267 }
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
268
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
269 char *
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
270 msn_p2p_footer_to_wire(MsnP2PInfo *info, size_t *len)
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
271 {
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
272 MsnP2PFooter *footer;
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
273 char *wire;
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
274 char *tmp;
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
275
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
276 footer = &info->footer;
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
277 tmp = wire = g_new(char, P2P_PACKET_FOOTER_SIZE);
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
278
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
279 msn_push32be(tmp, footer->value);
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
280
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
281 if (len)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
282 *len = P2P_PACKET_FOOTER_SIZE;
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
283
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
284 return wire;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
285 }
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
286
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
287 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
288 msn_p2p_info_to_string(MsnP2PInfo *info, GString *str)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
289 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
290 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
291 case MSN_P2P_VERSION_ONE: {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
292 MsnP2PHeader *header = &info->header.v1;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
293 g_string_append_printf(str, "Session ID: %u\r\n", header->session_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
294 g_string_append_printf(str, "ID: %u\r\n", header->id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
295 g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", header->offset);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
296 g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", header->total_size);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
297 g_string_append_printf(str, "Length: %u\r\n", header->length);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
298 g_string_append_printf(str, "Flags: 0x%x\r\n", header->flags);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
299 g_string_append_printf(str, "ACK ID: %u\r\n", header->ack_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
300 g_string_append_printf(str, "SUB ID: %u\r\n", header->ack_sub_id);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
301 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", header->ack_size);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
302
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
303 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
304 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
305
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
306 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
307 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
308 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
309
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
310 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
311 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
312 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
313
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
314 g_string_append_printf(str, "Footer: 0x%08X\r\n", info->footer.value);
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
315 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
316
31070
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
317 gboolean
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
318 msn_p2p_msg_is_data(const MsnP2PInfo *info)
31070
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
319 {
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
320 gboolean data = FALSE;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
321
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
322 switch (info->version) {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
323 case MSN_P2P_VERSION_ONE: {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
324 guint32 flags = info->header.v1.flags;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
325 data = (flags == P2P_MSN_OBJ_DATA ||
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
326 flags == (P2P_WLM2009_COMP | P2P_MSN_OBJ_DATA) ||
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
327 flags == P2P_FILE_DATA);
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
328 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
329 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
330
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
331 case MSN_P2P_VERSION_TWO:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
332 data = info->header.v2.message_len > 0;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
333 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
334
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
335 default:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
336 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
337 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
338
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
339 return data;
31070
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
340 }
31247
57079aab03d0 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31185
diff changeset
341
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
342 gboolean
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
343 msn_p2p_info_is_valid(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
344 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
345 gboolean valid = FALSE;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
346
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
347 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
348 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
349 valid = info->header.v1.total_size >= info->header.v1.length;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
350 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
351
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
352 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
353 /* Nothing to do! */
31791
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
354 valid = TRUE;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
355 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
356
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
357 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
358 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
359 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
360
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
361 return valid;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
362 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
363
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
364 gboolean
31791
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
365 msn_p2p_info_is_first(MsnP2PInfo *info)
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
366 {
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
367 gboolean first = FALSE;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
368
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
369 switch (info->version) {
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
370 case MSN_P2P_VERSION_ONE:
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
371 first = info->header.v1.offset == 0;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
372 break;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
373
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
374 case MSN_P2P_VERSION_TWO:
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
375 /* Nothing to do! */
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
376 first = info->header.v2.data_tf & TF_FIRST;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
377 break;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
378
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
379 default:
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
380 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
381 }
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
382
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
383 return first;
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
384 }
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
385
d09a1b6dc386 Hide some offset occurrences and define a couple of abstractions in
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31790
diff changeset
386 gboolean
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
387 msn_p2p_info_is_final(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
388 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
389 gboolean final = FALSE;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
390
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
391 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
392 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
393 final = info->header.v1.offset + info->header.v1.length >= info->header.v1.total_size;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
394 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
395
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
396 case MSN_P2P_VERSION_TWO:
31792
ebe13c307f60 Rename this enums a little better. And I don't think we need these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31791
diff changeset
397 final = msn_tlv_gettlv(info->header.v2.data_tlv, P2P_DATA_TLV_REMAINING, 1) == NULL;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
398 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
399
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
400 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
401 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
402 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
403
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
404 return final;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
405 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
406
31771
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
407 void
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
408 msn_p2p_info_create_ack(MsnP2PInfo *old_info, MsnP2PInfo *new_info)
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
409 {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
410 switch (old_info->version) {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
411 case MSN_P2P_VERSION_ONE: {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
412 MsnP2PHeader *old = &old_info->header.v1;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
413 MsnP2PHeader *new = &new_info->header.v1;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
414
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
415 new->session_id = old->session_id;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
416 new->flags = P2P_ACK;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
417 new->ack_id = old->id;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
418 new->ack_sub_id = old->ack_id;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
419 new->ack_size = old->total_size;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
420 break;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
421 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
422
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
423 case MSN_P2P_VERSION_TWO: {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
424 MsnP2Pv2Header *old = &old_info->header.v2;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
425 MsnP2Pv2Header *new = &new_info->header.v2;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
426
31792
ebe13c307f60 Rename this enums a little better. And I don't think we need these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31791
diff changeset
427 msn_tlvlist_add_32(&new->header_tlv, P2P_HEADER_TLV_TYPE_ACK, old->base_id + old->message_len);
31771
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
428 new->opcode = P2P_OPCODE_NONE;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
429
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
430 if (old->message_len > 0) {
31792
ebe13c307f60 Rename this enums a little better. And I don't think we need these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31791
diff changeset
431 if (!msn_tlv_gettlv(old->header_tlv, P2P_HEADER_TLV_TYPE_ACK, 1)) {
31771
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
432 if (old->opcode & P2P_OPCODE_SYN) {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
433 msn_tlv_t *ack_tlv;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
434 new->opcode |= P2P_OPCODE_RAK;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
435
31792
ebe13c307f60 Rename this enums a little better. And I don't think we need these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31791
diff changeset
436 ack_tlv = msn_tlv_gettlv(old->header_tlv, P2P_HEADER_TLV_TYPE_PEER_INFO, 1);
31771
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
437 if (ack_tlv) {
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
438 msn_tlvlist_add_tlv(&new->header_tlv, ack_tlv);
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
439 new->opcode |= P2P_OPCODE_SYN;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
440 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
441 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
442 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
443 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
444 break;
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
445 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
446
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
447 default:
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
448 purple_debug_error("msn", "Invalid P2P Info version: %d\n", old_info->version);
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
449 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
450 }
26e1c519295f Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31761
diff changeset
451
31772
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
452 gboolean
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
453 msn_p2p_info_require_ack(MsnP2PInfo *info)
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
454 {
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
455 gboolean ret = FALSE;
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
456
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
457 switch (info->version) {
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
458 case MSN_P2P_VERSION_ONE: {
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
459 guint32 flags = msn_p2p_info_get_flags(info);
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
460
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
461 ret = flags == P2P_NO_FLAG || flags == P2P_WLM2009_COMP ||
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
462 msn_p2p_msg_is_data(info);
31772
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
463 break;
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
464 }
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
465
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
466 case MSN_P2P_VERSION_TWO:
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
467 ret = (info->header.v2.opcode & P2P_OPCODE_RAK) > 0;
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
468 break;
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
469
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
470 default:
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
471 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
472 }
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
473
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
474 return ret;
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
475 }
ad88c7c133a3 Only send acks on p2pv2 when required.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31771
diff changeset
476
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
477 gboolean
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
478 msn_p2p_info_is_ack(MsnP2PInfo *info)
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
479 {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
480 gboolean ret = FALSE;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
481
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
482 switch (info->version) {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
483 case MSN_P2P_VERSION_ONE: {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
484 ret = msn_p2p_info_get_flags(info) == P2P_ACK;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
485 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
486 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
487
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
488 case MSN_P2P_VERSION_TWO:
31792
ebe13c307f60 Rename this enums a little better. And I don't think we need these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31791
diff changeset
489 ret = msn_tlv_gettlv(info->header.v2.header_tlv, P2P_HEADER_TLV_TYPE_ACK, 1) != NULL;
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
490 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
491
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
492 default:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
493 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
494 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
495
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
496 return ret;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
497 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
498
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
499 void
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
500 msn_p2p_info_init_first(MsnP2PInfo *info, MsnP2PInfo *old_info)
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
501 {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
502 switch (info->version) {
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
503 case MSN_P2P_VERSION_ONE:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
504 info->header.v1.session_id = old_info->header.v1.session_id;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
505 info->header.v1.flags = old_info->header.v1.flags;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
506 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
507
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
508 case MSN_P2P_VERSION_TWO:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
509 info->header.v2.data_tf = TF_FIRST;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
510 break;
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
511
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
512 default:
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
513 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
514 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
515 }
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
516
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
517 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
518 msn_p2p_info_get_session_id(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
519 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
520 guint32 session_id = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
521
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
522 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
523 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
524 session_id = info->header.v1.session_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
525 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
526
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
527 case MSN_P2P_VERSION_TWO:
31761
de2ccb87bfe0 I think this is the way to map to P2Pv2, but I don't have Internet
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31759
diff changeset
528 session_id = info->header.v2.session_id;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
529 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
530
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
531 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
532 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
533 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
534
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
535 return session_id;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
536 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
537
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
538 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
539 msn_p2p_info_get_id(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
540 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
541 guint32 id = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
542
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
543 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
544 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
545 id = info->header.v1.id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
546 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
547
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
548 case MSN_P2P_VERSION_TWO:
31761
de2ccb87bfe0 I think this is the way to map to P2Pv2, but I don't have Internet
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31759
diff changeset
549 id = info->header.v2.base_id;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
550 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
551
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
552 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
553 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
554 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
555
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
556 return id;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
557 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
558
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
559 guint64
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
560 msn_p2p_info_get_offset(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
561 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
562 guint64 offset = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
563
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
564 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
565 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
566 offset = info->header.v1.offset;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
567 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
568
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
569 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
570 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
571 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
572
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
573 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
574 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
575 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
576
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
577 return offset;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
578 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
579
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
580 guint64
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
581 msn_p2p_info_get_total_size(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
582 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
583 guint64 total_size = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
584
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
585 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
586 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
587 total_size = info->header.v1.total_size;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
588 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
589
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
590 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
591 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
592 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
593
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
594 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
595 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
596 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
597
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
598 return total_size;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
599 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
600
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
601 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
602 msn_p2p_info_get_length(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
603 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
604 guint32 length = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
605
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
606 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
607 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
608 length = info->header.v1.length;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
609 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
610
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
611 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
612 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
613 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
614
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
615 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
616 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
617 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
618
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
619 return length;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
620 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
621
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
622 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
623 msn_p2p_info_get_flags(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
624 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
625 guint32 flags = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
626
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
627 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
628 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
629 flags = info->header.v1.flags;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
630 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
631
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
632 case MSN_P2P_VERSION_TWO:
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
633 flags = info->header.v2.data_tf;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
634 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
635
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
636 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
637 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
638 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
639
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
640 return flags;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
641 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
642
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
643 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
644 msn_p2p_info_get_ack_id(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
645 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
646 guint32 ack_id = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
647
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
648 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
649 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
650 ack_id = info->header.v1.ack_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
651 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
652
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
653 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
654 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
655 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
656
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
657 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
658 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
659 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
660
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
661 return ack_id;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
662 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
663
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
664 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
665 msn_p2p_info_get_ack_sub_id(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
666 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
667 guint32 ack_sub_id = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
668
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
669 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
670 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
671 ack_sub_id = info->header.v1.ack_sub_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
672 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
673
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
674 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
675 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
676 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
677
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
678 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
679 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
680 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
681
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
682 return ack_sub_id;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
683 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
684
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
685 guint64
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
686 msn_p2p_info_get_ack_size(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
687 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
688 guint64 ack_size = 0;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
689
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
690 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
691 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
692 ack_size = info->header.v1.ack_size;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
693 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
694
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
695 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
696 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
697 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
698
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
699 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
700 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
701 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
702
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
703 return ack_size;
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
704 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
705
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
706 guint32
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
707 msn_p2p_info_get_app_id(MsnP2PInfo *info)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
708 {
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
709 return info->footer.value;
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
710 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
711
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
712 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
713 msn_p2p_info_set_session_id(MsnP2PInfo *info, guint32 session_id)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
714 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
715 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
716 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
717 info->header.v1.session_id = session_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
718 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
719
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
720 case MSN_P2P_VERSION_TWO:
31761
de2ccb87bfe0 I think this is the way to map to P2Pv2, but I don't have Internet
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31759
diff changeset
721 info->header.v2.session_id = session_id;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
722 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
723
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
724 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
725 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
726 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
727
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
728 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
729
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
730 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
731 msn_p2p_info_set_id(MsnP2PInfo *info, guint32 id)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
732 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
733 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
734 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
735 info->header.v1.id = id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
736 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
737
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
738 case MSN_P2P_VERSION_TWO:
31761
de2ccb87bfe0 I think this is the way to map to P2Pv2, but I don't have Internet
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31759
diff changeset
739 info->header.v2.base_id = id;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
740 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
741
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
742 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
743 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
744 }
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
745
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
746 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
747
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
748 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
749 msn_p2p_info_set_offset(MsnP2PInfo *info, guint64 offset)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
750 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
751 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
752 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
753 info->header.v1.offset = offset;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
754 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
755
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
756 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
757 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
758 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
759
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
760 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
761 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
762 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
763 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
764
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
765 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
766 msn_p2p_info_set_total_size(MsnP2PInfo *info, guint64 total_size)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
767 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
768 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
769 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
770 info->header.v1.total_size = total_size;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
771 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
772
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
773 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
774 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
775 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
776
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
777 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
778 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
779 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
780 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
781
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
782 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
783 msn_p2p_info_set_length(MsnP2PInfo *info, guint32 length)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
784 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
785 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
786 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
787 info->header.v1.length = length;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
788 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
789
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
790 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
791 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
792 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
793
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
794 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
795 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
796 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
797 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
798
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
799 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
800 msn_p2p_info_set_flags(MsnP2PInfo *info, guint32 flags)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
801 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
802 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
803 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
804 info->header.v1.flags = flags;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
805 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
806
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
807 case MSN_P2P_VERSION_TWO:
31773
4de9d3a046be Try to hide msn_p2p_info_get_flags as much as possible, since it may
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31772
diff changeset
808 info->header.v2.data_tf = flags;
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
809 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
810
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
811 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
812 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
813 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
814 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
815
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
816 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
817 msn_p2p_info_set_ack_id(MsnP2PInfo *info, guint32 ack_id)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
818 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
819 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
820 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
821 info->header.v1.ack_id = ack_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
822 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
823
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
824 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
825 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
826 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
827
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
828 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
829 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
830 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
831 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
832
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
833 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
834 msn_p2p_info_set_ack_sub_id(MsnP2PInfo *info, guint32 ack_sub_id)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
835 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
836 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
837 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
838 info->header.v1.ack_sub_id = ack_sub_id;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
839 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
840
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
841 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
842 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
843 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
844
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
845 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
846 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
847 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
848 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
849
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
850 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
851 msn_p2p_info_set_ack_size(MsnP2PInfo *info, guint64 ack_size)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
852 {
31475
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
853 switch (info->version) {
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
854 case MSN_P2P_VERSION_ONE:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
855 info->header.v1.ack_size = ack_size;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
856 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
857
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
858 case MSN_P2P_VERSION_TWO:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
859 /* Nothing to do! */
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
860 break;
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
861
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
862 default:
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
863 purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
a9c9f5b22102 Add P2Pv2 header information to the P2P info struct. Of course, all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31367
diff changeset
864 }
31367
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
865 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
866
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
867 void
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
868 msn_p2p_info_set_app_id(MsnP2PInfo *info, guint32 app_id)
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
869 {
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
870 info->footer.value = app_id;
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
871 }
743e9d0967aa Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31294
diff changeset
872

mercurial