@@ -108,26 +108,21 @@ connection_shutdown(void)
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
|
||||
connection_connect(const char *const jid, const char *const passwd, const char *const altdomain, int port,
|
||||
const char *const tls_policy)
|
||||
{
|
||||
assert(fulljid != NULL);
|
||||
assert(jid != NULL);
|
||||
assert(passwd != NULL);
|
||||
|
||||
Jid *jid = jid_create(fulljid);
|
||||
if (jid == NULL) {
|
||||
log_error("Malformed JID not able to connect: %s", fulljid);
|
||||
Jid *jidp = jid_create(jid);
|
||||
if (jidp == NULL) {
|
||||
log_error("Malformed JID not able to connect: %s", jid);
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
return conn.conn_status;
|
||||
} else if (jid->fulljid == NULL) {
|
||||
log_error("Full JID required to connect, received: %s", fulljid);
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
jid_destroy(jid);
|
||||
return conn.conn_status;
|
||||
}
|
||||
jid_destroy(jid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
log_info("Connecting as %s", fulljid);
|
||||
log_info("Connecting as %s", jid);
|
||||
|
||||
if (conn.xmpp_log) {
|
||||
free(conn.xmpp_log);
|
||||
@@ -150,7 +145,7 @@ connection_connect(const char *const fulljid, const char *const passwd, const ch
|
||||
log_warning("Failed to get libstrophe conn during connect");
|
||||
return JABBER_DISCONNECTED;
|
||||
}
|
||||
xmpp_conn_set_jid(conn.xmpp_conn, fulljid);
|
||||
xmpp_conn_set_jid(conn.xmpp_conn, jid);
|
||||
xmpp_conn_set_pass(conn.xmpp_conn, passwd);
|
||||
|
||||
if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) {
|
||||
@@ -349,7 +344,12 @@ connection_get_ctx(void)
|
||||
const char*
|
||||
connection_get_fulljid(void)
|
||||
{
|
||||
return xmpp_conn_get_jid(conn.xmpp_conn);
|
||||
const char *jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
|
||||
if (jid) {
|
||||
return jid;
|
||||
} else {
|
||||
return xmpp_conn_get_jid(conn.xmpp_conn);
|
||||
}
|
||||
}
|
||||
|
||||
GHashTable*
|
||||
|
||||
@@ -106,10 +106,10 @@ jid_create(const gchar *const str)
|
||||
}
|
||||
|
||||
Jid*
|
||||
jid_create_from_bare_and_resource(const char *const room, const char *const nick)
|
||||
jid_create_from_bare_and_resource(const char *const barejid, const char *const resource)
|
||||
{
|
||||
Jid *result;
|
||||
char *jid = create_fulljid(room, nick);
|
||||
char *jid = create_fulljid(barejid, resource);
|
||||
result = jid_create(jid);
|
||||
free(jid);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ struct jid_t {
|
||||
typedef struct jid_t Jid;
|
||||
|
||||
Jid* jid_create(const gchar *const str);
|
||||
Jid* jid_create_from_bare_and_resource(const char *const room, const char *const nick);
|
||||
Jid* jid_create_from_bare_and_resource(const char *const barejid, const char *const resource);
|
||||
void jid_destroy(Jid *jid);
|
||||
|
||||
gboolean jid_is_valid_room_form(Jid *jid);
|
||||
|
||||
@@ -118,15 +118,22 @@ session_connect_with_account(const ProfAccount *const account)
|
||||
}
|
||||
saved_account.passwd = strdup(account->password);
|
||||
|
||||
// connect with fulljid
|
||||
Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
||||
char *jid = NULL;
|
||||
if (account->resource) {
|
||||
Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
|
||||
jid = strdup(jidp->fulljid);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
jid = strdup(account->jid);
|
||||
}
|
||||
|
||||
jabber_conn_status_t result = connection_connect(
|
||||
jidp->fulljid,
|
||||
jid,
|
||||
account->password,
|
||||
account->server,
|
||||
account->port,
|
||||
account->tls_policy);
|
||||
jid_destroy(jidp);
|
||||
free(jid);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -499,10 +506,16 @@ _session_reconnect(void)
|
||||
return;
|
||||
}
|
||||
|
||||
char *fulljid = create_fulljid(account->jid, account->resource);
|
||||
char *jid = NULL;
|
||||
if (account->resource) {
|
||||
jid = create_fulljid(account->jid, account->resource);
|
||||
} else {
|
||||
jid = strdup(account->jid);
|
||||
}
|
||||
|
||||
log_debug("Attempting reconnect with account %s", account->name);
|
||||
connection_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
|
||||
free(fulljid);
|
||||
connection_connect(jid, saved_account.passwd, account->server, account->port, account->tls_policy);
|
||||
free(jid);
|
||||
account_free(account);
|
||||
g_timer_start(reconnect_timer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user