[MOD/FIX] Separate XMPP thread, fix EINVAL issue

threading is good actually. please hmu if you ever trigger the
achievement.
This commit is contained in:
LDA 2024-07-17 22:55:25 +02:00
commit 143bdf0a5a
21 changed files with 2314 additions and 1764 deletions

View file

@ -281,14 +281,15 @@ XMPPLeaveMUC(XMPPComponent *comp, char *fr, char *muc, char *reason)
pthread_mutex_unlock(&comp->write_lock);
}
void
bool
XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc)
{
XMLElement *presence, *x;
XMLElement *presence, *x, *reply;
char *from, *id;
if (!comp || !fr || !muc)
{
return;
return false;
}
pthread_mutex_lock(&comp->write_lock);
@ -308,9 +309,25 @@ XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc)
XMLFreeElement(presence);
Free(from);
Free(id);
pthread_mutex_unlock(&comp->write_lock);
if ((reply = ParseeAwaitStanza(id, 500)))
{
bool exit_code = true;
if (XMPPHasError(reply, "conflict"))
{
Log(LOG_WARNING, "UNIMPLEMENTED NAMING CONFLICT.");
exit_code = false;
}
XMLFreeElement(reply);
Free(id);
return exit_code;
}
Free(id);
return true;
}
bool
XMPPIsParseeStanza(XMLElement *stanza)
@ -432,7 +449,6 @@ XMPPGetModeration(XMLElement *stanza)
moderate = XMLookForTKV(stanza, "moderate", "xmlns", MOD_BASE ":1");
if (moderate)
{
Log(LOG_WARNING, "0.3.0 moderation");
return HashMapGet(moderate->attrs, "id");
}
@ -452,3 +468,20 @@ XMPPGetModeration(XMLElement *stanza)
return NULL;
#undef MOD_BASE
}
bool
XMPPHasError(XMLElement *stanza, char *type)
{
XMLElement *err;
if (!stanza || !type)
{
return false;
}
err = XMLookForUnique(stanza, "error");
if (!err)
{
return false;
}
return XMLookForUnique(err, type);
}