From 80bab890f62a78886f9577aafb81f0009bb65d7d Mon Sep 17 00:00:00 2001 From: LDA Date: Sat, 31 Aug 2024 17:59:39 +0200 Subject: [PATCH] [MOD] Start separating build config, HTML in edits --- Makefile | 6 +----- build.conf | 4 ++++ src/Events.c | 12 ++++++++++++ src/XMPPThread/ReListener.c | 5 ++++- 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 build.conf diff --git a/Makefile b/Makefile index 8d71552..cfcc15f 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,7 @@ # =========================== Parsee Flags ============================= -# phantasmagoria - test runs without an actual code -CODE=phantasmagoria -NAME=Parsee -VERSION=0.0.0 +include build.conf REPOSITORY=$(shell git remote get-url origin) @@ -32,7 +29,6 @@ CC ?=cc CFLAGS=-I$(SOURCE) -I$(INCLUDES) -I$(CYTO_INC) -DNAME="\"$(NAME)\"" -DVERSION="\"$(VERSION)\"" -DREPOSITORY=\"$(REPOSITORY)\" -DCODE=\"$(CODE)\" -O3 -g -Wall -Werror LDFLAGS=-L $(CYTO_LIB) -lCytoplasm -O3 -g AFLAGS=-C "$(ETC)/ayadoc/style.css" -p "$(NAME)" -BINARY=parsee # ============================ Compilation ================================= SRC_FILES:=$(shell find $(SOURCE) -name '*.c') $(shell find $(ETC)/media -name '*.png') OBJ_FILES:=${subst $(ETC)/media/,$(OBJECT)/,${subst $(SOURCE)/,$(OBJECT)/,$(patsubst %.png, %.o, $(patsubst %.c, %.o, $(SRC_FILES)))}} diff --git a/build.conf b/build.conf new file mode 100644 index 0000000..fd384e4 --- /dev/null +++ b/build.conf @@ -0,0 +1,4 @@ +CODE=phantasmagoria +NAME=Parsee +VERSION=0.0.0 +BINARY=parsee diff --git a/src/Events.c b/src/Events.c index ded7b89..e625d07 100644 --- a/src/Events.c +++ b/src/Events.c @@ -180,6 +180,18 @@ MatrixCreateReplace(char *event, char *body) HashMapSet(map, "m.new_content", JsonValueObject(new)); HashMapSet(map, "m.relates_to", JsonValueObject(rel)); + { + XEP393Element *e = XEP393(body); + char *text = XEP393ToXMLString(e); + XEP393FreeElement(e); + + HashMapSet(map, "formatted_body", JsonValueString(text)); + HashMapSet(map, "format", JsonValueString("org.matrix.custom.html")); + HashMapSet(new, "formatted_body", JsonValueString(text)); + HashMapSet(new, "format", JsonValueString("org.matrix.custom.html")); + Free(text); + } + return map; } HashMap * diff --git a/src/XMPPThread/ReListener.c b/src/XMPPThread/ReListener.c index 914b774..5d410f6 100644 --- a/src/XMPPThread/ReListener.c +++ b/src/XMPPThread/ReListener.c @@ -28,6 +28,9 @@ RetrieveStanza(XMPPThread *thread) { XMLElement *ret = NULL; + /* TODO: We're polling here... Parsee should avoid doing that, + * in favour of condition variables, which should lower the system + * load of Parsee as a whole. */ pthread_mutex_lock(&thread->info->lock); ret = ArrayDelete(thread->info->stanzas, 0); pthread_mutex_unlock(&thread->info->lock); @@ -54,7 +57,7 @@ XMPPDispatcher(void *argp) if (!stanza) { - UtilSleepMillis(5); + UtilSleepMillis(10); continue; }