annotate src/protocols/yahoo/yahoo_filexfer.c @ 11620:fbc4eeab2227

[gaim-migrate @ 13894] this lets you leave a highlighted tab by control-tab (forward) or control-shift-tab (backwards). its not 100% intuitive though, because it leaves the tab highlighed, which means that in the case of 1 highlighted tab, the current one, you will leave the tab on the first control-tab, then immediately return to it on the second one. For this reason, removing the highlighting of current tabs would be a better permanent solution. In talking with Tim however, he suggested we do both, on the off chance we change our minds about the tab highlighting and go back to the autoswitching. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 06 Oct 2005 15:01:08 +0000
parents 7fab28c991f3
children f4e58e94ced3
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 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7827
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7827
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7827
diff changeset
6 * source distribution.
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 *
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #include "prpl.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #include "internal.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #include "util.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #include "debug.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27 #include "notify.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include "proxy.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "ft.h"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "yahoo.h"
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 10361
diff changeset
31 #include "yahoo_packet.h"
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32 #include "yahoo_filexfer.h"
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
33 #include "yahoo_doodle.h"
7651
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) {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10651
diff changeset
70 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10651
diff changeset
71 xfer->who, _("Unable to connect."));
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
72 gaim_xfer_cancel_remote(xfer);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
73 return;
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 xfer->fd = source;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77 gaim_xfer_start(xfer, source, NULL, 0);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78
10651
8fbab42659c2 [gaim-migrate @ 12176]
Tim Ringenbach <marv@pidgin.im>
parents: 10579
diff changeset
79 buf = g_strdup_printf("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
8fbab42659c2 [gaim-migrate @ 12176]
Tim Ringenbach <marv@pidgin.im>
parents: 10579
diff changeset
80 xd->path, xd->host);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 write(xfer->fd, buf, strlen(buf));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82 g_free(buf);
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 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85 }
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 static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
88 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
89 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
90 struct yahoo_xfer_data *xd;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 struct yahoo_packet *pkt;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 gchar *size, *post, *buf;
10576
6c6772d3ea31 [gaim-migrate @ 11970]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10575
diff changeset
93 const char *host;
10575
96307e1a47c9 [gaim-migrate @ 11968]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10394
diff changeset
94 int content_length, port;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 GaimConnection *gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97 struct yahoo_data *yd;
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
98 char *filename, *encoded_filename;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 gaim_debug(GAIM_DEBUG_INFO, "yahoo",
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 "AAA - in yahoo_sendfile_connected\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102 if (!(xfer = data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 if (!(xd = xfer->data))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 return;
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 gc = xd->gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 account = gaim_connection_get_account(gc);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 yd = gc->proto_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 if (source < 0) {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10651
diff changeset
114 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10651
diff changeset
115 xfer->who, _("Unable to connect."));
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
116 gaim_xfer_cancel_remote(xfer);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 xfer->fd = source;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 gaim_xfer_start(xfer, source, NULL, 0);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 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
125
10111
8490f2e292a6 [gaim-migrate @ 11144]
Nathan Walp <nwalp@pidgin.im>
parents: 9798
diff changeset
126 size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer));
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
127 filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer));
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
128 encoded_filename = yahoo_string_encode(gc, filename, NULL);
10394
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
129
45a0a07e8b25 [gaim-migrate @ 11623]
Tim Ringenbach <marv@pidgin.im>
parents: 10392
diff changeset
130 yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc),
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
131 5, xfer->who, 14, "", 27, encoded_filename, 28, size);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 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
136
10576
6c6772d3ea31 [gaim-migrate @ 11970]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10575
diff changeset
137 host = gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST);
10575
96307e1a47c9 [gaim-migrate @ 11968]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10394
diff changeset
138 port = gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT);
96307e1a47c9 [gaim-migrate @ 11968]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10394
diff changeset
139 post = g_strdup_printf("POST http://%s:%d/notifyft HTTP/1.0\r\n"
10111
8490f2e292a6 [gaim-migrate @ 11144]
Nathan Walp <nwalp@pidgin.im>
parents: 9798
diff changeset
140 "Content-length: %" G_GSIZE_FORMAT "\r\n"
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 "Host: %s:%d\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 "Cookie: %s\r\n"
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 "\r\n",
10576
6c6772d3ea31 [gaim-migrate @ 11970]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10575
diff changeset
144 host, port, content_length + 4 + gaim_xfer_get_size(xfer), host, port, buf);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 write(xfer->fd, post, strlen(post));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146
10392
a8f9e5ce4f92 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 10361
diff changeset
147 yahoo_packet_send_special(pkt, xfer->fd, 8);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148 yahoo_packet_free(pkt);
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 write(xfer->fd, "29\xc0\x80", 4);
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 g_free(size);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
153 g_free(post);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154 g_free(buf);
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
155 g_free(encoded_filename);
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7710
diff changeset
156 g_free(filename);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 static void yahoo_xfer_init(GaimXfer *xfer)
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 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 GaimConnection *gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 GaimAccount *account;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7805
diff changeset
164 struct yahoo_data *yd;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 gc = xfer_data->gc;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 7805
diff changeset
168 yd = gc->proto_data;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 account = gaim_connection_get_account(gc);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) {
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
172 if (yd->jp) {
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
173 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
174 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
175 yahoo_sendfile_connected, xfer) == -1)
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
176 {
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
177 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
178 _("Unable to establish file descriptor."));
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
179 gaim_xfer_cancel_remote(xfer);
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
180 }
8282
ab35a0bec13a [gaim-migrate @ 9006]
Luke Schierer <lschiere@pidgin.im>
parents: 8231
diff changeset
181 } else {
10937
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
182 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
183 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
184 yahoo_sendfile_connected, xfer) == -1)
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
185 {
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
186 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
187 _("Unable to establish file descriptor."));
ca3e0882d377 [gaim-migrate @ 12721]
Mark Doliner <mark@kingant.net>
parents: 10654
diff changeset
188 gaim_xfer_cancel_remote(xfer);
8282
ab35a0bec13a [gaim-migrate @ 9006]
Luke Schierer <lschiere@pidgin.im>
parents: 8231
diff changeset
189 }
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191 } else {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port,
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 yahoo_receivefile_connected, xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 if (xfer->fd == -1) {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10651
diff changeset
195 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196 _("Unable to establish file descriptor."));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 gaim_xfer_cancel_remote(xfer);
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 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202 static void yahoo_xfer_start(GaimXfer *xfer)
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 /* We don't need to do anything here, do we? */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
205 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 static void yahoo_xfer_end(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212 account = gaim_xfer_get_account(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
214
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 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
218 xfer->data = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222 guint calculate_length(const gchar *l, size_t len)
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 int i;
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 for (i = 0; i < len; i++) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
227 if (!g_ascii_isdigit(l[i]))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
228 continue;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 return strtol(l + i, NULL, 10);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 return 0;
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 10976
diff changeset
235 ssize_t yahoo_xfer_read(guchar **buffer, GaimXfer *xfer)
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236 {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
237 gchar buf[4096];
7682
d9caaddaa56d [gaim-migrate @ 8326]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
238 ssize_t len;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239 gchar *start = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240 gchar *length;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241 gchar *end;
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
242 int filelen;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243 struct yahoo_xfer_data *xd = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 if (gaim_xfer_get_type(xfer) != GAIM_XFER_RECEIVE) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 return 0;
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 len = read(xfer->fd, buf, sizeof(buf));
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250
7682
d9caaddaa56d [gaim-migrate @ 8326]
Luke Schierer <lschiere@pidgin.im>
parents: 7651
diff changeset
251 if (len <= 0) {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
252 if ((gaim_xfer_get_size(xfer) > 0) &&
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
253 (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
254 gaim_xfer_set_completed(xfer, TRUE);
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
255 return 0;
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
256 } else
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
257 return -1;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261 if (!xd->started) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 xd->rxqueue = g_realloc(xd->rxqueue, len + xd->rxlen);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 memcpy(xd->rxqueue + xd->rxlen, buf, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 xd->rxlen += len;
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 length = g_strstr_len(xd->rxqueue, len, "Content-length:");
10579
71478e6a6074 [gaim-migrate @ 11976]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10576
diff changeset
267 /* some proxies re-write this header, changing the capitalization :(
71478e6a6074 [gaim-migrate @ 11976]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10576
diff changeset
268 * technically that's allowed since headers are case-insensitive
71478e6a6074 [gaim-migrate @ 11976]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10576
diff changeset
269 * [RFC 2616, section 4.2] */
71478e6a6074 [gaim-migrate @ 11976]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10576
diff changeset
270 if (length == NULL)
71478e6a6074 [gaim-migrate @ 11976]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10576
diff changeset
271 length = g_strstr_len(xd->rxqueue, len, "Content-Length:");
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 if (length) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 end = g_strstr_len(length, length - xd->rxqueue, "\r\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 if (!end)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 return 0;
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
276 if ((filelen = calculate_length(length, len - (length - xd->rxqueue))))
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
277 gaim_xfer_set_size(xfer, filelen);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279 start = g_strstr_len(xd->rxqueue, len, "\r\n\r\n");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280 if (start)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 start += 4;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
282 if (!start || start > (xd->rxqueue + len))
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283 return 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 xd->started = TRUE;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
285
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 len -= (start - xd->rxqueue);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
287
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 *buffer = g_malloc(len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 memcpy(*buffer, start, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 g_free(xd->rxqueue);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291 xd->rxqueue = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 xd->rxlen = 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293 } else {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294 *buffer = g_malloc(len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295 memcpy(*buffer, buf, len);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
296 }
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 return len;
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
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 10976
diff changeset
301 ssize_t yahoo_xfer_write(const guchar *buffer, size_t size, GaimXfer *xfer)
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
302 {
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
303 ssize_t len;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304 struct yahoo_xfer_data *xd = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306 if (!xd)
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
307 return -1;
7651
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 if (gaim_xfer_get_type(xfer) != GAIM_XFER_SEND) {
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
310 return -1;
7651
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 len = write(xfer->fd, buffer, size);
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 if (len == -1) {
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
316 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
317 gaim_xfer_set_completed(xfer, TRUE);
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
318 if ((errno != EAGAIN) && (errno != EINTR))
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9466
diff changeset
319 return -1;
7710
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
320 return 0;
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
321 }
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
322
45fd907e1d48 [gaim-migrate @ 8355]
Luke Schierer <lschiere@pidgin.im>
parents: 7682
diff changeset
323 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
324 gaim_xfer_set_completed(xfer, TRUE);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
325
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
326 return len;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
327 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
328
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
329 static void yahoo_xfer_cancel_send(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
330 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
331 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
332 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
333
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
334 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
335 account = gaim_xfer_get_account(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
336
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
337 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
338 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 xfer->data = NULL;
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
342 static void yahoo_xfer_cancel_recv(GaimXfer *xfer)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
343 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
344 GaimAccount *account;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
345 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
346
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 xfer_data = xfer->data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
349
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
350 if (xfer_data)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
351 yahoo_xfer_data_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
352 xfer->data = NULL;
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
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
355 void yahoo_process_p2pfilexfer( GaimConnection *gc, struct yahoo_packet *pkt )
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
356 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
357 GSList *l = pkt->hash;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
358
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
359 char *me = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
360 char *from = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
361 char *service = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
362 char *message = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
363 char *command = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
364 char *imv = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
365 char *unknown = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
366
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
367 // Get all the necessary values from this new packet
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
368 while( l )
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
369 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
370 struct yahoo_pair *pair = l->data;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
371
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
372 if( pair->key == 5 ) // Get who the packet is for
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
373 me = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
374
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
375 if( pair->key == 4 ) // Get who the packet is from
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
376 from = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
377
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
378 if( pair->key == 49 ) // Get the type of service
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
379 service = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
380
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
381 if( pair->key == 14 ) // Get the 'message' of the packet
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
382 message = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
383
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
384 if( pair->key == 13 ) // Get the command associated with this packet
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
385 command = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
386
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
387 if( pair->key == 63 ) // IMVironment name and version
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
388 imv = pair->value;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
389
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
390 if( pair->key == 64 ) // Not sure, but it does vary with initialization of Doodle
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
391 unknown = pair->value; // So, I'll keep it (for a little while atleast)
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
392
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
393 l = l->next;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
394 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
395
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
396 // If this packet is an IMVIRONMENT, handle it accordingly
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
397 if( !strcmp( service, "IMVIRONMENT" ) )
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
398 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
399 // Check for a Doodle packet and handle it accordingly
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
400 if( !strcmp( imv, "doodle;11" ) )
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
401 yahoo_doodle_process( gc, me, from, command, message );
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
402
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
403 // If an IMVIRONMENT packet comes without a specific imviroment name
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
404 if( !strcmp( imv, ";0" ) )
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
405 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
406 // It is unfortunately time to close all IMVironments with remote client
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
407 yahoo_doodle_command_got_shutdown( gc, from );
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
408 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
409
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
410 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
411 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
412
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
413 void yahoo_process_filetransfer(GaimConnection *gc, struct yahoo_packet *pkt)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
414 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
415 char *from = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
416 char *to = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
417 char *msg = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
418 char *url = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
419 long expires = 0;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
420 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
421 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
422
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
423 char *service = NULL;
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 char *filename = NULL;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
426 unsigned long filesize = 0L;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
427
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
428 GSList *l;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
429
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
430 for (l = pkt->hash; l; l = l->next) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
431 struct yahoo_pair *pair = l->data;
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 if (pair->key == 4)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
434 from = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
435 if (pair->key == 5)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
436 to = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
437 if (pair->key == 14)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
438 msg = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
439 if (pair->key == 20)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
440 url = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
441 if (pair->key == 38)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
442 expires = strtol(pair->value, NULL, 10);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
443
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
444 if (pair->key == 27)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
445 filename = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
446 if (pair->key == 28)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
447 filesize = atol(pair->value);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
448
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
449 if (pair->key == 49)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
450 service = pair->value;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
451 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
452
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
453 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {
10261
d4e9ff2edc4e [gaim-migrate @ 11405]
Tim Ringenbach <marv@pidgin.im>
parents: 10111
diff changeset
454 if (service && (strcmp("FILEXFER", service) != 0)) {
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
455 gaim_debug_misc("yahoo", "unhandled service 0x%02x", pkt->service);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
456 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
457 }
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
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
460 if (msg) {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
461 char *tmp;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
462 tmp = strchr(msg, '\006');
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
463 if (tmp)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
464 *tmp = '\0';
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
465 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
466
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
467 if (!url || !from)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
468 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
469
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 /* Setup the Yahoo-specific file transfer data */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
472 xfer_data = g_new0(struct yahoo_xfer_data, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
473 xfer_data->gc = gc;
9227
9171e528d7e5 [gaim-migrate @ 10023]
Christian Hammond <chipx86@chipx86.com>
parents: 9164
diff changeset
474 if (!gaim_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) {
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
475 g_free(xfer_data);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
476 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
477 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
478
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
479 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
480 xfer_data->host, xfer_data->port, xfer_data->path, url);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
481
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
482 /* Build the file transfer handle. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
483 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, from);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
484 xfer->data = xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
485
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
486 /* Set the info about the incoming file. */
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
487 if (filename) {
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
488 char *utf8_filename = yahoo_string_decode(gc, filename, TRUE);
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
489 gaim_xfer_set_filename(xfer, utf8_filename);
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
490 g_free(utf8_filename);
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
491 } else {
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
492 gchar *start, *end;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
493 start = g_strrstr(xfer_data->path, "/");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
494 if (start)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
495 start++;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
496 end = g_strrstr(xfer_data->path, "?");
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
497 if (start && *start && end) {
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
498 char *utf8_filename;
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
499 filename = g_strndup(start, end - start);
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
500 utf8_filename = yahoo_string_decode(gc, filename, TRUE);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
501 g_free(filename);
10976
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
502 gaim_xfer_set_filename(xfer, utf8_filename);
be22eb8fa671 [gaim-migrate @ 12802]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10937
diff changeset
503 g_free(utf8_filename);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
504 filename = NULL;
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 }
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
507
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
508 gaim_xfer_set_size(xfer, filesize);
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 /* Setup our I/O op functions */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
511 gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
512 gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
513 gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
514 gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
515 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
516 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
517 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
518
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
519 /* Now perform the request */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
520 gaim_xfer_request(xfer);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
521 }
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 void yahoo_send_file(GaimConnection *gc, const char *who, const char *file)
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
524 {
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
525 GaimXfer *xfer;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
526 struct yahoo_xfer_data *xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
527
9466
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9306
diff changeset
528 if (!who)
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
529 return;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
530
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
531 xfer_data = g_new0(struct yahoo_xfer_data, 1);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
532 xfer_data->gc = gc;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
533
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
534
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
535 /* Build the file transfer handle. */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
536 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
537 xfer->data = xfer_data;
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
538
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
539 /* Setup our I/O op functions */
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
540 gaim_xfer_set_init_fnc(xfer, yahoo_xfer_init);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
541 gaim_xfer_set_start_fnc(xfer, yahoo_xfer_start);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
542 gaim_xfer_set_end_fnc(xfer, yahoo_xfer_end);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
543 gaim_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
544 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
545 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
546 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
547
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
548 /* Now perform the request */
9466
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9306
diff changeset
549 if (file)
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9306
diff changeset
550 gaim_xfer_request_accepted(xfer, file);
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9306
diff changeset
551 else
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9306
diff changeset
552 gaim_xfer_request(xfer);
7651
580bd39219a2 [gaim-migrate @ 8295]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
553 }