mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:45:10 +00:00
[ADD/WIP] Basic XEP-0393 support.
Still needs lots of work. Did I fail to mention I _hate_ HTML?
This commit is contained in:
parent
94cba7acf0
commit
771c3271ad
10 changed files with 473 additions and 9 deletions
|
|
@ -124,6 +124,83 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
|
|||
return true;
|
||||
}
|
||||
|
||||
#define DISCO "http://jabber.org/protocol/disco#info"
|
||||
static void
|
||||
IQDiscoGet(ParseeData *args, XMPPComponent *jabber, XMLElement *stanza)
|
||||
{
|
||||
char *from, *to, *id;
|
||||
XMLElement *iq_reply, *query;
|
||||
|
||||
from = HashMapGet(stanza->attrs, "from");
|
||||
to = HashMapGet(stanza->attrs, "to");
|
||||
id = HashMapGet(stanza->attrs, "id");
|
||||
|
||||
/* Generate an IQ reply with discovery information */
|
||||
iq_reply = XMLCreateTag("iq");
|
||||
XMLAddAttr(iq_reply, "to", from);
|
||||
XMLAddAttr(iq_reply, "from", to);
|
||||
XMLAddAttr(iq_reply, "type", "result");
|
||||
XMLAddAttr(iq_reply, "id", id);
|
||||
{
|
||||
query = XMLCreateTag("query");
|
||||
XMLAddAttr(query, "xmlns", DISCO);
|
||||
{
|
||||
XMLElement *feature;
|
||||
#define AdvertiseSimple(f) do \
|
||||
{ \
|
||||
feature = XMLCreateTag("feature"); \
|
||||
XMLAddAttr(feature, "var", f); \
|
||||
XMLAddChild(query, feature); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
AdvertiseSimple("urn:xmpp:reply:0");
|
||||
AdvertiseSimple("urn:xmpp:styling:0");
|
||||
|
||||
AdvertiseSimple("urn:parsee:x-parsee:0");
|
||||
AdvertiseSimple("urn:parsee:jealousy:0");
|
||||
/* TODO: Advertise more things */
|
||||
#undef AdvertiseSimple
|
||||
}
|
||||
XMLAddChild(iq_reply, query);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iq_reply);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
|
||||
XMLFreeElement(iq_reply);
|
||||
}
|
||||
static void
|
||||
IQGet(ParseeData *args, XMLElement *stanza)
|
||||
{
|
||||
XMPPComponent *jabber = args->jabber;
|
||||
if (XMLookForTKV(stanza, "query", "xmlns", DISCO))
|
||||
{
|
||||
IQDiscoGet(args, jabber, stanza);
|
||||
}
|
||||
|
||||
}
|
||||
#undef DISCO
|
||||
static void
|
||||
IQStanza(ParseeData *args, XMLElement *stanza)
|
||||
{
|
||||
char *type;
|
||||
type = HashMapGet(stanza->attrs, "type");
|
||||
#define OnType(ctyp, callback) do \
|
||||
{ \
|
||||
if (StrEquals(type, #ctyp)) \
|
||||
{ \
|
||||
callback(args, stanza); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
OnType(get, IQGet);
|
||||
#undef OnType
|
||||
}
|
||||
|
||||
void *
|
||||
ParseeXMPPThread(void *argp)
|
||||
{
|
||||
|
|
@ -177,10 +254,7 @@ ParseeXMPPThread(void *argp)
|
|||
}
|
||||
else if (StrEquals(stanza->name, "iq"))
|
||||
{
|
||||
/* TODO: Ought to manage info/query requests */
|
||||
Log(LOG_WARNING, "Unimplemented 'iq' stanza.");
|
||||
Log(LOG_WARNING, "Odds are, this is the programmer's fault");
|
||||
Log(LOG_WARNING, "and this needs to be implemented later on.");
|
||||
IQStanza(args, stanza);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue