annotate libpurple/protocols/msn/slpmsg_part.c @ 30847:74c4aa38adfc

Add support to ref/unref SlpMessageParts.
author masca@cpw.pidgin.im
date Tue, 06 Jul 2010 19:00:21 +0000
parents 98cd0ea847ec
children e358e16e527f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30796
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;
30822
e0dd17804079 Fix typo.
masca@cpw.pidgin.im
parents: 30796
diff changeset
18 part->nak_cb = msn_slpmsgpart_nak;
30796
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
30847
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
20 return msn_slpmsgpart_ref(part);
30796
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);
30840
df3e9c686b02 Update tmp pointer after reading the header.
masca@cpw.pidgin.im
parents: 30824
diff changeset
39 tmp += P2P_PACKET_HEADER_SIZE;
30796
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 */
30843
98cd0ea847ec Properly set the body_len of the SlpMessagePart, this set correctly the footer value.
masca@cpw.pidgin.im
parents: 30840
diff changeset
42 body_len = data_len - P2P_PACKET_HEADER_SIZE - P2P_PACKET_FOOTER_SIZE;
30796
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 {
30824
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 30822
diff changeset
61 if (!part)
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 30822
diff changeset
62 return;
a743c25b27a8 Destroying Parts return silently when it's passed a NULL pointer.
masca@cpw.pidgin.im
parents: 30822
diff changeset
63
30847
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
64 if (part->ref_count > 0) {
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
65 msn_slpmsgpart_unref(part);
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
66
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
67 return;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
68 }
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
69
30796
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 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
71 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
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_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
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 }
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
30847
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
77 MsnSlpMessagePart *msn_slpmsgpart_ref(MsnSlpMessagePart *part)
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
78 {
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
79 g_return_val_if_fail(part != NULL, NULL);
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
80 part->ref_count ++;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
81
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
82 return part;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
83 }
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
84
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
85 MsnSlpMessagePart *msn_slpmsgpart_unref(MsnSlpMessagePart *part)
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
86 {
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
87 g_return_val_if_fail(part != NULL, NULL);
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
88 g_return_val_if_fail(part->ref_count > 0, NULL);
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
89
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
90 part->ref_count--;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
91
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
92 if (part->ref_count == 0) {
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
93 msn_slpmsgpart_destroy(part);
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
94
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
95 return NULL;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
96 }
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
97
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
98 return part;
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
99 }
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30843
diff changeset
100
30796
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 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
102 {
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 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
104
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 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
106 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
107
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 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
109 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
110 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
111 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
112 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
113 } 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
114 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
115 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
116 }
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 }
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 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
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 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
123 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
124 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
125 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
126 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
127
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 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
129 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
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 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
132 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
133
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 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
135 /* 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
136 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
137 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
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 /* 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
140 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
141 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
142
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 /* 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
144 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
145 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
146 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
147
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 *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
149
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 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
151 }
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 /* 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
153 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
154 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
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 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
157 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
158
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 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
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 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
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 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
164
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 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
166
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 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
168 {
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 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
170 {
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 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
172 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
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 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
175 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
176 }
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
177 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
178 {
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
179 /* 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
180 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
181 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
182 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
183 {
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
184 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
185 {
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
186 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
187 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
188 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
189 }
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
190 }
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
191 }
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
192 }
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
193
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
194 /* 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
195 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
196 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
197 {
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
198 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
199
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
200 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
201
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
202 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
203
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
204 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
205 }