From 8f1efe1635c9572771a2e9e319e52dd989c87f90 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 1 May 2024 13:40:41 +0300 Subject: fixes #4386 (Folders: add support for changing "Preview" folder path) --- src/mir_app/src/proto_interface.cpp | 25 ++++++++++++++++++++++++- src/mir_app/src/stdafx.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') 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() @@ -274,6 +277,25 @@ int PROTO_INTERFACE::UserIsTyping(MCONTACT, int) return 1; // error } +///////////////////////////////////////////////////////////////////////////////////////// +// 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 @@ -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 #include #include +#include #include #include #include -- cgit v1.2.3