diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-12-18 11:24:50 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-12-18 11:24:50 +0100 |
commit | e3538cf73976738c190777d055f8766e4247a906 (patch) | |
tree | a4b11ec42e98b4d9afb2cfc6a9e77cd62b3e9a95 /src | |
parent | 771dfab12354bc509af9163fca0c599ec9e58433 (diff) | |
download | profani-tty-e3538cf73976738c190777d055f8766e4247a906.tar.gz |
xep-0084: Look for specific user and print ID
Add a `/avatar` command.
Diffstat (limited to 'src')
-rw-r--r-- | src/command/cmd_defs.c | 15 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 9 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 2 | ||||
-rw-r--r-- | src/xmpp/avatar.c | 22 | ||||
-rw-r--r-- | src/xmpp/avatar.h | 1 |
5 files changed, 47 insertions, 2 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 7e0001c6..509b78e2 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2312,6 +2312,21 @@ static struct cmd_t command_defs[] = "/color on", "/color blue") }, + + { "/avatar", + parse_args, 1, 1, NULL, + CMD_NOSUBFUNCS + CMD_MAINFUNC(cmd_avatar) + CMD_TAGS( + CMD_TAG_CHAT) + CMD_SYN( + "/color nick") + CMD_DESC( + "Not ready") + CMD_ARGS( + { "nick", "Not ready"}) + CMD_NOEXAMPLES + }, }; static GHashTable *search_index; diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 425b50fc..2b9acb02 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -78,6 +78,7 @@ #include "xmpp/jid.h" #include "xmpp/muc.h" #include "xmpp/chat_session.h" +#include "xmpp/avatar.h" #ifdef HAVE_LIBOTR #include "otr/otr.h" @@ -8660,3 +8661,11 @@ cmd_color(ProfWin *window, const char *const command, gchar **args) return TRUE; } + +gboolean +cmd_avatar(ProfWin *window, const char *const command, gchar **args) +{ + avatar_get_by_nick(args[0]); + + return TRUE; +} diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index cd37192e..4ce1e284 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -223,6 +223,6 @@ gboolean cmd_save(ProfWin *window, const char *const command, gchar **args); gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args); gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args); - gboolean cmd_color(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args); #endif diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c index 29ec453b..2685472a 100644 --- a/src/xmpp/avatar.c +++ b/src/xmpp/avatar.c @@ -41,6 +41,9 @@ #include "xmpp/iq.h" #include "xmpp/message.h" #include "xmpp/stanza.h" +#include "ui/ui.h" + +char *looking_for = NULL; static int _avatar_metadata_nofication(xmpp_stanza_t *const stanza, void *const userdata); @@ -50,7 +53,15 @@ avatar_pep_subscribe(void) message_pubsub_event_handler_add(STANZA_NS_USER_AVATAR_METADATA, _avatar_metadata_nofication, NULL, NULL); message_pubsub_event_handler_add(STANZA_NS_USER_AVATAR_DATA, _avatar_metadata_nofication, NULL, NULL); + //caps_add_feature(XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY); +} + +bool +avatar_get_by_nick(const char* nick) +{ + looking_for = strdup(nick); caps_add_feature(XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY); + return TRUE; } static int @@ -59,6 +70,14 @@ _avatar_metadata_nofication(xmpp_stanza_t *const stanza, void *const userdata) const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); from = from; + if (!(looking_for && + (g_strcmp0(looking_for, from) == 0))) { + return 1; + } + + free(looking_for); + looking_for = NULL; + xmpp_stanza_t *root = NULL; xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); if (event) { @@ -87,7 +106,8 @@ _avatar_metadata_nofication(xmpp_stanza_t *const stanza, void *const userdata) xmpp_stanza_t *info = xmpp_stanza_get_child_by_name(metadata, "info"); const char *id = xmpp_stanza_get_id(info); - id = id; + + cons_show("Id for %s is: %s", from, id); } return 1; diff --git a/src/xmpp/avatar.h b/src/xmpp/avatar.h index dcaaf24a..6a8ce94b 100644 --- a/src/xmpp/avatar.h +++ b/src/xmpp/avatar.h @@ -36,3 +36,4 @@ #include <glib.h> void avatar_pep_subscribe(void); +bool avatar_get_by_nick(const char* nick); |