From 30516cfd877bf99f56ef43a7fe50ff8154f703b8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Nov 2023 16:25:16 +0300 Subject: =?UTF-8?q?fixes=20#3596=20(ICQ:=20"Copy=20URL"=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BD=D0=BE=D0=BC=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0/=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=84=D1=84=D0=BB=D0=B0=D0=B9=D0=BD=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=B5=20=D0=BE=D1=82=D0=B4=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=20=D0=B1=D0=B5=D1=81=D1=81=D0=BC=D1=8B=D1=81=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=83=D1=8E=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/src/file.cpp | 2 +- src/mir_app/src/file.h | 17 ++++++++++---- src/mir_app/src/mir_app.def | 2 +- src/mir_app/src/mir_app64.def | 2 +- src/mir_app/src/srmm_log_rtf.cpp | 10 +++++--- src/mir_app/src/srmm_util.cpp | 51 ++++++++++++++++++++++------------------ 6 files changed, 51 insertions(+), 33 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index 04cc6c0af8..8274b8fb22 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -297,7 +297,7 @@ MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) // or if they are less than a limit (if a transfer has specified file size) if (bSilent && File::bOfflineAuto) if (File::iOfflineSize == 0 || (blob.getSize() > 0 && blob.getSize() < File::iOfflineSize * 1024)) - DownloadOfflineFile(hContact, hdbe, false, new OFD_Download()); + DownloadOfflineFile(hContact, hdbe, dbei, false, new OFD_Download()); bool bShow = !Contact::IsGroupChat(hContact); if (bShow && blob.isOffline()) { diff --git a/src/mir_app/src/file.h b/src/mir_app/src/file.h index 2decb52aa5..9a21931359 100644 --- a/src/mir_app/src/file.h +++ b/src/mir_app/src/file.h @@ -143,10 +143,19 @@ int GetRegValue(HKEY hKeyBase, const wchar_t *szSubKey, const wchar_t *szValue, void GetSensiblyFormattedSize(__int64 size, wchar_t *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed); // downloads or launches cloud file -struct OFD_Callback + +struct OFD_CopyUrl : public OFD_Callback { - virtual ~OFD_Callback() {} - virtual void Invoke(const OFDTHREAD &ofd) = 0; + CMStringW wszUrl; + + OFD_CopyUrl(const CMStringW &url) : + wszUrl(url) + {} + + void Invoke(const OFDTHREAD &ofd) override + { + Utils_ClipboardCopy(ofd.wszPath.IsEmpty() ? wszUrl : ofd.wszPath); + } }; struct OFD_Download : public OFD_Callback @@ -175,4 +184,4 @@ public: } }; -void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen, OFD_Callback *pCallback); +void DownloadOfflineFile(MCONTACT, MEVENT, DB::EventInfo &dbei, int iCommand, OFD_Callback *pCallback); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index fb83d97f00..e0919c872a 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -875,7 +875,7 @@ Clist_RemoveEvent @989 ?Chat_EmptyHistory@@YGXPAUSESSION_INFO@@@Z @992 NONAME ?Utils_Unzip@@YG?AVMBinBuffer@@PBXI@Z @993 NONAME ?OnNickListTimer@CSrmmBaseDialog@@AAEXPAVCTimer@@@Z @994 NONAME -??0OFDTHREAD@@QAE@IABV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@_N@Z @995 NONAME +??0OFDTHREAD@@QAE@IABV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@H@Z @995 NONAME ??1OFDTHREAD@@QAE@XZ @996 NONAME ?Finish@OFDTHREAD@@QAEXXZ @997 NONAME ?getLocalName@FILE_BLOB@DB@@QBEPB_WXZ @998 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index d977ff1183..c60f03222e 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -875,7 +875,7 @@ Clist_RemoveEvent @989 ?Chat_EmptyHistory@@YAXPEAUSESSION_INFO@@@Z @992 NONAME ?Utils_Unzip@@YA?AVMBinBuffer@@PEBX_K@Z @993 NONAME ?OnNickListTimer@CSrmmBaseDialog@@AEAAXPEAVCTimer@@@Z @994 NONAME -??0OFDTHREAD@@QEAA@IAEBV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@_N@Z @995 NONAME +??0OFDTHREAD@@QEAA@IAEBV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@H@Z @995 NONAME ??1OFDTHREAD@@QEAA@XZ @996 NONAME ?Finish@OFDTHREAD@@QEAAXXZ @997 NONAME ?getLocalName@FILE_BLOB@DB@@QEBAPEB_WXZ @998 NONAME diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp index 852b07b192..91e8b40cb6 100644 --- a/src/mir_app/src/srmm_log_rtf.cpp +++ b/src/mir_app/src/srmm_log_rtf.cpp @@ -215,8 +215,8 @@ INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam) DB::EventInfo dbei(hDbEvent); if (!dbei) return FALSE; + DB::FILE_BLOB blob(dbei); - int nCmd = 2; if (pLink->msg == WM_RBUTTONDOWN) { HMENU hMenu = CreatePopupMenu(); @@ -235,11 +235,15 @@ INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam) switch (nCmd) { case 2: case 3: - DownloadOfflineFile(m_pDlg.m_hContact, hDbEvent, nCmd == 2, new OFD_Download()); + DownloadOfflineFile(m_pDlg.m_hContact, hDbEvent, dbei, nCmd == 2, new OFD_Download()); break; case 4: - Utils_ClipboardCopy(blob.getUrl()); + { + OFDTHREAD *ofd = new OFDTHREAD(hDbEvent, L"", OFD_COPYURL); + ofd->pCallback = new OFD_CopyUrl(blob.getUrl()); + CallProtoService(dbei.szModule, PS_OFFLINEFILE, (WPARAM)ofd, 0); + } break; case 5: diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index 2cd125e453..87e0b890a3 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -114,11 +114,12 @@ MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd) ///////////////////////////////////////////////////////////////////////////////////////// // downloads or launches cloud file -OFDTHREAD::OFDTHREAD(MEVENT _1, const CMStringW &_2, bool _3) : +OFDTHREAD::OFDTHREAD(MEVENT _1, const CMStringW &_2, int iCommand) : hDbEvent(_1), - wszPath(_2), - bOpen(_3) + wszPath(_2) { + bOpen = (iCommand & OFD_RUN) != 0; + bCopy = (iCommand & OFD_COPYURL) != 0; } OFDTHREAD::~OFDTHREAD() @@ -166,12 +167,8 @@ static void GenerateLocalName(const DB::EventInfo &dbei, DB::FILE_BLOB &blob, MC blob.setLocalName(FindUniqueFileName(wszFullName)); } -void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen, OFD_Callback *pCallback) +void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, DB::EventInfo &dbei, int iCommand, OFD_Callback *pCallback) { - DB::EventInfo dbei(hDbEvent); - if (!dbei) - return; - DB::FILE_BLOB blob(dbei); if (!blob.isOffline()) return; @@ -191,12 +188,12 @@ void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen, OFD_Cal } if (bDownloaded) { - OFDTHREAD ofd(hDbEvent, blob.getLocalName(), bOpen); + OFDTHREAD ofd(hDbEvent, blob.getLocalName(), iCommand); pCallback->Invoke(ofd); delete pCallback; } else { - OFDTHREAD *ofd = new OFDTHREAD(hDbEvent, blob.getLocalName(), bOpen); + OFDTHREAD *ofd = new OFDTHREAD(hDbEvent, blob.getLocalName(), iCommand); ofd->pCallback = pCallback; CallProtoService(dbei.szModule, PS_OFFLINEFILE, (WPARAM)ofd, 0); } @@ -204,19 +201,23 @@ void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen, OFD_Cal MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, int iCommand) { - bool bOpen = false; - if (iCommand & OFD_RUN) { - bOpen = true; - iCommand &= ~OFD_RUN; - } + DB::EventInfo dbei(hDbEvent); + if (!dbei) + return; - if (iCommand == OFD_SAVEAS) { - DB::EventInfo dbei(hDbEvent); - if (!dbei) - return; + DB::FILE_BLOB blob(dbei); + OFD_Callback *pCallback = 0; + + switch (iCommand & 0xFFF) { + case OFD_COPYURL: + pCallback = new OFD_CopyUrl(blob.getUrl()); + break; - DB::FILE_BLOB blob(dbei); + case OFD_DOWNLOAD: + pCallback = new OFD_Download(); + break; + case OFD_SAVEAS: wchar_t str[MAX_PATH]; mir_wstrncpy(str, blob.getName(), _countof(str)); @@ -230,10 +231,14 @@ MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, i ofn.lpstrFile = str; ofn.nMaxFile = _countof(str); ofn.nMaxFileTitle = MAX_PATH; - if (GetSaveFileNameW(&ofn)) - DownloadOfflineFile(hContact, hDbEvent, bOpen, new OFD_SaveAs(str)); + if (!GetSaveFileNameW(&ofn)) + return; + + pCallback = new OFD_SaveAs(str); + break; } - else DownloadOfflineFile(hContact, hDbEvent, bOpen, new OFD_Download()); + + DownloadOfflineFile(hContact, hDbEvent, dbei, iCommand, pCallback); } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3