Mercurial > pidgin
annotate libpurple/protocols/msn/p2p.c @ 31086:a8cc50c2279f
Remove trailing whitespace
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 04 Jan 2011 06:55:30 +0000 |
parents | 7b771e6f1142 |
children | 34da321b60f1 |
rev | line source |
---|---|
30969
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
1 /** |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
2 * @file p2p.c MSN P2P functions |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
3 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
4 * purple |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
5 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
8 * source distribution. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
9 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
13 * (at your option) any later version. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
14 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
18 * GNU General Public License for more details. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
19 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
23 */ |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30868
diff
changeset
|
24 |
30771
198d5bf82e09
Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents:
30768
diff
changeset
|
25 #include "internal.h" |
198d5bf82e09
Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents:
30768
diff
changeset
|
26 |
198d5bf82e09
Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents:
30768
diff
changeset
|
27 #include "p2p.h" |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
28 #include "msnutils.h" |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
29 |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
30 MsnP2PHeader * |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
31 msn_p2p_header_from_wire(const char *wire) |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
32 { |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
33 MsnP2PHeader *header; |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
34 |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
35 header = g_new(MsnP2PHeader, 1); |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
36 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
37 header->session_id = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
38 header->id = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
39 header->offset = msn_pop64le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
40 header->total_size = msn_pop64le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
41 header->length = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
42 header->flags = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
43 header->ack_id = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
44 header->ack_sub_id = msn_pop32le(wire); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
45 header->ack_size = msn_pop64le(wire); |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
46 |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
47 return header; |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
48 } |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
49 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
50 char * |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
51 msn_p2p_header_to_wire(MsnP2PHeader *header) |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
52 { |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
53 char *wire; |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
54 char *tmp; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31044
diff
changeset
|
55 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
56 tmp = wire = g_new(char, P2P_PACKET_HEADER_SIZE); |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
57 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
58 msn_push32le(tmp, header->session_id); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
59 msn_push32le(tmp, header->id); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
60 msn_push64le(tmp, header->offset); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
61 msn_push64le(tmp, header->total_size); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
62 msn_push32le(tmp, header->length); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
63 msn_push32le(tmp, header->flags); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
64 msn_push32le(tmp, header->ack_id); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
65 msn_push32le(tmp, header->ack_sub_id); |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
66 msn_push64le(tmp, header->ack_size); |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
67 |
30771
198d5bf82e09
Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents:
30768
diff
changeset
|
68 return wire; |
198d5bf82e09
Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents:
30768
diff
changeset
|
69 |
30768
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
70 } |
f66e289bebc6
Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
71 |
30782 | 72 MsnP2PFooter * |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
73 msn_p2p_footer_from_wire(const char *wire) |
30782 | 74 { |
75 MsnP2PFooter *footer; | |
76 | |
77 footer = g_new(MsnP2PFooter, 1); | |
78 | |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
79 footer->value = msn_pop32be(wire); |
30782 | 80 |
81 return footer; | |
82 } | |
83 | |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
84 char * |
30782 | 85 msn_p2p_footer_to_wire(MsnP2PFooter *footer) |
86 { | |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
87 char *wire; |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
88 char *tmp; |
30782 | 89 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
90 tmp = wire = g_new(char, P2P_PACKET_FOOTER_SIZE); |
30782 | 91 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
92 msn_push32be(tmp, footer->value); |
30782 | 93 |
94 return wire; | |
95 } | |
96 | |
30868
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
97 gboolean |
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
98 msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags) |
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
99 { |
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
100 return (flags == P2P_MSN_OBJ_DATA || |
30974
f26e961e1274
Fix the name of this flag.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
101 flags == (P2P_WLM2009_COMP | P2P_MSN_OBJ_DATA) || |
30868
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
102 flags == P2P_FILE_DATA); |
5964f65c17ed
Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents:
30782
diff
changeset
|
103 } |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30974
diff
changeset
|
104 |