about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-14 22:09:18 +0100
committerJames Booth <boothj5@gmail.com>2015-10-14 22:09:18 +0100
commitd38e10828edac7c57481f0e2995c69f219d54a12 (patch)
treea873d2c534cfdd7b75c09f22842e2a84529e5606
parent1fd2a8a4e91e2bdb21a6ad5643eee875894001fb (diff)
downloadprofani-tty-d38e10828edac7c57481f0e2995c69f219d54a12.tar.gz
Added /lastactivity on|off
-rw-r--r--src/command/command.c9
-rw-r--r--src/command/commands.c9
-rw-r--r--src/ui/console.c6
3 files changed, 19 insertions, 5 deletions
diff --git a/src/command/command.c b/src/command/command.c
index def2815b..6309ce93 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -703,13 +703,16 @@ static struct cmd_t command_defs[] =
         CMD_TAGS(
             CMD_TAG_PRESENCE)
         CMD_SYN(
+            "/lastactivity on|off",
             "/lastactivity [<jid>]")
         CMD_DESC(
-            "Send a last activity query to the supplied JID, omitting the JID will send the query to your server.")
+            "Enable/disable sending last activity, and send last activity requests.")
         CMD_ARGS(
-            { "<jid>", "The JID of the entity to which the query will be sent." })
+            { "on|off", "Enable or disable sending of last activity." },
+            { "<jid>",  "The JID of the entity to query, omitting the JID will query your server." })
         CMD_EXAMPLES(
             "/lastactivity",
+            "/lastactivity off",
             "/lastactivity alice@securechat.org",
             "/lastactivity alice@securechat.org/laptop",
             "/lastactivity someserver.com")
@@ -2564,7 +2567,7 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
     // autocomplete boolean settings
     gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
         "/flash", "/splash", "/chlog", "/grlog", "/history", "/vercheck",
-        "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn" };
+        "/privileges", "/presence", "/wrap", "/winstidy", "/carbons", "/encwarn", "/lastactivity" };
 
     for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
         result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice);
diff --git a/src/command/commands.c b/src/command/commands.c
index 94e768db..df730c63 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3279,11 +3279,16 @@ cmd_lastactivity(ProfWin *window, const char * const command, gchar **args)
 
         g_string_free(jid, TRUE);
         jid_destroy(jidp);
+
+        return TRUE;
+
+    } else if ((g_strcmp0(args[0], "on") == 0) || (g_strcmp0(args[0], "off") == 0)) {
+        return _cmd_set_boolean_preference(args[0], command, "Last activity responses", PREF_LASTACTIVITY);
+
     } else {
         iq_last_activity_request(args[0]);
+        return TRUE;
     }
-
-    return TRUE;
 }
 
 gboolean
diff --git a/src/ui/console.c b/src/ui/console.c
index 319e451d..f5014013 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1459,6 +1459,12 @@ cons_show_presence_prefs(void)
     cons_show("");
     cons_autoaway_setting();
 
+    if (prefs_get_boolean(PREF_LASTACTIVITY)) {
+        cons_show("Send last activity (/lastactivity)        : ON");
+    } else {
+        cons_show("Send last activity (/lastactivity)        : OFF");
+    }
+
     cons_alert();
 }