annotate src/protocols/msn/ft.c @ 8420:c25c697525b7

[gaim-migrate @ 9150] Phase II. If anyone finds anything problematic here that can't be attributed to GtkIMHtml itself, please let me know (I'll probably tell you it can be attributed to GtkIMHtml itself ;)). Love, Sean. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 10 Mar 2004 06:10:00 +0000
parents b7e113a59b51
children 61602bc26a65
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file msn.c The MSN protocol plugin
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5914
diff changeset
7 *
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "msn.h"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
4546
a951bb590857 [gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4542
diff changeset
25 #ifdef _WIN32
a951bb590857 [gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4542
diff changeset
26 #include "win32dep.h"
a951bb590857 [gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4542
diff changeset
27 #endif
a951bb590857 [gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4542
diff changeset
28
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 static struct gaim_xfer *
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
30 find_xfer_by_cookie(GaimConnection *gc, unsigned long cookie)
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 GSList *g;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 struct msn_data *md = (struct msn_data *)gc->proto_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 struct gaim_xfer *xfer = NULL;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 for (g = md->file_transfers; g != NULL; g = g->next) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 xfer = (struct gaim_xfer *)g->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 if (xfer_data->cookie == cookie)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 break;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 xfer = NULL;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 return xfer;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 static void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 msn_xfer_init(struct gaim_xfer *xfer)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
53 GaimAccount *account;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 struct msn_switchboard *ms;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 char header[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 char buf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 account = gaim_xfer_get_account(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 ms = msn_find_switch(account->gc, xfer->who);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 * NOTE: We actually have to wait for the next Invitation message
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 * before the transfer starts. We handle that in
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 * msn_xfer_start().
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 g_snprintf(header, sizeof(header),
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 "MIME-Version: 1.0\r\n"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 "Invitation-Command: ACCEPT\r\n"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 "Invitation-Cookie: %lu\r\n"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 "Launch-Application: FALSE\r\n"
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 "Request-Data: IP-Address:\r\n",
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 (unsigned long)xfer_data->cookie);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n",
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 ++ms->trId, strlen(header) + strlen("\r\n\r\n"),
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 header);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 msn_kill_switch(ms);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 gaim_xfer_destroy(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 static void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 msn_xfer_start(struct gaim_xfer *xfer)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 xfer_data->transferring = TRUE;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 char sendbuf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 /* Send the TFR string to request the start of a transfer. */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 if (msn_write(xfer->fd, sendbuf, strlen(sendbuf)) < 0) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
110 gaim_xfer_cancel_remote(xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 static void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 msn_xfer_end(struct gaim_xfer *xfer)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
118 GaimAccount *account;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 struct msn_data *md;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 account = gaim_xfer_get_account(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 md = (struct msn_data *)account->gc->proto_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 char sendbuf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 g_snprintf(sendbuf, sizeof(sendbuf), "BYE 16777989\r\n");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 msn_write(xfer->fd, sendbuf, strlen(sendbuf));
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 md->file_transfers = g_slist_remove(md->file_transfers, xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 g_free(xfer_data);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 xfer->data = NULL;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 static void
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
141 msn_xfer_cancel_send(struct gaim_xfer *xfer)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
142 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
143 GaimAccount *account;
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
144 struct msn_xfer_data *xfer_data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
145 struct msn_data *md;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
146
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
147 xfer_data = (struct msn_xfer_data *)xfer->data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
148
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
149 xfer_data->do_cancel = TRUE;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
150
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
151 account = gaim_xfer_get_account(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
152 md = (struct msn_data *)account->gc->proto_data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
153
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
154 md->file_transfers = g_slist_remove(md->file_transfers, xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
155
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
156 g_free(xfer_data);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
157 xfer->data = NULL;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
158 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
159
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
160 static void
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
161 msn_xfer_cancel_recv(struct gaim_xfer *xfer)
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
163 GaimAccount *account;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 struct msn_data *md;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 account = gaim_xfer_get_account(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 md = (struct msn_data *)account->gc->proto_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
171 md->file_transfers = g_slist_remove(md->file_transfers, xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
173 g_free(xfer_data);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
174 xfer->data = NULL;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 static size_t
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 msn_xfer_read(char **buffer, struct gaim_xfer *xfer)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
180 struct msn_xfer_data *xfer_data;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 unsigned char header[3];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 size_t len, size;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
184 xfer_data = (struct msn_xfer_data *)xfer->data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
185
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
186 if (xfer_data->do_cancel)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
187 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
188 write(xfer->fd, "CCL\n", 4);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
189
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
190 return 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
191 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
192
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 if (read(xfer->fd, header, sizeof(header)) < 3) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 gaim_xfer_set_completed(xfer, TRUE);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 return 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 if (header[0] != 0) {
5221
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
199 gaim_debug(GAIM_DEBUG_ERROR, "msn",
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
200 "MSNFTP: Invalid header[0]: %d. Aborting.\n",
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
201 header[0]);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 return 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 size = header[1] | (header[2] << 8);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 *buffer = g_new0(char, size);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 for (len = 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 len < size;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 len += read(xfer->fd, *buffer + len, size - len))
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 ;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 if (len == 0)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 gaim_xfer_set_completed(xfer, TRUE);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 return len;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 static size_t
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 msn_xfer_write(const char *buffer, size_t size, struct gaim_xfer *xfer)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
223 GaimAccount *account;
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
224 struct msn_xfer_data *xfer_data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
225 struct msn_data *md;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
226 unsigned char header[3];
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
227
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
228 xfer_data = (struct msn_xfer_data *)xfer->data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
229 account = gaim_xfer_get_account(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
230 md = (struct msn_data *)account->gc->proto_data;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
231
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
232 if (xfer_data->do_cancel)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
233 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
234 header[0] = 1;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
235 header[1] = 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
236 header[2] = 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
237
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
238 if (write(xfer->fd, header, sizeof(header)) < 3) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
239 gaim_xfer_cancel_remote(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
240 return 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
241 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
242 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
243 else
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
244 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
245 /* Not implemented yet. */
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
246 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
247
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 return 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 static int
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 msn_process_msnftp(struct gaim_xfer *xfer, gint source, const char *buf)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 struct msn_xfer_data *xfer_data;
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
255 GaimAccount *account;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 char sendbuf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 account = gaim_xfer_get_account(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4675
diff changeset
261 if (!g_ascii_strncasecmp(buf, "VER MSNFTP", 10)) {
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 /* Send the USR string */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 g_snprintf(sendbuf, sizeof(sendbuf), "USR %s %lu\r\n",
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 account->gc->username,
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 (unsigned long)xfer_data->authcookie);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 if (msn_write(source, sendbuf, strlen(sendbuf)) < 0) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
268 gaim_xfer_cancel_remote(xfer); /* ? */
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 return 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 }
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4675
diff changeset
273 else if (!g_ascii_strncasecmp(buf, "FIL", 3)) {
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 gaim_input_remove(xfer_data->inpa);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 xfer_data->inpa = 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 gaim_xfer_start(xfer, source, NULL, 0);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 #if 0
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 char *tmp = buf;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 * This data is the size, but we already have
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 * the size, so who cares.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 /* Send the TFR string to request the start of a transfer. */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 if (msn_write(source, sendbuf, strlen(sendbuf)) < 0) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 gaim_xfer_cancel(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 return 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 #endif
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 return 1;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 static void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 msn_msnftp_cb(gpointer data, gint source, GaimInputCondition cond)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 struct gaim_xfer *xfer;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 char buf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 gboolean cont = TRUE;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 size_t len;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 xfer = (struct gaim_xfer *)data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 len = read(source, buf, sizeof(buf));
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 if (len <= 0) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
317 gaim_xfer_cancel_remote(xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 xfer_data->rxqueue = g_realloc(xfer_data->rxqueue,
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 len + xfer_data->rxlen);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 memcpy(xfer_data->rxqueue + xfer_data->rxlen, buf, len);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 xfer_data->rxlen += len;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 while (cont) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 char *end = xfer_data->rxqueue;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 char *cmd;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 int cmdlen;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 int i = 0;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 if (!xfer_data->rxlen)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 for (i = 0; i < xfer_data->rxlen - 1; end++, i++) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 if (*end == '\r' && *(end + 1) == '\n')
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 break;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 if (i == xfer_data->rxlen - 1)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 cmdlen = end - xfer_data->rxqueue + 2;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 cmd = xfer_data->rxqueue;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 xfer_data->rxlen -= cmdlen;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 if (xfer_data->rxlen)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 xfer_data->rxqueue = g_memdup(cmd + cmdlen, xfer_data->rxlen);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 else {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 xfer_data->rxqueue = NULL;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 cmd = g_realloc(cmd, cmdlen + 1);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 cmd[cmdlen] = '\0';
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 g_strchomp(cmd);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 cont = msn_process_msnftp(xfer, source, cmd);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 g_free(cmd);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 static void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 msn_msnftp_connect(gpointer data, gint source, GaimInputCondition cond)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
368 GaimAccount *account;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 struct gaim_xfer *xfer;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 char buf[MSN_BUF_LEN];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 xfer = (struct gaim_xfer *)data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 account = gaim_xfer_get_account(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376
5914
1344aeab6baa [gaim-migrate @ 6346]
Nathan Walp <nwalp@pidgin.im>
parents: 5912
diff changeset
377 if (source == -1 || !g_slist_find(gaim_connections_get_all(), account->gc)) {
5221
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
378 gaim_debug(GAIM_DEBUG_ERROR, "msn",
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
379 "MSNFTP: Error establishing connection\n");
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 close(source);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
382 gaim_xfer_cancel_remote(xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 g_snprintf(buf, sizeof(buf), "VER MSNFTP\r\n");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 if (msn_write(source, buf, strlen(buf)) < 0) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
390 gaim_xfer_cancel_remote(xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 xfer_data->inpa = gaim_input_add(source, GAIM_INPUT_READ,
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 msn_msnftp_cb, xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 void
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 msn_process_ft_msg(struct msn_switchboard *ms, char *msg)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 struct gaim_xfer *xfer;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 struct msn_xfer_data *xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 struct msn_data *md = ms->gc->proto_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 char *tmp = msg;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 if (strstr(msg, "Application-GUID: " MSN_FT_GUID) &&
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 strstr(msg, "Invitation-Command: INVITE")) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 * First invitation message, requesting an ACCEPT or CANCEL from
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 * the recipient. Used in incoming file transfers.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 char *filename;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 char *cookie_s, *filesize_s;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 tmp = strstr(msg, "Invitation-Cookie");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 cookie_s = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 filename = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 /* Needed for filenames with spaces */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 tmp = strchr(tmp, '\r');
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 *tmp = '\0';
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 tmp += 2;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 filesize_s = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 /* Setup the MSN-specific file transfer data */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 xfer_data = g_new0(struct msn_xfer_data, 1);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435 xfer_data->cookie = atoi(cookie_s);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 xfer_data->transferring = FALSE;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 /* Build the file transfer handle. */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 xfer = gaim_xfer_new(ms->gc->account, GAIM_XFER_RECEIVE, ms->msguser);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 xfer->data = xfer_data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 /* Set the info about the incoming file. */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 gaim_xfer_set_filename(xfer, filename);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 gaim_xfer_set_size(xfer, atoi(filesize_s));
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 /* Setup our I/O op functions */
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
447 gaim_xfer_set_init_fnc(xfer, msn_xfer_init);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
448 gaim_xfer_set_start_fnc(xfer, msn_xfer_start);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
449 gaim_xfer_set_end_fnc(xfer, msn_xfer_end);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
450 gaim_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel_send);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
451 gaim_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel_recv);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
452 gaim_xfer_set_read_fnc(xfer, msn_xfer_read);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
453 gaim_xfer_set_write_fnc(xfer, msn_xfer_write);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455 /* Keep track of this transfer for later. */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 md->file_transfers = g_slist_append(md->file_transfers, xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 /* Now perform the request */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 gaim_xfer_request(xfer);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 else if (strstr(msg, "Invitation-Command: ACCEPT")) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 * XXX I hope these checks don't return false positives, but they
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 * seem like they should work. The only issue is alternative
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 * protocols, *maybe*.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 if (strstr(msg, "AuthCookie:")) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 * Second invitation request, sent after the recipient accepts
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473 * the request. Used in incoming file transfers.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 char *cookie_s, *ip, *port_s, *authcookie_s;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476 char ip_s[16];
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478 tmp = strstr(msg, "Invitation-Cookie");
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 cookie_s = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483 ip = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
486 port_s = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489 authcookie_s = tmp;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 GET_NEXT(tmp);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 xfer = find_xfer_by_cookie(ms->gc, atoi(cookie_s));
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494 if (xfer == NULL)
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 {
5221
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
496 gaim_debug(GAIM_DEBUG_ERROR, "msn",
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
497 "MSNFTP : Cookie not found. "
abe4d103e300 [gaim-migrate @ 5591]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
498 "File transfer aborted.\n");
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 xfer_data = (struct msn_xfer_data *)xfer->data;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 xfer_data->authcookie = atol(authcookie_s);
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 strncpy(ip_s, ip, sizeof(ip_s));
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
507 if (gaim_proxy_connect(xfer->account, ip_s, atoi(port_s),
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508 msn_msnftp_connect, xfer) != 0) {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
510 gaim_xfer_cancel_remote(xfer);
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 return;
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515 else
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 {
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517 /*
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 * An accept message from the recipient. Used in outgoing
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519 * file transfers.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524