From 4092498de8ccb03d5f119fbd3d10d4fd4e0e73de Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 26 Jan 2013 21:03:04 +0000 Subject: Reverted some previous changes to fix login attempt and reconnect issues fixes #142 fixes #143 --- src/connection.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/connection.c b/src/connection.c index 226a00f0..d117f6ed 100644 --- a/src/connection.c +++ b/src/connection.c @@ -108,12 +108,20 @@ jabber_restart(void) jabber_conn_status_t jabber_connect_with_account(ProfAccount *account, const char * const passwd) { - FREE_SET_NULL(saved_user.account); + saved_user.account = strdup(account->name); - if (account->name == NULL) - return JABBER_UNDEFINED; + if (saved_user.jid == NULL) { + saved_user.jid = strdup(account->jid); + } + if (saved_user.passwd == NULL) { + saved_user.passwd = strdup(passwd); + } + if (saved_user.altdomain == NULL) { + if (account->server != NULL) { + saved_user.altdomain = strdup(account->server); + } + } - saved_user.account = strdup(account->name); log_info("Connecting with account: %s", account->name); return jabber_connect(account->jid, passwd, account->server); } @@ -122,17 +130,22 @@ jabber_conn_status_t jabber_connect(const char * const jid, const char * const passwd, const char * const altdomain) { - FREE_SET_NULL(saved_user.jid); - FREE_SET_NULL(saved_user.passwd); - FREE_SET_NULL(saved_user.altdomain); - - if (jid == NULL || passwd == NULL) - return JABBER_UNDEFINED; + if (saved_user.account != NULL) { + free(saved_user.account); + saved_user.account = NULL; + } - saved_user.jid = strdup(jid); - saved_user.passwd = strdup(passwd); - if (altdomain != NULL) - saved_user.altdomain = strdup(altdomain); + if (saved_user.jid == NULL) { + saved_user.jid = strdup(jid); + } + if (saved_user.passwd == NULL) { + saved_user.passwd = strdup(passwd); + } + if (saved_user.altdomain == NULL) { + if (altdomain != NULL) { + saved_user.altdomain = strdup(altdomain); + } + } log_info("Connecting as %s", jid); xmpp_initialize(); -- cgit 1.4.1-2-gfad0