libpurple/protocols/jabber/bosh.c

Tue, 02 Nov 2021 00:30:07 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 02 Nov 2021 00:30:07 -0500
changeset 41157
f223b69f7da2
parent 40819
54b2a95ac176
child 41211
2e804c9c0919
permissions
-rw-r--r--

Fix some bugs with proxies for xmpp

Testing Done:
Compiled and ran, was unable to get it to actually use charles proxy though.

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

23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
1 /*
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28079
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28079
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28079
diff changeset
6 * source distribution.
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
7 *
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
12 *
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
17 *
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
21 *
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
22 */
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
23 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
24
40358
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 40336
diff changeset
25 #include <purple.h>
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
26
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
27 #include <libsoup/soup.h>
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
28
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
29 #include "bosh.h"
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
30
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
31 /*
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
32 TODO: test, what happens, if the http server (BOSH server) doesn't support
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
33 keep-alive (sends connection: close).
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
34 */
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
35
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
36 #define JABBER_BOSH_SEND_DELAY 250
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
37
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
38 #define JABBER_BOSH_TIMEOUT 10
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
39
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
40 static gchar *jabber_bosh_useragent = NULL;
28062
f743d255c355 jabber: Re-order the BOSH structs and normalize the buffer names.
Paul Aurich <darkrain42@pidgin.im>
parents: 27811
diff changeset
41
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
42 struct _PurpleJabberBOSHConnection {
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
43 JabberStream *js;
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
44 SoupSession *payload_reqs;
28062
f743d255c355 jabber: Re-order the BOSH structs and normalize the buffer names.
Paul Aurich <darkrain42@pidgin.im>
parents: 27811
diff changeset
45
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
46 gchar *url;
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
47 gboolean is_ssl;
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
48 gboolean is_terminating;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
49
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
50 gchar *sid;
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
51 guint64 rid; /* Must be big enough to hold 2^53 - 1 */
26083
e716012de66e Rearrange the structs and fix the indentation. No functional changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 26082
diff changeset
52
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
53 GString *send_buff;
28072
208dfa375b79 jabber: Add a BOSH send timer (queue up stanzas), fixes connecting to Prosody
Paul Aurich <darkrain42@pidgin.im>
parents: 28066
diff changeset
54 guint send_timer;
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
55 };
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
56
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
57 static SoupMessage *jabber_bosh_connection_http_request_new(
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
58 PurpleJabberBOSHConnection *conn, const GString *data);
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
59 static void
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
60 jabber_bosh_connection_session_create(PurpleJabberBOSHConnection *conn);
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
61 static void
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
62 jabber_bosh_connection_send_now(PurpleJabberBOSHConnection *conn);
23607
bc82598d3798 * looking for alternative connection methods if direct connection fails
Tobias Markmann <tfar@soc.pidgin.im>
parents:
diff changeset
63
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
64 void
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
65 jabber_bosh_init(void)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
66 {
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
67 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
68 const gchar *ui_name = NULL;
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
69 const gchar *ui_version = NULL;
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
70
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
71 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
72 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
73 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
74 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
75
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
76 if(ui_name) {
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
77 jabber_bosh_useragent = g_strdup_printf(
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
78 "%s%s%s (libpurple " VERSION ")", ui_name,
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
79 ui_version ? " " : "", ui_version ? ui_version : "");
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
80 } else {
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
81 jabber_bosh_useragent = g_strdup("libpurple " VERSION);
40312
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
82 }
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
83
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
84 if(ui_info) {
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
85 g_object_unref(G_OBJECT(ui_info));
956745ff3ee8 Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents: 40112
diff changeset
86 }
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
87 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
88
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
89 void jabber_bosh_uninit(void)
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
90 {
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
91 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
92 jabber_bosh_useragent = NULL;
24874
33902e1daba1 Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents: 24873
diff changeset
93 }
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*
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
96 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
97 {
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
98 PurpleJabberBOSHConnection *conn;
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
99 PurpleAccount *account;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
100 GProxyResolver *resolver;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
101 GError *error = NULL;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
102 SoupURI *url_p;
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
103
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
104 account = purple_connection_get_account(js->gc);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
105 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
106 if (resolver == NULL) {
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
107 purple_debug_error("jabber-bosh",
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
108 "Unable to get account proxy resolver: %s",
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
109 error->message);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
110 g_error_free(error);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
111 return NULL;
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
112 }
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
113
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
114 url_p = soup_uri_new(url);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
115 if (!SOUP_URI_VALID_FOR_HTTP(url_p)) {
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
116 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
117 url);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
118 g_object_unref(resolver);
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
119 return NULL;
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
120 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
121
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
122 conn = g_new0(PurpleJabberBOSHConnection, 1);
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
123 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
124 "proxy-resolver", resolver,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
125 "timeout", JABBER_BOSH_TIMEOUT + 2,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
126 "user-agent", jabber_bosh_useragent,
54b2a95ac176 Cleanup deprecated libsoup usage
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
127 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
128 conn->url = g_strdup(url);
23613
1da7c5cbcc54 * doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23612
diff changeset
129 conn->js = js;
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
130 conn->is_ssl = (url_p->scheme == SOUP_URI_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
131 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
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 /*
d424e92111b5 A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents: 26664
diff changeset
134 * 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
135 *
d424e92111b5 A better random number for the rid in the range [0, 2**52).
Paul Aurich <darkrain42@pidgin.im>
parents: 26664
diff changeset
136 * 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
137 * 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
138 * 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
139 */
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
140 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
141 conn->rid &= 0xFFFFFFFFFFFFFLL;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
142
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
143 soup_uri_free(url_p);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
144 g_object_unref(resolver);
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
145
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
146 jabber_bosh_connection_session_create(conn);
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
147
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
148 return conn;
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
149 }
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
150
24874
33902e1daba1 Reorder some functions to eliminate prototypes and
Paul Aurich <darkrain42@pidgin.im>
parents: 24873
diff changeset
151 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
152 jabber_bosh_connection_destroy(PurpleJabberBOSHConnection *conn)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
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 == 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
155 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
156 conn->is_terminating = TRUE;
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
157
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
158 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
159 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
160 "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
161 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
162 }
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
163
28072
208dfa375b79 jabber: Add a BOSH send timer (queue up stanzas), fixes connecting to Prosody
Paul Aurich <darkrain42@pidgin.im>
parents: 28066
diff changeset
164 if (conn->send_timer)
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
165 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
166
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
167 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
168
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
169 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
170 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
171 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
172
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
173 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
174 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
175 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
176 conn->url = NULL;
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
177
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
178 g_free(conn);
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
179 }
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
180
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
181 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
182 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
183 {
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 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
185 }
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26085
diff changeset
186
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
187 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
188 jabber_bosh_connection_parse(PurpleJabberBOSHConnection *conn,
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
189 SoupMessage *response)
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
190 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
191 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
192 const gchar *type;
28066
6e27a78baf3d jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 28065
diff changeset
193
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
194 g_return_val_if_fail(conn != NULL, 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
195 g_return_val_if_fail(response != NULL, NULL);
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
196
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
197 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
198 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
199 {
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
200 return NULL;
27811
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
201 }
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
202
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
203 if (!SOUP_STATUS_IS_SUCCESSFUL(response->status_code)) {
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
204 gchar *tmp = g_strdup_printf(_("Unable to connect: %s"),
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
205 response->reason_phrase);
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
206 purple_connection_error(conn->js->gc,
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
207 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
208 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
209 return NULL;
31360
4ddd59618002 jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents: 31350
diff changeset
210 }
4ddd59618002 jabber: Be friendlier to servers when we have nothing to say.
Paul Aurich <darkrain42@pidgin.im>
parents: 31350
diff changeset
211
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
212 root = purple_xmlnode_from_str(response->response_body->data,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
213 response->response_body->length);
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
214
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
215 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
216 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
217 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
218 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
219 "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
220 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
221 return NULL;
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
222 }
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
223
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
224 return root;
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
225 }
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 static void
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
228 jabber_bosh_connection_recv(SoupSession *session, SoupMessage *msg,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
229 gpointer user_data)
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
230 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
231 PurpleJabberBOSHConnection *bosh_conn = user_data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
232 PurpleXmlNode *node, *child;
27811
9db18cacd8fc Various fixes to get BOSH working with Prosody 0.5.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
233
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
234 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
235 purple_debug_misc("jabber-bosh", "received: %s\n",
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
236 msg->response_body->data);
26664
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
237 }
a42da6facb80 Reorder functions to remove prototypes
Paul Aurich <darkrain42@pidgin.im>
parents: 26661
diff changeset
238
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
239 node = jabber_bosh_connection_parse(bosh_conn, 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
240 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
241 return;
0fa0cf6ea28e Make the Request ID a long long (fit in 2^53-1)
Paul Aurich <darkrain42@pidgin.im>
parents: 24874
diff changeset
242
23620
e306af5178d7 * data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23619
diff changeset
243 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
244 while (child != NULL) {
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
245 /* 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
246 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
247 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
248
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
249 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
250 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
251 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
252 }
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
253
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
254 /* 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
255 * 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
256 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
257 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
258 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
259 (purple_strequal(child->name, "iq") ||
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
260 purple_strequal(child->name, "message") ||
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36257 38260
diff changeset
261 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
262 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
263 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
264 }
cf61366236ee HTTP: connections set support added; 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
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
266 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
267
24886
de0388948ac8 Jabber BOSH: memory management fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 24885
diff changeset
268 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
269 }
23619
5c215ab46f1e * moving BOSH interfacing from jabber_send to jabber_send_raw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23618
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 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
272 }
8497c2f5e62d * using libpurple's internal SASL mechanisms during BOSH authentication phase
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23617
diff changeset
273
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
274 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
275 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
276 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
277 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
278 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
279
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
280 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
281
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
282 if (conn->send_timer != 0) {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
283 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
284 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
285 }
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26085
diff changeset
286
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
287 if (conn->sid == NULL)
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
288 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
289
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
290 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
291
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 /* 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
293 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
294 "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
295 "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
296 "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
297 "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
298 ++conn->rid, conn->sid);
26076
1755f871f1d1 Restore BOSH to a more-or-less working state.
Paul Aurich <darkrain42@pidgin.im>
parents: 25489
diff changeset
299
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
300 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
301 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
302 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
303 } 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
304 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
305 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
306 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
307 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
308 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
309 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
310 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
311 }
28079
69fc36a9cbe3 jabber: Keep a second connection open over which to send the terminate.
Paul Aurich <darkrain42@pidgin.im>
parents: 28072
diff changeset
312
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
313 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
314 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
315
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
316 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
317 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
318
cf61366236ee HTTP: connections set support added; 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 if (conn->is_terminating) {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
320 soup_session_send_async(conn->payload_reqs, req, NULL, NULL, 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
321 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
322 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
323 } else {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
324 soup_session_queue_message(conn->payload_reqs, req,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
325 jabber_bosh_connection_recv, conn);
26534
20a970cad8e2 Because BOSH works over connections that may die non-fatally, we need to
Paul Aurich <darkrain42@pidgin.im>
parents: 26533
diff changeset
326 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
327 }
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
328
35264
5b9619d1dec4 Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents: 35263
diff changeset
329 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
330 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
331 {
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
332 PurpleJabberBOSHConnection *conn = _conn;
31350
c4038b151558 jabber: Handle the connection: close header. Closes #13008
Paul Aurich <darkrain42@pidgin.im>
parents: 31349
diff changeset
333
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
334 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
335 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
336
5b9619d1dec4 Fix dropping incoming stanzas on BOSH connections when we receive
Mark Doliner <mark@kingant.net>
parents: 35263
diff changeset
337 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
338 }
e306af5178d7 * data buffer for received data. Support for any HTTP resonse size now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23619
diff changeset
339
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
340 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
341 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
342 const gchar *data)
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
343 {
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
344 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
345
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
346 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
347 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
348
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
349 if (conn->send_timer == 0) {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
350 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
351 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
352 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
353 }
23612
0d8cc9f7f223 * adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23611
diff changeset
354 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
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 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
357 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
358 {
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
359 g_return_if_fail(conn != NULL);
27154
2ef476bfe073 Various BOSH fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 27152
diff changeset
360
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
361 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
362 }
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
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 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
365 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
366 {
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
367 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
368 int major, minor = 0;
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 (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
371 return FALSE;
26081
ef41d4bd0dfa Clean up BOSH reading and disconnection handling.
Paul Aurich <darkrain42@pidgin.im>
parents: 26079
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 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
374 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
375 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
376 minor = atoi(dot + 1);
24884
896733ece217 Jabber BOSH: Model the parsing on the SOAP stuff
Paul Aurich <darkrain42@pidgin.im>
parents: 24883
diff changeset
377
34268
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
378 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
379 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
380 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
381 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
382 return TRUE;
23612
0d8cc9f7f223 * adding receive callback; preparing receiving and boot code
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23611
diff changeset
383 }
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
384
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
385 static void
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
386 jabber_bosh_connection_session_created(SoupSession *session, SoupMessage *msg,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
387 gpointer user_data)
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
388 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
389 PurpleJabberBOSHConnection *bosh_conn = user_data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
390 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
391 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
392 int inactivity = 0;
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
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 (purple_debug_is_verbose() && purple_debug_is_unsafe()) {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
395 purple_debug_misc("jabber-bosh", "received (session creation): %s\n",
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
396 msg->response_body->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
397 }
cf61366236ee HTTP: connections set support added; 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
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
399 node = jabber_bosh_connection_parse(bosh_conn, 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
400 if (node == 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
401 return;
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
402
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
403 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
404 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
405 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
406 /* 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
407
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
408 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
409 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
410 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
411 _("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
412 purple_xmlnode_free(node);
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
413 return;
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
414 }
26085
6b5686df629c BOSH: Support HTTPS connections to the connection manager
Paul Aurich <darkrain42@pidgin.im>
parents: 26084
diff changeset
415
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
416 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
417 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
418 } 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
419 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
420 "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
421 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
422 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
423 _("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
424 purple_xmlnode_free(node);
23611
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
425 return;
d811757e19b5 * adding bosh files to Makefile.am & .mingw
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23609
diff changeset
426 }
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
427
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
428 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
429
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
430 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
431
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
432 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
433 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
434 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
435 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
436 "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
437 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
438 }
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446 "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
447 "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
448 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
449 }
24872
68de61b562f6 Jabber BOSH: Many fixes
Paul Aurich <darkrain42@pidgin.im>
parents: 23625
diff changeset
450 }
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
451
cf61366236ee HTTP: connections set support added; 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 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
453
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
454 /* 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
455 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
456 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
457
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
458 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
459
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
460 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
461 }
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
462
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
463 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
464 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
465 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
466 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
467 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
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", "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
470 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
471
cf61366236ee HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34219
diff changeset
472 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
473
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
474 /* 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
475 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
476 "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
477 "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
478 "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
479 "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
480 "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
481 "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
482 "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
483 "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
484 "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
485 "/>",
cf61366236ee HTTP: connections set support added; 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 ++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
487
cf61366236ee HTTP: connections set support added; 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 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
489 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
490
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
491 soup_session_queue_message(conn->payload_reqs, req,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
492 jabber_bosh_connection_session_created, 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
493 }
f632d4de4bce BOSH: Use a write buffer (read: basically cut-n-paste from jabber.c)
Paul Aurich <darkrain42@pidgin.im>
parents: 26672
diff changeset
494
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
495 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
496 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
497 const GString *data)
24873
7d1e91d5ec46 Jabber BOSH: more fixes.
Paul Aurich <darkrain42@pidgin.im>
parents: 24872
diff changeset
498 {
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
499 SoupMessage *req;
28065
f9b9e38c98f4 jabber: Better inactivity timer logic.
Paul Aurich <darkrain42@pidgin.im>
parents: 28064
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_stream_restart_inactivity_timer(conn->js);
28066
6e27a78baf3d jabber: Ridiculously verbose logging for BOSH.
Paul Aurich <darkrain42@pidgin.im>
parents: 28065
diff changeset
502
40002
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
503 req = soup_message_new("POST", conn->url);
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
504 soup_message_set_request(req, "text/xml; charset=utf-8", SOUP_MEMORY_TAKE,
f08d87a438c2 Convert Jabber BOSH to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39987
diff changeset
505 data->str, data->len);
24883
c283f8737645 Jabber BOSH: Store less for each Request/Response
Paul Aurich <darkrain42@pidgin.im>
parents: 24875
diff changeset
506
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
507 return req;
23613
1da7c5cbcc54 * doing HTTP requests
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23612
diff changeset
508 }

mercurial