diff --git a/CHANGELOG.md b/CHANGELOG.md index be12615..bf82211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,10 +18,16 @@ of Parsee. May occasionally deadlock. *NONE* ### v0.1.1[star-of-hope] -Fixes some media metadata things. +Fixes some media metadata things, and replaces the build +system of Parsee. #### New things *NONE* #### Bugfixes - Adds more information to media events so that clients can behave. +- Fixes issues where SIGPIPE can actually just kill Parsee. +- Allows MbedTLS through a specific Cytoplasm patch. +- "Lone" XMPP messages no longer render weirdly on Element Android's +weird rendering. #### Deprecated features -*NONE* +- The old `build.c` and `Makefile`s used for building are removed, +and replaced by the `configure.c` C file(/script via TCC). diff --git a/README.MD b/README.MD index 251f68d..5205590 100644 --- a/README.MD +++ b/README.MD @@ -68,6 +68,8 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th (see `etc/man`) ## TODOS before 1.0 rolls around +- PROPER FUCKING AVATARS + XMPP->Matrix is decent, Matrix->XMPP is effectiveny not done - Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency. - It depends on more stuff anyways, and I don't want to weigh down the dependency list of Parsee for that. @@ -79,8 +81,6 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th extension packagers may integrate properly. - Get rid of the '?'-syntax and use another invalid Matrix char/valid XMPP char ('$'?) for escaped? -- PROPER FUCKING AVATARS - XMPP->Matrix is decent, Matrix->XMPP is effectiveny not done - Consider making room/MUC admins/owners be able to plumb instead of it being restricted to Parsee admins, with permission from MUC owners, too - Limiting to admins may be a way to "control" consent for both, but this is @@ -91,7 +91,6 @@ restricted to Parsee admins, with permission from MUC owners, too support XMPP->Matrix bridging. - Manage MUC DMs in a reasonable manner. Thanks `@freeoffers4u:matrix.org` for being a fucking annoyance and DMing an old Parsee semi-anon user for no clear reason. -- Deadlocks. It's always deadlocks. ## DONATING/CONTRIBUTING If you know things about XMPP or Matrix, yet aren't familiar with C99, or just diff --git a/src/StanzaBuilder.c b/src/StanzaBuilder.c index 1817997..6ac3a5c 100644 --- a/src/StanzaBuilder.c +++ b/src/StanzaBuilder.c @@ -286,16 +286,6 @@ SetStanzaXParsee(StanzaBuilder *builder, HashMap *e) XMLAddChild(parsee_link, link_elem); XMLAddChild(parsee, parsee_link); - parsee_text = XMLCreateTag("zayds-note"); - text_elem = XMLCreateText("\"LDA HANG YOURSELF\" - Zayd"); - XMLAddChild(parsee_text, text_elem); - XMLAddChild(parsee, parsee_text); - - parsee_text = XMLCreateTag("mcnebs-note"); - text_elem = XMLCreateText("LDA will never beat the allegations"); - XMLAddChild(parsee_text, text_elem); - XMLAddChild(parsee, parsee_text); - if (event_id) { parsee_event = XMLCreateTag("event-id"); diff --git a/src/XMPPThread/PEP.c b/src/XMPPThread/PEP.c index 856d6de..c459292 100644 --- a/src/XMPPThread/PEP.c +++ b/src/XMPPThread/PEP.c @@ -10,6 +10,8 @@ #include #include +#define PUBSUB "http://jabber.org/protocol/pubsub" + XMLElement * CreatePubsubRequest(char *from, char *to, char *node) { @@ -22,7 +24,7 @@ CreatePubsubRequest(char *from, char *to, char *node) XMLAddAttr(iq_req, "type", "set"); pubsub = XMLCreateTag("pubsub"); - XMLAddAttr(pubsub, "xmlns", "http://jabber.org/protocol/pubsub"); + XMLAddAttr(pubsub, "xmlns", PUBSUB); XMLAddChild(iq_req, pubsub); sub = XMLCreateTag("subscribe"); @@ -34,12 +36,40 @@ CreatePubsubRequest(char *from, char *to, char *node) return iq_req; } +static bool +IsPubsubRequest(XMLElement *stanza) +{ + char *type = HashMapGet(stanza ? stanza->attrs : NULL, "type"); + XMLElement *pubsub, *subscribe; + if (!stanza) + { + return false; + } + + if (!StrEquals(stanza->name, "iq") || + !StrEquals(type, "set")) + { + return false; + } + + pubsub = XMLookForTKV(stanza, "pubsub", "xmlns", PUBSUB); + if (!pubsub) + { + return false; + } + + return XMLookForUnique(pubsub, "subscribe"); +} + + struct PEPManager { pthread_mutex_t lock; ParseeData *data; HashMap *node_table; + HashMap *followers; + void *cookie; }; @@ -56,6 +86,7 @@ CreatePEPManager(ParseeData *data, void *cookie) ret->cookie = cookie; ret->data = data; ret->node_table = HashMapCreate(); + ret->followers = HashMapCreate(); pthread_mutex_init(&ret->lock, NULL); return ret; @@ -91,9 +122,9 @@ PEPManagerHandleEvent(PEPManager *manager, XMLElement *stanza) { return false; } -#define PEP_NS "http://jabber.org/protocol/pubsub" - if (!(ps = XMLookForTKV(stanza, "pubsub", "xmlns", PEP_NS)) && - !(ev = XMLookForTKV(stanza, "event", "xmlns", PEP_NS "#event"))) + + if (!(ps = XMLookForTKV(stanza, "pubsub", "xmlns", PUBSUB)) && + !(ev = XMLookForTKV(stanza, "event", "xmlns", PUBSUB "#event"))) { return false; } @@ -135,6 +166,11 @@ PEPManagerHandle(PEPManager *manager, XMLElement *stanza) } /* Check if it is a PEP stanza */ + if (IsPubsubRequest(stanza)) + { + Log(LOG_DEBUG, "UNIMPLEMENTED PUBSUB SUBSCRIPTION"); + /* TODO */ + } if (PEPManagerHandleEvent(manager, stanza)) { return true; @@ -158,5 +194,8 @@ DestroyPEPManager(PEPManager *manager) Free(val); } HashMapFree(manager->node_table); + + HashMapFree(manager->followers); + Free(manager); } diff --git a/src/XMPPThread/ReListener.c b/src/XMPPThread/ReListener.c index 5d410f6..f518a67 100644 --- a/src/XMPPThread/ReListener.c +++ b/src/XMPPThread/ReListener.c @@ -68,7 +68,7 @@ XMPPDispatcher(void *argp) if (StrEquals(stanza->name, "presence")) { - PresenceStanza(args, stanza); + PresenceStanza(args, stanza, thread); XMLFreeElement(stanza); continue; } diff --git a/src/XMPPThread/Stanzas/Presence.c b/src/XMPPThread/Stanzas/Presence.c index 225a361..ed52364 100644 --- a/src/XMPPThread/Stanzas/Presence.c +++ b/src/XMPPThread/Stanzas/Presence.c @@ -57,7 +57,7 @@ GuessStatus(XMLElement *stanza) return USER_STATUS_ONLINE; } void -PresenceStanza(ParseeData *args, XMLElement *stanza) +PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr) { #define MUC_USER_NS "http://jabber.org/protocol/muc#user" XMLElement *user_info; @@ -66,6 +66,11 @@ PresenceStanza(ParseeData *args, XMLElement *stanza) char *oid = HashMapGet(stanza->attrs, "from"); + if (PEPManagerHandle(thr->info->pep_manager, stanza)) + { + return; + } + if (ServerHasXEP421(args, oid)) { XMLElement *occupant = XMLookForTKV( diff --git a/src/XMPPThread/internal.h b/src/XMPPThread/internal.h index d937b8a..4c39b40 100644 --- a/src/XMPPThread/internal.h +++ b/src/XMPPThread/internal.h @@ -78,7 +78,7 @@ XMLElement * CreatePubsubRequest(char *from, char *to, char *node); bool MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr); void IQStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr); -void PresenceStanza(ParseeData *args, XMLElement *stanza); +void PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr); bool ServerHasXEP421(ParseeData *data, char *from); @@ -89,6 +89,7 @@ PEPManager * CreatePEPManager(ParseeData *data, void *cookie); void * PEPManagerCookie(PEPManager *manager); void PEPManagerAddEvent(PEPManager *manager, char *node, PEPEvent event); bool PEPManagerHandle(PEPManager *manager, XMLElement *stanza); +void PEPManagerBroadcast(PEPManager *manager, char *as, XMLElement *item); void DestroyPEPManager(PEPManager *manager); /* PEP callbacks for the handler */