about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-10-07 00:51:00 +0100
committerJames Booth <boothj5@gmail.com>2013-10-07 00:51:00 +0100
commitacf1afe02538d51b7b613b75334c824e2d314cf4 (patch)
tree06564a2f2709cfc23747bbd77942d3dcb7b3a1be
parent383d91ec36b7b4afad79dffe2049dabbe2ec93fa (diff)
downloadprofani-tty-acf1afe02538d51b7b613b75334c824e2d314cf4.tar.gz
Moved idle chat state handling out of ui module
-rw-r--r--src/profanity.c26
-rw-r--r--src/ui/core.c28
-rw-r--r--src/ui/ui.h2
3 files changed, 29 insertions, 27 deletions
diff --git a/src/profanity.c b/src/profanity.c
index 19613f7d..06067d93 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -453,7 +453,31 @@ prof_handle_idle(void)
 {
     jabber_conn_status_t status = jabber_get_connection_status();
     if (status == JABBER_CONNECTED) {
-        ui_idle();
+        GSList *recipients = ui_get_recipients();
+        GSList *curr = recipients;
+
+        while (curr != NULL) {
+            char *recipient = curr->data;
+            chat_session_no_activity(recipient);
+
+            if (chat_session_is_gone(recipient) &&
+                    !chat_session_get_sent(recipient)) {
+                message_send_gone(recipient);
+            } else if (chat_session_is_inactive(recipient) &&
+                    !chat_session_get_sent(recipient)) {
+                message_send_inactive(recipient);
+            } else if (prefs_get_boolean(PREF_OUTTYPE) &&
+                    chat_session_is_paused(recipient) &&
+                    !chat_session_get_sent(recipient)) {
+                message_send_paused(recipient);
+            }
+
+            curr = g_slist_next(curr);
+        }
+
+        if (recipients != NULL) {
+            g_slist_free(recipients);
+        }
     }
 }
 
diff --git a/src/ui/core.c b/src/ui/core.c
index 6a6c15c4..24e8b822 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -211,33 +211,11 @@ ui_contact_typing(const char * const barejid)
     }
 }
 
-void
-ui_idle(void)
+GSList *
+ui_get_recipients(void)
 {
     GSList *recipients = wins_get_chat_recipients();
-    GSList *curr = recipients;
-    while (curr != NULL) {
-        char *recipient = curr->data;
-        chat_session_no_activity(recipient);
-
-        if (chat_session_is_gone(recipient) &&
-                !chat_session_get_sent(recipient)) {
-            message_send_gone(recipient);
-        } else if (chat_session_is_inactive(recipient) &&
-                !chat_session_get_sent(recipient)) {
-            message_send_inactive(recipient);
-        } else if (prefs_get_boolean(PREF_OUTTYPE) &&
-                chat_session_is_paused(recipient) &&
-                !chat_session_get_sent(recipient)) {
-            message_send_paused(recipient);
-        }
-
-        curr = g_slist_next(curr);
-    }
-
-    if (recipients != NULL) {
-        g_slist_free(recipients);
-    }
+    return recipients;
 }
 
 void
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 7fff0703..9c1cba52 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -48,7 +48,7 @@ void ui_refresh(void);
 void ui_close(void);
 void ui_resize(const int ch, const char * const input,
     const int size);
-void ui_idle(void);
+GSList* ui_get_recipients(void);
 void ui_handle_special_keys(const wint_t * const ch, const char * const inp,
     const int size);
 void ui_switch_win(const int i);