summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_ft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src/jabber_ft.cpp')
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index 60faeb53c4..096351d713 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -707,11 +707,11 @@ LBL_Fail:
int tmp_len = 0, outl;
//EVP_EncryptUpdate(ctx, nullptr, &outl, aad, _countof(aad));
- unsigned char *out = (unsigned char*)mir_alloc(_filelength(fileId) + _countof(key) - 1 + _countof(tag));
- unsigned char *in = (unsigned char*)mir_alloc(1024 * 1024);
+ unsigned char *out = (unsigned char *)mir_alloc(_filelength(fileId) + _countof(key) - 1 + _countof(tag));
+ unsigned char *in = (unsigned char *)mir_alloc(128 * 1024);
for (;;) {
- int inl = _read(fileId, in, 1024 * 1024);
- if(inl == 0)
+ int inl = _read(fileId, in, 128 * 1024);
+ if (inl == 0)
break;
EVP_EncryptUpdate(ctx, out + tmp_len, &outl, in, inl);
tmp_len += outl;
@@ -725,8 +725,9 @@ LBL_Fail:
memcpy(out + tmp_len, tag, _countof(tag));
nlhr.dataLength = tmp_len + _countof(tag);
- nlhr.pData = (char*)out;
- } else {
+ nlhr.pData = (char *)out;
+ }
+ else {
nlhr.dataLength = _filelength(fileId);
nlhr.pData = new char[nlhr.dataLength];
_read(fileId, nlhr.pData, nlhr.dataLength);
@@ -738,7 +739,7 @@ LBL_Fail:
debugLogA("error uploading file %S", pwszFileName);
goto LBL_Fail;
}
-
+
switch (res->resultCode) {
case 200: // ok
case 201: // created
@@ -754,11 +755,12 @@ LBL_Fail:
// this parameter is optional, if not specified we simply use upload URL
CMStringA szMessage;
- if (auto *szGetUrl = version ? XmlGetChildText(slotNode, "get") : XmlGetAttr(XmlFirstChild(slotNode, "get"), "url"))
+ if (auto *szGetUrl = version ? XmlGetChildText(slotNode, "get") : XmlGetAttr(XmlFirstChild(slotNode, "get"), "url"))
szMessage = szGetUrl;
else
szMessage = szUrl;
+ XmlNode m("message");
if (enOmemo) {
int i = szMessage.Find("://");
char szIv[2*_countof(iv) + 1], szKey[2*_countof(key) + 1];
@@ -766,15 +768,15 @@ LBL_Fail:
bin2hex(key, _countof(key), szKey);
szMessage.Format("aesgcm%s#%s%s", szMessage.Mid(i).c_str(), szIv, szKey);
}
+ else m << XCHILDNS("x", JABBER_FEAT_OOB2) << XCHILD("url", szMessage.c_str());
if (m_bEmbraceUrls && ProtoGetAvatarFormat(_A2T(szMessage)) != PA_FORMAT_UNKNOWN) {
szMessage.Insert(0, "[img]");
szMessage.Append("[/img]");
}
- if (isChatRoom(ft->std.hContact))
- GroupchatSendMsg(ft->pItem, ptrA(mir_utf8encode(szMessage)));
- else if (ProtoChainSend(ft->std.hContact, PSS_MESSAGE, 0, (LPARAM)szMessage.c_str()) != -1) {
+ int ret = SendMsgEx(ft->std.hContact, szMessage.c_str(), m);
+ if (ret != -1 && !isChatRoom(ft->std.hContact)) {
PROTORECVEVENT recv = {};
recv.flags = PREF_CREATEREAD | PREF_SENT;
recv.szMessage = szMessage.GetBuffer();
@@ -857,7 +859,7 @@ bool CJabberProto::FtTryInlineFile(filetransfer *ft)
m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS);
m << XCHILDNS("markable", JABBER_FEAT_CHAT_MARKERS);
}
-
+
m_ThreadInfo->send(m);
// emulate a message for us
@@ -879,7 +881,7 @@ bool CJabberProto::FtHandleCidRequest(const TiXmlElement*, CJabberIqInfo *pInfo)
const char *cid = XmlGetAttr(pChild, "cid");
if (cid == nullptr) {
- LBL_Error:
+LBL_Error:
XmlNodeIq iq("error", pInfo);
TiXmlElement *error = iq << XCHILD("error") << XATTRI("code", 400) << XATTR("type", "cancel");
error << XCHILDNS("bad-request", "urn:ietf:params:xml:ns:xmpp-stanzas");
@@ -898,7 +900,7 @@ bool CJabberProto::FtHandleCidRequest(const TiXmlElement*, CJabberIqInfo *pInfo)
HANDLE hFind = FindFirstFileW(wszFileMask, &data);
if (hFind == nullptr)
goto LBL_Error;
-
+
FindClose(hFind);
int fileFormat = ProtoGetAvatarFormat(data.cFileName);