about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-12-29 02:17:20 +0000
committerJames Booth <boothj5@gmail.com>2014-12-29 02:17:20 +0000
commit254179e128b577c8f929b38edab4e43fd6b4bffd (patch)
tree2396805baea5cebd6ef2353528478a0829052018
parente75b8dcfb318bc76ddfddf796da5824e906c8701 (diff)
downloadprofani-tty-254179e128b577c8f929b38edab4e43fd6b4bffd.tar.gz
Removed active and composing static functions
-rw-r--r--src/chat_session.c77
1 files changed, 27 insertions, 50 deletions
diff --git a/src/chat_session.c b/src/chat_session.c
index 43b20806..d27a3449 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -65,26 +65,7 @@ typedef struct chat_session_t {
 
 static GHashTable *sessions;
 
-static ChatSession* _chat_session_new(const char * const barejid, gboolean supported);
-static void _chat_session_set_composing(const char * const barejid);
-static void _chat_session_set_active(const char * const barejid);
-static void _chat_session_free(ChatSession *session);
-
-void
-chat_sessions_init(void)
-{
-    sessions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-        (GDestroyNotify)_chat_session_free);
-}
-
-void
-chat_sessions_clear(void)
-{
-    if (sessions != NULL)
-        g_hash_table_remove_all(sessions);
-}
-
-ChatSession*
+static ChatSession*
 _chat_session_new(const char * const barejid, gboolean supported)
 {
     ChatSession *new_session = malloc(sizeof(struct chat_session_t));
@@ -99,29 +80,30 @@ _chat_session_new(const char * const barejid, gboolean supported)
 }
 
 static void
-_chat_session_set_composing(const char * const barejid)
+_chat_session_free(ChatSession *session)
 {
-    ChatSession *session = g_hash_table_lookup(sessions, barejid);
-
     if (session != NULL) {
-        if (session->state != CHAT_STATE_COMPOSING) {
-            session->sent = FALSE;
+        free(session->barejid);
+        if (session->active_timer != NULL) {
+            g_timer_destroy(session->active_timer);
+            session->active_timer = NULL;
         }
-        session->state = CHAT_STATE_COMPOSING;
-        g_timer_start(session->active_timer);
+        free(session);
     }
 }
 
-static void
-_chat_session_set_active(const char * const barejid)
+void
+chat_sessions_init(void)
 {
-    ChatSession *session = g_hash_table_lookup(sessions, barejid);
+    sessions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+        (GDestroyNotify)_chat_session_free);
+}
 
-    if (session != NULL) {
-        session->state = CHAT_STATE_ACTIVE;
-        g_timer_start(session->active_timer);
-        session->sent = TRUE;
-    }
+void
+chat_sessions_clear(void)
+{
+    if (sessions != NULL)
+        g_hash_table_remove_all(sessions);
 }
 
 gboolean
@@ -136,7 +118,9 @@ chat_session_on_message_send(const char * const barejid)
 
         }
         if (session->supported) {
-            _chat_session_set_active(barejid);
+            session->state = CHAT_STATE_ACTIVE;
+            g_timer_start(session->active_timer);
+            session->sent = TRUE;
             send_state = TRUE;
         }
     }
@@ -200,7 +184,13 @@ chat_session_on_activity(const char * const barejid)
     ChatSession *session = g_hash_table_lookup(sessions, barejid);
     if (session) {
         if (session->supported) {
-            _chat_session_set_composing(barejid);
+            if (session->state != CHAT_STATE_COMPOSING) {
+                session->sent = FALSE;
+            }
+
+            session->state = CHAT_STATE_COMPOSING;
+            g_timer_start(session->active_timer);
+
             if (!session->sent || session->state == CHAT_STATE_PAUSED) {
                 message_send_composing(barejid);
                 session->sent = TRUE;
@@ -250,17 +240,4 @@ chat_session_on_inactivity(const char * const barejid)
             }
         }
     }
-}
-
-static void
-_chat_session_free(ChatSession *session)
-{
-    if (session != NULL) {
-        free(session->barejid);
-        if (session->active_timer != NULL) {
-            g_timer_destroy(session->active_timer);
-            session->active_timer = NULL;
-        }
-        free(session);
-    }
 }
\ No newline at end of file