mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Refactored disconnect
This commit is contained in:
parent
d658915740
commit
847850742c
@ -577,21 +577,17 @@ _cmd_connect(const char * const inp, struct cmd_help_t help)
|
||||
static gboolean
|
||||
_cmd_disconnect(const char * const inp, struct cmd_help_t help)
|
||||
{
|
||||
char *jid = strdup(jabber_get_jid());
|
||||
gboolean wait_response = jabber_disconnect();
|
||||
|
||||
if (wait_response) {
|
||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||
jabber_process_events();
|
||||
}
|
||||
jabber_free_resources();
|
||||
if (jabber_get_connection_status() == JABBER_CONNECTED) {
|
||||
char *jid = strdup(jabber_get_jid());
|
||||
jabber_disconnect();
|
||||
contact_list_clear();
|
||||
jabber_restart();
|
||||
cons_show("%s logged out successfully.", jid);
|
||||
free(jid);
|
||||
} else {
|
||||
cons_show("You are not currently connected.");
|
||||
}
|
||||
|
||||
contact_list_clear();
|
||||
jabber_restart();
|
||||
cons_show("%s logged out successfully.", jid);
|
||||
free(jid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
15
src/jabber.c
15
src/jabber.c
@ -105,7 +105,7 @@ jabber_connect(const char * const user,
|
||||
return jabber_conn.conn_status;
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
jabber_disconnect(void)
|
||||
{
|
||||
// if connected, send end stream and wait for response
|
||||
@ -113,16 +113,11 @@ jabber_disconnect(void)
|
||||
log_info("Closing connection");
|
||||
xmpp_disconnect(jabber_conn.conn);
|
||||
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
||||
return TRUE;
|
||||
|
||||
// if disconnected dont wait just shutdown
|
||||
} else if (jabber_conn.conn_status == JABBER_DISCONNECTED) {
|
||||
log_info("No connection open");
|
||||
return FALSE;
|
||||
|
||||
// any other states, just shutdown
|
||||
} else {
|
||||
return FALSE;
|
||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||
jabber_process_events();
|
||||
}
|
||||
jabber_free_resources();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ typedef enum {
|
||||
void jabber_init(const int disable_tls);
|
||||
jabber_conn_status_t jabber_connect(const char * const user,
|
||||
const char * const passwd);
|
||||
gboolean jabber_disconnect(void);
|
||||
void jabber_disconnect(void);
|
||||
void jabber_roster_request(void);
|
||||
void jabber_process_events(void);
|
||||
void jabber_send(const char * const msg, const char * const recipient);
|
||||
|
@ -292,15 +292,7 @@ _init(const int disable_tls, char *log_level)
|
||||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
gboolean wait_response = jabber_disconnect();
|
||||
|
||||
if (wait_response) {
|
||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||
jabber_process_events();
|
||||
}
|
||||
jabber_free_resources();
|
||||
}
|
||||
|
||||
jabber_disconnect();
|
||||
contact_list_clear();
|
||||
gui_close();
|
||||
chat_log_close();
|
||||
|
Loading…
Reference in New Issue
Block a user