# HG changeset patch # User Nathan Walp # Date 1061617251 0 # Node ID 0473a28ce807cc9566158a5699f4dd1473cb7207 # Parent 74d1cd241a3dcff5087a0c5427823bc51da76806 [gaim-migrate @ 7103] this should fix jabber registrations yet again committer: Tailor Script diff -r 74d1cd241a3d -r 0473a28ce807 src/account.c --- a/src/account.c Sat Aug 23 05:39:10 2003 +0000 +++ b/src/account.c Sat Aug 23 05:40:51 2003 +0000 @@ -172,6 +172,26 @@ } GaimConnection * +gaim_account_register(GaimAccount *account) +{ + GaimConnection *gc; + + g_return_val_if_fail(account != NULL, NULL); + + if (gaim_account_get_connection(account) != NULL) + return NULL; + + gc = gaim_connection_new(account); + + gaim_debug(GAIM_DEBUG_INFO, "account", + "Registering account %p. gc = %p\n", account, gc); + + gaim_connection_register(gc); + + return gc; +} + +GaimConnection * gaim_account_connect(GaimAccount *account) { GaimConnection *gc; diff -r 74d1cd241a3d -r 0473a28ce807 src/account.h --- a/src/account.h Sat Aug 23 05:39:10 2003 +0000 +++ b/src/account.h Sat Aug 23 05:40:51 2003 +0000 @@ -97,6 +97,15 @@ GaimConnection *gaim_account_connect(GaimAccount *account); /** + * Registers an account. + * + * @param account The account to register. + * + * @return The gaim connection. + */ +GaimConnection *gaim_account_register(GaimAccount *account); + +/** * Disconnects from an account. * * @param account The account to disconnect from. diff -r 74d1cd241a3d -r 0473a28ce807 src/connection.c --- a/src/connection.c Sat Aug 23 05:39:10 2003 +0000 +++ b/src/connection.c Sat Aug 23 05:40:51 2003 +0000 @@ -97,6 +97,53 @@ gaim_account_connect(account); } +void +gaim_connection_register(GaimConnection *gc) +{ + GaimAccount *account; + GaimConnectionUiOps *ops; + GaimPluginProtocolInfo *prpl_info = NULL; + + g_return_if_fail(gc != NULL); + + gaim_debug(GAIM_DEBUG_INFO, "connection", + "Registering. gc = %p\n", gc); + + ops = gaim_get_connection_ui_ops(); + + if (gc->prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); + else { + gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), + gaim_account_get_username(gaim_connection_get_account(gc))); + + gaim_debug(GAIM_DEBUG_ERROR, "connection", + "Could not get prpl info for %p\n", gc); + gaim_notify_error(NULL, _("Registration Error"), + message, NULL); + g_free(message); + return; + } + + account = gaim_connection_get_account(gc); + + if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) + return; + + gaim_connection_set_state(gc, GAIM_CONNECTING); + + connections = g_list_append(connections, gc); + + gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); + + /* set this so we don't auto-reconnect after registering */ + gc->wants_to_die = TRUE; + + gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling register_user\n"); + + prpl_info->register_user(account); +} + void gaim_connection_connect(GaimConnection *gc) diff -r 74d1cd241a3d -r 0473a28ce807 src/connection.h --- a/src/connection.h Sat Aug 23 05:39:10 2003 +0000 +++ b/src/connection.h Sat Aug 23 05:40:51 2003 +0000 @@ -127,6 +127,13 @@ void gaim_connection_connect(GaimConnection *gc); /** + * Registers a connection. + * + * @param gc The connection to register. + */ +void gaim_connection_register(GaimConnection *gc); + +/** * Signs a connection off. * @param gc The connection to sign off. diff -r 74d1cd241a3d -r 0473a28ce807 src/gtkaccount.c --- a/src/gtkaccount.c Sat Aug 23 05:39:10 2003 +0000 +++ b/src/gtkaccount.c Sat Aug 23 05:40:51 2003 +0000 @@ -1106,12 +1106,11 @@ static void register_account_prefs_cb(GtkWidget *w, AccountPrefsDialog *dialog) { - GaimAccount *account = dialog->account; GaimPluginProtocolInfo *prpl_info = dialog->prpl_info; ok_account_prefs_cb(NULL, dialog); - prpl_info->register_user(account); + gaim_account_register(dialog->account); } void diff -r 74d1cd241a3d -r 0473a28ce807 src/protocols/jabber/jabber.c --- a/src/protocols/jabber/jabber.c Sat Aug 23 05:39:10 2003 +0000 +++ b/src/protocols/jabber/jabber.c Sat Aug 23 05:40:51 2003 +0000 @@ -4276,7 +4276,7 @@ */ void jabber_register_user(GaimAccount *account) { - GaimConnection *gc = gaim_connection_new(account); + GaimConnection *gc = gaim_account_get_connection(account); struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim");