Mercurial > pidgin
annotate libpurple/protocols/msn/slpmsg.c @ 31086:a8cc50c2279f
Remove trailing whitespace
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 04 Jan 2011 06:55:30 +0000 |
parents | 7b771e6f1142 |
children | dcd407e6c004 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
30969
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30946
diff
changeset
|
2 * @file slpmsg.c SLP Message functions |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15822 | 4 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15822 | 6 * Purple is the legal property of its developers, whose names are too numerous |
15373
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 |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16528
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 */ |
30742
a99b6dcdb60d
Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents:
30089
diff
changeset
|
24 |
30758
230caecf5435
Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents:
30742
diff
changeset
|
25 #include "internal.h" |
30742
a99b6dcdb60d
Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents:
30089
diff
changeset
|
26 #include "debug.h" |
a99b6dcdb60d
Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents:
30089
diff
changeset
|
27 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "slpmsg.h" |
30823
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
29 #include "slpmsg_part.h" |
15373
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 |
27432
35b6fd563056
Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24390
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:
24390
diff
changeset
|
44 purple_debug_info("msn", "slpmsg new (%p)\n", slpmsg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31044
diff
changeset
|
46 if (slplink) |
30789
2c3d7104ef1e
Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents:
30788
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:
30788
diff
changeset
|
48 else |
30781
74e372b31486
Allow temporary SlpMessages so we can get slp specific code from MsnMessage.
masca@cpw.pidgin.im
parents:
30780
diff
changeset
|
49 slpmsg->slplink = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 |
30855
6814678f3c63
Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents:
30836
diff
changeset
|
51 slpmsg->header = g_new0(MsnP2PHeader, 1); |
30780
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:
30758
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:
30758
diff
changeset
|
53 |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 msn_slpmsg_destroy(MsnSlpMessage *slpmsg) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 MsnSlpLink *slplink; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 GList *cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 g_return_if_fail(slpmsg != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
27432
35b6fd563056
Change all MSN_DEBUG_* messages to use the new purple_debug_is_verbose call
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24390
diff
changeset
|
65 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:
24390
diff
changeset
|
66 purple_debug_info("msn", "slpmsg destroy (%p)\n", slpmsg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 slplink = slpmsg->slplink; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
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:
15822
diff
changeset
|
70 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:
15822
diff
changeset
|
71 |
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:
15822
diff
changeset
|
72 /* 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:
15822
diff
changeset
|
73 * 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:
15822
diff
changeset
|
74 if (slpmsg->img == NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 g_free(slpmsg->buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
30823
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
77 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:
30813
diff
changeset
|
78 { |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
79 /* Something is pointing to this slpmsg, so we should remove that |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
80 * pointer to prevent a crash. */ |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
81 /* 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:
30813
diff
changeset
|
82 |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
83 MsnSlpMessagePart *part = cur->data; |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
84 |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
85 part->ack_cb = NULL; |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
86 part->nak_cb = NULL; |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
87 part->ack_data = NULL; |
31036
05e05d96ba75
Use the unref functions everywhere, instead of destroy. I also removed
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
88 msn_slpmsgpart_unref(part); |
30823
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
89 } |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
90 |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
91 slplink->slp_msgs = g_list_remove(slplink->slp_msgs, slpmsg); |
ede71a46ef16
Destroy Parts when the SlpMessage is destroyed.
masca@cpw.pidgin.im
parents:
30813
diff
changeset
|
92 |
30780
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:
30758
diff
changeset
|
93 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:
30758
diff
changeset
|
94 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:
30758
diff
changeset
|
95 |
15373
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 |
30789
2c3d7104ef1e
Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
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:
30788
diff
changeset
|
110 |
2c3d7104ef1e
Since we can create a SlpMessage without a SlpLink, add a function to relate them post-creation.
masca@cpw.pidgin.im
parents:
30788
diff
changeset
|
111 void |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 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
|
113 long long size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 { |
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:
15822
diff
changeset
|
115 /* We can only have one data source at a time. */ |
16528
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->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
|
117 g_return_if_fail(slpmsg->img == NULL); |
28693
6aea98f6a5cd
Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27432
diff
changeset
|
118 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:
15822
diff
changeset
|
119 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 if (body != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 slpmsg->buffer = g_memdup(body, size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 slpmsg->buffer = g_new0(guchar, size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 slpmsg->size = size; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 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:
15822
diff
changeset
|
129 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:
15822
diff
changeset
|
130 { |
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:
15822
diff
changeset
|
131 /* We can only have one data source at a time. */ |
16528
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->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
|
133 g_return_if_fail(slpmsg->img == NULL); |
28693
6aea98f6a5cd
Get rid of slpmsg->fp since the core is handling all the partial reads and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27432
diff
changeset
|
134 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:
15822
diff
changeset
|
135 |
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:
15822
diff
changeset
|
136 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:
15822
diff
changeset
|
137 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:
15822
diff
changeset
|
138 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:
15822
diff
changeset
|
139 } |
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:
15822
diff
changeset
|
140 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 MsnSlpMessage * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 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
|
144 const char *header, const char *branch, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 const char *content_type, const char *content) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 MsnSlpLink *slplink; |
24390
c6c714b7841d
Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents:
23661
diff
changeset
|
148 PurpleAccount *account; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 MsnSlpMessage *slpmsg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 char *body; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 gsize body_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 gsize content_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 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
|
155 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
|
156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 slplink = slpcall->slplink; |
24390
c6c714b7841d
Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents:
23661
diff
changeset
|
158 account = slplink->session->account; |
15373
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 /* 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
|
161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 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
|
163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 body = g_strdup_printf( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 "%s\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 "To: <msnmsgr:%s>\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 "From: <msnmsgr:%s>\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 "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
|
169 "CSeq: %d\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 "Call-ID: {%s}\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 "Max-Forwards: 0\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 "Content-Type: %s\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 "\r\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 header, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 slplink->remote_user, |
24390
c6c714b7841d
Get rid of slplink->local_user because it's a copy of
Mark Doliner <mark@kingant.net>
parents:
23661
diff
changeset
|
177 purple_account_get_username(account), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 branch, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 cseq, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 slpcall->id, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 content_type, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 content_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 body_len = strlen(body); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 if (content_len > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 body_len += content_len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 body = g_realloc(body, body_len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 g_strlcat(body, content, body_len); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 slpmsg = msn_slpmsg_new(slplink); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 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
|
195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 slpmsg->sip = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 slpmsg->slpcall = slpcall; |
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 g_free(body); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 return slpmsg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 } |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
203 |
30792 | 204 MsnSlpMessage *msn_slpmsg_ack_new(MsnP2PHeader *header) |
30790
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
205 { |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
206 MsnSlpMessage *slpmsg; |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
207 |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
208 slpmsg = msn_slpmsg_new(NULL); |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
209 |
30855
6814678f3c63
Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents:
30836
diff
changeset
|
210 slpmsg->header->session_id = header->session_id; |
30790
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
211 slpmsg->size = header->total_size; |
30870
d9ca3798faa5
Get rid of the Flags field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents:
30867
diff
changeset
|
212 slpmsg->header->flags = P2P_ACK; |
30864
e32332ac385c
Get rid of the ack_id field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents:
30855
diff
changeset
|
213 slpmsg->header->ack_id = header->id; |
30866
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:
30865
diff
changeset
|
214 slpmsg->header->ack_sub_id = header->ack_id; |
30867
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:
30866
diff
changeset
|
215 slpmsg->header->ack_size = header->total_size; |
30790
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
216 slpmsg->info = "SLP ACK"; |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
217 |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
218 return slpmsg; |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
219 } |
545fa069c531
The creation of SlpMessage must be done in its own module.
masca@cpw.pidgin.im
parents:
30789
diff
changeset
|
220 |
30792 | 221 MsnSlpMessage *msn_slpmsg_obj_new(MsnSlpCall *slpcall, PurpleStoredImage *img) |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
222 { |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
223 MsnSlpMessage *slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
224 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
225 slpmsg = msn_slpmsg_new(NULL); |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
226 slpmsg->slpcall = slpcall; |
30870
d9ca3798faa5
Get rid of the Flags field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents:
30867
diff
changeset
|
227 slpmsg->header->flags = P2P_MSN_OBJ_DATA; |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
228 slpmsg->info = "SLP DATA"; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
229 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
230 msn_slpmsg_set_image(slpmsg, img); |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
231 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
232 return slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
233 } |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
234 |
30792 | 235 MsnSlpMessage *msn_slpmsg_dataprep_new(MsnSlpCall *slpcall) |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
236 { |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
237 MsnSlpMessage *slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
238 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
239 slpmsg = msn_slpmsg_new(NULL); |
30855
6814678f3c63
Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents:
30836
diff
changeset
|
240 |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
241 slpmsg->slpcall = slpcall; |
30855
6814678f3c63
Remove session_id from SlpMsg and use the one from the header.
masca@cpw.pidgin.im
parents:
30836
diff
changeset
|
242 slpmsg->header->session_id = slpcall->session_id; |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
243 msn_slpmsg_set_body(slpmsg, NULL, 4); |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
244 slpmsg->info = "SLP DATA PREP"; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
245 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
246 return slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
247 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
248 } |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
249 |
30792 | 250 MsnSlpMessage *msn_slpmsg_file_new(MsnSlpCall *slpcall, size_t size) |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
251 { |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
252 MsnSlpMessage *slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
253 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
254 slpmsg = msn_slpmsg_new(NULL); |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
255 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
256 slpmsg->slpcall = slpcall; |
30870
d9ca3798faa5
Get rid of the Flags field in the SlpMessage in favor of the one in the Header.
masca@cpw.pidgin.im
parents:
30867
diff
changeset
|
257 slpmsg->header->flags = P2P_FILE_DATA; |
30791
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
258 slpmsg->info = "SLP FILE"; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
259 slpmsg->size = size; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
260 |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
261 return slpmsg; |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
262 } |
64a6ce55aa63
Move more SlpMessage creation to its module.
masca@cpw.pidgin.im
parents:
30790
diff
changeset
|
263 |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
264 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:
30781
diff
changeset
|
265 { |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
266 char *header; |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
267 char *footer; |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
268 char *base; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
269 char *tmp; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
270 size_t siz; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
271 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
272 base = g_malloc(P2P_PACKET_HEADER_SIZE + slpmsg->size + P2P_PACKET_FOOTER_SIZE); |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
273 tmp = base; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
274 |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
275 header = msn_p2p_header_to_wire(slpmsg->header); |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
276 footer = msn_p2p_footer_to_wire(slpmsg->footer); |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
277 |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
278 siz = P2P_PACKET_HEADER_SIZE; |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
279 /* Copy header */ |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
280 memcpy(tmp, header, siz); |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
281 tmp += siz; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
282 |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
283 /* Copy body */ |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
284 memcpy(tmp, slpmsg->buffer, slpmsg->size); |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
285 tmp += slpmsg->size; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
286 |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
287 /* Copy footer */ |
31044
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
288 siz = P2P_PACKET_FOOTER_SIZE; |
7b771e6f1142
Change SLP P2P functions to use the new buffer access functions
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31036
diff
changeset
|
289 memcpy(tmp, footer, siz); |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
290 tmp += siz; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
291 |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
292 *ret_size = tmp - base; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
293 |
30934
4e097dfb7784
Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30870
diff
changeset
|
294 g_free(header); |
4e097dfb7784
Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30870
diff
changeset
|
295 g_free(footer); |
4e097dfb7784
Fix some leaks. Header and footer are allocated, copied and not freed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30870
diff
changeset
|
296 |
30783
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
297 return base; |
09f2a7d2ac99
Add SlpMessage parser and serializer functions to SlpMessage module.
masca@cpw.pidgin.im
parents:
30781
diff
changeset
|
298 } |
30836
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
299 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
300 void msn_slpmsg_show_readable(MsnSlpMessage *slpmsg) |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
301 { |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
302 GString *str; |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
303 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
304 str = g_string_new(NULL); |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
305 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
306 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:
30828
diff
changeset
|
307 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:
30828
diff
changeset
|
308 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:
30828
diff
changeset
|
309 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:
30828
diff
changeset
|
310 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:
30828
diff
changeset
|
311 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:
30828
diff
changeset
|
312 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:
30828
diff
changeset
|
313 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:
30828
diff
changeset
|
314 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:
30828
diff
changeset
|
315 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
316 if (purple_debug_is_verbose() && slpmsg->buffer != NULL) { |
30865
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:
30864
diff
changeset
|
317 g_string_append_len(str, (gchar*)slpmsg->buffer, slpmsg->size); |
30836
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
318 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
319 if (slpmsg->buffer[slpmsg->size - 1] == '\0') { |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
320 str->len--; |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
321 g_string_append(str, " 0x00"); |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
322 } |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
323 g_string_append(str, "\r\n"); |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
324 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
325 } |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
326 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
327 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:
30828
diff
changeset
|
328 |
237e2c2874e6
Add a function that will help debug of SlpMessages.
masca@cpw.pidgin.im
parents:
30828
diff
changeset
|
329 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:
30828
diff
changeset
|
330 } |