annotate libpurple/protocols/msn/slpmsg.c @ 32755:867104ed576a

Update MSN for 64-bit file transfers. Refs #8477.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 16 Oct 2011 07:01:52 +0000
parents cf702c6ab9e7
children
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 /**
31412
72e6fa6caecc These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31387
diff changeset
2 * @file slpmsg.c SLP Message functions
15374
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 *
32024
2201ecdf0c45 Add the slpcall as a parameter when creating a slpmsg.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32019
diff changeset
37 msn_slpmsg_new(MsnSlpLink *slplink, MsnSlpCall *slpcall)
15374
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;
32029
9a23c70bdb7a Get the P2P version based on the user. Still hard-coded as v1 though.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32028
diff changeset
40 MsnP2PVersion p2p;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
32035
5a6c5a4f1aea Let's not fool anyone here. The slplink is never NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
42 g_return_val_if_fail(slplink != NULL, NULL);
5a6c5a4f1aea Let's not fool anyone here. The slplink is never NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
43
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 slpmsg = g_new0(MsnSlpMessage, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
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
46 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
47 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
48
32035
5a6c5a4f1aea Let's not fool anyone here. The slplink is never NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32029
diff changeset
49 msn_slpmsg_set_slplink(slpmsg, slplink);
32024
2201ecdf0c45 Add the slpcall as a parameter when creating a slpmsg.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32019
diff changeset
50 slpmsg->slpcall = slpcall;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
32036
cf702c6ab9e7 Getting the P2P version is probably the slplink's job, since it has
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32035
diff changeset
52 p2p = msn_slplink_get_p2p_version(slplink);
32029
9a23c70bdb7a Get the P2P version based on the user. Still hard-coded as v1 though.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32028
diff changeset
53 slpmsg->p2p_info = msn_p2p_info_new(p2p);
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
54
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 return slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 msn_slpmsg_destroy(MsnSlpMessage *slpmsg)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 MsnSlpLink *slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 GList *cur;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 g_return_if_fail(slpmsg != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
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
66 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
67 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
68
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 slplink = slpmsg->slplink;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
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
71 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
72
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
73 /* 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
74 * 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
75 if (slpmsg->img == NULL)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 g_free(slpmsg->buffer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
31261
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
78 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
79 {
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
80 /* 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
81 * pointer to prevent a crash. */
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
82 /* 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
83
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
84 MsnSlpMessagePart *part = cur->data;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
85
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
86 part->ack_cb = NULL;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
87 part->nak_cb = NULL;
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
88 part->ack_data = NULL;
31483
05e05d96ba75 Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31412
diff changeset
89 msn_slpmsgpart_unref(part);
31261
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
90 }
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
91
ede71a46ef16 Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents: 31251
diff changeset
92 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
93
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
94 msn_p2p_info_free(slpmsg->p2p_info);
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
95
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 g_free(slpmsg);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 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
100 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
101 {
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
102 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
103
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
104 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
105
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
106 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
107 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
108 }
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
109
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
110 void
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 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
112 long long size)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 {
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
114 /* 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
115 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
116 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
117 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
118
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 if (body != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 slpmsg->buffer = g_memdup(body, size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 slpmsg->buffer = g_new0(guchar, size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 slpmsg->size = size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 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
128 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
129 {
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
130 /* 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
131 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
132 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
133 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
134
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
135 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
136 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
137 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
138 }
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
139
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 MsnSlpMessage *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 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
143 const char *header, const char *branch,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 const char *content_type, const char *content)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 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
147 PurpleAccount *account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 MsnSlpMessage *slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 char *body;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 gsize body_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 gsize content_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 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
154 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
155
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 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
157 account = slplink->session->account;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 /* 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
160
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 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
162
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 body = g_strdup_printf(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 "%s\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 "To: <msnmsgr:%s>\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 "From: <msnmsgr:%s>\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 "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
168 "CSeq: %d\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 "Call-ID: {%s}\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 "Max-Forwards: 0\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 "Content-Type: %s\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 "Content-Length: %" G_GSIZE_FORMAT "\r\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 "\r\n",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 header,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 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
176 purple_account_get_username(account),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 branch,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 cseq,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 slpcall->id,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 content_type,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 content_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 body_len = strlen(body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 if (content_len > 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 body_len += content_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 body = g_realloc(body, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 g_strlcat(body, content, body_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
32024
2201ecdf0c45 Add the slpcall as a parameter when creating a slpmsg.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32019
diff changeset
192 slpmsg = msn_slpmsg_new(slplink, slpcall);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 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
194
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 g_free(body);
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 return slpmsg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 }
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
199
32025
c23778d56269 Add the slplink as a parameter when creating a slpmsg ack.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32024
diff changeset
200 MsnSlpMessage *msn_slpmsg_ack_new(MsnSlpLink *slplink, MsnP2PInfo *ack_info)
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
201 {
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
202 MsnSlpMessage *slpmsg;
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
203 MsnP2PInfo *new_info;
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
204
32025
c23778d56269 Add the slplink as a parameter when creating a slpmsg ack.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32024
diff changeset
205 slpmsg = msn_slpmsg_new(slplink, NULL);
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
206
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
207 new_info = slpmsg->p2p_info;
32019
968103d932d6 Add P2Pv2 ack'ing.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31717
diff changeset
208 msn_p2p_info_create_ack(ack_info, new_info);
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
209 slpmsg->size = msn_p2p_info_get_total_size(ack_info);
31228
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
210 slpmsg->info = "SLP ACK";
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
211
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
212 return slpmsg;
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
213 }
545fa069c531 The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents: 31227
diff changeset
214
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
215 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
216 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
217 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
218
32028
8f3cb00ad798 Get the slplink from the slpcall as needed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32025
diff changeset
219 slpmsg = msn_slpmsg_new(slpcall->slplink, slpcall);
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
220 msn_p2p_info_set_flags(slpmsg->p2p_info, P2P_MSN_OBJ_DATA);
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
221 slpmsg->info = "SLP DATA";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
222
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
223 msn_slpmsg_set_image(slpmsg, img);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
224
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
225 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
226 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
227
31230
9192c59f2f84 Use better function names.
masca@cpw.pidgin.im
parents: 31229
diff changeset
228 MsnSlpMessage *msn_slpmsg_dataprep_new(MsnSlpCall *slpcall)
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
229 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
230 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
231
32028
8f3cb00ad798 Get the slplink from the slpcall as needed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32025
diff changeset
232 slpmsg = msn_slpmsg_new(slpcall->slplink, slpcall);
31293
6814678f3c63 Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents: 31274
diff changeset
233
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
234 msn_p2p_info_set_session_id(slpmsg->p2p_info, slpcall->session_id);
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
235 msn_slpmsg_set_body(slpmsg, NULL, 4);
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
236 slpmsg->info = "SLP DATA PREP";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
237
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
238 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
239
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
240 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
241
32755
867104ed576a Update MSN for 64-bit file transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32036
diff changeset
242 MsnSlpMessage *msn_slpmsg_file_new(MsnSlpCall *slpcall, goffset size)
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
243 {
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
244 MsnSlpMessage *slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
245
32028
8f3cb00ad798 Get the slplink from the slpcall as needed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32025
diff changeset
246 slpmsg = msn_slpmsg_new(slpcall->slplink, slpcall);
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
247
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
248 msn_p2p_info_set_flags(slpmsg->p2p_info, P2P_FILE_DATA);
31229
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
249 slpmsg->info = "SLP FILE";
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
250 slpmsg->size = size;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
251
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
252 return slpmsg;
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
253 }
64a6ce55aa63 Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents: 31228
diff changeset
254
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
255 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
256 {
31491
7b771e6f1142 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31483
diff changeset
257 char *header;
7b771e6f1142 Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31483
diff changeset
258 char *footer;
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
259 char *base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
260 char *tmp;
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
261 size_t header_size, footer_size;
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
262
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
263 header = msn_p2p_header_to_wire(slpmsg->p2p_info, &header_size);
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
264 footer = msn_p2p_footer_to_wire(slpmsg->p2p_info, &footer_size);
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
265
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
266 base = g_malloc(header_size + slpmsg->size + footer_size);
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
267 tmp = base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
268
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
269 /* Copy header */
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
270 memcpy(tmp, header, header_size);
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
271 tmp += header_size;
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
272
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
273 /* Copy body */
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
274 memcpy(tmp, slpmsg->buffer, slpmsg->size);
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
275 tmp += slpmsg->size;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
276
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
277 /* Copy footer */
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
278 memcpy(tmp, footer, footer_size);
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
279 tmp += footer_size;
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
280
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
281 *ret_size = tmp - base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
282
31375
4e097dfb7784 Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31308
diff changeset
283 g_free(header);
4e097dfb7784 Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31308
diff changeset
284 g_free(footer);
4e097dfb7784 Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31308
diff changeset
285
31221
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
286 return base;
09f2a7d2ac99 Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents: 31219
diff changeset
287 }
31274
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
288
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
289 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
290 {
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
291 GString *str;
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
292
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
293 str = g_string_new(NULL);
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
294
31599
34da321b60f1 Try to hide all P2P fields away behind accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31590
diff changeset
295 msn_p2p_info_to_string(slpmsg->p2p_info, str);
31274
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
296
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
297 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
298 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
299
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
300 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
301 str->len--;
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
302 g_string_append(str, " 0x00");
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
303 }
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
304 g_string_append(str, "\r\n");
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
305
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
306 }
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
307
237e2c2874e6 Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents: 31266
diff changeset
308 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
309 }