changeset 27059:9639747bb98c

Remove debugging, use user's server as default, and avoid a GTK+ assertion.
author Paul Aurich <paul@darkrain42.org>
date Tue, 26 May 2009 02:46:14 +0000
parents 08964b4b2fe4
children 1c8d7165df6b
files pidgin/plugins/disco/gtkdisco.c pidgin/plugins/disco/xmppdisco.c
diffstat 2 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/disco/gtkdisco.c	Tue May 26 02:27:49 2009 +0000
+++ b/pidgin/plugins/disco/gtkdisco.c	Tue May 26 02:46:14 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:27:49 2009 +0000
+++ b/pidgin/plugins/disco/xmppdisco.c	Tue May 26 02:46:14 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;
 		}