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
|
static gboolean
|
||||||
_cmd_disconnect(const char * const inp, struct cmd_help_t help)
|
_cmd_disconnect(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
char *jid = strdup(jabber_get_jid());
|
if (jabber_get_connection_status() == JABBER_CONNECTED) {
|
||||||
gboolean wait_response = jabber_disconnect();
|
char *jid = strdup(jabber_get_jid());
|
||||||
|
jabber_disconnect();
|
||||||
if (wait_response) {
|
contact_list_clear();
|
||||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
jabber_restart();
|
||||||
jabber_process_events();
|
cons_show("%s logged out successfully.", jid);
|
||||||
}
|
free(jid);
|
||||||
jabber_free_resources();
|
} else {
|
||||||
|
cons_show("You are not currently connected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
contact_list_clear();
|
|
||||||
jabber_restart();
|
|
||||||
cons_show("%s logged out successfully.", jid);
|
|
||||||
free(jid);
|
|
||||||
|
|
||||||
return TRUE;
|
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;
|
return jabber_conn.conn_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
void
|
||||||
jabber_disconnect(void)
|
jabber_disconnect(void)
|
||||||
{
|
{
|
||||||
// if connected, send end stream and wait for response
|
// if connected, send end stream and wait for response
|
||||||
@ -113,16 +113,11 @@ jabber_disconnect(void)
|
|||||||
log_info("Closing connection");
|
log_info("Closing connection");
|
||||||
xmpp_disconnect(jabber_conn.conn);
|
xmpp_disconnect(jabber_conn.conn);
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
// if disconnected dont wait just shutdown
|
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
||||||
} else if (jabber_conn.conn_status == JABBER_DISCONNECTED) {
|
jabber_process_events();
|
||||||
log_info("No connection open");
|
}
|
||||||
return FALSE;
|
jabber_free_resources();
|
||||||
|
|
||||||
// any other states, just shutdown
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ typedef enum {
|
|||||||
void jabber_init(const int disable_tls);
|
void jabber_init(const int disable_tls);
|
||||||
jabber_conn_status_t jabber_connect(const char * const user,
|
jabber_conn_status_t jabber_connect(const char * const user,
|
||||||
const char * const passwd);
|
const char * const passwd);
|
||||||
gboolean jabber_disconnect(void);
|
void jabber_disconnect(void);
|
||||||
void jabber_roster_request(void);
|
void jabber_roster_request(void);
|
||||||
void jabber_process_events(void);
|
void jabber_process_events(void);
|
||||||
void jabber_send(const char * const msg, const char * const recipient);
|
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
|
static void
|
||||||
_shutdown(void)
|
_shutdown(void)
|
||||||
{
|
{
|
||||||
gboolean wait_response = jabber_disconnect();
|
jabber_disconnect();
|
||||||
|
|
||||||
if (wait_response) {
|
|
||||||
while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
|
|
||||||
jabber_process_events();
|
|
||||||
}
|
|
||||||
jabber_free_resources();
|
|
||||||
}
|
|
||||||
|
|
||||||
contact_list_clear();
|
contact_list_clear();
|
||||||
gui_close();
|
gui_close();
|
||||||
chat_log_close();
|
chat_log_close();
|
||||||
|
Loading…
Reference in New Issue
Block a user