From 254179e128b577c8f929b38edab4e43fd6b4bffd Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 29 Dec 2014 02:17:20 +0000 Subject: Removed active and composing static functions --- src/chat_session.c | 77 +++++++++++++++++++----------------------------------- 1 file 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 -- cgit 1.4.1-2-gfad0 '#n25'>25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40