From 5fb8acb17fcf52cbab6abbeb7d34a5bc5de2dfac Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 14 Oct 2015 21:30:48 +0100 Subject: Use lastactivity preference for presence updates --- src/profanity.c | 12 ++++++++++-- src/xmpp/roster.c | 7 ++++++- 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); -- cgit 1.4.1-2-gfad0