diff libpurple/connection.c @ 18703:033b128f7c21

Added unregistering XMPP accounts. This requires a new prpl-struct entry, but I got an ok for that on the mailing list.
author Andreas Monitzer <pidgin@monitzer.com>
date Mon, 30 Jul 2007 00:01:08 +0000
parents 873ee0038752
children 2a9d60d7af82
line wrap: on
line diff
--- a/libpurple/connection.c	Thu Jul 26 01:32:21 2007 +0000
+++ b/libpurple/connection.c	Mon Jul 30 00:01:08 2007 +0000
@@ -158,6 +158,62 @@
 }
 
 void
+purple_connection_new_unregister(PurpleAccount *account, const char *password)
+{
+	/* Lots of copy/pasted code to avoid API changes. You might want to integrate that into the previous function when posssible. */
+	PurpleConnection *gc;
+	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
+	
+	g_return_if_fail(account != NULL);
+		
+	prpl = purple_find_prpl(purple_account_get_protocol_id(account));
+	
+	if (prpl != NULL)
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+	else {
+		gchar *message;
+		
+		message = g_strdup_printf(_("Missing protocol plugin for %s"),
+								  purple_account_get_username(account));
+		purple_notify_error(NULL, _("Unregistration Error"), message, NULL);
+		g_free(message);
+		return;
+	}
+
+	if (!purple_account_is_disconnected(account)) {
+		prpl_info->unregister_user(account);
+		return;
+	}
+	
+	if (((password == NULL) || (*password == '\0')) &&
+		!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
+		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
+	{
+		purple_debug_error("connection", "Can not connect to account %s without "
+						   "a password.\n", purple_account_get_username(account));
+		return;
+	}
+	
+	gc = g_new0(PurpleConnection, 1);
+	PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
+	
+	gc->prpl = prpl;
+	if ((password != NULL) && (*password != '\0'))
+		gc->password = g_strdup(password);
+	purple_connection_set_account(gc, account);
+	purple_connection_set_state(gc, PURPLE_CONNECTING);
+	connections = g_list_append(connections, gc);
+	purple_account_set_connection(account, gc);
+	
+	purple_signal_emit(purple_connections_get_handle(), "signing-on", gc);
+	
+	purple_debug_info("connection", "Unregistering.  gc = %p\n", gc);
+	
+	prpl_info->unregister_user(account);
+}
+
+void
 purple_connection_destroy(PurpleConnection *gc)
 {
 	PurpleAccount *account;