pidgin: 32c5c2d4: jabber: Fix using BOSH and legacy auth t...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Tue Aug 25 12:41:21 EDT 2009
-----------------------------------------------------------------
Revision: 32c5c2d4cfb2bede5ffb66792760a368ba8b9f0a
Ancestor: d00066cd4a288d711bb0d302fc36272c915aab26
Author: darkrain42 at pidgin.im
Date: 2009-08-25T16:38:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/32c5c2d4cfb2bede5ffb66792760a368ba8b9f0a
Modified files:
ChangeLog libpurple/protocols/jabber/auth.c
libpurple/protocols/jabber/bosh.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
ChangeLog:
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Thanks to Perel for testing.
-------------- next part --------------
============================================================
--- ChangeLog 4312076f99953fdf162edd1e0bf75839656298e3
+++ ChangeLog 80e4cf8fa8c64bb03ae4fde84800bbc4ab1e9a4c
@@ -5,7 +5,7 @@ version 2.6.2 (??/??/2009):
* Fix --disable-avahi to actually disable it in configure, as opposed
to just making the warning non-fatal.
* Sending custom smileys in MSN chats is now supported.
- * Fix using GNOME proxy settings properly.
+ * Fix using GNOME proxy settings properly. (Erik van Pienbroek)
XMPP:
* Prompt the user before cancelling a presence subscription.
@@ -13,6 +13,7 @@ version 2.6.2 (??/??/2009):
* Fix connecting to XMPP domains with no SRV records from Pidgin on
Windows.
* Fix typing notifications with Pidgin 2.5.9 or earlier.
+ * Fix connecting using BOSH and legacy authentication (XEP-0078).
Finch:
* Properly detect libpanel on OpenBSD. (Brad Smith)
============================================================
--- libpurple/protocols/jabber/auth.c 4dad1a3d65a3de4c54890f5d39c9487d415d9da7
+++ libpurple/protocols/jabber/auth.c 61b2ff9dacd9b550e6a7f89f2193c788876c3155
@@ -575,6 +575,7 @@ static void auth_old_result_cb(JabberStr
xmlnode *packet, gpointer data)
{
if (type == JABBER_IQ_RESULT) {
+ jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
jabber_disco_items_server(js);
} else {
PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
@@ -1072,7 +1073,12 @@ void jabber_auth_handle_success(JabberSt
}
#endif
- jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING);
+ /*
+ * The stream will be reinitialized later in jabber_recv_cb_ssl() or
+ * jabber_bosh_connection_send.
+ */
+ js->reinit = TRUE;
+ jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
}
void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet)
============================================================
--- libpurple/protocols/jabber/bosh.c 3bd3a2dab265ba4366fbf9797681836d2c943e5e
+++ libpurple/protocols/jabber/bosh.c 85feb2be20ee6f4488b71baec8a3d6a11636cdcb
@@ -70,7 +70,6 @@ struct _PurpleBOSHConnection {
gboolean pipelining;
gboolean ssl;
- gboolean needs_restart;
enum {
BOSH_CONN_OFFLINE,
@@ -197,7 +196,6 @@ jabber_bosh_connection_init(JabberStream
conn->path = g_strdup_printf("/%s", path);
g_free(path);
conn->pipelining = TRUE;
- conn->needs_restart = FALSE;
if ((user && user[0] != '\0') || (passwd && passwd[0] != '\0')) {
purple_debug_info("jabber", "Ignoring unexpected username and password "
@@ -377,10 +375,10 @@ jabber_bosh_connection_send(PurpleBOSHCo
conn->sid,
conn->js->user->domain);
- if (conn->needs_restart) {
+ if (conn->js->reinit) {
packet = g_string_append(packet, " xmpp:restart='true'/>");
/* TODO: Do we need to wait for a response? */
- conn->needs_restart = FALSE;
+ conn->js->reinit = FALSE;
} else {
gsize read_amt;
if (type == PACKET_TERMINATE)
@@ -406,12 +404,6 @@ void jabber_bosh_connection_close(Purple
jabber_bosh_connection_send(conn, PACKET_TERMINATE, NULL);
}
-static void jabber_bosh_connection_stream_restart(PurpleBOSHConnection *conn)
-{
- conn->needs_restart = TRUE;
- jabber_bosh_connection_send(conn, PACKET_NORMAL, NULL);
-}
-
static gboolean jabber_bosh_connection_error_check(PurpleBOSHConnection *conn, xmlnode *node) {
const char *type;
@@ -490,35 +482,8 @@ static void jabber_bosh_connection_recei
}
}
-static void auth_response_cb(PurpleBOSHConnection *conn, xmlnode *node) {
- xmlnode *child;
-
- g_return_if_fail(node != NULL);
- if (jabber_bosh_connection_error_check(conn, node))
- return;
-
- child = node->child;
- while(child != NULL && child->type != XMLNODE_TYPE_TAG) {
- child = child->next;
- }
-
- /* We're only expecting one XML node here, so only process the first one */
- if (child != NULL && child->type == XMLNODE_TYPE_TAG) {
- JabberStream *js = conn->js;
- if (!strcmp(child->name, "success")) {
- jabber_bosh_connection_stream_restart(conn);
- jabber_process_packet(js, &child);
- conn->receive_cb = jabber_bosh_connection_received;
- } else {
- js->state = JABBER_STREAM_AUTHENTICATING;
- jabber_process_packet(js, &child);
- }
- } else {
- purple_debug_warning("jabber", "Received unexepcted empty BOSH packet.\n");
- }
-}
-
static void boot_response_cb(PurpleBOSHConnection *conn, xmlnode *node) {
+ JabberStream *js = conn->js;
const char *sid, *version;
const char *inactivity, *requests;
xmlnode *packet;
@@ -536,7 +501,7 @@ static void boot_response_cb(PurpleBOSHC
if (sid) {
conn->sid = g_strdup(sid);
} else {
- purple_connection_error_reason(conn->js->gc,
+ purple_connection_error_reason(js->gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("No session ID given"));
return;
@@ -553,7 +518,7 @@ static void boot_response_cb(PurpleBOSHC
minor = atoi(dot + 1);
if (major != 1 || minor < 6) {
- purple_connection_error_reason(conn->js->gc,
+ purple_connection_error_reason(js->gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("Unsupported version of BOSH protocol"));
return;
@@ -583,11 +548,13 @@ static void boot_response_cb(PurpleBOSHC
if (requests)
conn->max_requests = atoi(requests);
+ jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
+
/* FIXME: Depending on receiving features might break with some hosts */
packet = xmlnode_get_child(node, "features");
conn->state = BOSH_CONN_ONLINE;
- conn->receive_cb = auth_response_cb;
- jabber_stream_features_parse(conn->js, packet);
+ conn->receive_cb = jabber_bosh_connection_received;
+ jabber_stream_features_parse(js, packet);
}
static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) {
@@ -663,8 +630,8 @@ connection_common_established_cb(PurpleH
conn->headers_done = FALSE;
conn->handled_len = conn->body_len = 0;
- if (conn->bosh->needs_restart)
- jabber_bosh_connection_stream_restart(conn->bosh);
+ if (conn->bosh->js->reinit)
+ jabber_bosh_connection_send(conn->bosh, PACKET_NORMAL, NULL);
else if (conn->bosh->state == BOSH_CONN_ONLINE) {
purple_debug_info("jabber", "BOSH session already exists. Trying to reuse it.\n");
if (conn->bosh->requests == 0 || conn->bosh->pending->bufused > 0) {
============================================================
--- libpurple/protocols/jabber/jabber.c 962bd67222ca0e6351eeeaf35e566134f4cf30cd
+++ libpurple/protocols/jabber/jabber.c 543a269241301747a30676bcaa76d8ecfdc4a8f3
@@ -1605,13 +1605,10 @@ void jabber_stream_set_state(JabberStrea
jabber_auth_start_old(js);
}
break;
- case JABBER_STREAM_REINITIALIZING:
+ case JABBER_STREAM_POST_AUTH:
purple_connection_update_progress(js->gc, _("Re-initializing Stream"),
(js->gsc ? 8 : 4), JABBER_CONNECT_STEPS);
- /* The stream will be reinitialized later, in jabber_recv_cb_ssl() */
- js->reinit = TRUE;
-
break;
case JABBER_STREAM_CONNECTED:
/* Send initial presence */
============================================================
--- libpurple/protocols/jabber/jabber.h 6805f5860c8e374a5f88b971c7fc94e70db4f7e8
+++ libpurple/protocols/jabber/jabber.h 2d8f26d7c8eafa62b4ca8ce877f356e82b29abfa
@@ -87,7 +87,7 @@ typedef enum {
JABBER_STREAM_INITIALIZING,
JABBER_STREAM_INITIALIZING_ENCRYPTION,
JABBER_STREAM_AUTHENTICATING,
- JABBER_STREAM_REINITIALIZING,
+ JABBER_STREAM_POST_AUTH,
JABBER_STREAM_CONNECTED
} JabberStreamState;
More information about the Commits
mailing list