[MOD] One-way Matrix->XMPP comms.

This is not sanitised. I need to make an XML writer.
This commit is contained in:
LDA 2024-06-17 18:26:37 +02:00
commit bdb4fd2f68
17 changed files with 421 additions and 61 deletions

43
src/XMPP/Stanza.c Normal file
View file

@ -0,0 +1,43 @@
#include <XMPP.h>
void
XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type)
{
if (!comp || !fr || !to || !msg)
{
return;
}
StreamPrintf(
comp->stream, "<message from='%s@%s' to='%s'",
fr, comp->host, to
);
if (type)
{
StreamPrintf(comp->stream, " type='%s'", type);
}
StreamPrintf(comp->stream, ">");
StreamPrintf(comp->stream,
"<body>"
"%s"
"</body>"
"</message>",
msg
);
StreamFlush(comp->stream);
}
void
XMPPSendPresence(XMPPComponent *comp, char *fr, char *to)
{
if (!comp || !fr || !to)
{
return;
}
StreamPrintf(comp->stream,
"<presence from='%s@%s' to='%s'>"
"<x xmlns='http://jabber.org/protocol/muc'/>"
"</presence>",
fr, comp->host,
to
);
StreamFlush(comp->stream);
}