summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-02 16:25:16 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-02 16:25:22 +0300
commit30516cfd877bf99f56ef43a7fe50ff8154f703b8 (patch)
tree084861977edb60bbdaf38ea904fa055d13f8419e /src/mir_app
parentc3fb56beba551ba6f40e2ba8b9b0dc8b862c53e6 (diff)
fixes #3596 (ICQ: "Copy URL" в контекстном меню журнала/истории на оффлайн файле отдает бессмысленную ссылку)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/file.cpp2
-rw-r--r--src/mir_app/src/file.h17
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/srmm_log_rtf.cpp10
-rw-r--r--src/mir_app/src/srmm_util.cpp51
6 files changed, 51 insertions, 33 deletions
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);
}
/////////////////////////////////////////////////////////////////////////////////////////