Fix reconnect when no account has been set up yet.
e.g. if one connects with an account for the first time and the server returns a `see-other-host` error. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -73,7 +73,7 @@ static struct
|
|||||||
char* passwd;
|
char* passwd;
|
||||||
} saved_account;
|
} saved_account;
|
||||||
|
|
||||||
static struct
|
static struct session_details
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
char* jid;
|
char* jid;
|
||||||
@@ -159,6 +159,18 @@ session_connect_with_account(const ProfAccount* const account)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jabber_conn_status_t
|
||||||
|
_session_connect(struct session_details* details)
|
||||||
|
{
|
||||||
|
return connection_connect(
|
||||||
|
details->jid,
|
||||||
|
details->passwd,
|
||||||
|
details->altdomain,
|
||||||
|
details->port,
|
||||||
|
details->tls_policy,
|
||||||
|
details->auth_policy);
|
||||||
|
}
|
||||||
|
|
||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
session_connect_with_details(const char* const jid, const char* const passwd, const char* const altdomain,
|
session_connect_with_details(const char* const jid, const char* const passwd, const char* const altdomain,
|
||||||
const int port, const char* const tls_policy, const char* const auth_policy)
|
const int port, const char* const tls_policy, const char* const auth_policy)
|
||||||
@@ -206,13 +218,7 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
|
|||||||
// connect with fulljid
|
// connect with fulljid
|
||||||
log_info("Connecting without account, JID: %s", saved_details.jid);
|
log_info("Connecting without account, JID: %s", saved_details.jid);
|
||||||
|
|
||||||
return connection_connect(
|
return _session_connect(&saved_details);
|
||||||
saved_details.jid,
|
|
||||||
passwd,
|
|
||||||
saved_details.altdomain,
|
|
||||||
saved_details.port,
|
|
||||||
saved_details.tls_policy,
|
|
||||||
saved_details.auth_policy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -552,6 +558,7 @@ void
|
|||||||
session_reconnect_now(void)
|
session_reconnect_now(void)
|
||||||
{
|
{
|
||||||
// reconnect with account.
|
// reconnect with account.
|
||||||
|
if (saved_account.name) {
|
||||||
ProfAccount* account = accounts_get_account(saved_account.name);
|
ProfAccount* account = accounts_get_account(saved_account.name);
|
||||||
if (account == NULL) {
|
if (account == NULL) {
|
||||||
log_error("Unable to reconnect, account no longer exists: %s", saved_account.name);
|
log_error("Unable to reconnect, account no longer exists: %s", saved_account.name);
|
||||||
@@ -577,6 +584,9 @@ session_reconnect_now(void)
|
|||||||
log_debug("Attempting reconnect with account %s", account->name);
|
log_debug("Attempting reconnect with account %s", account->name);
|
||||||
connection_connect(jid, saved_account.passwd, server, port, account->tls_policy, account->auth_policy);
|
connection_connect(jid, saved_account.passwd, server, port, account->tls_policy, account->auth_policy);
|
||||||
account_free(account);
|
account_free(account);
|
||||||
|
} else {
|
||||||
|
_session_connect(&saved_details);
|
||||||
|
}
|
||||||
if (reconnect_timer)
|
if (reconnect_timer)
|
||||||
g_timer_start(reconnect_timer);
|
g_timer_start(reconnect_timer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user