about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-12-18 13:37:42 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-12-18 13:37:42 +0100
commit3fdeb52f1c481982c68e9cbcb7206ff145f942b6 (patch)
tree4a0558eeea6bd0f86b5d0ef0db6174e61c6ddbe7 /src
parent3f58aba2bd373b011f104c499ff42f1bf4b45226 (diff)
downloadprofani-tty-3fdeb52f1c481982c68e9cbcb7206ff145f942b6.tar.gz
xep-0084: add /avatar help and autocompletion
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_ac.c18
-rw-r--r--src/command/cmd_defs.c6
2 files changed, 21 insertions, 3 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 8908777a..9399aa8d 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -112,6 +112,7 @@ static char* _invite_autocomplete(ProfWin *window, const char *const input, gboo
 static char* _status_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _logging_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 static char* _color_autocomplete(ProfWin *window, const char *const input, gboolean previous);
+static char* _avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous);
 
 static char* _script_autocomplete_func(const char *const prefix, gboolean previous);
 
@@ -1608,6 +1609,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
     g_hash_table_insert(ac_funcs, "/status",        _status_autocomplete);
     g_hash_table_insert(ac_funcs, "/logging",       _logging_autocomplete);
     g_hash_table_insert(ac_funcs, "/color",         _color_autocomplete);
+    g_hash_table_insert(ac_funcs, "/avatar",        _avatar_autocomplete);
 
     int len = strlen(input);
     char parsed[len+1];
@@ -3619,3 +3621,19 @@ _color_autocomplete(ProfWin *window, const char *const input, gboolean previous)
 
     return NULL;
 }
+
+static char*
+_avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous)
+{
+    char *result = NULL;
+
+    jabber_conn_status_t conn_status = connection_get_status();
+    if (conn_status == JABBER_CONNECTED) {
+        result = autocomplete_param_with_func(input, "/avatar", roster_barejid_autocomplete, previous);
+        if (result) {
+            return result;
+        }
+    }
+
+    return NULL;
+}
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 509b78e2..9b7c6b37 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2320,11 +2320,11 @@ static struct cmd_t command_defs[] =
         CMD_TAGS(
             CMD_TAG_CHAT)
         CMD_SYN(
-            "/color nick")
+            "/avatar <barejid>")
         CMD_DESC(
-            "Not ready")
+            "Download avatar for a certain contact.")
         CMD_ARGS(
-            { "nick", "Not ready"})
+            { "<barejid>", "JID to download avatar from."})
         CMD_NOEXAMPLES
     },
 };