[ADD/WIP] Matrix<->XMPP DMs.

There is still this fun issue with the blocking XML parser leaking
memory on pthread_cancel, I'll try to deal with that later, maybe with a
test stanza.

I also apologise for swearing in the last commit. I promise it won't
happen again, Prosody.
This commit is contained in:
LDA 2024-06-18 20:59:35 +02:00
commit 2cc4b0ed17
11 changed files with 325 additions and 63 deletions

View file

@ -1,6 +1,7 @@
#include <Cytoplasm/HttpServer.h>
#include <Cytoplasm/Log.h>
#include <pthread.h>
#include <string.h>
#include <signal.h>
@ -10,6 +11,7 @@
#include <AS.h>
static HttpServer *server = NULL;
static pthread_t xmpp_thr;
static void
SignalHandler(int signal)
{
@ -26,6 +28,7 @@ SignalHandler(int signal)
return;
}
HttpServerStop(server);
pthread_cancel(xmpp_thr);
break;
}
}
@ -59,7 +62,6 @@ Main(void)
parsee_conf->shared_comp_secret
);
}
Log(LOG_INFO, "HS token: %s", parsee_conf->hs_token);
ASRegisterUser(parsee_conf, parsee_conf->sender_localpart);
@ -70,6 +72,12 @@ Main(void)
conf.handlerArgs = ParseeInitData(jabber);
conf.handler = ParseeRequest;
if (pthread_create(&xmpp_thr, NULL, ParseeXMPPThread, conf.handlerArgs))
{
Log(LOG_ERR, "Couldn't start XMPP listener thread.");
/* TODO: Die */
}
sigAction.sa_handler = SignalHandler;
sigfillset(&sigAction.sa_mask);
sigAction.sa_flags = SA_RESTART;