Fri, 06 Sep 2013 03:12:43 +0530
Removed IO ops from protocols
| 7170 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7170 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28206
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28206
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28206
diff
changeset
|
6 | * source distribution. |
| 7170 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 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:
15884
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7170 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 7234 | 24 | #include "debug.h" |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34287
diff
changeset
|
25 | #include "xfer.h" |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
26 | #include "http.h" |
| 7170 | 27 | #include "util.h" |
| 28 | ||
| 29 | #include "jabber.h" | |
| 30 | #include "iq.h" | |
|
12324
caf9784f2405
[gaim-migrate @ 14628]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
31 | #include "oob.h" |
| 7170 | 32 | |
| 33 | typedef struct _JabberOOBXfer { | |
| 34 | JabberStream *js; | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
35 | gchar *iq_id; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
36 | gchar *url; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
37 | PurpleHttpConnection *hc; |
| 7170 | 38 | } JabberOOBXfer; |
| 39 | ||
| 15884 | 40 | static void jabber_oob_xfer_init(PurpleXfer *xfer) |
| 7170 | 41 | { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
42 | purple_xfer_start(xfer, -1, NULL, 0); |
| 7170 | 43 | } |
| 44 | ||
| 15884 | 45 | static void jabber_oob_xfer_free(PurpleXfer *xfer) |
| 7170 | 46 | { |
|
32245
6e7b93c200fe
Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
30708
diff
changeset
|
47 | JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
48 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
49 | purple_xfer_set_protocol_data(xfer, NULL); |
| 7395 | 50 | jox->js->oob_file_transfers = g_list_remove(jox->js->oob_file_transfers, |
| 51 | xfer); | |
| 7170 | 52 | |
| 53 | g_free(jox->iq_id); | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
54 | g_free(jox->url); |
| 7170 | 55 | g_free(jox); |
| 56 | } | |
| 57 | ||
| 15884 | 58 | static void jabber_oob_xfer_end(PurpleXfer *xfer) |
| 7170 | 59 | { |
|
32245
6e7b93c200fe
Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
30708
diff
changeset
|
60 | JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); |
| 7170 | 61 | JabberIq *iq; |
| 62 | ||
| 63 | iq = jabber_iq_new(jox->js, JABBER_IQ_RESULT); | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32245
diff
changeset
|
64 | xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer)); |
| 7170 | 65 | jabber_iq_set_id(iq, jox->iq_id); |
| 66 | ||
| 67 | jabber_iq_send(iq); | |
| 68 | ||
| 69 | jabber_oob_xfer_free(xfer); | |
| 70 | } | |
| 71 | ||
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
72 | static void |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
73 | jabber_oob_xfer_got(PurpleHttpConnection *hc, PurpleHttpResponse *response, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
74 | gpointer _xfer) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
75 | { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
76 | PurpleXfer *xfer = _xfer; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
77 | JabberOOBXfer *jox; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
78 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
79 | if (purple_xfer_is_cancelled(xfer)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
80 | return; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
81 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
82 | jox = purple_xfer_get_protocol_data(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
83 | jox->hc = NULL; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
84 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
85 | if (!purple_http_response_is_successful(response) || |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
86 | purple_xfer_get_bytes_remaining(xfer) > 0) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
87 | { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
88 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
89 | purple_xfer_end(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
90 | } else { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
91 | purple_xfer_set_completed(xfer, TRUE); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
92 | purple_xfer_end(xfer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
93 | } |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
94 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
95 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
96 | static void |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
97 | jabber_oob_xfer_progress_watcher(PurpleHttpConnection *hc, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
98 | gboolean reading_state, int processed, int total, gpointer _xfer) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
99 | { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
100 | PurpleXfer *xfer = _xfer; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
101 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
102 | if (!reading_state) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
103 | return; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
104 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
105 | purple_xfer_set_size(xfer, total); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
106 | purple_xfer_update_progress(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
107 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
108 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
109 | static gboolean |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
110 | jabber_oob_xfer_writer(PurpleHttpConnection *http_conn, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
111 | PurpleHttpResponse *response, const gchar *buffer, size_t offset, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
112 | size_t length, gpointer _xfer) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
113 | { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
114 | PurpleXfer *xfer = _xfer; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
115 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
116 | return purple_xfer_write_file(xfer, (const guchar*)buffer, length); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
117 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
118 | |
| 15884 | 119 | static void jabber_oob_xfer_start(PurpleXfer *xfer) |
| 7170 | 120 | { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
121 | PurpleHttpRequest *req; |
|
32245
6e7b93c200fe
Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
30708
diff
changeset
|
122 | JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); |
| 7170 | 123 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
124 | req = purple_http_request_new(jox->url); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
125 | purple_http_request_set_timeout(req, -1); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
126 | purple_http_request_set_max_len(req, -1); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
127 | purple_http_request_set_response_writer(req, jabber_oob_xfer_writer, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
128 | xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
129 | jox->hc = purple_http_request(jox->js->gc, req, jabber_oob_xfer_got, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
130 | xfer); |
| 7170 | 131 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
132 | purple_http_conn_set_progress_watcher(jox->hc, |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
133 | jabber_oob_xfer_progress_watcher, xfer, -1); |
| 7170 | 134 | } |
| 135 | ||
| 15884 | 136 | static void jabber_oob_xfer_recv_error(PurpleXfer *xfer, const char *code) { |
|
32245
6e7b93c200fe
Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents:
30708
diff
changeset
|
137 | JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); |
| 7170 | 138 | JabberIq *iq; |
| 8399 | 139 | xmlnode *y, *z; |
| 7170 | 140 | |
| 141 | iq = jabber_iq_new(jox->js, JABBER_IQ_ERROR); | |
|
32270
028a4b3c0402
Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents:
32245
diff
changeset
|
142 | xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer)); |
| 7170 | 143 | jabber_iq_set_id(iq, jox->iq_id); |
| 144 | y = xmlnode_new_child(iq->node, "error"); | |
| 8399 | 145 | xmlnode_set_attrib(y, "code", code); |
| 146 | if(!strcmp(code, "406")) { | |
| 147 | z = xmlnode_new_child(y, "not-acceptable"); | |
| 148 | xmlnode_set_attrib(y, "type", "modify"); | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
149 | xmlnode_set_namespace(z, NS_XMPP_STANZAS); |
| 8399 | 150 | } else if(!strcmp(code, "404")) { |
| 151 | z = xmlnode_new_child(y, "not-found"); | |
| 152 | xmlnode_set_attrib(y, "type", "cancel"); | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
153 | xmlnode_set_namespace(z, NS_XMPP_STANZAS); |
| 8399 | 154 | } |
| 7170 | 155 | jabber_iq_send(iq); |
| 156 | ||
| 157 | jabber_oob_xfer_free(xfer); | |
| 158 | } | |
| 159 | ||
| 15884 | 160 | static void jabber_oob_xfer_recv_denied(PurpleXfer *xfer) { |
| 8399 | 161 | jabber_oob_xfer_recv_error(xfer, "406"); |
| 162 | } | |
| 163 | ||
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28984
diff
changeset
|
164 | static void jabber_oob_xfer_recv_cancelled(PurpleXfer *xfer) { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
165 | JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
166 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
167 | purple_http_conn_cancel(jox->hc); |
| 8399 | 168 | jabber_oob_xfer_recv_error(xfer, "404"); |
| 169 | } | |
| 170 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
171 | void jabber_oob_parse(JabberStream *js, const char *from, JabberIqType type, |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
172 | const char *id, xmlnode *querynode) { |
| 7170 | 173 | JabberOOBXfer *jox; |
| 15884 | 174 | PurpleXfer *xfer; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
175 | const gchar *filename, *slash; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
176 | gchar *url; |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
177 | xmlnode *urlnode; |
| 7170 | 178 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
179 | if(type != JABBER_IQ_SET) |
| 14356 | 180 | return; |
| 181 | ||
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
182 | if(!from) |
| 7170 | 183 | return; |
| 184 | ||
| 185 | if(!(urlnode = xmlnode_get_child(querynode, "url"))) | |
| 186 | return; | |
| 187 | ||
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
188 | url = xmlnode_get_data(urlnode); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
189 | if (!url) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
190 | return; |
| 7170 | 191 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
192 | xfer = purple_xfer_new(purple_connection_get_account(js->gc), |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
193 | PURPLE_XFER_RECEIVE, from); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
194 | if (!xfer) { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
195 | g_free(url); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
196 | return; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
197 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
198 | |
| 7170 | 199 | jox = g_new0(JabberOOBXfer, 1); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
200 | jox->iq_id = g_strdup(id); |
| 7170 | 201 | jox->js = js; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
202 | jox->url = url; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
203 | purple_xfer_set_protocol_data(xfer, jox); |
| 7170 | 204 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
205 | slash = strrchr(url, '/'); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
206 | if (slash == NULL) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
207 | filename = url; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
208 | else |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
209 | filename = slash + 1; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
210 | purple_xfer_set_filename(xfer, filename); |
| 34920 | 211 | |
| 212 | purple_xfer_set_init_fnc(xfer, jabber_oob_xfer_init); | |
| 213 | purple_xfer_set_end_fnc(xfer, jabber_oob_xfer_end); | |
| 214 | purple_xfer_set_request_denied_fnc(xfer, jabber_oob_xfer_recv_denied); | |
| 215 | purple_xfer_set_cancel_recv_fnc(xfer, jabber_oob_xfer_recv_cancelled); | |
| 216 | purple_xfer_set_start_fnc(xfer, jabber_oob_xfer_start); | |
| 7170 | 217 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
218 | js->oob_file_transfers = g_list_append(js->oob_file_transfers, xfer); |
| 7170 | 219 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
220 | purple_xfer_request(xfer); |
| 7170 | 221 | } |