libpurple/protocols/jabber/bosh.c

Wed, 26 Oct 2022 02:06:39 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 26 Oct 2022 02:06:39 -0500
changeset 41838
54f5dccdd78c
parent 41700
9f6a2c90800e
child 41867
5375c1d58c50
permissions
-rw-r--r--

Port XMPP to libsoup3

Testing Done:
Compiled with libsoup2 and libsoup3.

Reviewed at https://reviews.imfreedom.org/r/1962/

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>
41212
9f0f4c23132e Use accessor for SoupMessage->status_code
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 41211
diff changeset
28 #include "libpurple/soupcompat.h"
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
29
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
30 #include "bosh.h"
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
31
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
32 /*
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 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
34 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
35 */
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
36
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
37 #define JABBER_BOSH_SEND_DELAY 250
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
38
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
39 #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
40
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
41 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
42
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
43 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
44 JabberStream *js;
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
45 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
46
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
47 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
48 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
49 gboolean is_terminating;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
50
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
51 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
52 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
53
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
54 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
55 guint send_timer;
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
56 };
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
57
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
58 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
59 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
60 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
61 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
62 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
63 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
64
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
65 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
66 jabber_bosh_init(void)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
67 {
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
68 PurpleUiInfo *ui_info = purple_core_get_ui_info();
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
69 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
70 const gchar *ui_version = NULL;
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
71
40336
4e766d681de5 purple_core_get_ui_info now transfers the PurpleUiInfo to the caller, so we need to make sure to not cache it.
Gary Kramlich <grim@reaperworld.com>
parents: 40312
diff changeset
72 if(PURPLE_IS_UI_INFO(ui_info)) {
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
73 ui_name = purple_ui_info_get_name(ui_info);
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
74 ui_version = purple_ui_info_get_version(ui_info);
25487
00e94f044205 The BOSH User Agent should include the client name (and optionally version),
Paul Aurich <darkrain42@pidgin.im>
parents: 25486
diff changeset
75 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
76
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
77 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
78 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
79 "%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
80 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
81 } 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
82 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
83 }
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
84 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
85
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
86 void jabber_bosh_uninit(void)
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
87 {
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
88 g_free(jabber_bosh_useragent);
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
89 jabber_bosh_useragent = NULL;
24874
33902e1daba1 Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents: 24873
diff changeset
90 }
33902e1daba1 Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents: 24873
diff changeset
91
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
92 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
93 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
94 {
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
95 PurpleJabberBOSHConnection *conn;
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
96 PurpleAccount *account;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
97 GProxyResolver *resolver;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
98 GError *error = NULL;
41211
2e804c9c0919 Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40819
diff changeset
99 const gchar *scheme;
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
100
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
101 account = purple_connection_get_account(js->gc);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
102 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
103 if (resolver == NULL) {
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
104 purple_debug_error("jabber-bosh",
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
105 "Unable to get account proxy resolver: %s",
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
106 error->message);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
107 g_error_free(error);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
108 return NULL;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
109 }
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
110
41211
2e804c9c0919 Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40819
diff changeset
111 scheme = g_uri_peek_scheme(url);
2e804c9c0919 Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40819
diff changeset
112 if (scheme == NULL) {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
113 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
114 url);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
115 g_object_unref(resolver);
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
116 return NULL;
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
117 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
118
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
119 conn = g_new0(PurpleJabberBOSHConnection, 1);
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
120 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
121 "proxy-resolver", resolver,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
122 "timeout", JABBER_BOSH_TIMEOUT + 2,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
123 "user-agent", jabber_bosh_useragent,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
124 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
125 conn->url = g_strdup(url);
23613
1da7c5cbcc54 * doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23612
diff changeset
126 conn->js = js;
41211
2e804c9c0919 Switch SoupURI to GUri
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40819
diff changeset
127 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
128 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
129
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 * 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
132 *
d424e92111b5 A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents: 26664
diff changeset
133 * 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
134 * 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
135 * 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
136 */
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
137 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
138 conn->rid &= 0xFFFFFFFFFFFFFLL;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
139
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
140 g_object_unref(resolver);
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
141
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
142 jabber_bosh_connection_session_create(conn);
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
143
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
144 return conn;
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
145 }
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
146
24874
33902e1daba1 Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents: 24873
diff changeset
147 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
148 jabber_bosh_connection_destroy(PurpleJabberBOSHConnection *conn)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
149 {
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
150 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
151 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
152 conn->is_terminating = TRUE;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
153
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
154 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
155 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
156 "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
157 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
158 }
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
159
28072
208dfa375b79 jabber: Add a BOSH send timer (queue up stanzas), fixes connecting to Prosody
Paul Aurich <darkrain42@pidgin.im>
parents: 28066
diff changeset
160 if (conn->send_timer)
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
161 g_source_remove(conn->send_timer);
26082
7e3952f2713d Obey the 'inactivity' attribute and send blank updates often enough. Also,
Paul Aurich <darkrain42@pidgin.im>
parents: 26081
diff changeset
162
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
163 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
164
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
165 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
166 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
167 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
168
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 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
170 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
171 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
172 conn->url = NULL;
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
173
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
174 g_free(conn);
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
175 }
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
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 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
178 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
179 {
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
180 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
181 }
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26085
diff changeset
182
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
183 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
184 jabber_bosh_connection_parse(PurpleJabberBOSHConnection *conn,
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
185 SoupMessage *msg, GBytes *response_body,
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
186 GError *error)
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
187 {
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
188 gconstpointer body = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
189 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
190 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
191 const gchar *type;
28066
6e27a78baf3d jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 28065
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 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
194 g_return_val_if_fail(msg != NULL, NULL);
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
195
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
196 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
197 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
198 {
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
199 return NULL;
27811
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
200 }
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
201
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
202 if(error != NULL ||
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
203 !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
204 gchar *tmp = g_strdup_printf(
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
205 _("Unable to connect: %s"),
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
206 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
207 purple_connection_error(conn->js->gc,
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
208 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
209 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
210 return NULL;
31360
4ddd59618002 jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents: 31350
diff changeset
211 }
4ddd59618002 jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents: 31350
diff changeset
212
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
213 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
214 root = purple_xmlnode_from_str(body, length);
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
215
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
216 type = purple_xmlnode_get_attrib(root, "type");
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
217 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
218 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
219 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
220 "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
221 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
222 return NULL;
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
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
225 return root;
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
226 }
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
227
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
228 static void
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
229 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
230 gpointer data)
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
231 {
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
232 SoupMessage *msg = data;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
233 PurpleJabberBOSHConnection *bosh_conn = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
234 GBytes *response_body = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
235 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
236 PurpleXmlNode *node, *child;
27811
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
237
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
238 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
239 result, &error);
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
240 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
241
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
242 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
243 purple_debug_is_unsafe())
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 const gchar *body = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
246 gsize length = 0;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
247
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
248 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
249 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
250 }
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
251
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
252 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
253 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
254 g_clear_error(&error);
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
255
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
256 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
257 return;
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
258 }
24875
0fa0cf6ea28e Make the Request ID a long long (fit in 2^53-1)
Paul Aurich <darkrain42@pidgin.im>
parents: 24874
diff changeset
259
23620
e306af5178d7 * data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23619
diff changeset
260 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
261 while (child != NULL) {
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
262 /* 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
263 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
264 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
265
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
266 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
267 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
268 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
269 }
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
270
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
271 /* 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
272 * 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
273 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
274 xmlns = purple_xmlnode_get_namespace(child);
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
275 if ((xmlns == NULL || purple_strequal(xmlns, NS_BOSH)) &&
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
276 (purple_strequal(child->name, "iq") ||
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
277 purple_strequal(child->name, "message") ||
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
278 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
279 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
280 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
281 }
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
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
283 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
284
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
285 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
286 }
23619
5c215ab46f1e * moving BOSH interfacing from jabber_send to jabber_send_raw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23618
diff changeset
287
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
288 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
289 }
8497c2f5e62d * using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23617
diff changeset
290
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
291 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
292 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
293 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
294 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
295 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
296
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
297 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
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->send_timer != 0) {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
300 g_source_remove(conn->send_timer);
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
301 conn->send_timer = 0;
26533
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26085
diff changeset
302 }
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26085
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 if (conn->sid == NULL)
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
305 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
306
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
307 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
308
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
309 /* 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
310 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
311 "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
312 "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
313 "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
314 "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
315 ++conn->rid, conn->sid);
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
316
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
317 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
318 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
319 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
320 } 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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328 }
28079
69fc36a9cbe3 jabber: Keep a second connection open over which to send the terminate.
Paul Aurich <darkrain42@pidgin.im>
parents: 28072
diff changeset
329
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 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
331 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
332
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
333 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
334 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
335
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
336 if (conn->is_terminating) {
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
337 #if SOUP_MAJOR_VERSION >= 3
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
338 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
339 NULL, NULL, NULL);
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
340 #else
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
341 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
342 #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
343 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
344 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
345 } else {
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
346 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
347 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
348 G_PRIORITY_DEFAULT, NULL,
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
349 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
350 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
351 }
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
352
35264
5b9619d1dec4 Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents: 35263
diff changeset
353 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
354 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
355 {
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
356 PurpleJabberBOSHConnection *conn = _conn;
31350
c4038b151558 jabber: Handle the connection: close header. Closes #13008
Paul Aurich <darkrain42@pidgin.im>
parents: 31349
diff changeset
357
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
358 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
359 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
360
5b9619d1dec4 Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents: 35263
diff changeset
361 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
362 }
e306af5178d7 * data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23619
diff changeset
363
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
364 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
365 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
366 const gchar *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 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
369
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 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
371 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
372
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
373 if (conn->send_timer == 0) {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
374 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
375 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
376 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
377 }
23612
0d8cc9f7f223 * adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23611
diff changeset
378 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
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 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
381 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
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 g_return_if_fail(conn != NULL);
27154
2ef476bfe073 Various BOSH fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 27152
diff changeset
384
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
385 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
386 }
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
387
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
388 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
389 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
390 {
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
391 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
392 int major, minor = 0;
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
393
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
394 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
395 return FALSE;
26081
ef41d4bd0dfa Clean up BOSH reading and disconnection handling.
Paul Aurich <darkrain42@pidgin.im>
parents: 26079
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 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
398 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
399 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
400 minor = atoi(dot + 1);
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
401
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
402 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
403 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
404 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
405 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
406 return TRUE;
23612
0d8cc9f7f223 * adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23611
diff changeset
407 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
408
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
409 static void
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
410 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
411 gpointer data)
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
412 {
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
413 SoupMessage *msg = data;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
414 PurpleJabberBOSHConnection *bosh_conn = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
415 GBytes *response_body = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
416 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
417 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
418 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
419 int inactivity = 0;
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
420
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
421 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
422 result, &error);
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
423 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
424
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
425 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
426 purple_debug_is_unsafe())
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
427 {
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
428 const gchar *body = NULL;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
429 gsize length = 0;
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
430
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
431 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
432 purple_debug_misc("jabber-bosh", "received (session creation): %*s",
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
433 (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
434 }
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
435
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
436 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
437 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
438 g_clear_error(&error);
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
439
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
440 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
441 return;
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
442 }
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
443
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
444 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
445 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
446 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
447 /* 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
448
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
449 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
450 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
451 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
452 _("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
453 purple_xmlnode_free(node);
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
454 return;
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
455 }
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
456
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
457 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
458 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
459 } 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
460 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
461 "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
462 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
463 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
464 _("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
465 purple_xmlnode_free(node);
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
466 return;
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
467 }
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
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 purple_debug_misc("jabber-bosh", "Session created for %p\n", bosh_conn);
23609
94f1737e3853 * some refactoring
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23607
diff changeset
470
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
471 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
472
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
473 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
474 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
475 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
476 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
477 "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
478 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 }
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 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
481 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
482 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
483 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
484 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
485 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
486 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
487 "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
488 "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
489 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
490 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
491 }
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
492
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_set_state(bosh_conn->js, JABBER_STREAM_AUTHENTICATING);
23613
1da7c5cbcc54 * doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23612
diff changeset
494
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
495 /* 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
496 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
497 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
498
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
499 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
500
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_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
502 }
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
503
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
504 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
505 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
506 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
507 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
508 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
509
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
510 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
511 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
512
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 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
514
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
515 /* 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
516 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
517 "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
518 "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
519 "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
520 "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
521 "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
522 "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
523 "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
524 "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
525 "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
526 "/>",
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 ++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
528
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
529 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
530 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
531
41838
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
532 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
533 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
534 G_PRIORITY_DEFAULT, NULL,
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
535 jabber_bosh_connection_session_created,
54f5dccdd78c Port XMPP to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41700
diff changeset
536 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
537 }
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
538
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
539 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
540 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
541 const GString *data)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
542 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
543 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
544 GBytes *body = NULL;
28065
f9b9e38c98f4 jabber: Better inactivity timer logic.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
diff changeset
545
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
546 jabber_stream_restart_inactivity_timer(conn->js);
28066
6e27a78baf3d jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 28065
diff changeset
547
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
548 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
549 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
550 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
551 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
552 g_bytes_unref(body);
24883
c283f8737645 Jabber BOSH: Store less for each Request/Response
Paul Aurich <darkrain42@pidgin.im>
parents: 24875
diff changeset
553
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
554 return req;
23613
1da7c5cbcc54 * doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23612
diff changeset
555 }

mercurial