about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-05-11 00:02:39 +0100
committerJames Booth <boothj5@gmail.com>2016-05-11 00:02:39 +0100
commitb935b4621c89bb7aefe9d6456083fbb1835a14d1 (patch)
tree0b9044ab21885fcc84850f558ab708009e88325e /src/xmpp
parent7e079f3684b3dc863130716ccca3decec6d0d4b3 (diff)
downloadprofani-tty-b935b4621c89bb7aefe9d6456083fbb1835a14d1.tar.gz
Add connection_set_disconnected()
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/connection.c26
-rw-r--r--src/xmpp/connection.h5
-rw-r--r--src/xmpp/session.c21
3 files changed, 22 insertions, 30 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 283d0efb..ffabc149 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -206,6 +206,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
 connection_clear_data(void)
 {
     g_hash_table_destroy(conn.features_by_jid);
@@ -310,12 +318,6 @@ connection_get_status(void)
     return conn.conn_status;
 }
 
-void
-connection_set_status(jabber_conn_status_t status)
-{
-    conn.conn_status = status;
-}
-
 xmpp_conn_t*
 connection_get_conn(void)
 {
@@ -385,12 +387,6 @@ connection_get_presence_msg(void)
 }
 
 void
-connection_free_presence_msg(void)
-{
-    FREE_SET_NULL(conn.presence_message);
-}
-
-void
 connection_set_presence_msg(const char *const message)
 {
     FREE_SET_NULL(conn.presence_message);
@@ -400,12 +396,6 @@ connection_set_presence_msg(const char *const message)
 }
 
 void
-connection_free_domain(void)
-{
-    FREE_SET_NULL(conn.domain);
-}
-
-void
 connection_set_priority(const int priority)
 {
     conn.priority = priority;
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index 82ca4ab7..2465afd6 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -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,
     const char *const tls_policy);
 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_priority(const int priority);
 void connection_set_priority(int priority);
 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_ctx_t* connection_get_ctx(void);
 char *connection_get_domain(void);
diff --git a/src/xmpp/session.c b/src/xmpp/session.c
index 26e96863..93548d89 100644
--- a/src/xmpp/session.c
+++ b/src/xmpp/session.c
@@ -180,17 +180,17 @@ session_autoping_fail(void)
 {
     if (connection_get_status() == JABBER_CONNECTED) {
         log_info("Closing connection");
+
         char *account_name = session_get_account_name();
         const char *fulljid = connection_get_fulljid();
         plugins_on_disconnect(account_name, fulljid);
+
         accounts_set_last_activity(session_get_account_name());
+
         connection_disconnect();
     }
 
-    connection_free_presence_msg();
-    connection_free_domain();
-
-    connection_set_status(JABBER_DISCONNECTED);
+    connection_set_disconnected();
 
     session_lost_connection();
 }
@@ -201,22 +201,25 @@ session_disconnect(void)
     // if connected, send end stream and wait for response
     if (connection_get_status() == JABBER_CONNECTED) {
         log_info("Closing connection");
+
         char *account_name = session_get_account_name();
         const char *fulljid = connection_get_fulljid();
         plugins_on_disconnect(account_name, fulljid);
+
         accounts_set_last_activity(session_get_account_name());
+
         connection_disconnect();
+
         _session_free_saved_account();
         _session_free_saved_details();
+
         connection_clear_data();
+
         chat_sessions_clear();
         presence_clear_sub_requests();
     }
 
-    connection_free_presence_msg();
-    connection_free_domain();
-
-    connection_set_status(JABBER_DISCONNECTED);
+    connection_set_disconnected();
 }
 
 void
@@ -224,8 +227,10 @@ session_shutdown(void)
 {
     _session_free_saved_account();
     _session_free_saved_details();
+
     chat_sessions_clear();
     presence_clear_sub_requests();
+
     connection_shutdown();
 }