libpurple/protocols/msn/p2p.c

Sat, 27 Nov 2010 07:56:27 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sat, 27 Nov 2010 07:56:27 +0000
changeset 31180
3f527ea0d2ea
parent 31070
2a60d87864b9
child 31185
5ffa2e7ba2e1
permissions
-rw-r--r--

These new files are missing GPL headers. And fix a couple incorrect
names in there.

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"
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
26
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
27 #include "p2p.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
28
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
29 MsnP2PHeader *
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
30 msn_p2p_header_from_wire(MsnP2PHeader *wire)
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
31 {
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
32 MsnP2PHeader *header;
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
33
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
34 header = g_new(MsnP2PHeader, 1);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
35
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
36 header->session_id = GUINT32_FROM_LE(wire->session_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
37 header->id = GUINT32_FROM_LE(wire->id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
38 header->offset = GUINT64_FROM_LE(wire->offset);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
39 header->total_size = GUINT64_FROM_LE(wire->total_size);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
40 header->length = GUINT32_FROM_LE(wire->length);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
41 header->flags = GUINT32_FROM_LE(wire->flags);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
42 header->ack_id = GUINT32_FROM_LE(wire->ack_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
43 header->ack_sub_id = GUINT32_FROM_LE(wire->ack_sub_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
44 header->ack_size = GUINT64_FROM_LE(wire->ack_size);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
45
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
46 return header;
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
47 }
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
48
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
49 MsnP2PHeader *
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
50 msn_p2p_header_to_wire(MsnP2PHeader *header)
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
51 {
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
52 MsnP2PHeader *wire;
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
53
30975
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
54 wire = g_new(MsnP2PHeader, 1);
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
55
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
56 wire->session_id = GUINT32_TO_LE(header->session_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
57 wire->id = GUINT32_TO_LE(header->id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
58 wire->offset = GUINT64_TO_LE(header->offset);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
59 wire->total_size = GUINT64_TO_LE(header->total_size);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
60 wire->length = GUINT32_TO_LE(header->length);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
61 wire->flags = GUINT32_TO_LE(header->flags);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
62 wire->ack_id = GUINT32_TO_LE(header->ack_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
63 wire->ack_sub_id = GUINT32_TO_LE(header->ack_sub_id);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
64 wire->ack_size = GUINT64_TO_LE(header->ack_size);
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
65
30975
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
66 return wire;
da9bd715cc7a Oops, forgot to save before commiting.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30972
diff changeset
67
30972
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
68 }
6183fdc2c860 Move parsing of the p2p header to p2p to avoid duplicated code.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
diff changeset
69
30984
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
70 MsnP2PFooter *
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
71 msn_p2p_footer_from_wire(MsnP2PFooter *wire)
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
72 {
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
73 MsnP2PFooter *footer;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
74
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
75 footer = g_new(MsnP2PFooter, 1);
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
76
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
77 footer->value = GUINT32_FROM_BE(wire->value);
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
78
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
79 return footer;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
80 }
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
81
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
82 MsnP2PFooter *
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
83 msn_p2p_footer_to_wire(MsnP2PFooter *footer)
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
84 {
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
85 MsnP2PFooter *wire;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
86
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
87 wire = g_new(MsnP2PFooter, 1);
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
88
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
89 wire->value = GUINT32_TO_BE(footer->value);
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
90
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
91 return wire;
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
92 }
2898559aaaa7 Add P2PFooter helper functions.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30975
diff changeset
93
31070
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
94 gboolean
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
95 msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags)
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
96 {
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
97 return (flags == P2P_MSN_OBJ_DATA ||
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
98 flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
99 flags == P2P_FILE_DATA);
2a60d87864b9 Avoid duplicated code using a util function to check the flags.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 30984
diff changeset
100 }

mercurial