summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-12-19 15:25:41 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-12-19 15:25:41 +0300
commit19acd0ef59d7272db67ef54b331f32103dbd5aad (patch)
treeb5207c96b23ff65d3f929882dbe61046864bc916 /protocols
parent8bab65e5e51df9f5c70f9fd6d7e3fdb0771c37e9 (diff)
fixes #4071 (NewStory: Convert message to a file transfer не срабатывает в сообщениях, содержащих и файл и текст)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/ICQ-WIM/src/menus.cpp6
-rw-r--r--protocols/ICQ-WIM/src/server.cpp26
2 files changed, 23 insertions, 9 deletions
diff --git a/protocols/ICQ-WIM/src/menus.cpp b/protocols/ICQ-WIM/src/menus.cpp
index ddfa5f0745..4cb75fe7b0 100644
--- a/protocols/ICQ-WIM/src/menus.cpp
+++ b/protocols/ICQ-WIM/src/menus.cpp
@@ -48,18 +48,18 @@ INT_PTR CIcqProto::SvcExecMenu(WPARAM iCommand, LPARAM pHandle)
IcqFileInfo *pFileInfo = nullptr;
CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei, CP_UTF8)));
if (CheckFile(db_event_getContact(hEvent), wszText, pFileInfo)) {
- if (pFileInfo->bIsSticker) {
+ if (!pFileInfo || pFileInfo->bIsSticker) {
// sticker is a simple text message prcoessed by SmileyAdd
T2Utf szBody(wszText);
mir_free(dbei.pBlob);
- dbei.pBlob = (uint8_t*)szBody.get();
dbei.cbBlob = (int)mir_strlen(szBody.get());
+ dbei.pBlob = (uint8_t*)szBody.detach();
}
else {
// create the offline file event
dbei.eventType = EVENTTYPE_FILE;
- DB::FILE_BLOB blob(pFileInfo->wszDescr, L"");
+ DB::FILE_BLOB blob(pFileInfo->wszDescr, wszText);
blob.setUrl(pFileInfo->szOrigUrl);
blob.setSize(pFileInfo->dwFileSize);
blob.write(dbei);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index a84efd0a16..a44c753bec 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -183,16 +183,18 @@ IcqFileInfo *CIcqProto::RetrieveFileInfo(MCONTACT hContact, const CMStringW &wsz
bool CIcqProto::CheckFile(MCONTACT hContact, CMStringW &wszText, IcqFileInfo *&pFileInfo)
{
+ bool bRet;
CMStringW wszUrl;
- if (!fileText2url(wszText, &wszUrl))
+ int idx = wszText.Find(' ');
+ if (idx == -1)
+ bRet = fileText2url(wszText, &wszUrl);
+ else
+ bRet = fileText2url(wszText.Mid(0, idx), &wszUrl);
+ if (!bRet)
return false;
pFileInfo = nullptr;
- int idx = wszText.Find(' ');
- if (idx != -1)
- wszText.Truncate(idx);
-
// is it already downloaded sticker?
CMStringW wszLoadedPath(FORMAT, L"%s\\%S\\Stickers\\STK{%s}.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName, wszUrl.c_str());
if (!_waccess(wszLoadedPath, 0)) {
@@ -221,7 +223,16 @@ bool CIcqProto::CheckFile(MCONTACT hContact, CMStringW &wszText, IcqFileInfo *&p
}
else wszText = TranslateT("SmileyAdd plugin required to support stickers");
}
- else pFileInfo->szOrigUrl = wszText;
+ else {
+ if (idx != -1) {
+ pFileInfo->szOrigUrl = wszText.Mid(0, idx);
+ wszText.Delete(0, idx + 1);
+ }
+ else {
+ pFileInfo->szOrigUrl = wszText;
+ wszText.Empty();
+ }
+ }
return true;
}
@@ -578,7 +589,10 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
if (pFileInfo == nullptr && fileText2url(wszText)) {
if (hOldEvent)
return;
+
CheckFile(hContact, wszText, pFileInfo);
+ if (pFileInfo)
+ pFileInfo->wszDescr = wszText;
}
// process our own messages