annotate src/protocols/yahoo/yahoo_filexfer.c @ 7899:7b64108b8ae3

[gaim-migrate @ 8559] I forgot to allow for the setting/retrieval of multiple selection in a list. There we go. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 21 Dec 2003 08:01:06 +0000
parents ee32e030c9be
children fa6395637e2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * @file yahoo_filexfer.c Yahoo Filetransfer
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * Copyright (C) 2003 Timothy T Ringenbach <omarvo@hotmail.com>
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 * Some code borrowed from MSN and copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * Some code copyright (C) 2002, Philip S Tellis <philip . tellis AT gmx . net>
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #include "prpl.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #include "internal.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #include "util.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include "debug.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "notify.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "proxy.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31 #include "ft.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #include "yahoo.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 #include "yahoo_filexfer.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 struct yahoo_xfer_data {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 gchar *host;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 gchar *path;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40 int port;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 GaimConnection *gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42 long expires;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 gboolean started;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44 gchar *rxqueue;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 guint rxlen;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 };
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
47
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 static void yahoo_xfer_data_free(struct yahoo_xfer_data *xd)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 if (xd->host)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 g_free(xd->host);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 if (xd->path)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53 g_free(xd->path);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 g_free(xd);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 struct yahoo_xfer_data *xd;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 gchar *buf;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
62
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63 gaim_debug(GAIM_DEBUG_INFO, "yahoo",
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 "AAA - in yahoo_receivefile_connected\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65 if (!(xfer = data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
66 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 if (!(xd = xfer->data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 if (source < 0) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect."));
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
71 gaim_xfer_cancel_remote(xfer);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
72 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
74
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 xfer->fd = source;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 gaim_xfer_start(xfer, source, NULL, 0);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 buf = g_strdup_printf("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n", xd->path, xd->host);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 write(xfer->fd, buf, strlen(buf));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80 g_free(buf);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
83 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 static int yahoo_send_packet_special(int fd, struct yahoo_packet *pkt, int pad)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 int pktlen = yahoo_packet_length(pkt);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88 int len = YAHOO_PACKET_HDRLEN + pktlen;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 int ret;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 guchar *data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 int pos = 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 if (fd < 0)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 return -1;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 data = g_malloc0(len + 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99 memcpy(data + pos, "YMSG", 4); pos += 4;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 pos += yahoo_put16(data + pos, 0x0000);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 pos += yahoo_put16(data + pos, pktlen + pad);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 pos += yahoo_put16(data + pos, pkt->service);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 pos += yahoo_put32(data + pos, pkt->status);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 pos += yahoo_put32(data + pos, pkt->id);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 yahoo_packet_write(pkt, data + pos);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 ret = write(fd, data, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 g_free(data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 return ret;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 struct yahoo_xfer_data *xd;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 struct yahoo_packet *pkt;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 gchar *size, *post, *buf;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 int content_length;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 GaimConnection *gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 struct yahoo_data *yd;
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
125 char *filename;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 gaim_debug(GAIM_DEBUG_INFO, "yahoo",
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 "AAA - in yahoo_sendfile_connected\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 if (!(xfer = data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 if (!(xd = xfer->data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 gc = xd->gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 account = gaim_connection_get_account(gc);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 yd = gc->proto_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 if (source < 0) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect."));
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
142 gaim_xfer_cancel_remote(xfer);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 xfer->fd = source;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 gaim_xfer_start(xfer, source, NULL, 0);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
150 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
151
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
152 size = g_strdup_printf("%d", gaim_xfer_get_size(xfer));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154 yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
155 yahoo_packet_hash(pkt, 5, xfer->who);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156 yahoo_packet_hash(pkt, 14, "");
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
157 filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer));
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
158 yahoo_packet_hash(pkt, 27, filename);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 yahoo_packet_hash(pkt, 28, size);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 post = g_strdup_printf("POST /notifyft HTTP/1.0\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 "Content-length: %d\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 "Host: %s:%d\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 "Cookie: %s\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 "\r\n",
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 content_length + 4 + gaim_xfer_get_size(xfer),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 buf);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 write(xfer->fd, post, strlen(post));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 yahoo_send_packet_special(xfer->fd, pkt, 8);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177 yahoo_packet_free(pkt);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 write(xfer->fd, "29\xc0\x80", 4);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 g_free(size);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 g_free(post);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 g_free(buf);
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
184 g_free(filename);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 static void yahoo_xfer_init(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 GaimConnection *gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 GaimAccount *account;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7805
diff changeset
192 struct yahoo_data *yd;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195 gc = xfer_data->gc;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7805
diff changeset
196 yd = gc->proto_data;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 account = gaim_connection_get_account(gc);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202 yahoo_sendfile_connected, xfer) == -1)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
203 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
204 gaim_notify_error(gc, NULL, _("File Transfer Aborted"),
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7805
diff changeset
205 _("Unable to establish file descriptor."));
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206 gaim_xfer_cancel_remote(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 } else {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 yahoo_receivefile_connected, xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211 if (xfer->fd == -1) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212 gaim_notify_error(gc, NULL, _("File Transfer Aborted"),
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 _("Unable to establish file descriptor."));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
214 gaim_xfer_cancel_remote(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
215 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
216 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
218
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 static void yahoo_xfer_start(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221 /* We don't need to do anything here, do we? */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
223
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
224 static void yahoo_xfer_end(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
225 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
226 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
227 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
228
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 account = gaim_xfer_get_account(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
233 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
235 xfer->data = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
237 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
238
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239 guint calculate_length(const gchar *l, size_t len)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241 int i;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243 for (i = 0; i < len; i++) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244 if (!g_ascii_isdigit(l[i]))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 continue;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 return strtol(l + i, NULL, 10);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252 size_t yahoo_xfer_read(char **buffer, GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
254 gchar buf[4096];
7682
d9caaddaa56d [gaim-migrate @ 8326]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
255 ssize_t len;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 gchar *start = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 gchar *length;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 gchar *end;
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
259 int filelen;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 struct yahoo_xfer_data *xd = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 if (gaim_xfer_get_type(xfer) != GAIM_XFER_RECEIVE) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
265
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
266 len = read(xfer->fd, buf, sizeof(buf));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267
7682
d9caaddaa56d [gaim-migrate @ 8326]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
268 if (len <= 0) {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
269 if ((gaim_xfer_get_size(xfer) > 0) &&
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
270 (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer)))
7682
d9caaddaa56d [gaim-migrate @ 8326]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
271 gaim_xfer_set_completed(xfer, TRUE);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 else
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 gaim_xfer_cancel_remote(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 if (!xd->started) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279 xd->rxqueue = g_realloc(xd->rxqueue, len + xd->rxlen);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280 memcpy(xd->rxqueue + xd->rxlen, buf, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 xd->rxlen += len;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
282
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283 length = g_strstr_len(xd->rxqueue, len, "Content-length:");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 if (length) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
285 end = g_strstr_len(length, length - xd->rxqueue, "\r\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 if (!end)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
287 return 0;
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
288 if ((filelen = calculate_length(length, len - (length - xd->rxqueue))))
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
289 gaim_xfer_set_size(xfer, filelen);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291 start = g_strstr_len(xd->rxqueue, len, "\r\n\r\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 if (start)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293 start += 4;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294 if (!start || start > (xd->rxqueue + len))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
296 xd->started = TRUE;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
298 len -= (start - xd->rxqueue);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
299
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
300 *buffer = g_malloc(len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301 memcpy(*buffer, start, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
302 g_free(xd->rxqueue);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 xd->rxqueue = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304 xd->rxlen = 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305 } else {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306 *buffer = g_malloc(len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
307 memcpy(*buffer, buf, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
308 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
309
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
310 return len;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313 size_t yahoo_xfer_write(const char *buffer, size_t size, GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
314 {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
315 ssize_t len;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
316 struct yahoo_xfer_data *xd = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
317
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
318 if (!xd)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
319 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
320
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
321 if (gaim_xfer_get_type(xfer) != GAIM_XFER_SEND) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
322 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
323 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
324
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
325 len = write(xfer->fd, buffer, size);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
326
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
327 if (len == -1) {
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
328 if (gaim_xfer_get_bytes_sent(xfer) >= gaim_xfer_get_size(xfer))
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
329 gaim_xfer_set_completed(xfer, TRUE);
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
330 if ((errno != EAGAIN) && (errno != EINTR))
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
331 gaim_xfer_cancel_remote(xfer);
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
332 return 0;
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
333 }
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
334
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
335 if ((gaim_xfer_get_bytes_sent(xfer) + len) >= gaim_xfer_get_size(xfer))
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
336 gaim_xfer_set_completed(xfer, TRUE);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
337
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
338 return len;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
340
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
341 static void yahoo_xfer_cancel_send(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
342 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
343 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
344 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
345
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
346 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
347 account = gaim_xfer_get_account(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
348
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
349 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
350 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
351 xfer->data = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
352 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
353
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
354 static void yahoo_xfer_cancel_recv(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
355 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
356 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
357 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
358
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
359 account = gaim_xfer_get_account(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
360 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
361
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
362 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
363 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
364 xfer->data = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
365 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
366
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
367 void yahoo_process_filetransfer(GaimConnection *gc, struct yahoo_packet *pkt)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
368 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
369 char *from = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
370 char *to = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
371 char *msg = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
372 char *url = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
373 long expires = 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
374 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
375 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
376
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
377 char *service = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
378
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
379 char *filename = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
380 unsigned long filesize = 0L;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
381
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
382 GSList *l;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
383
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
384 for (l = pkt->hash; l; l = l->next) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
385 struct yahoo_pair *pair = l->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
386
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
387 if (pair->key == 4)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
388 from = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
389 if (pair->key == 5)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
390 to = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
391 if (pair->key == 14)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
392 msg = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
393 if (pair->key == 20)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
394 url = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
395 if (pair->key == 38)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
396 expires = strtol(pair->value, NULL, 10);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
397
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
398 if (pair->key == 27)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
399 filename = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
400 if (pair->key == 28)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
401 filesize = atol(pair->value);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
402
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
403 if (pair->key == 49)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
404 service = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
405 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
406
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
407 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
408 if (strcmp("FILEXFER", service) != 0) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
409 gaim_debug_misc("yahoo", "unhandled service 0x%02x", pkt->service);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
410 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
411 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
412 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
413
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
414 if (msg) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
415 char *tmp;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
416 tmp = strchr(msg, '\006');
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
417 if (tmp)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
418 *tmp = '\0';
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
419 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
420
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
421 if (!url || !from)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
422 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
423
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
424
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
425 /* Setup the Yahoo-specific file transfer data */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
426 xfer_data = g_new0(struct yahoo_xfer_data, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
427 xfer_data->gc = gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
428 if (!gaim_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path))) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
429 g_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
430 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
431 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
432
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
433 gaim_debug_misc("yahoo_filexfer", "Host is %s, port is %d, path is %s, and the full url was %s.\n",
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
434 xfer_data->host, xfer_data->port, xfer_data->path, url);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
435
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
436 /* Build the file transfer handle. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
437 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, from);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
438 xfer->data = xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
439
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
440 /* Set the info about the incoming file. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
441 if (filename)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
442 gaim_xfer_set_filename(xfer, filename);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
443 else {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
444 gchar *start, *end;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
445 start = g_strrstr(xfer_data->path, "/");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
446 if (start)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
447 start++;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
448 end = g_strrstr(xfer_data->path, "?");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
449 if (start && *start && end) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
450 filename = g_strndup(start, end - start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
451 gaim_xfer_set_filename(xfer, filename);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
452 g_free(filename);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
453 filename = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
454 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
455 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
456
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
457 gaim_xfer_set_size(xfer, filesize);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
458
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
459 /* Setup our I/O op functions */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
460 gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
461 gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
462 gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
463 gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
464 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
465 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
466 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
467
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
468 /* Now perform the request */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
469 gaim_xfer_request(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
470 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
471
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
472 void yahoo_ask_send_file(GaimConnection *gc, const char *who)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
473 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
474 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
475 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
476
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
477 xfer_data = g_new0(struct yahoo_xfer_data, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
478 xfer_data->gc = gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
479
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
480
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
481 /* Build the file transfer handle. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
482 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
483 xfer->data = xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
484
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
485 /* Setup our I/O op functions */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
486 gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
487 gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
488 gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
489 gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
490 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
491 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
492 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
493
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
494 /* Now perform the request */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
495 gaim_xfer_request(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
496 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
497
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
498 void yahoo_send_file(GaimConnection *gc, const char *who, const char *file)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
499 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
500 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
501 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
502
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
503 if (!who || !file)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
504 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
505
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
506 xfer_data = g_new0(struct yahoo_xfer_data, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
507 xfer_data->gc = gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
508
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
509
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
510 /* Build the file transfer handle. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
511 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
512 xfer->data = xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
513
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
514 /* Setup our I/O op functions */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
515 gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
516 gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
517 gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
518 gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
519 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
520 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
521 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
522
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
523 /* Now perform the request */
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
524 gaim_xfer_request_accepted(xfer, file);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
525 }