mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:45:10 +00:00
[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:
parent
299f473a81
commit
143bdf0a5a
21 changed files with 2314 additions and 1764 deletions
113
src/XMPPThread/Bridged.c
Normal file
113
src/XMPPThread/Bridged.c
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#include "XMPPThread/internal.h"
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
|
||||
char *
|
||||
ParseeGetBridgedRoom(ParseeData *data, XMLElement *stanza)
|
||||
{
|
||||
char *to = ParseeDecodeMXID(HashMapGet(stanza->attrs, "to"));
|
||||
char *from = HashMapGet(stanza->attrs, "from");
|
||||
char *chat_id = ParseeGetFromMUCID(data, from);
|
||||
char *mroom_id = ParseeGetRoomID(data, chat_id);
|
||||
char *ret;
|
||||
|
||||
Free(chat_id);
|
||||
if (mroom_id)
|
||||
{
|
||||
Free(to);
|
||||
return mroom_id;
|
||||
}
|
||||
|
||||
/* Not a MUC, find the DMd room. */
|
||||
ret = ParseeFindDMRoom(data, to, from);
|
||||
Free(to);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
ParseeGetEventFromID(ParseeData *data, XMLElement *stanza, char *id)
|
||||
{
|
||||
char *from = (HashMapGet(stanza->attrs, "from"));
|
||||
char *chat_id = ParseeGetFromMUCID(data, from);
|
||||
char *ret = ParseeEventFromSID(data, chat_id, id);
|
||||
char *mroom_id = ParseeGetBridgedRoom(data, stanza);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
Free(ret);
|
||||
ret = ParseeEventFromID(data, chat_id, id);
|
||||
}
|
||||
|
||||
Free(chat_id);
|
||||
if (ret)
|
||||
{
|
||||
Free(mroom_id);
|
||||
return ret;
|
||||
}
|
||||
ret = ParseeDMEventFromID(data, mroom_id, id);
|
||||
Free(mroom_id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
char *
|
||||
ParseeGetReactedEvent(ParseeData *data, XMLElement *stanza)
|
||||
{
|
||||
XMLElement *reactions = XMLookForTKV(stanza,
|
||||
"reactions", "xmlns", "urn:xmpp:reactions:0"
|
||||
);
|
||||
char *reacted_id = reactions ? HashMapGet(reactions->attrs, "id") : NULL;
|
||||
|
||||
return ParseeGetEventFromID(data, stanza, reacted_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ParseePushAllStanza(ParseeData *args, XMLElement *stanza, char *event)
|
||||
{
|
||||
char *xmpp_from = HashMapGet(stanza->attrs, "from");
|
||||
char *mroom_id = ParseeGetBridgedRoom(args, stanza);
|
||||
char *chat_id = ParseeGetFromMUCID(args, xmpp_from);
|
||||
|
||||
char *id_str = HashMapGet(stanza->attrs, "id");
|
||||
char *s_id_str = XMPPGetStanzaID(stanza);
|
||||
|
||||
if (!chat_id)
|
||||
{
|
||||
ParseePushDMStanza(
|
||||
args, mroom_id, s_id_str,
|
||||
id_str, event, xmpp_from
|
||||
);
|
||||
}
|
||||
ParseePushStanza(args, chat_id, s_id_str, id_str, event, xmpp_from);
|
||||
Free(mroom_id);
|
||||
Free(chat_id);
|
||||
}
|
||||
|
||||
bool
|
||||
ParseeVerifyAllStanza(ParseeData *args, XMLElement *stanza)
|
||||
{
|
||||
char *to, *room;
|
||||
char *from = HashMapGet(stanza->attrs, "from");
|
||||
char *id = HashMapGet(stanza->attrs, "id");
|
||||
char *chat_id = ParseeGetFromMUCID(args, from);
|
||||
bool ret;
|
||||
|
||||
if (chat_id)
|
||||
{
|
||||
char *s_id_str = XMPPGetStanzaID(stanza);
|
||||
ret = ParseeVerifyStanza(args, chat_id, s_id_str);
|
||||
|
||||
Free(chat_id);
|
||||
return ret;
|
||||
}
|
||||
to = ParseeDecodeMXID(HashMapGet(stanza->attrs, "to"));
|
||||
room = ParseeFindDMRoom(args, to, from);
|
||||
ret = ParseeVerifyDMStanza(args, chat_id, id);
|
||||
|
||||
Free(room);
|
||||
Free(to);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue