changeset 25596:7768cad83127

* looking for alternative connection methods if direct connection fails * introducing bosh files
author Tobias Markmann <tfar@soc.pidgin.im>
date Sun, 03 Aug 2008 13:48:59 +0000
parents 94c8bef52c66
children 9f8951284a2e
files libpurple/protocols/jabber/bosh.c libpurple/protocols/jabber/bosh.h libpurple/protocols/jabber/jabber.c
diffstat 3 files changed, 94 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/jabber/bosh.c	Sun Aug 03 13:48:59 2008 +0000
@@ -0,0 +1,39 @@
+/*
+ * purple - Jabber Protocol Plugin
+ *
+ * Copyright (C) 2008, Tobias Markmann <tmarkmann@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ *
+ */
+#include "internal.h"
+#include "cipher.h"
+#include "debug.h"
+#include "imgstore.h"
+#include "prpl.h"
+#include "notify.h"
+#include "request.h"
+#include "util.h"
+#include "xmlnode.h"
+
+#include "buddy.h"
+#include "chat.h"
+#include "jabber.h"
+#include "iq.h"
+#include "presence.h"
+#include "xdata.h"
+#include "pep.h"
+#include "adhoccommands.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/jabber/bosh.h	Sun Aug 03 13:48:59 2008 +0000
@@ -0,0 +1,34 @@
+/**
+ * @file bosh.h Buddy handlers
+ *
+ * purple
+ *
+ * Copyright (C) 2008, Tobias Markmann <tmarkmann@googlemail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#ifndef _PURPLE_JABBER_BOSH_H_
+#define _PURPLE_JABBER_BOSH_H_
+
+typedef struct {
+    char *url;
+    gboolean pipelining;
+} PurpleBOSHConnection;
+
+typedef struct {
+    
+} PurpleHTTPRequest;
+
+#endif /* _PURPLE_JABBER_BOSH_H_ */
--- a/libpurple/protocols/jabber/jabber.c	Sat Aug 02 16:43:04 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sun Aug 03 13:48:59 2008 +0000
@@ -521,6 +521,25 @@
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
 }
 
+static void 
+txt_resolved_cb(PurpleTxtResponse *resp, int results, gpointer data)
+{
+	PurpleConnection *gc = data;
+	JabberStream *js = gc->proto_data;
+	int n;
+	
+	if (results > 0) {
+		gchar *tmp;
+		tmp = g_strdup_printf(_("Could not find alternative XMPP connection methods after failing to connect directly.\n"));
+		purple_connection_error_reason (gc,
+				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
+		g_free(tmp);	
+	}
+	
+	for (n = 0; n < results; n++) {
+		purple_debug_info("dnssrv","TXT RDATA: %s\n", resp[n].content);	
+	}
+}
 
 static void
 jabber_login_callback(gpointer data, gint source, const gchar *error)
@@ -529,12 +548,8 @@
 	JabberStream *js = gc->proto_data;
 
 	if (source < 0) {
-		gchar *tmp;
-		tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
-				error);
-		purple_connection_error_reason (gc,
-				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
-		g_free(tmp);
+		purple_debug_info("jabber","Couldn't connect directly to %s. Trying to find alternative connection methods, like BOSH.\n", js->user->domain);
+		purple_txt_resolve("_xmppconnect", js->user->domain, txt_resolved_cb, gc);
 		return;
 	}