Tue, 21 Mar 2023 01:59:19 -0500
Use g_clear_handle_id everywhere
Testing Done:
Compiled and ran tests in valgrind.
Reviewed at https://reviews.imfreedom.org/r/2374/
|
23607
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
2 | * purple - Jabber Protocol Plugin |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28079
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:
28079
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:
28079
diff
changeset
|
6 | * source distribution. |
|
23607
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
7 | * |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
12 | * |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
17 | * |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
23607
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
21 | * |
|
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
22 | */ |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40336
diff
changeset
|
25 | #include <purple.h> |
|
23607
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
26 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
27 | #include <libsoup/soup.h> |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
28 | |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
29 | #include "bosh.h" |
|
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
30 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
31 | /* |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
32 | TODO: test, what happens, if the http server (BOSH server) doesn't support |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
33 | keep-alive (sends connection: close). |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
34 | */ |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
35 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
36 | #define JABBER_BOSH_SEND_DELAY 250 |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
37 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
38 | #define JABBER_BOSH_TIMEOUT 10 |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
39 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
40 | static gchar *jabber_bosh_useragent = NULL; |
|
28062
f743d255c355
jabber: Re-order the BOSH structs and normalize the buffer names.
Paul Aurich <darkrain42@pidgin.im>
parents:
27811
diff
changeset
|
41 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
42 | struct _PurpleJabberBOSHConnection { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
43 | JabberStream *js; |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
44 | SoupSession *payload_reqs; |
|
28062
f743d255c355
jabber: Re-order the BOSH structs and normalize the buffer names.
Paul Aurich <darkrain42@pidgin.im>
parents:
27811
diff
changeset
|
45 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
46 | gchar *url; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
47 | gboolean is_ssl; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
48 | gboolean is_terminating; |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
49 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
50 | gchar *sid; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
51 | guint64 rid; /* Must be big enough to hold 2^53 - 1 */ |
|
26083
e716012de66e
Rearrange the structs and fix the indentation. No functional changes.
Paul Aurich <darkrain42@pidgin.im>
parents:
26082
diff
changeset
|
52 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
53 | GString *send_buff; |
|
28072
208dfa375b79
jabber: Add a BOSH send timer (queue up stanzas), fixes connecting to Prosody
Paul Aurich <darkrain42@pidgin.im>
parents:
28066
diff
changeset
|
54 | guint send_timer; |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
55 | }; |
|
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
56 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
57 | static SoupMessage *jabber_bosh_connection_http_request_new( |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
58 | PurpleJabberBOSHConnection *conn, const GString *data); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
59 | static void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
60 | jabber_bosh_connection_session_create(PurpleJabberBOSHConnection *conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
61 | static void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
62 | jabber_bosh_connection_send_now(PurpleJabberBOSHConnection *conn); |
|
23607
bc82598d3798
* looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff
changeset
|
63 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
64 | void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
65 | jabber_bosh_init(void) |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
66 | { |
|
41867
5375c1d58c50
Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
41838
diff
changeset
|
67 | PurpleUi *ui = purple_core_get_ui(); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
68 | const gchar *ui_name = NULL; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
69 | const gchar *ui_version = NULL; |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
70 | |
|
41867
5375c1d58c50
Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
41838
diff
changeset
|
71 | if(PURPLE_IS_UI(ui)) { |
|
5375c1d58c50
Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
41838
diff
changeset
|
72 | ui_name = purple_ui_get_name(ui); |
|
5375c1d58c50
Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
41838
diff
changeset
|
73 | ui_version = purple_ui_get_version(ui); |
|
25487
00e94f044205
The BOSH User Agent should include the client name (and optionally version),
Paul Aurich <darkrain42@pidgin.im>
parents:
25486
diff
changeset
|
74 | } |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
75 | |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
40112
diff
changeset
|
76 | if(ui_name) { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
77 | jabber_bosh_useragent = g_strdup_printf( |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
78 | "%s%s%s (libpurple " VERSION ")", ui_name, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
79 | ui_version ? " " : "", ui_version ? ui_version : ""); |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
40112
diff
changeset
|
80 | } else { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
81 | jabber_bosh_useragent = g_strdup("libpurple " VERSION); |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
40112
diff
changeset
|
82 | } |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
83 | } |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
84 | |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
85 | void jabber_bosh_uninit(void) |
|
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
86 | { |
|
42172
7c2d151b410d
Use g_clear_* helpers where useful
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41921
diff
changeset
|
87 | g_clear_pointer(&jabber_bosh_useragent, g_free); |
|
24874
33902e1daba1
Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents:
24873
diff
changeset
|
88 | } |
|
33902e1daba1
Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents:
24873
diff
changeset
|
89 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
90 | PurpleJabberBOSHConnection* |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
91 | jabber_bosh_connection_new(JabberStream *js, const gchar *url) |
|
24874
33902e1daba1
Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents:
24873
diff
changeset
|
92 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
93 | PurpleJabberBOSHConnection *conn; |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
94 | PurpleAccount *account; |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
95 | GProxyResolver *resolver; |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
96 | GError *error = NULL; |
|
41211
2e804c9c0919
Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40819
diff
changeset
|
97 | const gchar *scheme; |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
98 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
99 | account = purple_connection_get_account(js->gc); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
100 | resolver = purple_proxy_get_proxy_resolver(account, &error); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
101 | if (resolver == NULL) { |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
102 | purple_debug_error("jabber-bosh", |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
103 | "Unable to get account proxy resolver: %s", |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
104 | error->message); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
105 | g_error_free(error); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
106 | return NULL; |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
107 | } |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
108 | |
|
41211
2e804c9c0919
Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40819
diff
changeset
|
109 | scheme = g_uri_peek_scheme(url); |
|
2e804c9c0919
Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40819
diff
changeset
|
110 | if (scheme == NULL) { |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
111 | purple_debug_error("jabber-bosh", "Unable to parse given BOSH URL: %s", |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
112 | url); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
113 | g_object_unref(resolver); |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
114 | return NULL; |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
115 | } |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
116 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
117 | conn = g_new0(PurpleJabberBOSHConnection, 1); |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
118 | conn->payload_reqs = soup_session_new_with_options( |
|
40819
54b2a95ac176
Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
119 | "proxy-resolver", resolver, |
|
54b2a95ac176
Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
120 | "timeout", JABBER_BOSH_TIMEOUT + 2, |
|
54b2a95ac176
Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
121 | "user-agent", jabber_bosh_useragent, |
|
54b2a95ac176
Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
122 | NULL); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
123 | conn->url = g_strdup(url); |
|
23613
1da7c5cbcc54
* doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23612
diff
changeset
|
124 | conn->js = js; |
|
41211
2e804c9c0919
Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40819
diff
changeset
|
125 | conn->is_ssl = g_str_equal(scheme, "https"); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
126 | conn->send_buff = g_string_new(NULL); |
|
26672
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
127 | |
|
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
128 | /* |
|
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
129 | * Random 64-bit integer masked off by 2^52 - 1. |
|
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
130 | * |
|
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
131 | * This should produce a random integer in the range [0, 2^52). It's |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
132 | * unlikely we'll send enough packets in one session to overflow the |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
133 | * rid. |
|
26672
d424e92111b5
A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents:
26664
diff
changeset
|
134 | */ |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
135 | conn->rid = (((guint64)g_random_int() << 32) | g_random_int()); |
|
26967
b52a6393cc13
Windows compilation complains (probably because it's 32-bit)
Paul Aurich <darkrain42@pidgin.im>
parents:
26673
diff
changeset
|
136 | conn->rid &= 0xFFFFFFFFFFFFFLL; |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
137 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
138 | g_object_unref(resolver); |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
139 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
140 | jabber_bosh_connection_session_create(conn); |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
141 | |
|
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
142 | return conn; |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
143 | } |
|
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
144 | |
|
24874
33902e1daba1
Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents:
24873
diff
changeset
|
145 | void |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
146 | jabber_bosh_connection_destroy(PurpleJabberBOSHConnection *conn) |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
147 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
148 | if (conn == NULL || conn->is_terminating) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
149 | return; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
150 | conn->is_terminating = TRUE; |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
151 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
152 | if (conn->sid != NULL) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
153 | purple_debug_info("jabber-bosh", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
154 | "Terminating a session for %p\n", conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
155 | jabber_bosh_connection_send_now(conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
156 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
157 | |
|
42175
4185b4043214
Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
158 | g_clear_handle_id(&conn->send_timer, g_source_remove); |
|
26082
7e3952f2713d
Obey the 'inactivity' attribute and send blank updates often enough. Also,
Paul Aurich <darkrain42@pidgin.im>
parents:
26081
diff
changeset
|
159 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
160 | soup_session_abort(conn->payload_reqs); |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
161 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
162 | g_clear_object(&conn->payload_reqs); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
163 | g_string_free(conn->send_buff, TRUE); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
164 | conn->send_buff = NULL; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
165 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
166 | g_free(conn->sid); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
167 | conn->sid = NULL; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
168 | g_free(conn->url); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
169 | conn->url = NULL; |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
170 | |
|
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
171 | g_free(conn); |
|
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
172 | } |
|
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
173 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
174 | gboolean |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
175 | jabber_bosh_connection_is_ssl(const PurpleJabberBOSHConnection *conn) |
|
26533
5c74696c34d1
BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents:
26085
diff
changeset
|
176 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
177 | return conn->is_ssl; |
|
26533
5c74696c34d1
BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents:
26085
diff
changeset
|
178 | } |
|
5c74696c34d1
BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents:
26085
diff
changeset
|
179 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
180 | static PurpleXmlNode * |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
181 | jabber_bosh_connection_parse(PurpleJabberBOSHConnection *conn, |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
182 | SoupMessage *msg, GBytes *response_body, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
183 | GError *error) |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
184 | { |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
185 | gconstpointer body = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
186 | gsize length = 0; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
187 | PurpleXmlNode *root; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
188 | const gchar *type; |
|
28066
6e27a78baf3d
jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents:
28065
diff
changeset
|
189 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
190 | g_return_val_if_fail(conn != NULL, NULL); |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
191 | g_return_val_if_fail(msg != NULL, NULL); |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
192 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
193 | if (conn->is_terminating || purple_account_is_disconnecting( |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
194 | purple_connection_get_account(conn->js->gc))) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
195 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
196 | return NULL; |
|
27811
9db18cacd8fc
Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
197 | } |
|
9db18cacd8fc
Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
198 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
199 | if(error != NULL || |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
200 | !SOUP_STATUS_IS_SUCCESSFUL(soup_message_get_status(msg))) { |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
201 | gchar *tmp = g_strdup_printf( |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
202 | _("Unable to connect: %s"), |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
203 | error ? error->message : soup_message_get_reason_phrase(msg)); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
204 | purple_connection_error(conn->js->gc, |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
205 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
206 | g_free(tmp); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
207 | return NULL; |
|
31360
4ddd59618002
jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents:
31350
diff
changeset
|
208 | } |
|
4ddd59618002
jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents:
31350
diff
changeset
|
209 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
210 | body = g_bytes_get_data(response_body, &length); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
211 | root = purple_xmlnode_from_str(body, length); |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
212 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
213 | type = purple_xmlnode_get_attrib(root, "type"); |
| 38358 | 214 | if (purple_strequal(type, "terminate")) { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
215 | purple_connection_error(conn->js->gc, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
216 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, _("The BOSH " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
217 | "connection manager terminated your session.")); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
218 | purple_xmlnode_free(root); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
219 | return NULL; |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
220 | } |
|
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
221 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
222 | return root; |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
223 | } |
|
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
224 | |
|
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
225 | static void |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
226 | jabber_bosh_connection_recv(GObject *source, GAsyncResult *result, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
227 | gpointer data) |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
228 | { |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
229 | SoupMessage *msg = data; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
230 | PurpleJabberBOSHConnection *bosh_conn = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
231 | GBytes *response_body = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
232 | GError *error = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
233 | PurpleXmlNode *node, *child; |
|
27811
9db18cacd8fc
Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
234 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
235 | response_body = soup_session_send_and_read_finish(SOUP_SESSION(source), |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
236 | result, &error); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
237 | bosh_conn = g_object_get_data(G_OBJECT(msg), "bosh-connection"); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
238 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
239 | if (response_body != NULL && purple_debug_is_verbose() && |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
240 | purple_debug_is_unsafe()) |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
241 | { |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
242 | const gchar *body = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
243 | gsize length = 0; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
244 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
245 | body = g_bytes_get_data(response_body, &length); |
|
41883
c67c45d70006
Fix string size specifier in debug prints
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41880
diff
changeset
|
246 | purple_debug_misc("jabber-bosh", "received: %.*s", (int)length, body); |
|
26664
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
247 | } |
|
a42da6facb80
Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents:
26661
diff
changeset
|
248 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
249 | node = jabber_bosh_connection_parse(bosh_conn, msg, response_body, error); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
250 | g_clear_pointer(&response_body, g_bytes_unref); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
251 | g_clear_error(&error); |
|
41880
4371fa2ce648
Fix SoupMessage leaks when using new libsoup3 API
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41867
diff
changeset
|
252 | g_clear_object(&msg); |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
253 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
254 | if (node == NULL) { |
|
24875
0fa0cf6ea28e
Make the Request ID a long long (fit in 2^53-1)
Paul Aurich <darkrain42@pidgin.im>
parents:
24874
diff
changeset
|
255 | return; |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
256 | } |
|
24875
0fa0cf6ea28e
Make the Request ID a long long (fit in 2^53-1)
Paul Aurich <darkrain42@pidgin.im>
parents:
24874
diff
changeset
|
257 | |
|
23620
e306af5178d7
* data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23619
diff
changeset
|
258 | child = node->child; |
|
24875
0fa0cf6ea28e
Make the Request ID a long long (fit in 2^53-1)
Paul Aurich <darkrain42@pidgin.im>
parents:
24874
diff
changeset
|
259 | while (child != NULL) { |
|
24886
de0388948ac8
Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
24885
diff
changeset
|
260 | /* jabber_process_packet might free child */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
261 | PurpleXmlNode *next = child->next; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
262 | const gchar *xmlns; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
263 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
264 | if (child->type != PURPLE_XMLNODE_TYPE_TAG) { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
265 | child = next; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
266 | continue; |
|
23620
e306af5178d7
* data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23619
diff
changeset
|
267 | } |
|
24886
de0388948ac8
Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
24885
diff
changeset
|
268 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
269 | /* Workaround for non-compliant servers that don't stamp |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
270 | * the right xmlns on these packets. See #11315. |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
271 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
272 | xmlns = purple_xmlnode_get_namespace(child); |
| 38358 | 273 | if ((xmlns == NULL || purple_strequal(xmlns, NS_BOSH)) && |
| 274 | (purple_strequal(child->name, "iq") || | |
| 275 | purple_strequal(child->name, "message") || | |
| 276 | purple_strequal(child->name, "presence"))) | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
277 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
278 | purple_xmlnode_set_namespace(child, NS_XMPP_CLIENT); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
279 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
280 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
281 | jabber_process_packet(bosh_conn->js, &child); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
282 | |
|
24886
de0388948ac8
Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
24885
diff
changeset
|
283 | child = next; |
|
23620
e306af5178d7
* data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23619
diff
changeset
|
284 | } |
|
23619
5c215ab46f1e
* moving BOSH interfacing from jabber_send to jabber_send_raw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23618
diff
changeset
|
285 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
286 | jabber_bosh_connection_send(bosh_conn, NULL); |
|
23618
8497c2f5e62d
* using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23617
diff
changeset
|
287 | } |
|
8497c2f5e62d
* using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23617
diff
changeset
|
288 | |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
289 | static void |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
290 | jabber_bosh_connection_send_now(PurpleJabberBOSHConnection *conn) |
|
26078
3526ac955ce3
Rename a few functions and drop some data members.
Paul Aurich <darkrain42@pidgin.im>
parents:
26076
diff
changeset
|
291 | { |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
292 | SoupMessage *req; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
293 | GString *data; |
|
31349
dd0d5d14b148
jabber: Make the BOSH parsing a little more resilient and add more diagnostic output
Paul Aurich <darkrain42@pidgin.im>
parents:
31348
diff
changeset
|
294 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
295 | g_return_if_fail(conn != NULL); |
|
23621
d7a6cc7ca517
* sending empty <body> requests if there are not othere requests to be answered to keep a CM -> client channel open
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23620
diff
changeset
|
296 | |
|
42175
4185b4043214
Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42172
diff
changeset
|
297 | g_clear_handle_id(&conn->send_timer, g_source_remove); |
|
26533
5c74696c34d1
BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents:
26085
diff
changeset
|
298 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
299 | if (conn->sid == NULL) |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
300 | return; |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
301 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
302 | data = g_string_new(NULL); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
303 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
304 | /* missing parameters: route, from, ack */ |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
305 | g_string_printf(data, "<body " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
306 | "rid='%" G_GUINT64_FORMAT "' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
307 | "sid='%s' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
308 | "xmlns='" NS_BOSH "' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
309 | "xmlns:xmpp='" NS_XMPP_BOSH "' ", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
310 | ++conn->rid, conn->sid); |
|
26076
1755f871f1d1
Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents:
25489
diff
changeset
|
311 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
312 | if (conn->js->reinit && !conn->is_terminating) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
313 | g_string_append(data, "xmpp:restart='true'/>"); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
314 | conn->js->reinit = FALSE; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
315 | } else { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
316 | if (conn->is_terminating) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
317 | g_string_append(data, "type='terminate' "); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
318 | g_string_append_c(data, '>'); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
319 | g_string_append_len(data, conn->send_buff->str, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
320 | conn->send_buff->len); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
321 | g_string_append(data, "</body>"); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
322 | g_string_set_size(conn->send_buff, 0); |
|
28066
6e27a78baf3d
jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents:
28065
diff
changeset
|
323 | } |
|
28079
69fc36a9cbe3
jabber: Keep a second connection open over which to send the terminate.
Paul Aurich <darkrain42@pidgin.im>
parents:
28072
diff
changeset
|
324 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
325 | if (purple_debug_is_verbose() && purple_debug_is_unsafe()) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
326 | purple_debug_misc("jabber-bosh", "sending: %s\n", data->str); |
|
31360
4ddd59618002
jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents:
31350
diff
changeset
|
327 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
328 | req = jabber_bosh_connection_http_request_new(conn, data); |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
329 | g_string_free(data, FALSE); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
330 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
331 | if (conn->is_terminating) { |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
332 | #if SOUP_MAJOR_VERSION >= 3 |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
333 | soup_session_send_async(conn->payload_reqs, req, G_PRIORITY_DEFAULT, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
334 | NULL, NULL, NULL); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
335 | #else |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
336 | soup_session_send_async(conn->payload_reqs, req, NULL, NULL, NULL); |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
337 | #endif |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
338 | g_free(conn->sid); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
339 | conn->sid = NULL; |
|
26534
20a970cad8e2
Because BOSH works over connections that may die non-fatally, we need to
Paul Aurich <darkrain42@pidgin.im>
parents:
26533
diff
changeset
|
340 | } else { |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
341 | g_object_set_data(G_OBJECT(req), "bosh-connection", conn); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
342 | soup_session_send_and_read_async(conn->payload_reqs, req, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
343 | G_PRIORITY_DEFAULT, NULL, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
344 | jabber_bosh_connection_recv, req); |
|
26534
20a970cad8e2
Because BOSH works over connections that may die non-fatally, we need to
Paul Aurich <darkrain42@pidgin.im>
parents:
26533
diff
changeset
|
345 | } |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
346 | } |
|
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
347 | |
|
35264
5b9619d1dec4
Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents:
35263
diff
changeset
|
348 | static gboolean |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
349 | jabber_bosh_connection_send_delayed(gpointer _conn) |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
350 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
351 | PurpleJabberBOSHConnection *conn = _conn; |
|
31350
c4038b151558
jabber: Handle the connection: close header. Closes #13008
Paul Aurich <darkrain42@pidgin.im>
parents:
31349
diff
changeset
|
352 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
353 | conn->send_timer = 0; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
354 | jabber_bosh_connection_send_now(conn); |
|
35264
5b9619d1dec4
Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents:
35263
diff
changeset
|
355 | |
|
5b9619d1dec4
Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents:
35263
diff
changeset
|
356 | return FALSE; |
|
23620
e306af5178d7
* data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23619
diff
changeset
|
357 | } |
|
e306af5178d7
* data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23619
diff
changeset
|
358 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
359 | void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
360 | jabber_bosh_connection_send(PurpleJabberBOSHConnection *conn, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
361 | const gchar *data) |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
362 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
363 | g_return_if_fail(conn != NULL); |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
364 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
365 | if (data) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
366 | g_string_append(conn->send_buff, data); |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
367 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
368 | if (conn->send_timer == 0) { |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
369 | conn->send_timer = g_timeout_add( |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
370 | JABBER_BOSH_SEND_DELAY, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
371 | jabber_bosh_connection_send_delayed, conn); |
|
23614
cb637468e183
* preparing handling of multiple requests for pipelining support
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23613
diff
changeset
|
372 | } |
|
23612
0d8cc9f7f223
* adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23611
diff
changeset
|
373 | } |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
374 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
375 | void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
376 | jabber_bosh_connection_send_keepalive(PurpleJabberBOSHConnection *conn) |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
377 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
378 | g_return_if_fail(conn != NULL); |
| 27154 | 379 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
380 | jabber_bosh_connection_send_now(conn); |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
381 | } |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
382 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
383 | static gboolean |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
384 | jabber_bosh_version_check(const gchar *version, int major_req, int minor_min) |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
385 | { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
386 | const gchar *dot; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
387 | int major, minor = 0; |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
388 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
389 | if (version == NULL) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
390 | return FALSE; |
|
26081
ef41d4bd0dfa
Clean up BOSH reading and disconnection handling.
Paul Aurich <darkrain42@pidgin.im>
parents:
26079
diff
changeset
|
391 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
392 | major = atoi(version); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
393 | dot = strchr(version, '.'); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
394 | if (dot) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
395 | minor = atoi(dot + 1); |
|
24884
896733ece217
Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
24883
diff
changeset
|
396 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
397 | if (major != major_req) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
398 | return FALSE; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
399 | if (minor < minor_min) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
400 | return FALSE; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
401 | return TRUE; |
|
23612
0d8cc9f7f223
* adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23611
diff
changeset
|
402 | } |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
403 | |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
404 | static void |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
405 | jabber_bosh_connection_session_created(GObject *source, GAsyncResult *result, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
406 | gpointer data) |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
407 | { |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
408 | SoupMessage *msg = data; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
409 | PurpleJabberBOSHConnection *bosh_conn = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
410 | GBytes *response_body = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
411 | GError *error = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
412 | PurpleXmlNode *node, *features; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
413 | const gchar *sid, *ver, *inactivity_str; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
414 | int inactivity = 0; |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
415 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
416 | response_body = soup_session_send_and_read_finish(SOUP_SESSION(source), |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
417 | result, &error); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
418 | bosh_conn = g_object_get_data(G_OBJECT(msg), "bosh-connection"); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
419 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
420 | if (response_body != NULL && purple_debug_is_verbose() && |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
421 | purple_debug_is_unsafe()) |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
422 | { |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
423 | const gchar *body = NULL; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
424 | gsize length = 0; |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
425 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
426 | body = g_bytes_get_data(response_body, &length); |
|
41883
c67c45d70006
Fix string size specifier in debug prints
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41880
diff
changeset
|
427 | purple_debug_misc("jabber-bosh", "received (session creation): %.*s", |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
428 | (int)length, body); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
429 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
430 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
431 | node = jabber_bosh_connection_parse(bosh_conn, msg, response_body, error); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
432 | g_clear_pointer(&response_body, g_bytes_unref); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
433 | g_clear_error(&error); |
|
41880
4371fa2ce648
Fix SoupMessage leaks when using new libsoup3 API
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41867
diff
changeset
|
434 | g_clear_object(&msg); |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
435 | |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
436 | if (node == NULL) { |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
437 | return; |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
438 | } |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
439 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
440 | sid = purple_xmlnode_get_attrib(node, "sid"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
441 | ver = purple_xmlnode_get_attrib(node, "ver"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
442 | inactivity_str = purple_xmlnode_get_attrib(node, "inactivity"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
443 | /* requests = purple_xmlnode_get_attrib(node, "requests"); */ |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
444 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
445 | if (!sid) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
446 | purple_connection_error(bosh_conn->js->gc, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
447 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
448 | _("No BOSH session ID given")); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
449 | purple_xmlnode_free(node); |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
450 | return; |
|
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
451 | } |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
452 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
453 | if (ver == NULL) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
454 | purple_debug_info("jabber-bosh", "Missing version in BOSH initiation\n"); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
455 | } else if (!jabber_bosh_version_check(ver, 1, 6)) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
456 | purple_debug_error("jabber-bosh", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
457 | "Unsupported BOSH version: %s\n", ver); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
458 | purple_connection_error(bosh_conn->js->gc, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
459 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
460 | _("Unsupported version of BOSH protocol")); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
461 | purple_xmlnode_free(node); |
|
23611
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
462 | return; |
|
d811757e19b5
* adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23609
diff
changeset
|
463 | } |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
464 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
465 | purple_debug_misc("jabber-bosh", "Session created for %p\n", bosh_conn); |
| 23609 | 466 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
467 | bosh_conn->sid = g_strdup(sid); |
|
27811
9db18cacd8fc
Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
468 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
469 | if (inactivity_str) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
470 | inactivity = atoi(inactivity_str); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
471 | if (inactivity < 0 || inactivity > 3600) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
472 | purple_debug_warning("jabber-bosh", "Ignoring invalid " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
473 | "inactivity value: %s\n", inactivity_str); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
474 | inactivity = 0; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
475 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
476 | if (inactivity > 0) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
477 | inactivity -= 5; /* rounding */ |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
478 | if (inactivity <= 0) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
479 | inactivity = 1; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
480 | bosh_conn->js->max_inactivity = inactivity; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
481 | if (bosh_conn->js->inactivity_timer == 0) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
482 | purple_debug_misc("jabber-bosh", "Starting inactivity " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
483 | "timer for %d secs (compensating for " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
484 | "rounding)\n", inactivity); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
485 | jabber_stream_restart_inactivity_timer(bosh_conn->js); |
|
26085
6b5686df629c
BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents:
26084
diff
changeset
|
486 | } |
|
24872
68de61b562f6
Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents:
23625
diff
changeset
|
487 | } |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
488 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
489 | jabber_stream_set_state(bosh_conn->js, JABBER_STREAM_AUTHENTICATING); |
|
23613
1da7c5cbcc54
* doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23612
diff
changeset
|
490 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
491 | /* FIXME: Depending on receiving features might break with some hosts */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
492 | features = purple_xmlnode_get_child(node, "features"); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
493 | jabber_stream_features_parse(bosh_conn->js, features); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
494 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
495 | purple_xmlnode_free(node); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
496 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
497 | jabber_bosh_connection_send(bosh_conn, NULL); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
498 | } |
|
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
499 | |
|
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
500 | static void |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
501 | jabber_bosh_connection_session_create(PurpleJabberBOSHConnection *conn) |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
502 | { |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
503 | SoupMessage *req; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
504 | GString *data; |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
505 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
506 | purple_debug_misc("jabber-bosh", "Requesting Session Create for %p\n", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
507 | conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
508 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
509 | data = g_string_new(NULL); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
510 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
511 | /* missing optional parameters: route, from, ack */ |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
512 | g_string_printf(data, "<body content='text/xml; charset=utf-8' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
513 | "rid='%" G_GUINT64_FORMAT "' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
514 | "to='%s' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
515 | "xml:lang='en' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
516 | "ver='1.10' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
517 | "wait='%d' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
518 | "hold='1' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
519 | "xmlns='" NS_BOSH "' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
520 | "xmpp:version='1.0' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
521 | "xmlns:xmpp='urn:xmpp:xbosh' " |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
522 | "/>", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
523 | ++conn->rid, conn->js->user->domain, JABBER_BOSH_TIMEOUT); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
524 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
525 | req = jabber_bosh_connection_http_request_new(conn, data); |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
526 | g_string_free(data, FALSE); |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
527 | |
|
41838
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
528 | g_object_set_data(G_OBJECT(req), "bosh-connection", conn); |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
529 | soup_session_send_and_read_async(conn->payload_reqs, req, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
530 | G_PRIORITY_DEFAULT, NULL, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
531 | jabber_bosh_connection_session_created, |
|
54f5dccdd78c
Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41700
diff
changeset
|
532 | req); |
|
26673
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
533 | } |
|
f632d4de4bce
BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents:
26672
diff
changeset
|
534 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
535 | static SoupMessage * |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
536 | jabber_bosh_connection_http_request_new(PurpleJabberBOSHConnection *conn, |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
537 | const GString *data) |
|
24873
7d1e91d5ec46
Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents:
24872
diff
changeset
|
538 | { |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
539 | SoupMessage *req; |
|
41700
9f6a2c90800e
Convert soup_message_set_request to soup_message_set_request_body_from_bytes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41396
diff
changeset
|
540 | GBytes *body = NULL; |
|
28065
f9b9e38c98f4
jabber: Better inactivity timer logic.
Paul Aurich <darkrain42@pidgin.im>
parents:
28064
diff
changeset
|
541 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
542 | jabber_stream_restart_inactivity_timer(conn->js); |
|
28066
6e27a78baf3d
jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents:
28065
diff
changeset
|
543 | |
|
40002
f08d87a438c2
Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39987
diff
changeset
|
544 | req = soup_message_new("POST", conn->url); |
|
41700
9f6a2c90800e
Convert soup_message_set_request to soup_message_set_request_body_from_bytes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41396
diff
changeset
|
545 | body = g_bytes_new_take(data->str, data->len); |
|
9f6a2c90800e
Convert soup_message_set_request to soup_message_set_request_body_from_bytes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41396
diff
changeset
|
546 | soup_message_set_request_body_from_bytes(req, "text/xml; charset=utf-8", |
|
9f6a2c90800e
Convert soup_message_set_request to soup_message_set_request_body_from_bytes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41396
diff
changeset
|
547 | body); |
|
9f6a2c90800e
Convert soup_message_set_request to soup_message_set_request_body_from_bytes
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41396
diff
changeset
|
548 | g_bytes_unref(body); |
|
24883
c283f8737645
Jabber BOSH: Store less for each Request/Response
Paul Aurich <darkrain42@pidgin.im>
parents:
24875
diff
changeset
|
549 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
550 | return req; |
|
23613
1da7c5cbcc54
* doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents:
23612
diff
changeset
|
551 | } |