summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-29 14:23:02 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-29 14:23:02 +0300
commitedbfd659e4990494670e535d5be282659cd5bfc8 (patch)
tree47dabe0dd71e2fa07b8476273e58ead785317f36
parenta63fdd451d23aa5d4b33c1bcf3540bea411f3358 (diff)
fixes #3602 ("Copy path" в контекстном меню для файлов)
-rw-r--r--include/m_protosvc.h4
-rw-r--r--include/m_srmm_int.h3
-rw-r--r--libs/win32/mir_app.libbin266558 -> 266552 bytes
-rw-r--r--libs/win64/mir_app.libbin265642 -> 265636 bytes
-rw-r--r--plugins/NewStory/src/history_array.cpp1
-rw-r--r--plugins/NewStory/src/history_array.h2
-rw-r--r--plugins/NewStory/src/history_control.cpp22
-rw-r--r--plugins/NewStory/src/history_control.h1
-rw-r--r--plugins/NewStory/src/history_menus.cpp30
-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.cpp19
-rw-r--r--src/mir_app/src/srmm_util.cpp33
13 files changed, 90 insertions, 29 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index ec77c0fad0..601ddebb40 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -804,6 +804,10 @@ __forceinline INT_PTR ProtoChainRecvFile(MCONTACT hContact, PROTORECVFILE *pre)
#define PS_OFFLINEFILE "/OfflineFile"
+#define OFD_DOWNLOAD 0x0001
+#define OFD_SAVEAS 0x0002
+#define OFD_RUN 0x1000
+
struct MIR_APP_EXPORT OFDTHREAD : public MNonCopyable
{
OFDTHREAD(MEVENT, const CMStringW &, bool);
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index 12c2b1cd8a..d061fcd230 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -357,8 +357,9 @@ MIR_APP_DLL(void) Srmm_CreateHotkey(const char *pszSection, const char *pszDescr
/////////////////////////////////////////////////////////////////////////////////////////
// downloads or launches offline file
+// iCommand = combination of OFD_* constants
-MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen);
+MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, int iCommand);
/////////////////////////////////////////////////////////////////////////////////////////
// finds a SRMM window using hContact
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 795089f618..e0077abe30 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 052a17039e..b57b969b2e 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index 41b091b37c..5767b91330 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -215,6 +215,7 @@ void ItemData::load(bool bFullLoad)
DB::FILE_BLOB blob(dbe);
if (blob.isOffline()) {
m_bOfflineFile = true;
+ m_bOfflineDownloaded = blob.isCompleted();
CMStringW buf;
buf.Append(blob.getName() ? blob.getName() : TranslateT("Unnamed"));
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 212a85adbb..df9f2f9595 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -9,7 +9,7 @@ struct ItemData : public MZeroedObject
bool m_bRtf;
bool m_bSelected;
bool m_bLoaded;
- bool m_bOfflineFile;
+ bool m_bOfflineFile, m_bOfflineDownloaded;
int savedTop;
DB::EventInfo dbe;
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index 4e723dfa1c..7f25cfbc94 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -596,8 +596,19 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
int eventCount = data->items.getCount();
for (int i = 0; i < eventCount; i++) {
ItemData *p = data->items.get(i, false);
- if (p->m_bSelected)
- res.Append(ptrW(TplFormatString(p->getCopyTemplate(), p->hContact, p)));
+ if (!p->m_bSelected)
+ continue;
+
+ if (p->m_bOfflineFile) {
+ DB::EventInfo dbei(p->hEvent);
+ DB::FILE_BLOB blob(dbei);
+ if (p->m_bOfflineDownloaded)
+ res.Append(blob.getLocalName());
+ else
+ res.Append(_A2T(blob.getUrl()));
+ res.Append(L"\r\n");
+ }
+ else res.Append(ptrW(TplFormatString(p->getCopyTemplate(), p->hContact, p)));
}
Utils_ClipboardCopy(res);
@@ -605,6 +616,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
InvalidateRect(hwnd, 0, FALSE);
break;
+ case NSM_DOWNLOAD:
+ if (auto *p = data->items[data->caret])
+ Srmm_DownloadOfflineFile(p->hContact, p->hEvent, lParam);
+ break;
+
case UM_EDITEVENT:
idx = data->items.find(lParam);
if (idx != -1) {
@@ -835,7 +851,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
pt.y -= pItem->savedTop;
if (pItem->m_bOfflineFile) {
- Srmm_DownloadOfflineFile(pItem->hContact, pItem->hEvent, true);
+ Srmm_DownloadOfflineFile(pItem->hContact, pItem->hEvent, OFD_DOWNLOAD | OFD_RUN);
return 0;
}
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index 743992e90a..9c63d44df2 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -67,6 +67,7 @@ enum
//
NSM_COPY,
NSM_EXPORT,
+ NSM_DOWNLOAD,
//
NSM_GETCOUNT,
diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp
index 263d45cdf0..ad27626716 100644
--- a/plugins/NewStory/src/history_menus.cpp
+++ b/plugins/NewStory/src/history_menus.cpp
@@ -2,10 +2,20 @@
static int hMenuObject;
static HANDLE hEventPreBuildMenu;
-static HGENMENU hmiHistory;
+static HGENMENU hmiHistory, hmiCopy, hmiSaveAs, hmiDownload;
HMENU NSMenu_Build(ItemData *item)
{
+ if (item->m_bOfflineFile) {
+ Menu_ModifyItem(hmiCopy, (item->m_bOfflineDownloaded) ? TranslateT("Copy file name") : TranslateT("Copy url"));
+ Menu_ShowItem(hmiSaveAs, true);
+ Menu_ShowItem(hmiDownload, !item->m_bOfflineDownloaded);
+ }
+ else {
+ Menu_ShowItem(hmiSaveAs, false);
+ Menu_ShowItem(hmiDownload, false);
+ }
+
NotifyEventHooks(hEventPreBuildMenu, item->hContact, (LPARAM)&item->dbe);
HMENU hMenu = CreatePopupMenu();
@@ -39,6 +49,14 @@ static INT_PTR NSMenuHelper(WPARAM wParam, LPARAM lParam)
SendMessage(pData->hwnd, NSM_SELECTITEMS, 0, pData->items.getCount() - 1);
break;
+ case 5:
+ SendMessage(pData->hwnd, NSM_DOWNLOAD, 0, OFD_SAVEAS | OFD_RUN);
+ break;
+
+ case 6:
+ SendMessage(pData->hwnd, NSM_DOWNLOAD, 0, OFD_DOWNLOAD);
+ break;
+
default:
if (auto *pDlg = pData->pMsgDlg) {
PostMessage(pDlg->GetHwnd(), WM_MOUSEACTIVATE, 0, 0);
@@ -128,7 +146,15 @@ void InitMenus()
mi.position = 100000;
mi.name.a = LPGEN("Copy");
- Menu_AddNewStoryMenuItem(&mi, 1);
+ hmiCopy = Menu_AddNewStoryMenuItem(&mi, 1);
+
+ mi.position = 100001;
+ mi.name.a = LPGEN("Save as");
+ hmiSaveAs = Menu_AddNewStoryMenuItem(&mi, 5);
+
+ mi.position = 100002;
+ mi.name.a = LPGEN("Download");
+ hmiDownload = Menu_AddNewStoryMenuItem(&mi, 6);
mi.position = 200000;
mi.name.a = LPGEN("Edit");
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 1d06496629..e9772a9c25 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -246,7 +246,7 @@ Srmm_RedrawToolbarIcons @338
?Srmm_GetNthButton@@YGPAUCustomButtonData@@H@Z @339 NONAME
?Srmm_GetButtonCount@@YGHXZ @340 NONAME
?Srmm_ClickToolbarIcon@@YGXIHPAUHWND__@@H@Z @341 NONAME
-?Srmm_DownloadOfflineFile@@YGXII_N@Z @342 NONAME
+?Srmm_DownloadOfflineFile@@YGXIIH@Z @342 NONAME
Miranda_OkToExit @344
Miranda_GetVersion @345
Miranda_GetFileVersion @346
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 8c6bc1eadc..81ce7fd596 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -246,7 +246,7 @@ Srmm_RedrawToolbarIcons @338
?Srmm_GetNthButton@@YAPEAUCustomButtonData@@H@Z @339 NONAME
?Srmm_GetButtonCount@@YAHXZ @340 NONAME
?Srmm_ClickToolbarIcon@@YAXIHPEAUHWND__@@H@Z @341 NONAME
-?Srmm_DownloadOfflineFile@@YAXII_N@Z @342 NONAME
+?Srmm_DownloadOfflineFile@@YAXIIH@Z @342 NONAME
Miranda_OkToExit @344
Miranda_GetVersion @345
Miranda_GetFileVersion @346
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp
index 5ea77b4707..7ad3fb4659 100644
--- a/src/mir_app/src/srmm_log_rtf.cpp
+++ b/src/mir_app/src/srmm_log_rtf.cpp
@@ -243,24 +243,7 @@ INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam)
break;
case 5:
- wchar_t str[MAX_PATH];
- mir_wstrncpy(str, blob.getName(), _countof(str));
- {
- wchar_t filter[512];
- mir_snwprintf(filter, L"%s (*)%c*%c", TranslateT("All files"), 0, 0);
-
- OPENFILENAME ofn = {};
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = str;
- ofn.nMaxFile = _countof(str);
- ofn.nMaxFileTitle = MAX_PATH;
- if (!GetSaveFileNameW(&ofn))
- break;
- }
-
- DownloadOfflineFile(m_pDlg.m_hContact, hDbEvent, nCmd == 2, new OFD_SaveAs(str));
+ Srmm_DownloadOfflineFile(m_pDlg.m_hContact, hDbEvent, OFD_RUN | OFD_SAVEAS);
break;
}
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index a7f95f7752..bd942a0a8a 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -195,9 +195,38 @@ void DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen, OFD_Cal
}
}
-MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, bool bOpen)
+MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MCONTACT hContact, MEVENT hDbEvent, int iCommand)
{
- DownloadOfflineFile(hContact, hDbEvent, bOpen, new OFD_Download());
+ bool bOpen = false;
+ if (iCommand & OFD_RUN) {
+ bOpen = true;
+ iCommand &= ~OFD_RUN;
+ }
+
+ if (iCommand == OFD_SAVEAS) {
+ DB::EventInfo dbei(hDbEvent);
+ if (!dbei)
+ return;
+
+ DB::FILE_BLOB blob(dbei);
+
+ wchar_t str[MAX_PATH];
+ mir_wstrncpy(str, blob.getName(), _countof(str));
+
+ wchar_t filter[512];
+ mir_snwprintf(filter, L"%s (*)%c*%c", TranslateT("All files"), 0, 0);
+
+ OPENFILENAME ofn = {};
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = _countof(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ if (GetSaveFileNameW(&ofn))
+ DownloadOfflineFile(hContact, hDbEvent, bOpen, new OFD_SaveAs(str));
+ }
+ else DownloadOfflineFile(hContact, hDbEvent, bOpen, new OFD_Download());
}
/////////////////////////////////////////////////////////////////////////////////////////