[ADD/WIP] Continue MUCwerk

oh man this is gonna be painful to do... xmpp is fine iff youre doing
DMs isnt it?
This commit is contained in:
LDA 2024-06-21 00:48:27 +02:00
commit d3b7f2fee0
19 changed files with 707 additions and 44 deletions

View file

@ -2,6 +2,7 @@
#include <Cytoplasm/Memory.h>
#include <Cytoplasm/Str.h>
#include <Cytoplasm/Log.h>
#include <XML.h>
@ -32,11 +33,11 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type)
Free(from);
}
void
XMPPSendPresence(XMPPComponent *comp, char *fr, char *to)
XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc)
{
XMLElement *presence, *x;
char *from;
if (!comp || !fr || !to)
if (!comp || !fr || !muc)
{
return;
}
@ -44,28 +45,33 @@ XMPPSendPresence(XMPPComponent *comp, char *fr, char *to)
presence = XMLCreateTag("presence");
x = XMLCreateTag("x");
XMLAddAttr(presence, "from", (from = StrConcat(3, fr, "@", comp->host)));
XMLAddAttr(presence, "to", to);
XMLAddAttr(presence, "to", muc);
XMLAddAttr(x, "xmlns", "http://jabber.org/protocol/muc");
XMLAddChild(presence, x);
/* A*/
XMLEncode(comp->stream, presence);
Log(LOG_INFO, "Flushing...");
/* B */
StreamFlush(comp->stream);
XMLFreeElement(presence);
Free(from);
/* How is that leaking */
}
void
XMPPKillThread(XMPPComponent *jabber)
XMPPKillThread(XMPPComponent *jabber, char *killer)
{
XMLElement *message, *body, *data;
char *from;
if (!jabber)
if (!jabber || !killer)
{
return;
}
from = StrConcat(2, "jabber_die@", jabber->host);
from = StrConcat(3, killer, "@", jabber->host);
message = XMLCreateTag("message");
XMLAddAttr(message, "from", from);
XMLAddAttr(message, "to", from);