Mercurial > pidgin
annotate libpurple/protocols/msn/xfer.c @ 32253:9173ec5a45cf
merge of '1b285d0b375fbd5e778db6bb852a7b089feb16a3'
and 'd1328041ee003fdee29a0cf6ae44b44727a49bb8'
author | Kevin Stange <kevin@simguy.net> |
---|---|
date | Sun, 02 Oct 2011 00:06:40 +0000 |
parents | 92711688c245 |
children | 845885bd5e4d |
rev | line source |
---|---|
30969
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
1 /** |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
2 * @file xfer.c MSN File Transfer functions |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
3 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
4 * purple |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
5 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
8 * source distribution. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
9 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
13 * (at your option) any later version. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
14 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
18 * GNU General Public License for more details. |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
19 * |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
23 */ |
72e6fa6caecc
These new files are missing GPL headers. And fix a couple incorrect
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30832
diff
changeset
|
24 |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
25 #include "internal.h" |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
26 #include "debug.h" |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
27 |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
28 #include "msnutils.h" |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
29 #include "sbconn.h" |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
30 #include "xfer.h" |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
31 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
32 /************************************************************************** |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
33 * Xfer |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
34 **************************************************************************/ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
35 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
36 void |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
37 msn_xfer_init(PurpleXfer *xfer) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
38 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
39 MsnSlpCall *slpcall; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
40 /* MsnSlpLink *slplink; */ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
41 char *content; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
42 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
43 purple_debug_info("msn", "xfer_init\n"); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
44 |
31963
92711688c245
Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents:
31118
diff
changeset
|
45 slpcall = purple_xfer_get_protocol_data(xfer); |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
46 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
47 /* Send Ok */ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
48 content = g_strdup_printf("SessionID: %lu\r\n\r\n", |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
49 slpcall->session_id); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
50 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
51 msn_slp_send_ok(slpcall, slpcall->branch, "application/x-msnmsgr-sessionreqbody", |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
52 content); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
53 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
54 g_free(content); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
55 msn_slplink_send_queued_slpmsgs(slpcall->slplink); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
56 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
57 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
58 void |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
59 msn_xfer_cancel(PurpleXfer *xfer) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
60 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
61 MsnSlpCall *slpcall; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
62 char *content; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
63 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
64 g_return_if_fail(xfer != NULL); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
65 |
31963
92711688c245
Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents:
31118
diff
changeset
|
66 slpcall = purple_xfer_get_protocol_data(xfer); |
92711688c245
Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents:
31118
diff
changeset
|
67 g_return_if_fail(slpcall != NULL); |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
68 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
69 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
70 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
71 if (slpcall->started) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
72 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
73 msn_slpcall_close(slpcall); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
74 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
75 else |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
76 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
77 content = g_strdup_printf("SessionID: %lu\r\n\r\n", |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
78 slpcall->session_id); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
79 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
80 msn_slp_send_decline(slpcall, slpcall->branch, "application/x-msnmsgr-sessionreqbody", |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
81 content); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
82 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
83 g_free(content); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
84 msn_slplink_send_queued_slpmsgs(slpcall->slplink); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
85 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
86 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
87 slpcall->wasted = TRUE; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
88 else |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
89 msn_slpcall_destroy(slpcall); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
90 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
91 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
92 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
93 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
94 gssize |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
95 msn_xfer_write(const guchar *data, gsize len, PurpleXfer *xfer) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
96 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
97 MsnSlpCall *slpcall; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
98 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
99 g_return_val_if_fail(xfer != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
100 g_return_val_if_fail(data != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
101 g_return_val_if_fail(len > 0, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
102 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
103 g_return_val_if_fail(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
104 |
31963
92711688c245
Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents:
31118
diff
changeset
|
105 slpcall = purple_xfer_get_protocol_data(xfer); |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
106 /* Not sure I trust it'll be there */ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
107 g_return_val_if_fail(slpcall != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
108 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
109 g_return_val_if_fail(slpcall->xfer_msg != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
110 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
111 slpcall->u.outgoing.len = len; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
112 slpcall->u.outgoing.data = data; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
113 msn_slplink_send_msgpart(slpcall->slplink, slpcall->xfer_msg); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
114 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
115 return MIN(MSN_SBCONN_MAX_SIZE, len); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
116 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
117 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
118 gssize |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
119 msn_xfer_read(guchar **data, PurpleXfer *xfer) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
120 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
121 MsnSlpCall *slpcall; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
122 gsize len; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
123 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
124 g_return_val_if_fail(xfer != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
125 g_return_val_if_fail(data != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
126 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
127 g_return_val_if_fail(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
128 |
31963
92711688c245
Convert the msn prpl to use the new API.
andrew.victor@mxit.com
parents:
31118
diff
changeset
|
129 slpcall = purple_xfer_get_protocol_data(xfer); |
30832
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
130 /* Not sure I trust it'll be there */ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
131 g_return_val_if_fail(slpcall != NULL, -1); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
132 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
133 /* Just pass up the whole GByteArray. We'll make another. */ |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
134 *data = slpcall->u.incoming_data->data; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
135 len = slpcall->u.incoming_data->len; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
136 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
137 g_byte_array_free(slpcall->u.incoming_data, FALSE); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
138 slpcall->u.incoming_data = g_byte_array_new(); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
139 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
140 return len; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
141 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
142 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
143 void |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
144 msn_xfer_end_cb(MsnSlpCall *slpcall, MsnSession *session) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
145 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
146 if ((purple_xfer_get_status(slpcall->xfer) != PURPLE_XFER_STATUS_DONE) && |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
147 (purple_xfer_get_status(slpcall->xfer) != PURPLE_XFER_STATUS_CANCEL_REMOTE) && |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
148 (purple_xfer_get_status(slpcall->xfer) != PURPLE_XFER_STATUS_CANCEL_LOCAL)) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
149 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
150 purple_xfer_cancel_remote(slpcall->xfer); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
151 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
152 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
153 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
154 void |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
155 msn_xfer_completed_cb(MsnSlpCall *slpcall, const guchar *body, |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
156 gsize size) |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
157 { |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
158 PurpleXfer *xfer = slpcall->xfer; |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
159 |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
160 purple_xfer_set_completed(xfer, TRUE); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
161 purple_xfer_end(xfer); |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
162 } |
eabeba9c823f
Move msn_xfer code to it's own module aiming to simplify slp code.
masca@cpw.pidgin.im
parents:
diff
changeset
|
163 |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
164 gchar * |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
165 msn_file_context_to_wire(MsnFileContext *context) |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
166 { |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
167 gchar *ret, *tmp; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
168 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
169 tmp = ret = g_new(gchar, MSN_FILE_CONTEXT_SIZE + context->preview_len + 1); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
170 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
171 msn_push32le(tmp, context->length); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
172 msn_push32le(tmp, context->version); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
173 msn_push64le(tmp, context->file_size); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
174 msn_push32le(tmp, context->type); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
175 memcpy(tmp, context->file_name, MAX_FILE_NAME_LEN * 2); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
176 tmp += MAX_FILE_NAME_LEN * 2; |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
177 memcpy(tmp, context->unknown1, sizeof(context->unknown1)); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
178 tmp += sizeof(context->unknown1); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
179 msn_push32le(tmp, context->unknown2); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
180 if (context->preview) { |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
181 memcpy(tmp, context->preview, context->preview_len); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
182 } |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
183 tmp[context->preview_len] = '\0'; |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
184 |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
185 return ret; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
186 } |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
187 |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
188 MsnFileContext * |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
189 msn_file_context_from_wire(const char *buf, gsize len) |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
190 { |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
191 MsnFileContext *context; |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
192 |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
193 if (!buf || len < MSN_FILE_CONTEXT_SIZE) |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
194 return NULL; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
195 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
196 context = g_new(MsnFileContext, 1); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
197 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
198 context->length = msn_pop32le(buf); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
199 context->version = msn_pop32le(buf); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
200 if (context->version == 2) { |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
201 /* The length field is broken for this version. No check. */ |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
202 context->length = MSN_FILE_CONTEXT_SIZE; |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
203 } else if (context->version == 3) { |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
204 if (context->length != MSN_FILE_CONTEXT_SIZE + 63) { |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
205 g_free(context); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
206 return NULL; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
207 } else if (len < MSN_FILE_CONTEXT_SIZE + 63) { |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
208 g_free(context); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
209 return NULL; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
210 } |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
211 } else { |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
212 purple_debug_warning("msn", "Received MsnFileContext with unknown version: %d\n", context->version); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
213 g_free(context); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
214 return NULL; |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
215 } |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
216 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
217 context->file_size = msn_pop64le(buf); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
218 context->type = msn_pop32le(buf); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
219 memcpy(context->file_name, buf, MAX_FILE_NAME_LEN * 2); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
220 buf += MAX_FILE_NAME_LEN * 2; |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
221 memcpy(context->unknown1, buf, sizeof(context->unknown1)); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
222 buf += sizeof(context->unknown1); |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
223 context->unknown2 = msn_pop32le(buf); |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
224 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
225 if (context->type == 0 && len > context->length) { |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
226 context->preview_len = len - context->length; |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
227 context->preview = g_memdup(buf, context->preview_len); |
31055
d2d6668bde34
Fix a crash on receiving a file with no preview that I just introduced
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31046
diff
changeset
|
228 } else { |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
229 context->preview_len = 0; |
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
230 context->preview = NULL; |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
231 } |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
232 |
31118
9ccbd0302bb2
Change MsnFileContext variables from "header" to "context". This it
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31055
diff
changeset
|
233 return context; |
31046
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
234 } |
b4064198e017
Add functions for reading and writing a MsnFileContext which negates
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30969
diff
changeset
|
235 |