changeset 26979:1c8d7165df6b

merge of '17367f37cdcde61c1f7a9bc2df681c177a65ffbb' and 'ded483522069298e5562139fb48032231da598dc'
author Paul Aurich <paul@darkrain42.org>
date Tue, 26 May 2009 02:46:24 +0000
parents 45e812208f05 (current diff) 9639747bb98c (diff)
children b709ab0cb4bc
files
diffstat 2 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/disco/gtkdisco.c	Tue May 26 02:28:34 2009 +0000
+++ b/pidgin/plugins/disco/gtkdisco.c	Tue May 26 02:46:24 2009 +0000
@@ -156,6 +156,9 @@
 {
 	PurpleConnection *pc;
 	PidginDiscoList *pdl;
+	const char *username;
+	const char *at, *slash;
+	char *server = NULL;
 
 	pc = purple_account_get_connection(dialog->account);
 	if (!pc)
@@ -166,7 +169,10 @@
 	gtk_widget_set_sensitive(dialog->register_button, FALSE);
 
 	if (dialog->discolist != NULL) {
-		gtk_widget_destroy(dialog->discolist->tree);
+		if (dialog->discolist->tree) {
+			gtk_widget_destroy(dialog->discolist->tree);
+			dialog->discolist->tree = NULL;
+		}
 		pidgin_disco_list_unref(dialog->discolist);
 	}
 
@@ -183,12 +189,27 @@
 	if (dialog->account_widget)
 		gtk_widget_set_sensitive(dialog->account_widget, FALSE);
 
+	username = purple_account_get_username(dialog->account);
+	at = g_utf8_strchr(username, -1, '@');
+	slash = g_utf8_strchr(username, -1, '/');
+	if (at && !slash) {
+		server = g_strdup_printf("%s", at + 1);
+	} else if (at && slash && at + 1 < slash) {
+		server = g_strdup_printf("%.*s", (int)(slash - (at + 1)), at + 1);
+	}
+
+	if (server == NULL)
+		/* This shouldn't ever happen since the account is connected */
+		server = g_strdup("jabber.org");
+
 	purple_request_input(my_plugin, _("Server name request"), _("Enter an XMPP Server"),
 			_("Select an XMPP server to query"),
-			"jabber.org" /* FIXME */, FALSE, FALSE, NULL,
+			server, FALSE, FALSE, NULL,
 			_("Find Services"), PURPLE_CALLBACK(discolist_ok_cb),
 			_("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb),
 			purple_connection_get_account(pc), NULL, NULL, pdl);
+
+	g_free(server);
 }
 
 static void add_room_to_blist_cb(GtkButton *button, PidginDiscoDialog *dialog)
--- a/pidgin/plugins/disco/xmppdisco.c	Tue May 26 02:28:34 2009 +0000
+++ b/pidgin/plugins/disco/xmppdisco.c	Tue May 26 02:46:24 2009 +0000
@@ -220,10 +220,9 @@
 			return XMPP_DISCO_SERVICE_TYPE_PUBSUB_COLLECTION;
 		else if (g_str_equal(type, "leaf"))
 			return XMPP_DISCO_SERVICE_TYPE_PUBSUB_LEAF;
-		else if (g_str_equal(type, "service")) {
-			purple_debug_error("xmppdisco", "here\n");
+		else if (g_str_equal(type, "service"))
 			return XMPP_DISCO_SERVICE_TYPE_OTHER;
-		} else {
+		else {
 			purple_debug_warning("xmppdisco", "Unknown pubsub type '%s'\n", type);
 			return XMPP_DISCO_SERVICE_TYPE_OTHER;
 		}