mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
[FIX/MOD] Stanza send function, fix some errors
Negociating stanza sizes seems to be real trouble. Also this code is now `-fanalyzer'-safe! Also kills the last GNUMakefile present. It wasn't even used...
This commit is contained in:
parent
d9b5141eb5
commit
ff5f085b7f
24 changed files with 114 additions and 152 deletions
|
|
@ -65,6 +65,14 @@ GenerateAvatarData(ParseeData *data, char *mxid)
|
|||
goto end;
|
||||
}
|
||||
b64 = Base64Encode(out, len);
|
||||
if (!b64 || strlen(b64) > 64 KB) /* We still have stanza limitations. Thanks, Array.
|
||||
* TODO: Communicate with the server to discover it. */
|
||||
{
|
||||
Free(b64);
|
||||
Free(mime);
|
||||
b64 = StrDuplicate(media_parsee_logo); /* TODO: Different assets! */
|
||||
mime = StrDuplicate("image/png");
|
||||
}
|
||||
|
||||
elem = XMLCreateTag("PHOTO");
|
||||
type = XMLCreateTag("TYPE");
|
||||
|
|
@ -145,11 +153,7 @@ IQDiscoGet(ParseeData *args, XMPPComponent *jabber, XMLElement *stanza)
|
|||
}
|
||||
XMLAddChild(iq_reply, query);
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iq_reply);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
|
||||
XMPPSendStanza(jabber, iq_reply);
|
||||
XMLFreeElement(iq_reply);
|
||||
|
||||
(void) args;
|
||||
|
|
@ -386,10 +390,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMPPShoveCommandList(thr->info->m, to, q);
|
||||
XMLAddChild(iq_reply, q);
|
||||
}
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iq_reply);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMPPSendStanza(jabber, iq_reply);
|
||||
XMLFreeElement(iq_reply);
|
||||
}
|
||||
else if (XMLookForTKV(stanza, "vCard", "xmlns", "vcard-temp"))
|
||||
|
|
@ -427,10 +428,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMLAddChild(iqVCard, vCard);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iqVCard);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMPPSendStanza(jabber, iqVCard);
|
||||
XMLFreeElement(iqVCard);
|
||||
Free(to_matrix);
|
||||
Free(name);
|
||||
|
|
@ -457,10 +455,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMLAddChild(iqVCard, vCard);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iqVCard);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMPPSendStanza(jabber, iqVCard);
|
||||
XMLFreeElement(iqVCard);
|
||||
Free(to_matrix);
|
||||
Free(name);
|
||||
|
|
@ -474,7 +469,10 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
);
|
||||
if (a_items)
|
||||
{
|
||||
/* Do, without regret, start shoving an avatar out the bus */
|
||||
/* Do, without regret, start shoving an avatar out the bus.
|
||||
* NOTE: I explicitely choose to not do any manipulation
|
||||
* because messing with random user images is inherently a
|
||||
* risk I do *not* want to take. */
|
||||
char *to_matrix = ParseeDecodeMXID(to);
|
||||
char *avatar = ASGetAvatar(args->config, NULL, to_matrix);
|
||||
char *buf, *mime;
|
||||
|
|
@ -484,6 +482,13 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
|
||||
ASGrab(args->config, avatar, &mime, &buf, &len);
|
||||
b64 = Base64Encode(buf, len);
|
||||
if (!b64 || strlen(b64) > 64 KB)
|
||||
{
|
||||
Free(b64);
|
||||
Free(mime);
|
||||
b64 = StrDuplicate(media_parsee_logo); /* TODO: Different assets! */
|
||||
mime = StrDuplicate("image/png");
|
||||
}
|
||||
Free(buf);
|
||||
|
||||
Log(LOG_DEBUG, "IQ-GET: PUBSUB AVATAR OF=%s", to_matrix);
|
||||
|
|
@ -513,10 +518,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMLAddChild(reply, ps);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, reply);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMPPSendStanza(jabber, reply);
|
||||
XMLFreeElement(reply);
|
||||
|
||||
Free(to_matrix);
|
||||
|
|
@ -554,10 +556,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
XMLAddChild(query, version);
|
||||
XMLAddChild(iq_reply, query);
|
||||
|
||||
pthread_mutex_lock(&jabber->write_lock);
|
||||
XMLEncode(jabber->stream, iq_reply);
|
||||
StreamFlush(jabber->stream);
|
||||
pthread_mutex_unlock(&jabber->write_lock);
|
||||
XMPPSendStanza(jabber, iq_reply);
|
||||
XMLFreeElement(iq_reply);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue