[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

View file

@ -22,7 +22,7 @@
/* The default component port Prosody uses. */
#define DEFAULT_PROSODY_PORT 5347
Stream *
XMPPComponent *
XMPPInitialiseCompStream(char *host, int port)
{
/* TODO */
@ -31,6 +31,7 @@ XMPPInitialiseCompStream(char *host, int port)
int error;
char serv[8];
Stream *stream;
XMPPComponent *comp;
snprintf(serv, sizeof(serv), "%hu", port ? port : DEFAULT_PROSODY_PORT);
@ -74,7 +75,11 @@ XMPPInitialiseCompStream(char *host, int port)
return NULL;
}
return stream;
comp = Malloc(sizeof(*comp));
comp->host = StrDuplicate(host);
comp->stream = stream;
return comp;
}
#include <Cytoplasm/Sha.h>
@ -95,17 +100,22 @@ ComputeHandshake(char *shared, char *stream)
return sha;
}
bool
XMPPAuthenticateCompStream(Stream *stream, char *as, char *shared)
XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared)
{
/* TODO */
XMLexer *sax;
XMLEvent *ev;
char *stream_id, *handshake;
bool ret = false;
if (!stream || !as || !shared)
Stream *stream;
char *as;
if (!comp || !shared)
{
return false;
}
stream = comp->stream;
as = comp->host;
StreamPrintf(stream,
"<stream:stream "
"xmlns='jabber:component:accept' "
@ -171,7 +181,13 @@ end:
}
void
XMPPEndCompStream(Stream *stream)
XMPPEndCompStream(XMPPComponent *comp)
{
StreamClose(stream);
if (!comp)
{
return;
}
StreamClose(comp->stream);
Free(comp->host);
Free(comp);
}