1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Add connection_set_disconnected()

This commit is contained in:
James Booth 2016-05-11 00:02:39 +01:00
parent 7e079f3684
commit b935b4621c
3 changed files with 22 additions and 30 deletions

View File

@ -205,6 +205,14 @@ connection_disconnect(void)
} }
} }
void
connection_set_disconnected(void)
{
FREE_SET_NULL(conn.presence_message);
FREE_SET_NULL(conn.domain);
conn.conn_status = JABBER_DISCONNECTED;
}
void void
connection_clear_data(void) connection_clear_data(void)
{ {
@ -310,12 +318,6 @@ connection_get_status(void)
return conn.conn_status; return conn.conn_status;
} }
void
connection_set_status(jabber_conn_status_t status)
{
conn.conn_status = status;
}
xmpp_conn_t* xmpp_conn_t*
connection_get_conn(void) connection_get_conn(void)
{ {
@ -384,12 +386,6 @@ connection_get_presence_msg(void)
return conn.presence_message; return conn.presence_message;
} }
void
connection_free_presence_msg(void)
{
FREE_SET_NULL(conn.presence_message);
}
void void
connection_set_presence_msg(const char *const message) connection_set_presence_msg(const char *const message)
{ {
@ -399,12 +395,6 @@ connection_set_presence_msg(const char *const message)
} }
} }
void
connection_free_domain(void)
{
FREE_SET_NULL(conn.domain);
}
void void
connection_set_priority(const int priority) connection_set_priority(const int priority)
{ {

View File

@ -43,16 +43,13 @@ void connection_shutdown(void);
jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port, jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
const char *const tls_policy); const char *const tls_policy);
void connection_disconnect(void); void connection_disconnect(void);
void connection_set_disconnected(void);
void connection_set_status(jabber_conn_status_t status);
void connection_set_presence_msg(const char *const message); void connection_set_presence_msg(const char *const message);
void connection_set_priority(const int priority); void connection_set_priority(const int priority);
void connection_set_priority(int priority); void connection_set_priority(int priority);
void connection_set_disco_items(GSList *items); void connection_set_disco_items(GSList *items);
void connection_free_presence_msg(void);
void connection_free_domain(void);
xmpp_conn_t* connection_get_conn(void); xmpp_conn_t* connection_get_conn(void);
xmpp_ctx_t* connection_get_ctx(void); xmpp_ctx_t* connection_get_ctx(void);
char *connection_get_domain(void); char *connection_get_domain(void);

View File

@ -180,17 +180,17 @@ session_autoping_fail(void)
{ {
if (connection_get_status() == JABBER_CONNECTED) { if (connection_get_status() == JABBER_CONNECTED) {
log_info("Closing connection"); log_info("Closing connection");
char *account_name = session_get_account_name(); char *account_name = session_get_account_name();
const char *fulljid = connection_get_fulljid(); const char *fulljid = connection_get_fulljid();
plugins_on_disconnect(account_name, fulljid); plugins_on_disconnect(account_name, fulljid);
accounts_set_last_activity(session_get_account_name()); accounts_set_last_activity(session_get_account_name());
connection_disconnect(); connection_disconnect();
} }
connection_free_presence_msg(); connection_set_disconnected();
connection_free_domain();
connection_set_status(JABBER_DISCONNECTED);
session_lost_connection(); session_lost_connection();
} }
@ -201,22 +201,25 @@ session_disconnect(void)
// if connected, send end stream and wait for response // if connected, send end stream and wait for response
if (connection_get_status() == JABBER_CONNECTED) { if (connection_get_status() == JABBER_CONNECTED) {
log_info("Closing connection"); log_info("Closing connection");
char *account_name = session_get_account_name(); char *account_name = session_get_account_name();
const char *fulljid = connection_get_fulljid(); const char *fulljid = connection_get_fulljid();
plugins_on_disconnect(account_name, fulljid); plugins_on_disconnect(account_name, fulljid);
accounts_set_last_activity(session_get_account_name()); accounts_set_last_activity(session_get_account_name());
connection_disconnect(); connection_disconnect();
_session_free_saved_account(); _session_free_saved_account();
_session_free_saved_details(); _session_free_saved_details();
connection_clear_data(); connection_clear_data();
chat_sessions_clear(); chat_sessions_clear();
presence_clear_sub_requests(); presence_clear_sub_requests();
} }
connection_free_presence_msg(); connection_set_disconnected();
connection_free_domain();
connection_set_status(JABBER_DISCONNECTED);
} }
void void
@ -224,8 +227,10 @@ session_shutdown(void)
{ {
_session_free_saved_account(); _session_free_saved_account();
_session_free_saved_details(); _session_free_saved_details();
chat_sessions_clear(); chat_sessions_clear();
presence_clear_sub_requests(); presence_clear_sub_requests();
connection_shutdown(); connection_shutdown();
} }