mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
jabber.c: set jabber status in one place in connection handler
This commit is contained in:
parent
621832ee4a
commit
e0e8110746
23
src/jabber.c
23
src/jabber.c
@ -202,8 +202,8 @@ jabber_disconnect(void)
|
|||||||
// if connected, send end stream and wait for response
|
// if connected, send end stream and wait for response
|
||||||
if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
||||||
log_info("Closing connection");
|
log_info("Closing connection");
|
||||||
xmpp_disconnect(jabber_conn.conn);
|
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
||||||
|
xmpp_disconnect(jabber_conn.conn);
|
||||||
|
|
||||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||||
jabber_process_events();
|
jabber_process_events();
|
||||||
@ -782,41 +782,34 @@ _connection_handler(xmpp_conn_t * const conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if (status == XMPP_CONN_DISCONNECT) {
|
||||||
|
|
||||||
// received close stream response from server after disconnect
|
|
||||||
if (jabber_conn.conn_status == JABBER_DISCONNECTING) {
|
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
|
||||||
|
|
||||||
// lost connection for unkown reason
|
// lost connection for unkown reason
|
||||||
} else if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
||||||
prof_handle_lost_connection();
|
prof_handle_lost_connection();
|
||||||
if (prefs_get_reconnect() != 0) {
|
if (prefs_get_reconnect() != 0) {
|
||||||
assert(reconnect_timer == NULL);
|
assert(reconnect_timer == NULL);
|
||||||
reconnect_timer = g_timer_new();
|
reconnect_timer = g_timer_new();
|
||||||
}
|
}
|
||||||
xmpp_stop(ctx);
|
xmpp_stop(ctx);
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
|
||||||
|
|
||||||
// login attempt failed
|
// login attempt failed
|
||||||
} else {
|
} else if (jabber_conn.conn_status != JABBER_DISCONNECTING) {
|
||||||
if (reconnect_timer == NULL) {
|
if (reconnect_timer == NULL) {
|
||||||
prof_handle_failed_login();
|
prof_handle_failed_login();
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
|
||||||
jabber_free_resources();
|
jabber_free_resources();
|
||||||
} else {
|
} else {
|
||||||
xmpp_stop(ctx);
|
xmpp_stop(ctx);
|
||||||
if (prefs_get_reconnect() != 0) {
|
if (prefs_get_reconnect() != 0) {
|
||||||
g_timer_start(reconnect_timer);
|
g_timer_start(reconnect_timer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close stream response from server after disconnect is handled too
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence = PRESENCE_OFFLINE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user