annotate libpurple/protocols/msn/slpmsg.c @ 31305:6b73ff4fcc69

Get rid of the ack_size field in the SlpMessage in favor of the one in the Header. And do nothing if the released SlpMessage is an ACK or a 100 (DC Handshake).
author masca@cpw.pidgin.im
date Thu, 05 Aug 2010 23:16:49 +0000
parents b682664bae30
children d9ca3798faa5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file slpmsg.h SLP Message functions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16536
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30509
diff changeset
24
31196
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 31180
diff changeset
25 #include "internal.h"
31180
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30509
diff changeset
26 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30509
diff changeset
27
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "slpmsg.h"
31261
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
29 #include "slpmsg_part.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "slplink.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 * SLP Message
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 **************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 MsnSlpMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 msn_slpmsg_new(MsnSlpLink *slplink)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 slpmsg = g_new0(MsnSlpMessage, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24333
diff changeset
43 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24333
diff changeset
44 purple_debug_info("msn", "slpmsg new (%p)\n", slpmsg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
31227
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
46 if (slplink)
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
47 msn_slpmsg_set_slplink(slpmsg, slplink);
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
48 else
31219
74e372b31486 Allow temporary SlpMessages so we can get slp specific code from MsnMessage.
masca@cpw.pidgin.im
parents: 31218
diff changeset
49 slpmsg->slplink = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
31293
6814678f3c63 Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents: 31274
diff changeset
51 slpmsg->header = g_new0(MsnP2PHeader, 1);
31218
b98d1ca8422d This bits belong to SlpMessage, lets handle here, also I think it's easier to manage this bits being a pointer.
masca@cpw.pidgin.im
parents: 31196
diff changeset
52 slpmsg->footer = NULL;
b98d1ca8422d This bits belong to SlpMessage, lets handle here, also I think it's easier to manage this bits being a pointer.
masca@cpw.pidgin.im
parents: 31196
diff changeset
53
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 return slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
57 MsnSlpMessage *msn_slpmsg_new_from_data(const char *data, size_t data_len)
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
58 {
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
59 MsnSlpMessage *slpmsg;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
60 MsnP2PHeader *header;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
61 const char *tmp;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
62 int body_len;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
63
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
64 tmp = data;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
65 slpmsg = msn_slpmsg_new(NULL);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
66
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
67 if (data_len < sizeof(*header)) {
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
68 return NULL;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
69 }
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
70
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
71 /* Extract the binary SLP header */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
72 slpmsg->header = msn_p2p_header_from_wire((MsnP2PHeader*)tmp);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
73
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
74 /* Extract the body */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
75 body_len = data_len - (tmp - data);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
76 /* msg->body_len = msg->msnslp_header.length; */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
77
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
78 if (body_len > 0) {
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
79 slpmsg->size = body_len;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
80 slpmsg->buffer = g_malloc(body_len);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
81 memcpy(slpmsg->buffer, tmp, body_len);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
82 tmp += body_len;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
83 }
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
84
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
85 /* Extract the footer */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
86 if (body_len >= 0)
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
87 slpmsg->footer = msn_p2p_footer_from_wire((MsnP2PFooter*)tmp);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
88
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
89 return slpmsg;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
90 }
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
91
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 msn_slpmsg_destroy(MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 GList *cur;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 g_return_if_fail(slpmsg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
27509
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24333
diff changeset
100 if (purple_debug_is_verbose())
35b6fd563056 Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24333
diff changeset
101 purple_debug_info("msn", "slpmsg destroy (%p)\n", slpmsg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 slplink = slpmsg->slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
16390
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
105 purple_imgstore_unref(slpmsg->img);
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
106
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
107 /* We don't want to free the data of the PurpleStoredImage,
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
108 * but to avoid code duplication, it's sharing buffer. */
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
109 if (slpmsg->img == NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 g_free(slpmsg->buffer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
31261
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
112 for (cur = slpmsg->parts; cur != NULL; cur = g_list_delete_link(cur, cur))
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
113 {
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
114 /* Something is pointing to this slpmsg, so we should remove that
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
115 * pointer to prevent a crash. */
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
116 /* Ex: a user goes offline and after that we receive an ACK */
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
117
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
118 MsnSlpMessagePart *part = cur->data;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
119
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
120 part->ack_cb = NULL;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
121 part->nak_cb = NULL;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
122 part->ack_data = NULL;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
123 msn_slpmsgpart_destroy(part);
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
124 }
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
125
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
126 slplink->slp_msgs = g_list_remove(slplink->slp_msgs, slpmsg);
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
127
31218
b98d1ca8422d This bits belong to SlpMessage, lets handle here, also I think it's easier to manage this bits being a pointer.
masca@cpw.pidgin.im
parents: 31196
diff changeset
128 g_free(slpmsg->header);
b98d1ca8422d This bits belong to SlpMessage, lets handle here, also I think it's easier to manage this bits being a pointer.
masca@cpw.pidgin.im
parents: 31196
diff changeset
129 g_free(slpmsg->footer);
b98d1ca8422d This bits belong to SlpMessage, lets handle here, also I think it's easier to manage this bits being a pointer.
masca@cpw.pidgin.im
parents: 31196
diff changeset
130
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 g_free(slpmsg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 void
31227
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
135 msn_slpmsg_set_slplink(MsnSlpMessage *slpmsg, MsnSlpLink *slplink)
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
136 {
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
137 g_return_if_fail(slplink != NULL);
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
138
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
139 slpmsg->slplink = slplink;
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
140
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
141 slplink->slp_msgs =
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
142 g_list_append(slplink->slp_msgs, slpmsg);
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
143
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
144 }
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
145
2c3d7104ef1e Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents: 31226
diff changeset
146 void
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 msn_slpmsg_set_body(MsnSlpMessage *slpmsg, const char *body,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 long long size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 {
16390
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
150 /* We can only have one data source at a time. */
16536
1c07ce257fd7 Fix the g_return_if_fail() guards that prevent setting more than one data
Richard Laager <rlaager@wiktel.com>
parents: 16390
diff changeset
151 g_return_if_fail(slpmsg->buffer == NULL);
1c07ce257fd7 Fix the g_return_if_fail() guards that prevent setting more than one data
Richard Laager <rlaager@wiktel.com>
parents: 16390
diff changeset
152 g_return_if_fail(slpmsg->img == NULL);
29075
6aea98f6a5cd Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27509
diff changeset
153 g_return_if_fail(slpmsg->ft == FALSE);
16390
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
154
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 if (body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 slpmsg->buffer = g_memdup(body, size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 slpmsg->buffer = g_new0(guchar, size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 slpmsg->size = size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 void
16390
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
164 msn_slpmsg_set_image(MsnSlpMessage *slpmsg, PurpleStoredImage *img)
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
165 {
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
166 /* We can only have one data source at a time. */
16536
1c07ce257fd7 Fix the g_return_if_fail() guards that prevent setting more than one data
Richard Laager <rlaager@wiktel.com>
parents: 16390
diff changeset
167 g_return_if_fail(slpmsg->buffer == NULL);
1c07ce257fd7 Fix the g_return_if_fail() guards that prevent setting more than one data
Richard Laager <rlaager@wiktel.com>
parents: 16390
diff changeset
168 g_return_if_fail(slpmsg->img == NULL);
29075
6aea98f6a5cd Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27509
diff changeset
169 g_return_if_fail(slpmsg->ft == FALSE);
16390
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
170
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
171 slpmsg->img = purple_imgstore_ref(img);
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
172 slpmsg->buffer = (guchar *)purple_imgstore_get_data(img);
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
173 slpmsg->size = purple_imgstore_get_size(img);
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
174 }
4fc51a87ce42 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
175
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 MsnSlpMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 msn_slpmsg_sip_new(MsnSlpCall *slpcall, int cseq,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 const char *header, const char *branch,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 const char *content_type, const char *content)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 MsnSlpLink *slplink;
24333
c6c714b7841d Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents: 23718
diff changeset
183 PurpleAccount *account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 gsize body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 gsize content_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 g_return_val_if_fail(slpcall != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 g_return_val_if_fail(header != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 slplink = slpcall->slplink;
24333
c6c714b7841d Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents: 23718
diff changeset
193 account = slplink->session->account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 /* Let's remember that "content" should end with a 0x00 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 content_len = (content != NULL) ? strlen(content) + 1 : 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 body = g_strdup_printf(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 "%s\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 "To: <msnmsgr:%s>\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 "From: <msnmsgr:%s>\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 "Via: MSNSLP/1.0/TLP ;branch={%s}\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 "CSeq: %d\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 "Call-ID: {%s}\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 "Max-Forwards: 0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 "Content-Type: %s\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 "Content-Length: %" G_GSIZE_FORMAT "\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 "\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 header,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 slplink->remote_user,
24333
c6c714b7841d Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents: 23718
diff changeset
212 purple_account_get_username(account),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 branch,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 cseq,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 slpcall->id,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 content_type,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 content_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 body_len = strlen(body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 if (content_len > 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 body_len += content_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 body = g_realloc(body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 g_strlcat(body, content, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 slpmsg = msn_slpmsg_new(slplink);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 msn_slpmsg_set_body(slpmsg, body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 slpmsg->sip = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 slpmsg->slpcall = slpcall;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 g_free(body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 return slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 }
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
238
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
239 MsnSlpMessage *msn_slpmsg_ack_new(MsnP2PHeader *header)
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
240 {
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
241 MsnSlpMessage *slpmsg;
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
242
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
243 slpmsg = msn_slpmsg_new(NULL);
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
244
31293
6814678f3c63 Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents: 31274
diff changeset
245 slpmsg->header->session_id = header->session_id;
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
246 slpmsg->size = header->total_size;
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
247 slpmsg->flags = P2P_ACK;
31302
e32332ac385c Get rid of the ack_id field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents: 31293
diff changeset
248 slpmsg->header->ack_id = header->id;
31304
b682664bae30 Get rid of the ack_sub_id field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents: 31303
diff changeset
249 slpmsg->header->ack_sub_id = header->ack_id;
31305
6b73ff4fcc69 Get rid of the ack_size field in the SlpMessage in favor of the one in the Header. And do nothing if the released SlpMessage is an ACK or a 100 (DC Handshake).
masca@cpw.pidgin.im
parents: 31304
diff changeset
250 slpmsg->header->ack_size = header->total_size;
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
251 slpmsg->info = "SLP ACK";
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
252
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
253 return slpmsg;
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
254 }
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
255
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
256 MsnSlpMessage *msn_slpmsg_obj_new(MsnSlpCall *slpcall, PurpleStoredImage *img)
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
257 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
258 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
259
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
260 slpmsg = msn_slpmsg_new(NULL);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
261 slpmsg->slpcall = slpcall;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
262 slpmsg->flags = P2P_MSN_OBJ_DATA;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
263 slpmsg->info = "SLP DATA";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
264
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
265 msn_slpmsg_set_image(slpmsg, img);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
266
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
267 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
268 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
269
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
270 MsnSlpMessage *msn_slpmsg_dataprep_new(MsnSlpCall *slpcall)
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
271 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
272 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
273
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
274 slpmsg = msn_slpmsg_new(NULL);
31293
6814678f3c63 Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents: 31274
diff changeset
275
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
276 slpmsg->slpcall = slpcall;
31293
6814678f3c63 Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents: 31274
diff changeset
277 slpmsg->header->session_id = slpcall->session_id;
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
278 msn_slpmsg_set_body(slpmsg, NULL, 4);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
279 slpmsg->info = "SLP DATA PREP";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
280
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
281 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
282
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
283 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
284
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
285 MsnSlpMessage *msn_slpmsg_file_new(MsnSlpCall *slpcall, size_t size)
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
286 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
287 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
288
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
289 slpmsg = msn_slpmsg_new(NULL);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
290
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
291 slpmsg->slpcall = slpcall;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
292 slpmsg->flags = P2P_FILE_DATA;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
293 slpmsg->info = "SLP FILE";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
294 slpmsg->size = size;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
295
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
296 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
297 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
298
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
299 char *msn_slpmsg_serialize(MsnSlpMessage *slpmsg, size_t *ret_size)
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
300 {
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
301 MsnP2PHeader *header;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
302 MsnP2PFooter *footer;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
303 char *base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
304 char *tmp;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
305 size_t siz;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
306
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
307 base = g_malloc(P2P_PACKET_HEADER_SIZE + slpmsg->size + sizeof(MsnP2PFooter));
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
308 tmp = base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
309
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
310 header = msn_p2p_header_to_wire(slpmsg->header);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
311 footer = msn_p2p_footer_to_wire(slpmsg->footer);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
312
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
313 siz = sizeof(MsnP2PHeader);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
314 /* Copy header */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
315 memcpy(tmp, (char*)header, siz);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
316 tmp += siz;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
317
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
318 /* Copy body */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
319 memcpy(tmp, slpmsg->buffer, slpmsg->size);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
320 tmp += slpmsg->size;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
321
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
322 /* Copy footer */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
323 siz = sizeof(MsnP2PFooter);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
324 memcpy(tmp, (char*)footer, siz);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
325 tmp += siz;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
326
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
327 *ret_size = tmp - base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
328
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
329 return base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
330 }
31274
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
331
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
332 void msn_slpmsg_show_readable(MsnSlpMessage *slpmsg)
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
333 {
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
334 GString *str;
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
335
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
336 str = g_string_new(NULL);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
337
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
338 g_string_append_printf(str, "Session ID: %u\r\n", slpmsg->header->session_id);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
339 g_string_append_printf(str, "ID: %u\r\n", slpmsg->header->id);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
340 g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->offset);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
341 g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->total_size);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
342 g_string_append_printf(str, "Length: %u\r\n", slpmsg->header->length);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
343 g_string_append_printf(str, "Flags: 0x%x\r\n", slpmsg->header->flags);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
344 g_string_append_printf(str, "ACK ID: %u\r\n", slpmsg->header->ack_id);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
345 g_string_append_printf(str, "SUB ID: %u\r\n", slpmsg->header->ack_sub_id);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
346 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", slpmsg->header->ack_size);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
347
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
348 if (purple_debug_is_verbose() && slpmsg->buffer != NULL) {
31303
b785e4256a66 Fix a warning caused because slpmsg->buffer is unsigned and the function spect a gchar pointer. I don't think this can harm in any way.
masca@cpw.pidgin.im
parents: 31302
diff changeset
349 g_string_append_len(str, (gchar*)slpmsg->buffer, slpmsg->size);
31274
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
350
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
351 if (slpmsg->buffer[slpmsg->size - 1] == '\0') {
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
352 str->len--;
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
353 g_string_append(str, " 0x00");
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
354 }
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
355 g_string_append(str, "\r\n");
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
356
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
357 }
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
358
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
359 g_string_append_printf(str, "Footer: %u\r\n", slpmsg->footer->value);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
360
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
361 purple_debug_info("msn", "SlpMessage %s:\n{%s}\n", slpmsg->info, str->str);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
362 }