about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-14 21:30:48 +0100
committerJames Booth <boothj5@gmail.com>2015-10-14 21:30:48 +0100
commit5fb8acb17fcf52cbab6abbeb7d34a5bc5de2dfac (patch)
treef89db30d1fc65b60ef23803e578894f067c620aa
parent8c9174b82f239f23dee3172c68429758900bbe5a (diff)
downloadprofani-tty-5fb8acb17fcf52cbab6abbeb7d34a5bc5de2dfac.tar.gz
Use lastactivity preference for presence updates
-rw-r--r--src/profanity.c12
-rw-r--r--src/xmpp/roster.c7
2 files changed, 16 insertions, 3 deletions
diff --git a/src/profanity.c b/src/profanity.c
index bcbd8c2e..3bec7a99 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -212,7 +212,11 @@ _check_autoaway()
 
                     // send away presence with last activity
                     char *message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
-                    cl_ev_presence_send(RESOURCE_AWAY, message, idle_ms / 1000);
+                    if (prefs_get_boolean(PREF_LASTACTIVITY)) {
+                        cl_ev_presence_send(RESOURCE_AWAY, message, idle_ms / 1000);
+                    } else {
+                        cl_ev_presence_send(RESOURCE_AWAY, message, 0);
+                    }
 
                     int pri = accounts_get_priority_for_presence_type(account, RESOURCE_AWAY);
                     if (message) {
@@ -248,7 +252,11 @@ _check_autoaway()
 
             // send extended away presence with last activity
             char *message = prefs_get_string(PREF_AUTOXA_MESSAGE);
-            cl_ev_presence_send(RESOURCE_XA, message, idle_ms / 1000);
+            if (prefs_get_boolean(PREF_LASTACTIVITY)) {
+                cl_ev_presence_send(RESOURCE_XA, message, idle_ms / 1000);
+            } else {
+                cl_ev_presence_send(RESOURCE_XA, message, 0);
+            }
 
             int pri = accounts_get_priority_for_presence_type(account, RESOURCE_XA);
             if (message) {
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 020f01f6..1138061b 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -53,6 +53,7 @@
 #include "event/server_events.h"
 #include "event/client_events.h"
 #include "tools/autocomplete.h"
+#include "config/preferences.h"
 #include "xmpp/connection.h"
 #include "xmpp/roster.h"
 #include "roster_list.h"
@@ -355,7 +356,11 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, v
             GDateTime *lastdt = g_date_time_new_from_timeval_utc(&lasttv);
             GTimeSpan diff_micros = g_date_time_difference(nowdt, lastdt);
             int diff_secs = (diff_micros / 1000) / 1000;
-            cl_ev_presence_send(conn_presence, NULL, diff_secs);
+            if (prefs_get_boolean(PREF_LASTACTIVITY)) {
+                cl_ev_presence_send(conn_presence, NULL, diff_secs);
+            } else {
+                cl_ev_presence_send(conn_presence, NULL, 0);
+            }
             g_date_time_unref(lastdt);
         } else {
             cl_ev_presence_send(conn_presence, NULL, 0);