mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[MOD] Basic work to get XMPP avatars through PEP
Attaboy!
This commit is contained in:
parent
f31a9c37b6
commit
e54332e376
13 changed files with 428 additions and 25 deletions
|
|
@ -327,6 +327,7 @@ void
|
|||
IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||
{
|
||||
XMPPComponent *jabber = args->jabber;
|
||||
XMLElement *pubsub;
|
||||
char *from = HashMapGet(stanza->attrs, "from");
|
||||
char *to = HashMapGet(stanza->attrs, "to");
|
||||
char *id = HashMapGet(stanza->attrs, "id");
|
||||
|
|
@ -395,6 +396,68 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMLFreeElement(iqVCard);
|
||||
}
|
||||
}
|
||||
#define PS "http://jabber.org/protocol/pubsub"
|
||||
else if ((pubsub = XMLookForTKV(stanza, "pubsub", "xmlns", PS)))
|
||||
{
|
||||
/* TODO: Pass this through the PEP manager */
|
||||
XMLElement *a_items = XMLookForTKV(pubsub,
|
||||
"items", "node", "urn:xmpp:avatar:data"
|
||||
);
|
||||
if (a_items)
|
||||
{
|
||||
/* Do, without regret, start shoving an avatar out the bus */
|
||||
char *to_matrix = ParseeDecodeMXID(to);
|
||||
char *avatar = ASGetAvatar(args->config, NULL, to_matrix);
|
||||
char *buf, *mime;
|
||||
char *b64;
|
||||
size_t len;
|
||||
XMLElement *reply;
|
||||
|
||||
ASGrab(args->config, avatar, &mime, &buf, &len);
|
||||
b64 = Base64Encode(buf, len);
|
||||
Free(buf);
|
||||
|
||||
Log(LOG_INFO, "FM=%s", to_matrix);
|
||||
Log(LOG_INFO, "B=%s (%dB)", b64, (int) len);
|
||||
/* Strike back with a response */
|
||||
reply = XMLCreateTag("iq");
|
||||
XMLAddAttr(reply, "type", "result");
|
||||
XMLAddAttr(reply, "to", from);
|
||||
XMLAddAttr(reply, "from", to);
|
||||
XMLAddAttr(reply, "id", HashMapGet(stanza->attrs, "id"));
|
||||
{
|
||||
XMLElement *ps = XMLCreateTag("pubsub");
|
||||
XMLElement *items = XMLCreateTag("items");
|
||||
XMLAddAttr(ps, "xmlns", PS);
|
||||
XMLAddAttr(items, "node", "urn:xmpp:avatar:data");
|
||||
{
|
||||
XMLElement *item = XMLCreateTag("item");
|
||||
XMLElement *data = XMLCreateTag("data");
|
||||
XMLAddAttr(item, "id", "TODO");
|
||||
XMLAddAttr(data, "xmlns", "urn:xmpp:avatar:data");
|
||||
|
||||
XMLAddChild(data, XMLCreateText(b64));
|
||||
|
||||
XMLAddChild(item, data);
|
||||
XMLAddChild(items, item);
|
||||
}
|
||||
XMLAddChild(ps, items);
|
||||
XMLAddChild(reply, ps);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, reply);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMLFreeElement(reply);
|
||||
|
||||
Free(to_matrix);
|
||||
Free(avatar);
|
||||
Free(mime);
|
||||
Free(b64);
|
||||
}
|
||||
}
|
||||
#undef PS
|
||||
else if (XMLookForTKV(stanza, "query", "xmlns", DISCO))
|
||||
{
|
||||
IQDiscoGet(args, jabber, stanza);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue