about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-09-29 00:01:38 +0100
committerJames Booth <boothj5@gmail.com>2015-09-29 00:01:38 +0100
commit26d160cae861865191150c73853a748fcd9cfad1 (patch)
tree34acc6584ad8b52307d8ff1fe7a9d9eb1a6cfa4b /src/command
parenta12624ea753389cea2d16f179477d7f7b8aa5fa3 (diff)
downloadprofani-tty-26d160cae861865191150c73853a748fcd9cfad1.tar.gz
WIP: Added last activity request and response
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c17
-rw-r--r--src/command/commands.c25
-rw-r--r--src/command/commands.h1
3 files changed, 43 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 186155b0..603b0f12 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -695,6 +695,23 @@ static struct cmd_t command_defs[] =
             "/disco info myfriend@server.com/laptop")
     },
 
+    { "/lastactivity",
+        cmd_lastactivity, parse_args, 0, 1, NULL,
+        CMD_TAGS(
+            CMD_TAG_PRESENCE)
+        CMD_SYN(
+            "/lastactivity [<jid>]")
+        CMD_DESC(
+            "Send a last activity query to the supplied JID, omitting the JID will send the query to your server.")
+        CMD_ARGS(
+            { "<jid>", "The JID of the entity to which the query will be sent." })
+        CMD_EXAMPLES(
+            "/lastactivity",
+            "/lastactivity alice@securechat.org",
+            "/lastactivity alice@securechat.org/laptop",
+            "/lastactivity someserver.com")
+    },
+
     { "/nick",
         cmd_nick, parse_args_with_freetext, 1, 1, NULL,
         CMD_TAGS(
diff --git a/src/command/commands.c b/src/command/commands.c
index e6d1e277..6b301057 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -3262,6 +3262,31 @@ cmd_disco(ProfWin *window, const char * const command, gchar **args)
 }
 
 gboolean
+cmd_lastactivity(ProfWin *window, const char * const command, gchar **args)
+{
+    jabber_conn_status_t conn_status = jabber_get_connection_status();
+
+    if (conn_status != JABBER_CONNECTED) {
+        cons_show("You are not currenlty connected.");
+        return TRUE;
+    }
+
+    if (args[0] == NULL) {
+        Jid *jidp = jid_create(jabber_get_fulljid());
+        GString *jid = g_string_new(jidp->domainpart);
+
+        iq_last_activity_request(jid->str);
+
+        g_string_free(jid, TRUE);
+        jid_destroy(jidp);
+    } else {
+        iq_last_activity_request(args[0]);
+    }
+
+    return TRUE;
+}
+
+gboolean
 cmd_nick(ProfWin *window, const char * const command, gchar **args)
 {
     jabber_conn_status_t conn_status = jabber_get_connection_status();
diff --git a/src/command/commands.h b/src/command/commands.h
index e456e291..b3f83a70 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -85,6 +85,7 @@ gboolean cmd_connect(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_tls(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_decline(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_disco(ProfWin *window, const char * const command, gchar **args);
+gboolean cmd_lastactivity(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_disconnect(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_dnd(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_flash(ProfWin *window, const char * const command, gchar **args);