summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-05-01 13:40:41 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-05-01 13:40:44 +0300
commit8f1efe1635c9572771a2e9e319e52dd989c87f90 (patch)
treeb401f47784714b319b4789acee5c05ea6345049e /src
parentaf1ff0d3897352297c688785f2ca7545232858ea (diff)
fixes #4386 (Folders: add support for changing "Preview" folder path)
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/proto_interface.cpp25
-rw-r--r--src/mir_app/src/stdafx.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp
index 573a4177d8..3c0cd26ea7 100644
--- a/src/mir_app/src/proto_interface.cpp
+++ b/src/mir_app/src/proto_interface.cpp
@@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "file.h"
+static wchar_t wszPreviewFolder[MAX_PATH];
+static HANDLE hPreviewFolder;
+
static HGENMENU hReqAuth = nullptr, hGrantAuth = nullptr, hRevokeAuth = nullptr, hServerHist = nullptr;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -68,7 +71,7 @@ CMStringW PROTO_INTERFACE::GetAvatarPath() const
CMStringW PROTO_INTERFACE::GetPreviewPath() const
{
- return CMStringW(FORMAT, L"%s\\Preview\\%S", VARSW(L"%miranda_userdata%").get(), m_szModuleName);
+ return CMStringW(FORMAT, L"%s\\%S", wszPreviewFolder, m_szModuleName);
}
void PROTO_INTERFACE::OnBuildProtoMenu()
@@ -275,6 +278,25 @@ int PROTO_INTERFACE::UserIsTyping(MCONTACT, int)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// folders support
+
+static int FoldersPathChanged(WPARAM, LPARAM)
+{
+ FoldersGetCustomPathW(hPreviewFolder, wszPreviewFolder, _countof(wszPreviewFolder), L"");
+ return 0;
+}
+
+static int ProtoModulesLoaded(WPARAM, LPARAM)
+{
+ wcsncpy_s(wszPreviewFolder, VARSW(L"%miranda_userdata%\\Preview"), _TRUNCATE);
+ if (hPreviewFolder = FoldersRegisterCustomPathW("Preview", LPGEN("Preview folder"), wszPreviewFolder)) {
+ HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged);
+ FoldersPathChanged(0, 0);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// protocol menus
static INT_PTR __cdecl stubRequestAuth(WPARAM hContact, LPARAM)
@@ -356,5 +378,6 @@ void InitProtoMenus(void)
hServerHist = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, stubLoadHistory);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ProtoModulesLoaded);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, ProtoPrebuildContactMenu);
}
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index 3962c77b01..115b410aaa 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -73,6 +73,7 @@ typedef struct SslHandle *HSSL;
#include <m_extraicons.h>
#include <m_file.h>
#include <m_findadd.h>
+#include <m_folders.h>
#include <m_fontservice.h>
#include <m_gui.h>
#include <m_history.h>