annotate libpurple/protocols/msn/p2p.c @ 31469:78dccab9824c

Add the session user to the userlist. This reduces the amount of special-casing needed and corrects the buddy icon if you have yourself on your list. Fixes #12973.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 10 Dec 2010 06:38:17 +0000
parents f26e961e1274
children 7b771e6f1142
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31412
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
diff changeset
1 /**
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
diff changeset
3 *
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
diff changeset
5 *
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
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: 31306
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: 31306
diff changeset
9 *
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
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: 31306
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: 31306
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: 31306
diff changeset
14 *
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
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: 31306
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: 31306
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: 31306
diff changeset
19 *
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
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: 31306
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: 31306
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: 31306
diff changeset
23 */
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31306
diff changeset
24
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
25 #include "internal.h"
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
26
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
27 #include "p2p.h"
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
28
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
29 MsnP2PHeader *
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
30 msn_p2p_header_from_wire(MsnP2PHeader *wire)
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
31 {
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
32 MsnP2PHeader *header;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
33
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
34 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
35
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
36 header->session_id = GUINT32_FROM_LE(wire->session_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
37 header->id = GUINT32_FROM_LE(wire->id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
38 header->offset = GUINT64_FROM_LE(wire->offset);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
39 header->total_size = GUINT64_FROM_LE(wire->total_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
40 header->length = GUINT32_FROM_LE(wire->length);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
41 header->flags = GUINT32_FROM_LE(wire->flags);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
42 header->ack_id = GUINT32_FROM_LE(wire->ack_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
43 header->ack_sub_id = GUINT32_FROM_LE(wire->ack_sub_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
44 header->ack_size = GUINT64_FROM_LE(wire->ack_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
45
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
46 return header;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
47 }
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 MsnP2PHeader *
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
50 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
51 {
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
52 MsnP2PHeader *wire;
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
53
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
54 wire = g_new(MsnP2PHeader, 1);
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
55
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
56 wire->session_id = GUINT32_TO_LE(header->session_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
57 wire->id = GUINT32_TO_LE(header->id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
58 wire->offset = GUINT64_TO_LE(header->offset);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
59 wire->total_size = GUINT64_TO_LE(header->total_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
60 wire->length = GUINT32_TO_LE(header->length);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
61 wire->flags = GUINT32_TO_LE(header->flags);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
62 wire->ack_id = GUINT32_TO_LE(header->ack_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
63 wire->ack_sub_id = GUINT32_TO_LE(header->ack_sub_id);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
64 wire->ack_size = GUINT64_TO_LE(header->ack_size);
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
65
31209
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
66 return wire;
198d5bf82e09 Oops, forgot to save before commiting.
masca@cpw.pidgin.im
parents: 31206
diff changeset
67
31206
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
68 }
f66e289bebc6 Move parsing of the p2p header to p2p to avoid duplicated code.
masca@cpw.pidgin.im
parents:
diff changeset
69
31220
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
70 MsnP2PFooter *
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
71 msn_p2p_footer_from_wire(MsnP2PFooter *wire)
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
72 {
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
73 MsnP2PFooter *footer;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
74
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
75 footer = g_new(MsnP2PFooter, 1);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
76
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
77 footer->value = GUINT32_FROM_BE(wire->value);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
78
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
79 return footer;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
80 }
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
81
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
82 MsnP2PFooter *
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
83 msn_p2p_footer_to_wire(MsnP2PFooter *footer)
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
84 {
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
85 MsnP2PFooter *wire;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
86
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
87 wire = g_new(MsnP2PFooter, 1);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
88
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
89 wire->value = GUINT32_TO_BE(footer->value);
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
90
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
91 return wire;
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
92 }
3ccddae82532 Add P2PFooter helper functions.
masca@cpw.pidgin.im
parents: 31209
diff changeset
93
31306
5964f65c17ed Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents: 31220
diff changeset
94 gboolean
5964f65c17ed Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents: 31220
diff changeset
95 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: 31220
diff changeset
96 {
5964f65c17ed Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents: 31220
diff changeset
97 return (flags == P2P_MSN_OBJ_DATA ||
31417
f26e961e1274 Fix the name of this flag.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31412
diff changeset
98 flags == (P2P_WLM2009_COMP | P2P_MSN_OBJ_DATA) ||
31306
5964f65c17ed Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents: 31220
diff changeset
99 flags == P2P_FILE_DATA);
5964f65c17ed Avoid duplicated code using a util function to check the flags.
masca@cpw.pidgin.im
parents: 31220
diff changeset
100 }