From 19acd0ef59d7272db67ef54b331f32103dbd5aad Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Dec 2023 15:25:41 +0300 Subject: =?UTF-8?q?fixes=20#4071=20(NewStory:=20Convert=20message=20to=20a?= =?UTF-8?q?=20file=20transfer=20=D0=BD=D0=B5=20=D1=81=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D0=B2=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=D1=85,=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B4=D0=B5=D1=80=D0=B6=D0=B0=D1=89=D0=B8=D1=85=20?= =?UTF-8?q?=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=20=D0=B8=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/ICQ-WIM/src/menus.cpp | 6 +++--- protocols/ICQ-WIM/src/server.cpp | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'protocols') 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 -- cgit v1.2.3