libpurple/protocols/yahoo/yahoo_filexfer.c

Sun, 23 Jun 2013 01:03:34 +0200

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Sun, 23 Jun 2013 01:03:34 +0200
changeset 34219
eee308def583
parent 34218
de45cb0670a5
child 34286
8d0979967d05
permissions
-rw-r--r--

HTTP: get rid of purple_url_parse

7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /*
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * @file yahoo_filexfer.c Yahoo Filetransfer
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7827
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7827
diff changeset
6 * source distribution.
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 *
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 *
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 *
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19064
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 */
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22
18273
e61c53184c52 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
23 #include "internal.h"
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
24 #include "dnsquery.h"
18273
e61c53184c52 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
25
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
26 #include "prpl.h"
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
27 #include "util.h"
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28 #include "debug.h"
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
29 #include "http.h"
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
30 #include "network.h"
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
31 #include "notify.h"
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32 #include "proxy.h"
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33 #include "ft.h"
27555
afb7cb5c350c Update for file renames.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27547
diff changeset
34 #include "libymsg.h"
10392
6a9728e72c11 [gaim-migrate @ 11620]
Tim Ringenbach <marv@pidgin.im>
parents: 10361
diff changeset
35 #include "yahoo_packet.h"
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 #include "yahoo_filexfer.h"
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
37 #include "yahoo_doodle.h"
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
38 #include "yahoo_friend.h"
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
39
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
40 struct yahoo_xfer_data {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
41 gchar *host;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
42 gchar *path;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
43 int port;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
44 PurpleConnection *gc;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
45 long expires;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
46 gboolean started;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
47 guchar *txbuf;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
48 gsize txbuflen;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
49 gsize txbuf_written;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
50 guint tx_handler;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
51 gchar *rxqueue;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
52 guint rxlen;
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
53 gchar *xfer_peer_idstring;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
54 gchar *xfer_idstring_for_relay;
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
55 int version; /* 0 for old, 15 for Y7(YMSG 15) */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
56 int info_val_249;
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
57
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
58 enum {
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
59 STARTED = 0,
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
60 HEAD_REQUESTED,
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
61 HEAD_REPLY_RECEIVED,
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
62 TRANSFER_PHASE,
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
63 ACCEPTED,
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
64 P2P_HEAD_REQUESTED,
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
65 P2P_HEAD_REPLIED,
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
66 P2P_GET_REQUESTED
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
67 } status_15;
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
68
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
69 /* contains all filenames, in case of multiple transfers, with the first
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
70 * one in the list being the current file's name (ymsg15) */
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
71 GSList *filename_list;
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
72 GSList *size_list; /* corresponds to filename_list, with size as **STRING** */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
73 gboolean firstoflist;
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
74 gchar *xfer_url; /* url of the file, used when we are p2p server */
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
75 int yahoo_local_p2p_ft_server_fd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
76 int yahoo_local_p2p_ft_server_port;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
77 int yahoo_p2p_ft_server_watcher;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
78 int input_event;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
79 };
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
80
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
81 static void yahoo_xfer_data_free(struct yahoo_xfer_data *xd)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
82 {
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
83 PurpleConnection *gc;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
84 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
85 PurpleXfer *xfer;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
86 GSList *l;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
87
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
88 gc = xd->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
89 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
90
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
91 /* remove entry from map */
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
92 if(xd->xfer_peer_idstring) {
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
93 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map, xd->xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
94 if(xfer)
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
95 g_hash_table_remove(yd->xfer_peer_idstring_map, xd->xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
96 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
97
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
98 /* empty file & filesize list */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
99 for (l = xd->filename_list; l; l = l->next) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
100 g_free(l->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
101 l->data=NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
102 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
103 for (l = xd->size_list; l; l = l->next) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
104 g_free(l->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
105 l->data=NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
106 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
107 g_slist_free(xd->filename_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
108 g_slist_free(xd->size_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
109
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
110 g_free(xd->host);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
111 g_free(xd->path);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
112 g_free(xd->txbuf);
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
113 g_free(xd->xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
114 g_free(xd->xfer_idstring_for_relay);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
115 if (xd->tx_handler)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
116 purple_input_remove(xd->tx_handler);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
117 g_free(xd);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
118 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
119
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
120 static void yahoo_receivefile_send_cb(gpointer data, gint source, PurpleInputCondition condition)
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
121 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
122 PurpleXfer *xfer;
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
123 struct yahoo_xfer_data *xd;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
124 gssize remaining, written;
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
125
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
126 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
127 xd = purple_xfer_get_protocol_data(xfer);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
128
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
129 remaining = xd->txbuflen - xd->txbuf_written;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
130 written = purple_xfer_write(xfer, xd->txbuf + xd->txbuf_written, remaining);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
131
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
132 if (written < 0 && errno == EAGAIN)
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
133 written = 0;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
134 else if (written <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
135 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
136 purple_xfer_cancel_remote(xfer);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
137 return;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
138 }
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
139
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
140 if (written < remaining) {
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
141 xd->txbuf_written += written;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
142 return;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
143 }
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
144
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
145 purple_input_remove(xd->tx_handler);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
146 xd->tx_handler = 0;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
147 g_free(xd->txbuf);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
148 xd->txbuf = NULL;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
149 xd->txbuflen = 0;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
150
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
151 purple_xfer_start(xfer, source, NULL, 0);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
152
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
153 }
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
154
14182
517f4531b8a0 [gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
155 static void yahoo_receivefile_connected(gpointer data, gint source, const gchar *error_message)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
156 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
157 PurpleXfer *xfer;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
158 struct yahoo_xfer_data *xd;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
159
27547
c136491361eb Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27401
diff changeset
160 purple_debug_info("yahoo", "in yahoo_receivefile_connected\n");
c136491361eb Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27401
diff changeset
161
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
162 if (!(xfer = data))
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
163 return;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
164 if (!(xd = purple_xfer_get_protocol_data(xfer)))
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
165 return;
13144
e8c3eafab5f8 [gaim-migrate @ 15506]
Evan Schoenberg <evands@pidgin.im>
parents: 12412
diff changeset
166 if ((source < 0) || (xd->path == NULL) || (xd->host == NULL)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
167 purple_xfer_error(PURPLE_XFER_RECEIVE, purple_xfer_get_account(xfer),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
168 purple_xfer_get_remote_user(xfer), _("Unable to connect."));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
169 purple_xfer_cancel_remote(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
170 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
171 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
172
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
173 purple_xfer_set_fd(xfer, source);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
174
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
175 /* The first time we get here, assemble the tx buffer */
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
176 if (xd->txbuflen == 0) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
177 gchar *header = g_strdup_printf("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
22201
434114a12ae4 Revert patch that added receive-only transfer support for Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21918
diff changeset
178 xd->path, xd->host);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
179 xd->txbuf = (guchar*) header;
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
180 xd->txbuflen = strlen(header);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
181 xd->txbuf_written = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
182 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
183
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
184 if (!xd->tx_handler)
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
185 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
186 xd->tx_handler = purple_input_add(source, PURPLE_INPUT_WRITE,
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
187 yahoo_receivefile_send_cb, xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
188 yahoo_receivefile_send_cb(xfer, source, PURPLE_INPUT_WRITE);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
189 }
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
190 }
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
191
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
192 static void yahoo_sendfile_send_cb(gpointer data, gint source, PurpleInputCondition condition)
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
193 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
194 PurpleXfer *xfer;
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
195 struct yahoo_xfer_data *xd;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
196 gssize written, remaining;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
197
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
198 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
199 xd = purple_xfer_get_protocol_data(xfer);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
200
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
201 remaining = xd->txbuflen - xd->txbuf_written;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
202 written = purple_xfer_write(xfer, xd->txbuf + xd->txbuf_written, remaining);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
203
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
204 if (written < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
205 written = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
206 else if (written <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
207 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
208 purple_xfer_cancel_remote(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
209 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
210 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
211
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
212 if (written < remaining) {
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
213 xd->txbuf_written += written;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
214 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
215 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
216
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
217 purple_input_remove(xd->tx_handler);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
218 xd->tx_handler = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
219 g_free(xd->txbuf);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
220 xd->txbuf = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
221 xd->txbuflen = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
222
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
223 purple_xfer_start(xfer, source, NULL, 0);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
224 }
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
225
14182
517f4531b8a0 [gaim-migrate @ 16754]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
226 static void yahoo_sendfile_connected(gpointer data, gint source, const gchar *error_message)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
227 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
228 PurpleXfer *xfer;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
229 struct yahoo_xfer_data *xd;
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
230 struct yahoo_packet *pkt;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
231 gchar *size, *filename, *encoded_filename, *header;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
232 guchar *pkt_buf;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
233 const char *host;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
234 int port;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
235 size_t content_length, header_len, pkt_buf_len;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
236 PurpleConnection *gc;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
237 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
238 YahooData *yd;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
239
27547
c136491361eb Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27401
diff changeset
240 purple_debug_info("yahoo", "in yahoo_sendfile_connected\n");
c136491361eb Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27401
diff changeset
241
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
242 if (!(xfer = data))
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
243 return;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
244 if (!(xd = purple_xfer_get_protocol_data(xfer)))
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
245 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
246
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
247 if (source < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
248 purple_xfer_error(PURPLE_XFER_RECEIVE, purple_xfer_get_account(xfer),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
249 purple_xfer_get_remote_user(xfer), _("Unable to connect."));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
250 purple_xfer_cancel_remote(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
251 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
252 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
253
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
254 purple_xfer_set_fd(xfer, source);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
255
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
256 /* Assemble the tx buffer */
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
257 gc = xd->gc;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
258 account = purple_connection_get_account(gc);
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
259 yd = purple_connection_get_protocol_data(gc);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
260
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
261 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER,
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
262 YAHOO_STATUS_AVAILABLE, yd->session_id);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
263
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
264 size = g_strdup_printf("%" G_GOFFSET_FORMAT, purple_xfer_get_size(xfer));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
265 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
266 encoded_filename = yahoo_string_encode(gc, filename, NULL);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
267
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
268 yahoo_packet_hash(pkt, "sssss", 0, purple_connection_get_display_name(gc),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
269 5, purple_xfer_get_remote_user(xfer), 14, "", 27, encoded_filename, 28, size);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
270 g_free(size);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
271 g_free(encoded_filename);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
272 g_free(filename);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
273
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
274 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
275
24603
2a7015e8c12c Patch from 'siddish' to fix Yahoo! file transfers with older (i.e. non-p15)
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22966
diff changeset
276 pkt_buf_len = yahoo_packet_build(pkt, 4, FALSE, yd->jp, &pkt_buf);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
277 yahoo_packet_free(pkt);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
278
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
279 host = purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
280 port = purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
281 header = g_strdup_printf(
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
282 "POST http://%s:%d/notifyft HTTP/1.0\r\n"
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
283 "Content-length: %" G_GOFFSET_FORMAT "\r\n"
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
284 "Host: %s:%d\r\n"
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
285 "Cookie: Y=%s; T=%s\r\n"
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
286 "\r\n",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
287 host, port, content_length + 4 + purple_xfer_get_size(xfer),
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
288 host, port, yd->cookie_y, yd->cookie_t);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
289
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
290 header_len = strlen(header);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
291
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
292 xd->txbuflen = header_len + pkt_buf_len + 4;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
293 xd->txbuf = g_malloc(xd->txbuflen);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
294
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
295 memcpy(xd->txbuf, header, header_len);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
296 g_free(header);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
297 memcpy(xd->txbuf + header_len, pkt_buf, pkt_buf_len);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
298 g_free(pkt_buf);
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
299 memcpy(xd->txbuf + header_len + pkt_buf_len, "29\xc0\x80", 4);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13144
diff changeset
300
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
301 xd->txbuf_written = 0;
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
302
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
303 if (xd->tx_handler == 0)
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
304 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
305 xd->tx_handler = purple_input_add(source, PURPLE_INPUT_WRITE,
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
306 yahoo_sendfile_send_cb, xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
307 yahoo_sendfile_send_cb(xfer, source, PURPLE_INPUT_WRITE);
14146
4413802cb7a9 [gaim-migrate @ 16705]
Mark Doliner <markdoliner@pidgin.im>
parents: 13851
diff changeset
308 }
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
309 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
310
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
311 static void yahoo_xfer_init(PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
312 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
313 struct yahoo_xfer_data *xfer_data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
314 PurpleConnection *gc;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
315 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
316 YahooData *yd;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
317
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
318 xfer_data = purple_xfer_get_protocol_data(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
319 gc = xfer_data->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
320 yd = purple_connection_get_protocol_data(gc);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
321 account = purple_connection_get_account(gc);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
322
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
323 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
324 if (yd->jp) {
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
325 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
326 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
14170
f611621bc8a0 [gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents: 14151
diff changeset
327 yahoo_sendfile_connected, xfer) == NULL)
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
328 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
329 purple_notify_error(gc, NULL, _("File Transfer Failed"),
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
330 _("Unable to establish file descriptor."));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
331 purple_xfer_cancel_remote(xfer);
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
332 }
8282
2c6d8739141a [gaim-migrate @ 9006]
Tim Ringenbach <marv@pidgin.im>
parents: 8231
diff changeset
333 } else {
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
334 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
335 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
14170
f611621bc8a0 [gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents: 14151
diff changeset
336 yahoo_sendfile_connected, xfer) == NULL)
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
337 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
338 purple_notify_error(gc, NULL, _("File Transfer Failed"),
10937
1753f4709889 [gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents: 10654
diff changeset
339 _("Unable to establish file descriptor."));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
340 purple_xfer_cancel_remote(xfer);
8282
2c6d8739141a [gaim-migrate @ 9006]
Tim Ringenbach <marv@pidgin.im>
parents: 8231
diff changeset
341 }
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
342 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
343 } else {
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
344 purple_xfer_set_fd(xfer, -1);
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
345 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
20044
2b66cf7c7266 grab revision 24d76e86b06c5b1ab5f0a3ea37bd69ced034e0d0 (Reset file descriptors to -1 instead of 0 to fix some weird unexpected crashes in finch
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
346 yahoo_receivefile_connected, xfer) == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
347 purple_notify_error(gc, NULL, _("File Transfer Failed"),
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
348 _("Unable to establish file descriptor."));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
349 purple_xfer_cancel_remote(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
350 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
351 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
352 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
353
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
354 static void yahoo_xfer_init_15(PurpleXfer *xfer)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
355 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
356 struct yahoo_xfer_data *xfer_data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
357 PurpleConnection *gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
358 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
359 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
360 struct yahoo_packet *pkt;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
361
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
362 xfer_data = purple_xfer_get_protocol_data(xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
363 gc = xfer_data->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
364 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
365 account = purple_connection_get_account(gc);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
366
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
367 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
368 gchar *filename;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
369 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
370 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
371 YAHOO_STATUS_AVAILABLE,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
372 yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
373 yahoo_packet_hash(pkt, "sssiiiisiii",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
374 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
375 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
376 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
377 222, 1,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
378 266, 1,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
379 302, 268,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
380 300, 268,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
381 27, filename,
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
382 28, (int)purple_xfer_get_size(xfer),
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
383 301, 268,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
384 303, 268);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
385 g_free(filename);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
386 } else {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
387 if(xfer_data->firstoflist == TRUE) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
388 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
389 YAHOO_STATUS_AVAILABLE, yd->session_id);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
390
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
391 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
392 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
393 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
394 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
395 222, 3);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
396 } else {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
397 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
398 YAHOO_STATUS_AVAILABLE, yd->session_id);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
399
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
400 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
401 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
402 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
403 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
404 271, 1);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
405 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
406 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
407 yahoo_packet_send_and_free(pkt, yd);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
408 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
409
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
410 static void yahoo_xfer_start(PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
411 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
412 /* We don't need to do anything here, do we? */
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
413 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
414
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
415 static goffset calculate_length(const gchar *l, size_t len)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
416 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
417 int i;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
418
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
419 for (i = 0; i < len; i++) {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
420 if (!g_ascii_isdigit(l[i]))
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
421 continue;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
422 return g_ascii_strtoll(l + i, NULL, 10);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
423 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
424 return 0;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
425 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
426
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
427 static gssize yahoo_xfer_read(guchar **buffer, PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
428 {
7710
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
429 gchar buf[4096];
12151
8002bb57756b [gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents: 12143
diff changeset
430 gssize len;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
431 gchar *start = NULL;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
432 gchar *length;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
433 gchar *end;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
434 goffset filelen;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
435 struct yahoo_xfer_data *xd = purple_xfer_get_protocol_data(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
436
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
437 if (purple_xfer_get_type(xfer) != PURPLE_XFER_RECEIVE) {
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
438 return 0;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
439 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
440
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
441 len = read(purple_xfer_get_fd(xfer), buf, sizeof(buf));
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
442
7682
2f232f1f2584 [gaim-migrate @ 8326]
Kevin Stange <kstange@pidgin.im>
parents: 7651
diff changeset
443 if (len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
444 if ((purple_xfer_get_size(xfer) > 0) &&
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
445 (purple_xfer_get_bytes_sent(xfer) >= purple_xfer_get_size(xfer))) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
446 purple_xfer_set_completed(xfer, TRUE);
9798
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
447 return 0;
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
448 } else
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
449 return -1;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
450 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
451
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
452 if (!xd->started) {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
453 xd->rxqueue = g_realloc(xd->rxqueue, len + xd->rxlen);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
454 memcpy(xd->rxqueue + xd->rxlen, buf, len);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
455 xd->rxlen += len;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
456
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
457 length = g_strstr_len(xd->rxqueue, len, "Content-length:");
10579
f4576b2e0956 [gaim-migrate @ 11976]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10576
diff changeset
458 /* some proxies re-write this header, changing the capitalization :(
f4576b2e0956 [gaim-migrate @ 11976]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10576
diff changeset
459 * technically that's allowed since headers are case-insensitive
f4576b2e0956 [gaim-migrate @ 11976]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10576
diff changeset
460 * [RFC 2616, section 4.2] */
f4576b2e0956 [gaim-migrate @ 11976]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10576
diff changeset
461 if (length == NULL)
f4576b2e0956 [gaim-migrate @ 11976]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10576
diff changeset
462 length = g_strstr_len(xd->rxqueue, len, "Content-Length:");
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
463 if (length) {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
464 end = g_strstr_len(length, length - xd->rxqueue, "\r\n");
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
465 if (!end)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
466 return 0;
7710
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
467 if ((filelen = calculate_length(length, len - (length - xd->rxqueue))))
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
468 purple_xfer_set_size(xfer, filelen);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
469 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
470 start = g_strstr_len(xd->rxqueue, len, "\r\n\r\n");
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
471 if (start)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
472 start += 4;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
473 if (!start || start > (xd->rxqueue + len))
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
474 return 0;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
475 xd->started = TRUE;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
476
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
477 len -= (start - xd->rxqueue);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
478
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
479 *buffer = g_malloc(len);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
480 memcpy(*buffer, start, len);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
481 g_free(xd->rxqueue);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
482 xd->rxqueue = NULL;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
483 xd->rxlen = 0;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
484 } else {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
485 *buffer = g_malloc(len);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
486 memcpy(*buffer, buf, len);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
487 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
488
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
489 return len;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
490 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
491
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
492 static gssize yahoo_xfer_write(const guchar *buffer, size_t size, PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
493 {
12151
8002bb57756b [gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents: 12143
diff changeset
494 gssize len;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
495 struct yahoo_xfer_data *xd = purple_xfer_get_protocol_data(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
496
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
497 if (!xd)
9798
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
498 return -1;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
499
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
500 if (purple_xfer_get_type(xfer) != PURPLE_XFER_SEND) {
9798
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
501 return -1;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
502 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
503
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
504 len = write(purple_xfer_get_fd(xfer), buffer, size);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
505
7710
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
506 if (len == -1) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
507 if (purple_xfer_get_bytes_sent(xfer) >= purple_xfer_get_size(xfer))
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
508 purple_xfer_set_completed(xfer, TRUE);
7710
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
509 if ((errno != EAGAIN) && (errno != EINTR))
9798
9da203982089 [gaim-migrate @ 10666]
Joe Shaw <joe@joeshaw.org>
parents: 9466
diff changeset
510 return -1;
7710
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
511 return 0;
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
512 }
9e0642837d83 [gaim-migrate @ 8355]
Tim Ringenbach <marv@pidgin.im>
parents: 7682
diff changeset
513
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
514 return len;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
515 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
516
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
517 static void yahoo_xfer_cancel_send(PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
518 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
519 struct yahoo_xfer_data *xfer_data;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
520
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
521 xfer_data = purple_xfer_get_protocol_data(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
522
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
523 if(purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL && xfer_data->version == 15)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
524 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
525 PurpleConnection *gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
526 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
527 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
528 struct yahoo_packet *pkt;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
529
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
530 gc = xfer_data->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
531 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
532 account = purple_connection_get_account(gc);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
533 if(xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
534 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
535 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
536 YAHOO_STATUS_DISCONNECTED,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
537 yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
538 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
539 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
540 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
541 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
542 66, -1);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
543 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
544 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
545 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
546 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
547 YAHOO_STATUS_AVAILABLE,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
548 yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
549 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
550 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
551 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
552 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
553 222, 2);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
554 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
555 yahoo_packet_send_and_free(pkt, yd);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
556 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
557
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
558
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
559 if (xfer_data)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
560 yahoo_xfer_data_free(xfer_data);
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
561 purple_xfer_set_protocol_data(xfer, NULL);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
562 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
563
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
564 static void yahoo_xfer_cancel_recv(PurpleXfer *xfer)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
565 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
566 struct yahoo_xfer_data *xfer_data;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
567
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
568 xfer_data = purple_xfer_get_protocol_data(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
569
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
570 if(purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL && xfer_data->version == 15)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
571 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
572
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
573 PurpleConnection *gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
574 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
575 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
576 struct yahoo_packet *pkt;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
577
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
578 gc = xfer_data->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
579 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
580 account = purple_connection_get_account(gc);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
581 if(!xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
582 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
583 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
584 YAHOO_STATUS_AVAILABLE,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
585 yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
586 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
587 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
588 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
589 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
590 222, 4);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
591 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
592 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
593 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
594 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
595 YAHOO_STATUS_DISCONNECTED,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
596 yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
597 yahoo_packet_hash(pkt, "sssi",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
598 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
599 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
600 265, xfer_data->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
601 66, -1);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
602 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
603 yahoo_packet_send_and_free(pkt, yd);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
604 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
605
22201
434114a12ae4 Revert patch that added receive-only transfer support for Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21918
diff changeset
606 if (xfer_data)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
607 yahoo_xfer_data_free(xfer_data);
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
608 purple_xfer_set_protocol_data(xfer, NULL);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
609 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
610
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
611 /* Send HTTP OK after receiving file */
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
612 static void yahoo_p2p_ft_server_send_OK(PurpleXfer *xfer)
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
613 {
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
614 char *tx = NULL;
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
615 int written;
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
616 int fd = purple_xfer_get_fd(xfer);
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
617
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
618 tx = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\nContent-Type: application/octet-stream\r\nConnection: close\r\n\r\n";
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
619 written = write(fd, tx, strlen(tx));
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
620
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
621 if (written < 0 && errno == EAGAIN)
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
622 written = 0;
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
623 else if (written <= 0)
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
624 purple_debug_info("yahoo", "p2p filetransfer: Unable to write HTTP OK");
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
625
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
626 /* close connection */
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
627 close(fd);
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
628 purple_xfer_set_fd(xfer, -1);
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
629 }
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
630
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
631 static void yahoo_xfer_end(PurpleXfer *xfer_old)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
632 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
633 struct yahoo_xfer_data *xfer_data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
634 PurpleXfer *xfer = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
635 PurpleConnection *gc;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
636 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
637
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
638 xfer_data = purple_xfer_get_protocol_data(xfer_old);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
639 if(xfer_data && xfer_data->version == 15
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
640 && purple_xfer_get_type(xfer_old) == PURPLE_XFER_RECEIVE
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
641 && xfer_data->filename_list) {
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
642
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
643 /* Send HTTP OK in case of p2p transfer, when we act as server */
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
644 if((xfer_data->xfer_url != NULL) && (purple_xfer_get_fd(xfer_old) >=0) && (purple_xfer_get_status(xfer_old) == PURPLE_XFER_STATUS_DONE))
26374
0252e7af80f8 When acting as a p2p server, send HTTP OK after receiving file.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26361
diff changeset
645 yahoo_p2p_ft_server_send_OK(xfer_old);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
646
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
647 /* removing top of filename & size list completely */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
648 g_free( xfer_data->filename_list->data );
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
649 g_free( xfer_data->size_list->data );
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
650
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
651 xfer_data->filename_list->data = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
652 xfer_data->size_list->data = NULL;
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
653
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
654 xfer_data->filename_list = g_slist_delete_link(xfer_data->filename_list, xfer_data->filename_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
655 xfer_data->size_list = g_slist_delete_link(xfer_data->size_list, xfer_data->size_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
656
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
657 /* if there are still more files */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
658 if(xfer_data->filename_list)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
659 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
660 gchar* filename;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
661 goffset filesize;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
662
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
663 filename = xfer_data->filename_list->data;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
664 filesize = g_ascii_strtoll( xfer_data->size_list->data, NULL, 10 );
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
665
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
666 gc = xfer_data->gc;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
667 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
668
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
669 /* setting up xfer_data for next file's tranfer */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
670 g_free(xfer_data->host);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
671 g_free(xfer_data->path);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
672 g_free(xfer_data->txbuf);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
673 g_free(xfer_data->rxqueue);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
674 g_free(xfer_data->xfer_idstring_for_relay);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
675 if (xfer_data->tx_handler)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
676 purple_input_remove(xfer_data->tx_handler);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
677 xfer_data->host = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
678 xfer_data->host = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
679 xfer_data->port = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
680 xfer_data->expires = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
681 xfer_data->started = FALSE;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
682 xfer_data->txbuf = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
683 xfer_data->txbuflen = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
684 xfer_data->txbuf_written = 0;
22206
bb119c007a45 Fix a couple compile warnings.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22204
diff changeset
685 xfer_data->tx_handler = 0;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
686 xfer_data->rxqueue = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
687 xfer_data->rxlen = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
688 xfer_data->xfer_idstring_for_relay = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
689 xfer_data->info_val_249 = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
690 xfer_data->status_15 = STARTED;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
691 xfer_data->firstoflist = FALSE;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
692
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
693 /* Dereference xfer_data from old xfer */
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
694 purple_xfer_set_protocol_data(xfer_old, NULL);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
695
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
696 /* Build the file transfer handle. */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32668
diff changeset
697 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_RECEIVE, purple_xfer_get_remote_user(xfer_old));
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
698
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
699
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
700 if (xfer) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
701 /* Set the info about the incoming file. */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
702 char *utf8_filename = yahoo_string_decode(gc, filename, TRUE);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
703 purple_xfer_set_filename(xfer, utf8_filename);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
704 g_free(utf8_filename);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
705 purple_xfer_set_size(xfer, filesize);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
706
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
707 purple_xfer_set_protocol_data(xfer, xfer_data);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
708
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
709 /* Setup our I/O op functions */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
710 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init_15);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
711 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
712 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
713 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
714 purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
715 purple_xfer_set_read_fnc(xfer, yahoo_xfer_read);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
716 purple_xfer_set_write_fnc(xfer, yahoo_xfer_write);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
717 purple_xfer_set_request_denied_fnc(xfer,yahoo_xfer_cancel_recv);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
718
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
719 /* update map to current xfer */
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
720 g_hash_table_remove(yd->xfer_peer_idstring_map, xfer_data->xfer_peer_idstring);
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
721 g_hash_table_insert(yd->xfer_peer_idstring_map, xfer_data->xfer_peer_idstring, xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
722
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
723 /* Now perform the request */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
724 purple_xfer_request(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
725 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
726 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
727 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
728 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
729 if (xfer_data)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
730 yahoo_xfer_data_free(xfer_data);
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
731 purple_xfer_set_protocol_data(xfer_old, NULL);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
732 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
733
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
734 void yahoo_process_p2pfilexfer(PurpleConnection *gc, struct yahoo_packet *pkt)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
735 {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
736 GSList *l = pkt->hash;
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
737
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
738 char *me = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
739 char *from = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
740 char *service = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
741 char *message = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
742 char *command = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
743 char *imv = NULL;
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
744
11801
c19b37ac661b [gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents: 11644
diff changeset
745 /* Get all the necessary values from this new packet */
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
746 while(l != NULL)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
747 {
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
748 struct yahoo_pair *pair = l->data;
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
749
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
750 switch(pair->key) {
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
751 case 5: /* Get who the packet is for */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
752 me = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
753 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
754 case 4: /* Get who the packet is from */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
755 from = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
756 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
757 case 49: /* Get the type of service */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
758 service = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
759 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
760 case 14: /* Get the 'message' of the packet */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
761 message = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
762 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
763 case 13: /* Get the command associated with this packet */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
764 command = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
765 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
766 case 63: /* IMVironment name and version */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
767 imv = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
768 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
769 case 64: /* Not sure, but it does vary with initialization of Doodle */
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
770 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
771 }
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
772
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
773 l = l->next;
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
774 }
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
775
11801
c19b37ac661b [gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents: 11644
diff changeset
776 /* If this packet is an IMVIRONMENT, handle it accordingly */
13459
c20f00df92e5 [gaim-migrate @ 15833]
Daniel Atallah <datallah@pidgin.im>
parents: 13277
diff changeset
777 if(service != NULL && imv != NULL && !strcmp(service, "IMVIRONMENT"))
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
778 {
11801
c19b37ac661b [gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents: 11644
diff changeset
779 /* Check for a Doodle packet and handle it accordingly */
19064
1680699bdbf4 Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents: 18273
diff changeset
780 if(strstr(imv, "doodle;") != NULL)
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
781 yahoo_doodle_process(gc, me, from, command, message, imv);
11644
939411169d01 [gaim-migrate @ 13922]
Peter Lawler <pidgin@bleeter.id.au>
parents: 11475
diff changeset
782
11801
c19b37ac661b [gaim-migrate @ 14092]
Gary Kramlich <grim@reaperworld.com>
parents: 11644
diff changeset
783 /* If an IMVIRONMENT packet comes without a specific imviroment name */
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
784 if(!strcmp(imv, ";0"))
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
785 {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
786 /* It is unfortunately time to close all IMVironments with the remote client */
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
787 yahoo_doodle_command_got_shutdown(gc, from);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
788 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
789 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
790 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents: 11159
diff changeset
791
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
792 void yahoo_process_filetransfer(PurpleConnection *gc, struct yahoo_packet *pkt)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
793 {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
794 char *from = NULL;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
795 char *msg = NULL;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
796 char *url = NULL;
13851
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
797 char *imv = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
798 PurpleXfer *xfer;
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
799 PurpleHttpURL *url_p;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
800 YahooData *yd;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
801 struct yahoo_xfer_data *xfer_data;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
802 char *service = NULL;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
803 char *filename = NULL;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
804 goffset filesize = G_GOFFSET_CONSTANT(0);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
805 GSList *l;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
806
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
807 yd = purple_connection_get_protocol_data(gc);
13851
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
808
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
809 for (l = pkt->hash; l; l = l->next) {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
810 struct yahoo_pair *pair = l->data;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
811
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
812 switch (pair->key) {
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
813 case 4:
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
814 from = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
815 break;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
816 case 5: /* to */
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
817 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
818 case 14:
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
819 msg = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
820 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
821 case 20:
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
822 url = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
823 break;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
824 case 38: /* expires = strtol(pair->value, NULL, 10); */
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
825 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
826 case 27:
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
827 filename = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
828 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
829 case 28:
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
830 filesize = g_ascii_strtoll(pair->value, NULL, 10);
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
831 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
832 case 49:
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
833 service = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
834 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
835 case 63:
13851
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
836 imv = pair->value;
20150
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
837 break;
760aa4bea7c6 applied changes from 80e3a515775c28b61c4c155c4a524374ef3360ff
Richard Laager <rlaager@pidgin.im>
parents: 20044
diff changeset
838 }
13851
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
839 }
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
840
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
841 /*
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
842 * The remote user has changed their IMVironment. We
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
843 * record it for later use.
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
844 */
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
845 if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) {
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
846 g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv));
27bc39ea07f8 [gaim-migrate @ 16306]
Mark Doliner <markdoliner@pidgin.im>
parents: 13713
diff changeset
847 return;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
848 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
849
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
850 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {
10261
fdea752a175c [gaim-migrate @ 11405]
Tim Ringenbach <marv@pidgin.im>
parents: 10111
diff changeset
851 if (service && (strcmp("FILEXFER", service) != 0)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
852 purple_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
853 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
854 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
855 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
856
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
857 if (msg) {
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
858 char *tmp;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
859 tmp = strchr(msg, '\006');
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
860 if (tmp)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
861 *tmp = '\0';
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
862 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
863
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
864 if (!url || !from)
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
865 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
866
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
867 /* Setup the Yahoo-specific file transfer data */
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
868 xfer_data = g_new0(struct yahoo_xfer_data, 1);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
869 xfer_data->gc = gc;
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
870
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
871 url_p = purple_http_url_parse(url);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
872 if (!url_p) {
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
873 g_free(xfer_data);
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
874 purple_debug_error("yahoo_filexfer", "Couldn't parse URL\n");
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
875 return;
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
876 }
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
877 xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
878 xfer_data->port = purple_http_url_get_port(url_p);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
879 xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
880 purple_http_url_free(url_p);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
881
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
882 purple_debug_misc("yahoo_filexfer", "Host is %s, port is %d, path is %s, and the full url was %s.\n",
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
883 xfer_data->host, xfer_data->port, xfer_data->path, url);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
884
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
885 /* Build the file transfer handle. */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32668
diff changeset
886 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_RECEIVE, from);
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
887 if (xfer == NULL) {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
888 g_free(xfer_data);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
889 g_return_if_reached();
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
890 }
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
891
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
892 purple_xfer_set_protocol_data(xfer, xfer_data);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
893
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
894 /* Set the info about the incoming file. */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
895 if (filename) {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
896 char *utf8_filename = yahoo_string_decode(gc, filename, TRUE);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
897 purple_xfer_set_filename(xfer, utf8_filename);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
898 g_free(utf8_filename);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
899 } else {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
900 gchar *start, *end;
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
901 start = g_strrstr(xfer_data->path, "/");
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
902 if (start)
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
903 start++;
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
904 end = g_strrstr(xfer_data->path, "?");
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
905 if (start && *start && end) {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
906 char *utf8_filename;
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
907 filename = g_strndup(start, end - start);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
908 utf8_filename = yahoo_string_decode(gc, filename, TRUE);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
909 g_free(filename);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
910 purple_xfer_set_filename(xfer, utf8_filename);
10976
96153d16e808 [gaim-migrate @ 12802]
Daniel Atallah <datallah@pidgin.im>
parents: 10937
diff changeset
911 g_free(utf8_filename);
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
912 filename = NULL;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
913 }
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
914 }
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
915
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
916 purple_xfer_set_size(xfer, filesize);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
917
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
918 /* Setup our I/O op functions */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
919 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
920 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
921 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
922 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
923 purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
924 purple_xfer_set_read_fnc(xfer, yahoo_xfer_read);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
925 purple_xfer_set_write_fnc(xfer, yahoo_xfer_write);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
926
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
927 /* Now perform the request */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
928 purple_xfer_request(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
929 }
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
930
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
931 PurpleXfer *yahoo_new_xfer(PurpleConnection *gc, const char *who)
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
932 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
933 PurpleXfer *xfer;
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
934 struct yahoo_xfer_data *xfer_data;
19064
1680699bdbf4 Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents: 18273
diff changeset
935
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
936 g_return_val_if_fail(who != NULL, NULL);
19064
1680699bdbf4 Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents: 18273
diff changeset
937
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
938 xfer_data = g_new0(struct yahoo_xfer_data, 1);
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
939 xfer_data->gc = gc;
19064
1680699bdbf4 Fix yahoo doodling to work with newer yahoo messenger clients. This breaks doodling with older Pidgin clients (trying to support both looked too painful). Fixes #1445.
Daniel Atallah <datallah@pidgin.im>
parents: 18273
diff changeset
940
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
941 /* Build the file transfer handle. */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32668
diff changeset
942 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who);
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
943 if (xfer == NULL)
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
944 {
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
945 g_free(xfer_data);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
946 g_return_val_if_reached(NULL);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
947 }
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
948
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
949 purple_xfer_set_protocol_data(xfer, xfer_data);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
950
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
951 /* Setup our I/O op functions */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
952 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
953 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
954 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
955 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
956 purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
957 purple_xfer_set_read_fnc(xfer, yahoo_xfer_read);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
958 purple_xfer_set_write_fnc(xfer, yahoo_xfer_write);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
959
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
960 return xfer;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
961 }
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
962
22323
ef5a1f7861b4 Kill this warning when using -Wstrict-prototypes:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22206
diff changeset
963 static gchar* yahoo_xfer_new_xfer_id(void)
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
964 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
965 gchar *ans;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
966 int i,j;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
967 ans = g_strnfill(24, ' ');
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
968 ans[23] = '$';
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
969 ans[22] = '$';
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
970 for(i = 0; i < 22; i++)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
971 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
972 j = g_random_int_range (0,61);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
973 if(j < 26)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
974 ans[i] = j + 'a';
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
975 else if(j < 52)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
976 ans[i] = j - 26 + 'A';
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
977 else
22323
ef5a1f7861b4 Kill this warning when using -Wstrict-prototypes:
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22206
diff changeset
978 ans[i] = j - 52 + '0';
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
979 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
980 return ans;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
981 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
982
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
983 static void yahoo_xfer_dns_connected_15(GSList *hosts, gpointer data, const char *error_message)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
984 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
985 PurpleXfer *xfer;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
986 struct yahoo_xfer_data *xd;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
987 struct sockaddr_in *addr;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
988 struct yahoo_packet *pkt;
30470
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
989 unsigned long actaddr;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
990 unsigned char a,b,c,d;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
991 PurpleConnection *gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
992 PurpleAccount *account;
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
993 PurpleHttpURL *url_p;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
994 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
995 gchar *url;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
996 gchar *filename;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
997
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
998 if (!(xfer = data))
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
999 return;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1000 if (!(xd = purple_xfer_get_protocol_data(xfer)))
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1001 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1002 gc = xd->gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1003 account = purple_connection_get_account(gc);
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1004 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1005
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1006 if(!hosts)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1007 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1008 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n");
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1009 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1010 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1011 }
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1012
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1013 /* Discard the length... */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1014 hosts = g_slist_remove(hosts, hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1015 if(!hosts)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1016 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1017 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n");
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1018 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1019 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1020 }
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1021
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1022 /* TODO:actually, u must try with addr no.1 , if its not working addr no.2 ..... */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1023 addr = hosts->data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1024 actaddr = addr->sin_addr.s_addr;
30470
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1025 d = actaddr & 0xff;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1026 actaddr >>= 8;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1027 c = actaddr & 0xff;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1028 actaddr >>= 8;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1029 b = actaddr & 0xff;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1030 actaddr >>= 8;
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1031 a = actaddr & 0xff;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1032 if(yd->jp)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1033 xd->port = YAHOOJP_XFER_RELAY_PORT;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1034 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1035 xd->port = YAHOO_XFER_RELAY_PORT;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1036
30470
0670a9aedcd2 Fix Yahoo file transfers that get stuck saying \"Waiting for transfer to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29638
diff changeset
1037 url = g_strdup_printf("%u.%u.%u.%u", d, c, b, a);
26783
33c6f7d0fe9d Free the DNS query data before purple_url_parse() to avoid leaking on failure.
Paul Aurich <darkrain42@pidgin.im>
parents: 26770
diff changeset
1038
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1039 /* Free the address... */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1040 g_free(hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1041 hosts = g_slist_remove(hosts, hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1042 addr = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1043 while (hosts != NULL)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1044 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1045 /* Discard the length... */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1046 hosts = g_slist_remove(hosts, hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1047 /* Free the address... */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1048 g_free(hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1049 hosts = g_slist_remove(hosts, hosts->data);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1050 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1051
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1052 url_p = purple_http_url_parse(url);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1053 g_free(url);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1054 if (!url_p) {
26783
33c6f7d0fe9d Free the DNS query data before purple_url_parse() to avoid leaking on failure.
Paul Aurich <darkrain42@pidgin.im>
parents: 26770
diff changeset
1055 purple_xfer_cancel_remote(xfer);
33c6f7d0fe9d Free the DNS query data before purple_url_parse() to avoid leaking on failure.
Paul Aurich <darkrain42@pidgin.im>
parents: 26770
diff changeset
1056 return;
33c6f7d0fe9d Free the DNS query data before purple_url_parse() to avoid leaking on failure.
Paul Aurich <darkrain42@pidgin.im>
parents: 26770
diff changeset
1057 }
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1058 xd->host = g_strdup(purple_http_url_get_host(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1059 xd->port = purple_http_url_get_port(url_p);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1060 xd->path = g_strdup(purple_http_url_get_path(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1061 purple_http_url_free(url_p);
26783
33c6f7d0fe9d Free the DNS query data before purple_url_parse() to avoid leaking on failure.
Paul Aurich <darkrain42@pidgin.im>
parents: 26770
diff changeset
1062
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1063 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1064 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1065
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1066 yahoo_packet_hash(pkt, "ssssis",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1067 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1068 5, purple_xfer_get_remote_user(xfer),
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1069 265, xd->xfer_peer_idstring,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1070 27, filename,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1071 249, 3,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1072 250, xd->host);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1073
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1074 g_free(filename);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1075 yahoo_packet_send_and_free(pkt, yd);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1076 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1077
28786
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1078 gboolean yahoo_can_receive_file(PurpleConnection *gc, const char *who)
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1079 {
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1080 if (!who || yahoo_get_federation_from_name(who) != YAHOO_FEDERATION_NONE)
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1081 return FALSE;
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1082 return TRUE;
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1083 }
a0366821d1e4 Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 28588
diff changeset
1084
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1085 void yahoo_send_file(PurpleConnection *gc, const char *who, const char *file)
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
1086 {
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1087 struct yahoo_xfer_data *xfer_data;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1088 YahooData *yd = purple_connection_get_protocol_data(gc);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1089 PurpleXfer *xfer = yahoo_new_xfer(gc, who);
22401
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1090
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
1091 g_return_if_fail(xfer != NULL);
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11914
diff changeset
1092
26351
cb7bb2f504d6 When sending a file, if there isn't a p2p connection, try establishing it.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26344
diff changeset
1093 /* if we don't have a p2p connection, try establishing it now */
cb7bb2f504d6 When sending a file, if there isn't a p2p connection, try establishing it.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26344
diff changeset
1094 if( !g_hash_table_lookup(yd->peers, who) )
cb7bb2f504d6 When sending a file, if there isn't a p2p connection, try establishing it.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26344
diff changeset
1095 yahoo_send_p2p_pkt(gc, who, 0);
cb7bb2f504d6 When sending a file, if there isn't a p2p connection, try establishing it.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26344
diff changeset
1096
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1097 xfer_data = purple_xfer_get_protocol_data(xfer);
26343
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1098 xfer_data->status_15 = STARTED;
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1099 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init_15);
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1100 xfer_data->version = 15;
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1101 xfer_data->xfer_peer_idstring = yahoo_xfer_new_xfer_id();
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1102 g_hash_table_insert(yd->xfer_peer_idstring_map, xfer_data->xfer_peer_idstring, xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1103
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1104 /* Now perform the request */
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11897
diff changeset
1105 if (file)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1106 purple_xfer_request_accepted(xfer, file);
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9306
diff changeset
1107 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
1108 purple_xfer_request(xfer);
7651
43663aa7ef68 [gaim-migrate @ 8295]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1109 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1110
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1111 static void yahoo_p2p_ft_server_listen_cb(int listenfd, gpointer data); /* using this in yahoo_xfer_send_cb_15 */
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1112 static void yahoo_xfer_connected_15(gpointer data, gint source, const gchar *error_message);/* using this in recv_cb */
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1113
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1114 static void yahoo_xfer_recv_cb_15(gpointer data, gint source, PurpleInputCondition condition)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1115 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1116 PurpleXfer *xfer;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1117 struct yahoo_xfer_data *xd;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1118 int did;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1119 guchar buf[1000];
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1120 PurpleAccount *account;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1121 PurpleConnection *gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1122
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1123 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1124 xd = purple_xfer_get_protocol_data(xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1125 account = purple_connection_get_account(xd->gc);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1126 gc = xd->gc;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1127
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1128 while((did = read(source, buf, sizeof(buf))) > 0)
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1129 {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1130 /* TODO: Convert to circ buffer, this all is pretty horrible */
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1131 xd->txbuf = g_realloc(xd->txbuf, xd->txbuflen + did);
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1132 g_memmove(xd->txbuf + xd->txbuflen, buf, did);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1133 xd->txbuflen += did;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1134 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1135
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
1136 if (did < 0 && errno == EAGAIN)
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
1137 return;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1138 else if (did < 0) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1139 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1140 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1141 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1142 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1143
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1144 purple_input_remove(xd->tx_handler);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1145 xd->tx_handler = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1146 xd->txbuflen = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1147
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1148 if(xd->status_15 == HEAD_REQUESTED) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1149 xd->status_15 = HEAD_REPLY_RECEIVED;
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1150 close(source);/* Is this required? */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1151 g_free(xd->txbuf);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1152 xd->txbuf = NULL;
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
1153 if (purple_proxy_connect(gc, account, xd->host, xd->port, yahoo_xfer_connected_15, xfer) == NULL)
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1154 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1155 purple_notify_error(gc, NULL, _("File Transfer Failed"),
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1156 _("Unable to establish file descriptor."));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1157 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1158 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1159 } else {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1160 purple_debug_error("yahoo","Unrecognized yahoo file transfer mode and stage (ymsg15):%d,%d\n",
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1161 purple_xfer_get_type(xfer),
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1162 xd->status_15);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1163 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1164 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1165 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1166
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1167 static void yahoo_xfer_send_cb_15(gpointer data, gint source, PurpleInputCondition condition)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1168 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1169 PurpleXfer *xfer;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1170 struct yahoo_xfer_data *xd;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1171 int remaining, written;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1172
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1173 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1174 xd = purple_xfer_get_protocol_data(xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1175 remaining = xd->txbuflen - xd->txbuf_written;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1176 written = write(source, xd->txbuf + xd->txbuf_written, remaining);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1177
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1178 if (written < 0 && errno == EAGAIN)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1179 written = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1180 else if (written <= 0) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1181 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1182 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1183 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1184 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1185
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1186 if (written < remaining) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1187 xd->txbuf_written += written;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1188 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1189 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1190
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1191 purple_input_remove(xd->tx_handler);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1192 xd->tx_handler = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1193 g_free(xd->txbuf);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1194 xd->txbuf = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1195 xd->txbuflen = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1196 xd->txbuf_written = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1197
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1198 if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED)
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1199 {
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1200 xd->status_15 = HEAD_REQUESTED;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1201 xd->tx_handler = purple_input_add(source, PURPLE_INPUT_READ, yahoo_xfer_recv_cb_15, xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1202 yahoo_xfer_recv_cb_15(xfer, source, PURPLE_INPUT_READ);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1203 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1204 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == HEAD_REPLY_RECEIVED)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1205 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1206 xd->status_15 = TRANSFER_PHASE;
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1207 purple_xfer_set_fd(xfer, source);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1208 purple_xfer_start(xfer, source, NULL, 0);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1209 }
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1210 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && (xd->status_15 == ACCEPTED || xd->status_15 == P2P_GET_REQUESTED) )
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1211 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1212 xd->status_15 = TRANSFER_PHASE;
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1213 purple_xfer_set_fd(xfer, source);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1214 /* Remove Read event */
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1215 purple_input_remove(xd->input_event);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1216 xd->input_event = 0;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1217 purple_xfer_start(xfer, source, NULL, 0);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1218 }
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1219 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && xd->status_15 == P2P_HEAD_REQUESTED)
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1220 {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1221 xd->status_15 = P2P_HEAD_REPLIED;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1222 /* Remove Read event and close descriptor */
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1223 purple_input_remove(xd->input_event);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1224 xd->input_event = 0;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1225 close(source);
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1226 purple_xfer_set_fd(xfer, -1);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1227 /* start local server, listen for connections */
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
1228 purple_network_listen(xd->yahoo_local_p2p_ft_server_port, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1229 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1230 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1231 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1232 purple_debug_error("yahoo", "Unrecognized yahoo file transfer mode and stage (ymsg15):%d,%d\n", purple_xfer_get_type(xfer), xd->status_15);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1233 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1234 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1235 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1236
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1237 static void yahoo_xfer_connected_15(gpointer data, gint source, const gchar *error_message)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1238 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1239 PurpleXfer *xfer;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1240 struct yahoo_xfer_data *xd;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1241 PurpleAccount *account;
30706
612b36b49058 Kill off many dead assignments and any useless remaining variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30470
diff changeset
1242 PurpleConnection *gc;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1243
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1244 if (!(xfer = data))
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1245 return;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1246 if (!(xd = purple_xfer_get_protocol_data(xfer)))
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1247 return;
30706
612b36b49058 Kill off many dead assignments and any useless remaining variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30470
diff changeset
1248 gc = xd->gc;
612b36b49058 Kill off many dead assignments and any useless remaining variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30470
diff changeset
1249 account = purple_connection_get_account(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1250 if ((source < 0) || (xd->path == NULL) || (xd->host == NULL)) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1251 purple_xfer_error(PURPLE_XFER_RECEIVE, purple_xfer_get_account(xfer),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1252 purple_xfer_get_remote_user(xfer), _("Unable to connect."));
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1253 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1254 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1255 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1256 /* The first time we get here, assemble the tx buffer */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1257 if (xd->txbuflen == 0)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1258 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1259 gchar* cookies;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1260 gchar* initial_buffer;
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1261 YahooData *yd = purple_connection_get_protocol_data(gc);
30751
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1262
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1263 /* cookies = yahoo_get_cookies(gc);
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1264 * This doesn't seem to be working. The function is returning NULL, which yahoo servers don't like
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1265 * For now let us not use this function */
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1266
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1267 cookies = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
f4dda55ea733 Fix file transfers. yahoo_get_cookies() doesn't seem to be working. As a
Sulabh Mahajan <sulabh@pidgin.im>
parents: 30706
diff changeset
1268
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1269 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && xd->status_15 == ACCEPTED)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1270 {
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1271 if(xd->info_val_249 == 2)
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1272 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1273 /* sending file via p2p, we are connected as client */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1274 initial_buffer = g_strdup_printf("POST /%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1275 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1276 "Host: %s\r\n"
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1277 "Content-Length: %" G_GOFFSET_FORMAT "\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1278 "Cache-Control: no-cache\r\n\r\n",
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1279 xd->path,
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1280 xd->host,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1281 purple_xfer_get_size(xfer)); /* to do, add Referer */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1282 }
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1283 else
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1284 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1285 /* sending file via relaying */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1286 initial_buffer = g_strdup_printf("POST /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1287 "Cookie:%s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1288 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1289 "Host: %s\r\n"
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1290 "Content-Length: %" G_GOFFSET_FORMAT "\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1291 "Cache-Control: no-cache\r\n\r\n",
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1292 purple_url_encode(xd->xfer_idstring_for_relay),
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1293 purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1294 purple_xfer_get_remote_user(xfer),
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1295 cookies,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1296 xd->host,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1297 purple_xfer_get_size(xfer)); /* to do, add Referer */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1298 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1299 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1300 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED)
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1301 {
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1302 if(xd->info_val_249 == 1)
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1303 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1304 /* receiving file via p2p, connected as client */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1305 initial_buffer = g_strdup_printf("HEAD /%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1306 "Accept: */*\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1307 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1308 "Host: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1309 "Content-Length: 0\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1310 "Cache-Control: no-cache\r\n\r\n",
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1311 xd->path,xd->host);
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1312 }
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1313 else
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1314 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1315 /* receiving file via relaying */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1316 initial_buffer = g_strdup_printf("HEAD /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1317 "Accept: */*\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1318 "Cookie: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1319 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1320 "Host: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1321 "Content-Length: 0\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1322 "Cache-Control: no-cache\r\n\r\n",
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1323 purple_url_encode(xd->xfer_idstring_for_relay),
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1324 purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1325 purple_xfer_get_remote_user(xfer),
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1326 cookies,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1327 xd->host);
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1328 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1329 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1330 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == HEAD_REPLY_RECEIVED)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1331 {
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1332 if(xd->info_val_249 == 1)
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1333 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1334 /* receiving file via p2p, connected as client */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1335 initial_buffer = g_strdup_printf("GET /%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1336 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1337 "Host: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1338 "Connection: Keep-Alive\r\n\r\n",
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1339 xd->path, xd->host);
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1340 }
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1341 else
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1342 {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1343 /* receiving file via relaying */
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1344 initial_buffer = g_strdup_printf("GET /relay?token=%s&sender=%s&recver=%s HTTP/1.1\r\n"
27051
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1345 "Cookie: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1346 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1347 "Host: %s\r\n"
122397350352 Various minor cleanups. The majority of this is the #define for the useragent.
Paul Aurich <darkrain42@pidgin.im>
parents: 26783
diff changeset
1348 "Connection: Keep-Alive\r\n\r\n",
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1349 purple_url_encode(xd->xfer_idstring_for_relay),
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1350 purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1351 purple_xfer_get_remote_user(xfer),
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1352 cookies,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1353 xd->host);
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1354 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1355 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1356 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1357 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1358 purple_debug_error("yahoo", "Unrecognized yahoo file transfer mode and stage (ymsg15):%d,%d\n", purple_xfer_get_type(xfer), xd->status_15);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1359 g_free(cookies);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1360 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1361 }
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1362 xd->txbuf = (guchar*) initial_buffer;
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1363 xd->txbuflen = strlen(initial_buffer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1364 xd->txbuf_written = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1365 g_free(cookies);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1366 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1367
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1368 if (!xd->tx_handler)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1369 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1370 xd->tx_handler = purple_input_add(source, PURPLE_INPUT_WRITE,
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1371 yahoo_xfer_send_cb_15, xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1372 yahoo_xfer_send_cb_15(xfer, source, PURPLE_INPUT_WRITE);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1373 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1374 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1375
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1376 static void yahoo_p2p_ft_POST_cb(gpointer data, gint source, PurpleInputCondition cond)
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1377 {
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1378 PurpleXfer *xfer;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1379 struct yahoo_xfer_data *xd;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1380
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1381 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1382 if (!(xd = purple_xfer_get_protocol_data(xfer))) {
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1383 purple_xfer_cancel_remote(xfer);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1384 return;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1385 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1386
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1387 purple_input_remove(xd->input_event);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1388 xd->status_15 = TRANSFER_PHASE;
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1389 purple_xfer_set_fd(xfer, source);
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1390 purple_xfer_start(xfer, source, NULL, 0);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1391 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1392
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1393 static void yahoo_p2p_ft_HEAD_GET_cb(gpointer data, gint source, PurpleInputCondition cond)
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1394 {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1395 PurpleXfer *xfer;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1396 struct yahoo_xfer_data *xd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1397 guchar buf[1024];
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1398 int len;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1399 char *url_head;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1400 char *url_get;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1401 time_t unix_time;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1402 char *time_str;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1403
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1404 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1405 if (!(xd = purple_xfer_get_protocol_data(xfer))) {
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1406 purple_xfer_cancel_remote(xfer);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1407 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1408 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1409
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1410 len = read(source, buf, sizeof(buf));
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1411 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1412 return ; /* No Worries*/
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1413 else if (len <= 0) {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1414 purple_debug_warning("yahoo","p2p-ft: Error in connection, or host disconnected\n");
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1415 purple_input_remove(xd->input_event);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1416 purple_xfer_cancel_remote(xfer);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1417 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1418 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1419
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1420 url_head = g_strdup_printf("HEAD %s", xd->xfer_url);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1421 url_get = g_strdup_printf("GET %s", xd->xfer_url);
23687
c8b96ad9c946 Add + in place of spaces in p2p url, fixes transfer of file with name containing spaces
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23686
diff changeset
1422
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1423 if( strncmp(url_head, (char *)buf, strlen(url_head)) == 0 )
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1424 xd->status_15 = P2P_HEAD_REQUESTED;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1425 else if( strncmp(url_get, (char *)buf, strlen(url_get)) == 0 )
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1426 xd->status_15 = P2P_GET_REQUESTED;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1427 else {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1428 purple_debug_warning("yahoo","p2p-ft: Wrong HEAD/GET request from peer, disconnecting host\n");
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1429 purple_input_remove(xd->input_event);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1430 purple_xfer_cancel_remote(xfer);
33693
2c3efdc669c2 yahoo_filexfer.c: Fix memleak in yahoo_p2p_ft_HEAD_GET_cb
Niels Thykier <niels@thykier.net>
parents: 33440
diff changeset
1431 g_free(url_get);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1432 g_free(url_head);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1433 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1434 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1435
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1436 unix_time = time(NULL);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1437 time_str = ctime(&unix_time);
32005
d1970946b185 Fix truncation of a string in the Yahoo! prpl to be not quite so stupid.
Ethan Blanton <elb@pidgin.im>
parents: 31680
diff changeset
1438 time_str[strlen(time_str) - 1] = '\0';
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1439
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1440 if (xd->txbuflen == 0) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1441 gchar *initial_buffer = g_strdup_printf("HTTP/1.0 200 OK\r\n"
26769
7dad743942e2 Reformat a printf so the HTTP headers are easier to read
Paul Aurich <darkrain42@pidgin.im>
parents: 26374
diff changeset
1442 "Date: %s GMT\r\n"
7dad743942e2 Reformat a printf so the HTTP headers are easier to read
Paul Aurich <darkrain42@pidgin.im>
parents: 26374
diff changeset
1443 "Server: Y!/1.0\r\n"
7dad743942e2 Reformat a printf so the HTTP headers are easier to read
Paul Aurich <darkrain42@pidgin.im>
parents: 26374
diff changeset
1444 "MIME-version: 1.0\r\n"
7dad743942e2 Reformat a printf so the HTTP headers are easier to read
Paul Aurich <darkrain42@pidgin.im>
parents: 26374
diff changeset
1445 "Last-modified: %s GMT\r\n"
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1446 "Content-length: %" G_GOFFSET_FORMAT "\r\n\r\n",
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1447 time_str, time_str, purple_xfer_get_size(xfer));
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1448 xd->txbuf = (guchar *)initial_buffer;
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1449 xd->txbuflen = strlen(initial_buffer);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1450 xd->txbuf_written = 0;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1451 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1452
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1453 if (!xd->tx_handler) {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1454 xd->tx_handler = purple_input_add(source, PURPLE_INPUT_WRITE, yahoo_xfer_send_cb_15, xfer);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1455 yahoo_xfer_send_cb_15(xfer, source, PURPLE_INPUT_WRITE);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1456 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1457
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1458 g_free(url_head);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1459 g_free(url_get);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1460 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1461
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1462 static void yahoo_p2p_ft_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond)
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1463 {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1464 int acceptfd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1465 PurpleXfer *xfer;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1466 struct yahoo_xfer_data *xd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1467
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1468 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1469 if (!(xd = purple_xfer_get_protocol_data(xfer))) {
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1470 purple_xfer_cancel_remote(xfer);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1471 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1472 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1473
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1474 acceptfd = accept(source, NULL, 0);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1475 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1476 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1477 else if(acceptfd == -1) {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1478 purple_debug_warning("yahoo","yahoo_p2p_server_send_connected_cb: accept: %s\n", g_strerror(errno));
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1479 purple_xfer_cancel_remote(xfer);
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1480 /* remove watcher and close p2p ft server */
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1481 purple_input_remove(xd->yahoo_p2p_ft_server_watcher);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1482 close(xd->yahoo_local_p2p_ft_server_fd);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1483 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1484 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1485
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1486 /* remove watcher and close p2p ft server */
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1487 purple_input_remove(xd->yahoo_p2p_ft_server_watcher);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1488 close(xd->yahoo_local_p2p_ft_server_fd);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1489
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1490 /* Add an Input Read event to the file descriptor */
32707
33e4326b07bd Yahoo: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1491 purple_xfer_set_fd(xfer, acceptfd);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1492 if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE)
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1493 xd->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_ft_POST_cb, data);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1494 else
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1495 xd->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_ft_HEAD_GET_cb, data);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1496 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1497
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1498 static void yahoo_p2p_ft_server_listen_cb(int listenfd, gpointer data)
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1499 {
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1500 PurpleXfer *xfer;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1501 struct yahoo_xfer_data *xd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1502 struct yahoo_packet *pkt;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1503 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
1504 YahooData *yd;
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1505 gchar *filename;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1506 const char *local_ip;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1507 gchar *url_to_send = NULL;
23687
c8b96ad9c946 Add + in place of spaces in p2p url, fixes transfer of file with name containing spaces
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23686
diff changeset
1508 char *filename_without_spaces = NULL;
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1509
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1510 xfer = data;
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1511 if (!(xd = purple_xfer_get_protocol_data(xfer)) || (listenfd == -1)) {
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1512 purple_debug_warning("yahoo","p2p: error starting server for p2p file transfer\n");
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1513 purple_xfer_cancel_remote(xfer);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1514 return;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1515 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1516
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1517 if( (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) || (xd->status_15 != P2P_HEAD_REPLIED) ) {
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1518 yd = purple_connection_get_protocol_data(xd->gc);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1519 account = purple_connection_get_account(xd->gc);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1520 local_ip = purple_network_get_my_ip(listenfd);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1521 xd->yahoo_local_p2p_ft_server_port = purple_network_get_port_from_fd(listenfd);
23687
c8b96ad9c946 Add + in place of spaces in p2p url, fixes transfer of file with name containing spaces
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23686
diff changeset
1522
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1523 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
26344
a0af8ddd60e2 Use purple_util_chrreplace instead of g_strsplit then g_strjoinv
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26343
diff changeset
1524 filename_without_spaces = g_strdup(filename);
a0af8ddd60e2 Use purple_util_chrreplace instead of g_strsplit then g_strjoinv
Sulabh Mahajan <sulabh@pidgin.im>
parents: 26343
diff changeset
1525 purple_util_chrreplace(filename_without_spaces, ' ', '+');
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1526 xd->xfer_url = g_strdup_printf("/Messenger.%s.%d000%s?AppID=Messenger&UserID=%s&K=lc9lu2u89gz1llmplwksajkjx", purple_xfer_get_remote_user(xfer), (int)time(NULL), filename_without_spaces, purple_xfer_get_remote_user(xfer));
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1527 url_to_send = g_strdup_printf("http://%s:%d%s", local_ip, xd->yahoo_local_p2p_ft_server_port, xd->xfer_url);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1528
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1529 if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) {
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1530 xd->info_val_249 = 2; /* 249=2: we are p2p server, and receiving file */
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1531 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1532 YAHOO_STATUS_AVAILABLE, yd->session_id);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1533 yahoo_packet_hash(pkt, "ssssis",
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1534 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1535 5, purple_xfer_get_remote_user(xfer),
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1536 265, xd->xfer_peer_idstring,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1537 27, purple_xfer_get_filename(xfer),
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1538 249, 2,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1539 250, url_to_send);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1540 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1541 else {
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1542 xd->info_val_249 = 1; /* 249=1: we are p2p server, and sending file */
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1543 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1544 yahoo_packet_hash(pkt, "ssssis",
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1545 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1546 5, purple_xfer_get_remote_user(xfer),
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1547 265, xd->xfer_peer_idstring,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1548 27, filename,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1549 249, 1,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1550 250, url_to_send);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1551 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1552
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1553 yahoo_packet_send_and_free(pkt, yd);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1554
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1555 g_free(filename);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1556 g_free(url_to_send);
23687
c8b96ad9c946 Add + in place of spaces in p2p url, fixes transfer of file with name containing spaces
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23686
diff changeset
1557 g_free(filename_without_spaces);
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1558 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1559
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1560 /* Add an Input Read event to the file descriptor */
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1561 xd->yahoo_local_p2p_ft_server_fd = listenfd;
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1562 xd->yahoo_p2p_ft_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_ft_server_send_connected_cb, data);
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1563 }
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1564
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1565 /* send (p2p) file transfer information */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1566 static void yahoo_p2p_client_send_ft_info(PurpleConnection *gc, PurpleXfer *xfer)
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1567 {
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1568 struct yahoo_xfer_data *xd;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1569 struct yahoo_packet *pkt;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1570 PurpleAccount *account;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
1571 YahooData *yd;
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1572 gchar *filename;
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1573 struct yahoo_p2p_data *p2p_data;
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1574
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1575 if (!(xd = purple_xfer_get_protocol_data(xfer)))
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1576 return;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1577
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1578 account = purple_connection_get_account(gc);
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1579 yd = purple_connection_get_protocol_data(gc);
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1580
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1581 p2p_data = g_hash_table_lookup(yd->peers, purple_xfer_get_remote_user(xfer));
23693
100d744dc99b changed gboolean connection_type to enum yahoo_p2p_connection_type
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23688
diff changeset
1582 if( p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER )
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
1583 if(purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer))
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1584 return;
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1585
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1586 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1587 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1588
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1589 yahoo_packet_hash(pkt, "ssssi",
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1590 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1591 5, purple_xfer_get_remote_user(xfer),
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1592 265, xd->xfer_peer_idstring,
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1593 27, filename,
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1594 249, 2); /* 249=2: we are p2p client */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1595 xd->info_val_249 = 2;
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1596 yahoo_packet_send_and_free(pkt, yd);
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1597
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1598 g_free(filename);
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1599 }
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1600
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1601 void yahoo_process_filetrans_15(PurpleConnection *gc, struct yahoo_packet *pkt)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1602 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1603 char *from = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1604 char *imv = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1605 long val_222 = 0L;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1606 PurpleXfer *xfer;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
1607 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1608 struct yahoo_xfer_data *xfer_data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1609 char *service = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1610 char *filename = NULL;
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1611 char *xfer_peer_idstring = NULL;
28076
796f5a14f70b Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 28074
diff changeset
1612 char *utf8_filename;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1613 goffset filesize = G_GOFFSET_CONSTANT(0);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1614 GSList *l;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1615 GSList *filename_list = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1616 GSList *size_list = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1617 int nooffiles = 0;
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1618
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1619 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1620
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1621 for (l = pkt->hash; l; l = l->next) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1622 struct yahoo_pair *pair = l->data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1623
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1624 switch (pair->key) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1625 case 4:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1626 from = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1627 break;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
1628 case 5: /* to */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1629 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1630 case 265:
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1631 xfer_peer_idstring = pair->value;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1632 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1633 case 27:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1634 filename_list = g_slist_prepend(filename_list, g_strdup(pair->value));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1635 nooffiles++;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1636 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1637 case 28:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1638 size_list = g_slist_prepend(size_list, g_strdup(pair->value));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1639 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1640 case 222:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1641 val_222 = atol(pair->value);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1642 /* 1=send, 2=cancel, 3=accept, 4=reject */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1643 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1644
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1645 /* check for p2p and imviron .... not sure it comes by this service packet. Since it was bundled with filexfer in old ymsg version, still keeping it. */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1646 case 49:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1647 service = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1648 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1649 case 63:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1650 imv = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1651 break;
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1652 /* end check */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1653
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1654 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1655 }
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1656 if(!xfer_peer_idstring)
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1657 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1658
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1659 if(val_222 == 2 || val_222 == 4)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1660 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1661 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map,
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1662 xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1663 if(!xfer) return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1664 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1665 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1666 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1667 if(val_222 == 3)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1668 {
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1669 PurpleAccount *account;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1670 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map,
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1671 xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1672 if(!xfer)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1673 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1674 /*
22401
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1675 * In the file trans info packet that we must reply with, we are
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1676 * supposed to mention the ip address...
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1677 * purple connect does not give me a way of finding the ip address...
22401
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1678 * so, purple dnsquery is used... but retries, trying with next ip
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1679 * address etc. is not implemented..TODO
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1680 */
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1681
23686
ea2c220b8535 Send file by p2p when we are server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23680
diff changeset
1682 /* To send through p2p */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1683 if( g_hash_table_lookup(yd->peers, from) ) {
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1684 /* send p2p file transfer information */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1685 yahoo_p2p_client_send_ft_info(gc, xfer);
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1686 return;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1687 }
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1688
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1689 account = purple_connection_get_account(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1690 if (yd->jp)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1691 {
32297
100ef65e9664 Replace purple_dnsquery_a_account with purple_dnsquery_a.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32280
diff changeset
1692 purple_dnsquery_a(account, YAHOOJP_XFER_RELAY_HOST,
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1693 YAHOOJP_XFER_RELAY_PORT,
22401
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1694 yahoo_xfer_dns_connected_15, xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1695 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1696 else
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1697 {
32297
100ef65e9664 Replace purple_dnsquery_a_account with purple_dnsquery_a.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32280
diff changeset
1698 purple_dnsquery_a(account, YAHOO_XFER_RELAY_HOST,
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1699 YAHOO_XFER_RELAY_PORT,
22401
5fe1761a4a15 Simplified version of the newest patch on #4533 to not try Yahoo protocol
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22323
diff changeset
1700 yahoo_xfer_dns_connected_15, xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1701 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1702 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1703 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1704
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1705 /* processing for p2p and imviron .... not sure it comes by this service packet. Since it was bundled with filexfer in old ymsg version, still keeping it. */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1706 /*
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1707 * The remote user has changed their IMVironment. We
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1708 * record it for later use.
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1709 */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1710 if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1711 g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1712 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1713 }
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1714
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1715 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1716 if (service && (strcmp("FILEXFER", service) != 0)) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1717 purple_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1718 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1719 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1720 }
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1721 /* end processing */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1722
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1723 if(!filename_list)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1724 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1725 /* have to change list into order in which client at other end sends */
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1726 filename_list = g_slist_reverse(filename_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1727 size_list = g_slist_reverse(size_list);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1728 filename = filename_list->data;
32668
84472c7030e1 Update Yahoo for 64-bit file transfers. I'm not really sure if this
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1729 filesize = g_ascii_strtoll(size_list->data, NULL, 10);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1730
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1731 if(!from) return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1732 xfer_data = g_new0(struct yahoo_xfer_data, 1);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1733 xfer_data->version = 15;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1734 xfer_data->firstoflist = TRUE;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1735 xfer_data->gc = gc;
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1736 xfer_data->xfer_peer_idstring = g_strdup(xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1737 xfer_data->filename_list = filename_list;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1738 xfer_data->size_list = size_list;
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1739
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1740 /* Build the file transfer handle. */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32668
diff changeset
1741 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_RECEIVE, from);
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1742 if (xfer == NULL)
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1743 {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1744 g_free(xfer_data);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1745 g_return_if_reached();
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1746 }
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1747
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1748 /* Set the info about the incoming file. */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1749 utf8_filename = yahoo_string_decode(gc, filename, TRUE);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1750 purple_xfer_set_filename(xfer, utf8_filename);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1751 g_free(utf8_filename);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1752 purple_xfer_set_size(xfer, filesize);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1753
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1754 purple_xfer_set_protocol_data(xfer, xfer_data);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1755
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1756 /* Setup our I/O op functions */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1757 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init_15);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1758 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1759 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1760 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1761 purple_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1762 purple_xfer_set_read_fnc(xfer, yahoo_xfer_read);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1763 purple_xfer_set_write_fnc(xfer, yahoo_xfer_write);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1764 purple_xfer_set_request_denied_fnc(xfer,yahoo_xfer_cancel_recv);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1765
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1766 g_hash_table_insert(yd->xfer_peer_idstring_map,
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1767 xfer_data->xfer_peer_idstring,
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1768 xfer);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1769
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1770 if(nooffiles > 1) {
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1771 gchar* message;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1772 message = g_strdup_printf(_("%s is trying to send you a group of %d files.\n"), purple_xfer_get_remote_user(xfer), nooffiles);
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1773 purple_xfer_conversation_write(xfer, message, FALSE);
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1774 g_free(message);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1775 }
28074
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1776 /* Now perform the request */
0f75cd31966a yahoo: Fix some "leaks" (in reality these shouldn't happen). Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27959
diff changeset
1777 purple_xfer_request(xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1778 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1779
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1780 void yahoo_process_filetrans_info_15(PurpleConnection *gc, struct yahoo_packet *pkt)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1781 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1782 char *url = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1783 long val_249 = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1784 long val_66 = 0;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1785 PurpleXfer *xfer;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
1786 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1787 struct yahoo_xfer_data *xfer_data;
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1788 char *xfer_peer_idstring = NULL;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1789 char *xfer_idstring_for_relay = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1790 GSList *l;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1791 struct yahoo_packet *pkt_to_send;
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1792 struct yahoo_p2p_data *p2p_data;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1793
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1794 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1795
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1796 for (l = pkt->hash; l; l = l->next) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1797 struct yahoo_pair *pair = l->data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1798
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1799 switch (pair->key) {
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
1800 case 4: /* from */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1801 break;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
1802 case 5: /* to */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1803 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1804 case 265:
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1805 xfer_peer_idstring = pair->value;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1806 break;
33892
ef97228bc5f0 Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33693
diff changeset
1807 case 27: /* filename */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1808 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1809 case 66:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1810 val_66 = strtol(pair->value, NULL, 10);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1811 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1812 case 249:
23675
6c5ffe34cb35 Yahoo P2P File Transfer RECEIVE only support added.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 22966
diff changeset
1813 val_249 = strtol(pair->value, NULL, 10);
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1814 /* 249 has value 1 or 2 when doing p2p transfer and value 3 when relaying through yahoo server */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1815 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1816 case 250:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1817 url = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1818 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1819 case 251:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1820 xfer_idstring_for_relay = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1821 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1822 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1823 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1824
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1825 if(!xfer_peer_idstring)
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1826 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1827
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1828 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map, xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1829
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1830 if(!xfer) return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1831
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1832 if(val_66==-1)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1833 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1834 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1835 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1836 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1837
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1838 xfer_data = purple_xfer_get_protocol_data(xfer);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1839
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1840 xfer_data->info_val_249 = val_249;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1841 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1842 if(val_249 == 1 || val_249 == 3) {
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 30751
diff changeset
1843 PurpleAccount *account;
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1844 PurpleHttpURL *url_p;
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1845
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1846 url_p = purple_http_url_parse(url);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1847 if (!url_p) {
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1848 purple_xfer_cancel_remote(xfer);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1849 return;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1850 }
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1851 xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1852 xfer_data->port = purple_http_url_get_port(url_p);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1853 xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1854 purple_http_url_free(url_p);
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1855
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1856 account = purple_connection_get_account(xfer_data->gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1857
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1858 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15,
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1859 YAHOO_STATUS_AVAILABLE, yd->session_id);
27401
5e5dfa76ce64 Fix File transfer issue with Pidgin 2.5.7, ticket #9478
Sulabh Mahajan <sulabh@pidgin.im>
parents: 27343
diff changeset
1860 yahoo_packet_hash(pkt_to_send, "ssssis",
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1861 1, purple_normalize(account, purple_account_get_username(account)),
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1862 5, purple_xfer_get_remote_user(xfer),
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1863 265, xfer_data->xfer_peer_idstring,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1864 27, purple_xfer_get_filename(xfer),
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1865 249, xfer_data->info_val_249,
27401
5e5dfa76ce64 Fix File transfer issue with Pidgin 2.5.7, ticket #9478
Sulabh Mahajan <sulabh@pidgin.im>
parents: 27343
diff changeset
1866 251, xfer_data->xfer_idstring_for_relay);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1867
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1868 yahoo_packet_send_and_free(pkt_to_send, yd);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1869
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
1870 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1871 yahoo_xfer_connected_15, xfer) == NULL) {
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1872 purple_notify_error(gc, NULL, _("File Transfer Failed"),
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1873 _("Unable to establish file descriptor."));
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1874 purple_xfer_cancel_remote(xfer);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1875 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1876 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1877 else if(val_249 == 2) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32247
diff changeset
1878 p2p_data = g_hash_table_lookup(yd->peers, purple_xfer_get_remote_user(xfer));
23693
100d744dc99b changed gboolean connection_type to enum yahoo_p2p_connection_type
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23688
diff changeset
1879 if( !( p2p_data && (p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER) ) ) {
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1880 purple_xfer_cancel_remote(xfer);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1881 return;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1882 }
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
1883 if(!purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer)) {
23688
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1884 purple_xfer_cancel_remote(xfer);
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1885 return;
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1886 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1887 }
cdc6bf28417e Receive files when we are p2p server
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23687
diff changeset
1888 }
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1889
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1890 /* TODO: Check filename etc. No probs till some hacker comes in the way */
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1891 void yahoo_process_filetrans_acc_15(PurpleConnection *gc, struct yahoo_packet *pkt)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1892 {
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1893 gchar *xfer_peer_idstring = NULL;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1894 gchar *xfer_idstring_for_relay = NULL;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1895 PurpleXfer *xfer;
27959
f842ae57da4e Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27555
diff changeset
1896 YahooData *yd;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1897 struct yahoo_xfer_data *xfer_data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1898 GSList *l;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1899 PurpleAccount *account;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1900 long val_66 = 0;
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1901 gchar *url = NULL;
26343
b7be84823af9 Remove check of version for file transfer, use only version 15 file transfer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23695
diff changeset
1902 int val_249 = 0;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1903
32280
704f84f692f6 Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1904 yd = purple_connection_get_protocol_data(gc);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1905 for (l = pkt->hash; l; l = l->next) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1906 struct yahoo_pair *pair = l->data;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1907
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1908 switch (pair->key) {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1909 case 251:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1910 xfer_idstring_for_relay = pair->value;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1911 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1912 case 265:
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1913 xfer_peer_idstring = pair->value;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1914 break;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1915 case 66:
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1916 val_66 = atol(pair->value);
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1917 break;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1918 case 249:
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1919 val_249 = atol(pair->value);
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1920 break;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1921 case 250:
23694
95222c637ab6 minor changes in comments style and alphabetic ordering of header files.
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23693
diff changeset
1922 url = pair->value; /* we get a p2p url here when sending file, connected as client */
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1923 break;
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1924 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1925 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1926
22204
78dc320dad31 Some readability changes. Refs #4533.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22202
diff changeset
1927 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map, xfer_peer_idstring);
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1928 if(!xfer) return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1929
23680
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1930 if(val_66 == -1 || ( (!(xfer_idstring_for_relay)) && (val_249 != 2) ))
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1931 {
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1932 purple_xfer_cancel_remote(xfer);
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1933 return;
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1934 }
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1935
619bbd7ae401 Support for P2P file transfer (SEND), when we are client to the peer
Sulabh Mahajan <sulabh@pidgin.im>
parents: 23675
diff changeset
1936 if( (val_249 == 2) && (!(url)) )
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1937 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1938 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1939 return;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1940 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1941
32247
3de044282178 Convert the yahoo prpl to using the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 32005
diff changeset
1942 xfer_data = purple_xfer_get_protocol_data(xfer);
34219
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1943 if (url) {
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1944 PurpleHttpURL *url_p = purple_http_url_parse(url);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1945 if (!url_p) {
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1946 purple_debug_error("yahoo", "Invalid URL\n");
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1947 purple_xfer_cancel_remote(xfer);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1948 return;
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1949 }
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1950 xfer_data->host = g_strdup(purple_http_url_get_host(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1951 xfer_data->port = purple_http_url_get_port(url_p);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1952 xfer_data->path = g_strdup(purple_http_url_get_path(url_p));
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1953 purple_http_url_free(url_p);
eee308def583 HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34218
diff changeset
1954 }
27335
06a805d4e690 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents: 27051
diff changeset
1955
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1956 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1957 xfer_data->status_15 = ACCEPTED;
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1958 account = purple_connection_get_account(gc);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1959
27343
8a367ee70456 Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents: 27335
diff changeset
1960 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
22202
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1961 yahoo_xfer_connected_15, xfer) == NULL)
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1962 {
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1963 purple_notify_error(gc, NULL, _("File Transfer Failed"),_("Unable to connect"));
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1964 purple_xfer_cancel_remote(xfer);
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1965 }
e42ab2e3eba1 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents: 22201
diff changeset
1966 }

mercurial