annotate libpurple/protocols/msn/slpmsg_part.c @ 31278:df3e9c686b02

Update tmp pointer after reading the header.
author masca@cpw.pidgin.im
date Sat, 03 Jul 2010 06:55:33 +0000
parents a743c25b27a8
children 98cd0ea847ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31234
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
1 #include "internal.h"
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
2
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
3 #include "slpmsg.h"
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
4 #include "slpmsg_part.h"
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
5
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
6 MsnSlpMessagePart *msn_slpmsgpart_new(MsnP2PHeader *header, MsnP2PFooter *footer)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
7 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
8 MsnSlpMessagePart *part;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
9
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
10 part = g_new0(MsnSlpMessagePart, 1);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
11
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
12 if (header)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
13 part->header = g_memdup(header, P2P_PACKET_HEADER_SIZE);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
14 if (footer)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
15 part->footer = g_memdup(footer, P2P_PACKET_FOOTER_SIZE);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
16
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
17 part->ack_cb = msn_slpmsgpart_ack;
31260
e0dd17804079 Fix typo.
masca@cpw.pidgin.im
parents: 31234
diff changeset
18 part->nak_cb = msn_slpmsgpart_nak;
31234
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
19
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
20 return part;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
21 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
22
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
23 MsnSlpMessagePart *msn_slpmsgpart_new_from_data(const char *data, size_t data_len)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
24 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
25 MsnSlpMessagePart *part;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
26 MsnP2PHeader *header;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
27 const char *tmp;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
28 int body_len;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
29
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
30 tmp = data;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
31 part = msn_slpmsgpart_new(NULL, NULL);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
32
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
33 if (data_len < sizeof(*header)) {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
34 return NULL;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
35 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
36
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
37 /* Extract the binary SLP header */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
38 part->header = msn_p2p_header_from_wire((MsnP2PHeader*)tmp);
31278
df3e9c686b02 Update tmp pointer after reading the header.
masca@cpw.pidgin.im
parents: 31262
diff changeset
39 tmp += P2P_PACKET_HEADER_SIZE;
31234
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
40
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
41 /* Extract the body */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
42 body_len = data_len - (tmp - data);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
43 /* msg->body_len = msg->msnslp_header.length; */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
44
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
45 if (body_len > 0) {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
46 part->size = body_len;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
47 part->buffer = g_malloc(body_len);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
48 memcpy(part->buffer, tmp, body_len);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
49 tmp += body_len;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
50 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
51
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
52 /* Extract the footer */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
53 if (body_len >= 0)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
54 part->footer = msn_p2p_footer_from_wire((MsnP2PFooter*)tmp);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
55
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
56 return part;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
57 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
58
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
59 void msn_slpmsgpart_destroy(MsnSlpMessagePart *part)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
60 {
31262
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 31260
diff changeset
61 if (!part)
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 31260
diff changeset
62 return;
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 31260
diff changeset
63
31234
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
64 g_free(part->header);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
65 g_free(part->footer);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
66
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
67 g_free(part);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
68
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
69 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
70
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
71 void msn_slpmsgpart_set_bin_data(MsnSlpMessagePart *part, const void *data, size_t len)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
72 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
73 g_return_if_fail(part != NULL);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
74
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
75 if (part->buffer != NULL)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
76 g_free(part->buffer);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
77
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
78 if (data != NULL && len > 0) {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
79 part->buffer = g_malloc(len + 1);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
80 memcpy(part->buffer, data, len);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
81 part->buffer[len] = '\0';
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
82 part->size = len;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
83 } else {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
84 part->buffer = NULL;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
85 part->size = 0;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
86 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
87
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
88 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
89
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
90 char *msn_slpmsgpart_serialize(MsnSlpMessagePart *part, size_t *ret_size)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
91 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
92 MsnP2PHeader *header;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
93 MsnP2PFooter *footer;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
94 char *base;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
95 char *tmp;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
96 size_t siz;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
97
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
98 base = g_malloc(P2P_PACKET_HEADER_SIZE + part->size + sizeof(MsnP2PFooter));
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
99 tmp = base;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
100
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
101 header = msn_p2p_header_to_wire(part->header);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
102 footer = msn_p2p_footer_to_wire(part->footer);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
103
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
104 siz = sizeof(MsnP2PHeader);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
105 /* Copy header */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
106 memcpy(tmp, (char*)header, siz);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
107 tmp += siz;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
108
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
109 /* Copy body */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
110 memcpy(tmp, part->buffer, part->size);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
111 tmp += part->size;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
112
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
113 /* Copy footer */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
114 siz = sizeof(MsnP2PFooter);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
115 memcpy(tmp, (char*)footer, siz);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
116 tmp += siz;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
117
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
118 *ret_size = tmp - base;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
119
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
120 return base;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
121 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
122 /* We have received the message ack */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
123 void
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
124 msn_slpmsgpart_ack(MsnSlpMessagePart *part, void *data)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
125 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
126 MsnSlpMessage *slpmsg;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
127 long long real_size;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
128
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
129 slpmsg = data;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
130
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
131 real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
132
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
133 slpmsg->offset += part->header->length;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
134
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
135 slpmsg->parts = g_list_remove(slpmsg->parts, part);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
136
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
137 if (slpmsg->offset < real_size)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
138 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
139 if (slpmsg->slpcall->xfer && purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
140 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
141 slpmsg->slpcall->xfer_msg = slpmsg;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
142 purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
143 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
144 else
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
145 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
146 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
147 else
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
148 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
149 /* The whole message has been sent */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
150 if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
151 slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
152 slpmsg->flags == P2P_FILE_DATA)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
153 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
154 if (slpmsg->slpcall != NULL)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
155 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
156 if (slpmsg->slpcall->cb)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
157 slpmsg->slpcall->cb(slpmsg->slpcall,
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
158 NULL, 0);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
159 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
160 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
161 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
162 }
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
163
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
164 /* We have received the message nak. */
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
165 void
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
166 msn_slpmsgpart_nak(MsnSlpMessagePart *part, void *data)
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
167 {
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
168 MsnSlpMessage *slpmsg;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
169
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
170 slpmsg = data;
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
171
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
172 msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
173
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
174 slpmsg->parts = g_list_remove(slpmsg->parts, part);
e545b2b6f66a Introduce SlpMessagePart, It will replace MsnMessage in every Slp related code so MsnMessage just get used where it makes sense, in the Switchboard.
masca@cpw.pidgin.im
parents:
diff changeset
175 }