mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
xep-0084: Look for specific user and print ID
Add a `/avatar` command.
This commit is contained in:
parent
771dfab123
commit
e3538cf739
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -36,3 +36,4 @@
|
||||
#include <glib.h>
|
||||
|
||||
void avatar_pep_subscribe(void);
|
||||
bool avatar_get_by_nick(const char* nick);
|
||||
|
Loading…
Reference in New Issue
Block a user