Thu, 17 Oct 2019 23:36:37 -0400
Remove old #include of http header and its init.
| 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" |
| 7170 | 26 | #include "util.h" |
| 27 | ||
| 28 | #include "jabber.h" | |
| 29 | #include "iq.h" | |
|
12324
caf9784f2405
[gaim-migrate @ 14628]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
30 | #include "oob.h" |
| 7170 | 31 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
32 | struct _JabberOOBXfer { |
| 7170 | 33 | 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
|
34 | 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
|
35 | gchar *url; |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
36 | SoupMessage *msg; |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
37 | }; |
| 7170 | 38 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
39 | G_DEFINE_DYNAMIC_TYPE(JabberOOBXfer, jabber_oob_xfer, PURPLE_TYPE_XFER); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
40 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
41 | static void jabber_oob_xfer_xfer_init(PurpleXfer *xfer) |
| 7170 | 42 | { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
43 | purple_xfer_start(xfer, -1, NULL, 0); |
| 7170 | 44 | } |
| 45 | ||
| 15884 | 46 | static void jabber_oob_xfer_end(PurpleXfer *xfer) |
| 7170 | 47 | { |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
48 | JabberOOBXfer *jox = JABBER_OOB_XFER(xfer); |
| 7170 | 49 | JabberIq *iq; |
| 50 | ||
| 51 | iq = jabber_iq_new(jox->js, JABBER_IQ_RESULT); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
52 | purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer)); |
| 7170 | 53 | jabber_iq_set_id(iq, jox->iq_id); |
| 54 | ||
| 55 | jabber_iq_send(iq); | |
| 56 | } | |
| 57 | ||
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
58 | static void |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
59 | jabber_oob_xfer_got(G_GNUC_UNUSED SoupSession *session, SoupMessage *msg, |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
60 | gpointer user_data) |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
61 | { |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
62 | PurpleXfer *xfer = user_data; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
63 | JabberOOBXfer *jox; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
64 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
65 | if (purple_xfer_is_cancelled(xfer)) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
66 | return; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
67 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
68 | jox = JABBER_OOB_XFER(xfer); |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
69 | jox->msg = NULL; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
70 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
71 | if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code) || |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
72 | purple_xfer_get_bytes_remaining(xfer) > 0) { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
73 | 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
|
74 | 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
|
75 | } else { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
76 | 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
|
77 | purple_xfer_end(xfer); |
|
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 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
80 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
81 | static void |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
82 | jabber_oob_xfer_got_content_length(SoupMessage *msg, gpointer user_data) |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
83 | { |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
84 | PurpleXfer *xfer = user_data; |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
85 | goffset total; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
86 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
87 | total = soup_message_headers_get_content_length(msg->response_headers); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
88 | |
|
34272
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_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
|
90 | 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
|
91 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
92 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
93 | static void |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
94 | jabber_oob_xfer_writer(SoupMessage *msg, SoupBuffer *chunk, gpointer user_data) |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
95 | { |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
96 | PurpleXfer *xfer = user_data; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
97 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
98 | if (!purple_xfer_write_file(xfer, (const guchar *)chunk->data, |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
99 | chunk->length)) { |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
100 | JabberOOBXfer *jox = JABBER_OOB_XFER(xfer); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
101 | soup_session_cancel_message(jox->js->http_conns, msg, |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
102 | SOUP_STATUS_IO_ERROR); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
103 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
104 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12324
diff
changeset
|
105 | |
| 15884 | 106 | static void jabber_oob_xfer_start(PurpleXfer *xfer) |
| 7170 | 107 | { |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
108 | SoupMessage *msg; |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
109 | JabberOOBXfer *jox = JABBER_OOB_XFER(xfer); |
| 7170 | 110 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
111 | msg = soup_message_new("GET", jox->url); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
112 | soup_message_add_header_handler( |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
113 | msg, "got-headers", "Content-Length", |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
114 | G_CALLBACK(jabber_oob_xfer_got_content_length), xfer); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
115 | soup_message_body_set_accumulate(msg->response_body, FALSE); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
116 | g_signal_connect(msg, "got-chunk", G_CALLBACK(jabber_oob_xfer_writer), |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
117 | xfer); |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
118 | soup_session_queue_message(jox->js->http_conns, msg, jabber_oob_xfer_got, |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
119 | xfer); |
| 7170 | 120 | } |
| 121 | ||
| 15884 | 122 | static void jabber_oob_xfer_recv_error(PurpleXfer *xfer, const char *code) { |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
123 | JabberOOBXfer *jox = JABBER_OOB_XFER(xfer); |
| 7170 | 124 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
125 | PurpleXmlNode *y, *z; |
| 7170 | 126 | |
| 127 | iq = jabber_iq_new(jox->js, JABBER_IQ_ERROR); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
128 | purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer)); |
| 7170 | 129 | jabber_iq_set_id(iq, jox->iq_id); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
130 | y = purple_xmlnode_new_child(iq->node, "error"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
131 | purple_xmlnode_set_attrib(y, "code", code); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
132 | if(purple_strequal(code, "406")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
133 | z = purple_xmlnode_new_child(y, "not-acceptable"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
134 | purple_xmlnode_set_attrib(y, "type", "modify"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
135 | purple_xmlnode_set_namespace(z, NS_XMPP_STANZAS); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36256
diff
changeset
|
136 | } else if(purple_strequal(code, "404")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
137 | z = purple_xmlnode_new_child(y, "not-found"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
138 | purple_xmlnode_set_attrib(y, "type", "cancel"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
139 | purple_xmlnode_set_namespace(z, NS_XMPP_STANZAS); |
| 8399 | 140 | } |
| 7170 | 141 | jabber_iq_send(iq); |
| 142 | } | |
| 143 | ||
| 15884 | 144 | static void jabber_oob_xfer_recv_denied(PurpleXfer *xfer) { |
| 8399 | 145 | jabber_oob_xfer_recv_error(xfer, "406"); |
| 146 | } | |
| 147 | ||
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28984
diff
changeset
|
148 | static void jabber_oob_xfer_recv_cancelled(PurpleXfer *xfer) { |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
149 | JabberOOBXfer *jox = JABBER_OOB_XFER(xfer); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
150 | |
|
40004
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
151 | soup_session_cancel_message(jox->js->http_conns, jox->msg, |
|
cad626ba45b2
Convert XMPP OOB transfers to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39669
diff
changeset
|
152 | SOUP_STATUS_CANCELLED); |
| 8399 | 153 | jabber_oob_xfer_recv_error(xfer, "404"); |
| 154 | } | |
| 155 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
156 | void jabber_oob_parse(JabberStream *js, const char *from, JabberIqType type, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
157 | const char *id, PurpleXmlNode *querynode) { |
| 7170 | 158 | JabberOOBXfer *jox; |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
159 | 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
|
160 | gchar *url; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
161 | PurpleXmlNode *urlnode; |
| 7170 | 162 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
163 | if(type != JABBER_IQ_SET) |
| 14356 | 164 | return; |
| 165 | ||
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
166 | if(!from) |
| 7170 | 167 | return; |
| 168 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
169 | if(!(urlnode = purple_xmlnode_get_child(querynode, "url"))) |
| 7170 | 170 | return; |
| 171 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
172 | url = purple_xmlnode_get_data(urlnode); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
173 | if (!url) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
174 | return; |
| 7170 | 175 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
176 | jox = g_object_new( |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
177 | JABBER_TYPE_OOB_XFER, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
178 | "account", purple_connection_get_account(js->gc), |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
179 | "type", PURPLE_XFER_TYPE_RECEIVE, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
180 | "remote-user", from, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
181 | NULL |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
182 | ); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
183 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
184 | jox->iq_id = g_strdup(id); |
| 7170 | 185 | 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
|
186 | jox->url = url; |
| 7170 | 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 | slash = strrchr(url, '/'); |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
189 | if (slash == NULL) { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
190 | filename = url; |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
191 | } else { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
192 | filename = slash + 1; |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
193 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
194 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
195 | purple_xfer_set_filename(PURPLE_XFER(jox), filename); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
196 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
197 | js->oob_file_transfers = g_list_append(js->oob_file_transfers, jox); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
198 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
199 | purple_xfer_request(PURPLE_XFER(jox)); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
200 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
201 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
202 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
203 | jabber_oob_xfer_init(JabberOOBXfer *xfer) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
204 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
205 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
206 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
207 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
208 | jabber_oob_xfer_finalize(GObject *obj) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
209 | JabberOOBXfer *jox = JABBER_OOB_XFER(obj); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
210 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
211 | jox->js->oob_file_transfers = g_list_remove(jox->js->oob_file_transfers, |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
212 | jox); |
| 7170 | 213 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
214 | g_free(jox->iq_id); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
215 | g_free(jox->url); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
216 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
217 | G_OBJECT_CLASS(jabber_oob_xfer_parent_class)->finalize(obj); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
218 | } |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
219 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
220 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
221 | jabber_oob_xfer_class_finalize(JabberOOBXferClass *klass) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
222 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
223 | } |
| 7170 | 224 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
225 | static void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
226 | jabber_oob_xfer_class_init(JabberOOBXferClass *klass) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
227 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
228 | PurpleXferClass *xfer_class = PURPLE_XFER_CLASS(klass); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
229 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
230 | obj_class->finalize = jabber_oob_xfer_finalize; |
| 7170 | 231 | |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
232 | xfer_class->init = jabber_oob_xfer_xfer_init; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
233 | xfer_class->end = jabber_oob_xfer_end; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
234 | xfer_class->request_denied = jabber_oob_xfer_recv_denied; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
235 | xfer_class->cancel_recv = jabber_oob_xfer_recv_cancelled; |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
236 | xfer_class->start = jabber_oob_xfer_start; |
| 7170 | 237 | } |
|
39669
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
238 | |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
239 | void |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
240 | jabber_oob_xfer_register(GTypeModule *module) { |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
241 | jabber_oob_xfer_register_type(module); |
|
bab07ecb9330
Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents:
39556
diff
changeset
|
242 | } |