From ac91cd55be7e2f69cfbf7e039feba2bdee7edfc0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 8 Apr 2025 14:44:18 +0300 Subject: =?UTF-8?q?fixes=20#4965=20(Folders:=20=D0=BD=D0=B5=D0=BA=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=D1=8F=D1=82=D1=81=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Folders/folders.vcxproj | 1 + plugins/Folders/folders.vcxproj.filters | 3 +++ plugins/Folders/src/dlg_handlers.cpp | 27 ++++++++++++++------------- plugins/Folders/src/folderItem.cpp | 21 ++++++--------------- plugins/Folders/src/folderItem.h | 21 ++++++++++----------- plugins/Folders/src/services.cpp | 9 ++------- plugins/Folders/src/stdafx.h | 2 +- plugins/Folders/src/version.h | 4 ++-- 8 files changed, 39 insertions(+), 49 deletions(-) (limited to 'plugins/Folders') diff --git a/plugins/Folders/folders.vcxproj b/plugins/Folders/folders.vcxproj index e95ce180f6..b02c0b8685 100644 --- a/plugins/Folders/folders.vcxproj +++ b/plugins/Folders/folders.vcxproj @@ -35,6 +35,7 @@ Create + diff --git a/plugins/Folders/folders.vcxproj.filters b/plugins/Folders/folders.vcxproj.filters index fcdb537888..88a5ae7745 100644 --- a/plugins/Folders/folders.vcxproj.filters +++ b/plugins/Folders/folders.vcxproj.filters @@ -46,6 +46,9 @@ Header Files + + Header Files + diff --git a/plugins/Folders/src/dlg_handlers.cpp b/plugins/Folders/src/dlg_handlers.cpp index d71d9dd874..79ef80b6b7 100644 --- a/plugins/Folders/src/dlg_handlers.cpp +++ b/plugins/Folders/src/dlg_handlers.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -PFolderItem lastItem = nullptr; +CFolderItem *lastItem = nullptr; CDlgBase *pHelpDialog = nullptr; @@ -70,13 +70,13 @@ class COptDialog : public CDlgBase CCtrlEdit m_edtPreview, m_edtEdit; CCtrlButton m_btnRefresh, m_btnHelp; - PFolderItem GetSelectedItem() + CFolderItem* GetSelectedItem() { int index = m_lbItems.GetCurSel(); if (index == LB_ERR) return nullptr; - return (PFolderItem)m_lbItems.GetItemData(index); + return (CFolderItem *)m_lbItems.GetItemData(index); } int ContainsSection(const wchar_t *section) @@ -88,12 +88,12 @@ class COptDialog : public CDlgBase void LoadRegisteredFolderSections() { for (auto &it : lstRegisteredFolders) { - wchar_t *translated = mir_a2u(it->GetSection()); - if (!ContainsSection(TranslateW(translated))) { - int idx = m_lbSections.AddString(TranslateW(translated), 0); + _A2T pszSection(it->GetSection()); + auto *pwszSection = TranslateW_LP(pszSection, it->GetPlugin()); + if (!ContainsSection(pwszSection)) { + int idx = m_lbSections.AddString(pwszSection, 0); m_lbSections.SetItemData(idx, (LPARAM)it->GetSection()); } - mir_free(translated); } } @@ -108,7 +108,8 @@ class COptDialog : public CDlgBase m_lbItems.ResetContent(); for (auto &it : lstRegisteredFolders) { if (!mir_strcmp(szSection, it->GetSection())) { - idx = m_lbItems.AddString(TranslateW(it->GetUserName()), 0); + _A2T pszName(it->GetName()); + idx = m_lbItems.AddString(TranslateW_LP(pszName, it->GetPlugin()), 0); m_lbItems.SetItemData(idx, (LPARAM)it); } } @@ -123,7 +124,7 @@ class COptDialog : public CDlgBase m_edtPreview.SetText(ExpandPath(tmp)); } - void LoadItem(PFolderItem item) + void LoadItem(CFolderItem *item) { if (!item) return; @@ -132,7 +133,7 @@ class COptDialog : public CDlgBase RefreshPreview(); } - void SaveItem(PFolderItem item, int bEnableApply) + void SaveItem(CFolderItem *item, int bEnableApply) { if (!item) return; @@ -145,7 +146,7 @@ class COptDialog : public CDlgBase NotifyChange(); } - int ChangesNotSaved(PFolderItem item) + int ChangesNotSaved(CFolderItem *item) { if (!item) return 0; @@ -216,7 +217,7 @@ public: void OnItemsSelChange(CCtrlBase*) { - PFolderItem item = GetSelectedItem(); + CFolderItem *item = GetSelectedItem(); if (item != nullptr) { CheckForChanges(); LoadItem(item); @@ -226,7 +227,7 @@ public: bool OnApply() override { - PFolderItem item = GetSelectedItem(); + CFolderItem *item = GetSelectedItem(); if (item) { SaveItem(item, FALSE); LoadItem(item); diff --git a/plugins/Folders/src/folderItem.cpp b/plugins/Folders/src/folderItem.cpp index f6b96f153f..3d4c658e17 100644 --- a/plugins/Folders/src/folderItem.cpp +++ b/plugins/Folders/src/folderItem.cpp @@ -20,14 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -CFolderItem::CFolderItem(const char *sectionName, const char *name, const wchar_t *format, const wchar_t *userName) +CFolderItem::CFolderItem(HPLUGIN hPlugin, const char *sectionName, const char *name, const wchar_t *format) : + m_hPlugin(hPlugin) { m_szSection = mir_strdup(sectionName); m_szName = mir_strdup(name); - if (userName) - m_tszUserName = mir_wstrdup(userName); - else - m_tszUserName = mir_a2u(name); m_tszFormat = nullptr; m_tszOldFormat = nullptr; GetDataFromDatabase(format); @@ -40,7 +37,6 @@ CFolderItem::~CFolderItem() mir_free(m_szName); mir_free(m_tszFormat); mir_free(m_tszOldFormat); - mir_free(m_tszUserName); } void CFolderItem::SetFormat(const wchar_t *newFormat) @@ -50,19 +46,14 @@ void CFolderItem::SetFormat(const wchar_t *newFormat) m_tszFormat = mir_wstrdup(*newFormat ? newFormat : MIRANDA_PATHW); } -int CFolderItem::IsEqual(const CFolderItem *other) +bool CFolderItem::IsEqual(const CFolderItem *other) { - return (IsEqual(other->GetSection(), other->GetUserName())); + return IsEqual(other->GetSection(), other->GetName()); } -int CFolderItem::IsEqual(const char *section, const wchar_t *name) +bool CFolderItem::IsEqual(const char *section, const char *name) { - return !mir_wstrcmp(m_tszUserName, name) && !mir_strcmp(m_szSection, section); -} - -int CFolderItem::IsEqualTranslated(const char *trSection, const wchar_t *trName) -{ - return !mir_wstrcmp(TranslateW(m_tszUserName), trName) && !mir_strcmp(Translate(m_szSection), trSection); + return !mir_strcmp(m_szName, name) && !mir_strcmp(m_szSection, section); } int CFolderItem::operator ==(const CFolderItem *other) diff --git a/plugins/Folders/src/folderItem.h b/plugins/Folders/src/folderItem.h index cd35c36637..4f6b92654d 100644 --- a/plugins/Folders/src/folderItem.h +++ b/plugins/Folders/src/folderItem.h @@ -31,33 +31,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class CFolderItem { + HPLUGIN m_hPlugin; char *m_szSection, *m_szName; - wchar_t *m_tszFormat, *m_tszOldFormat, *m_tszUserName; + wchar_t *m_tszFormat, *m_tszOldFormat; void GetDataFromDatabase(const wchar_t *szNotFound); void WriteDataToDatabase(); int FolderCreateDirectory(int showFolder = 0); int FolderDeleteOldDirectory(int showFolder = 0); + public: - CFolderItem(const char *sectionName, const char *name, const wchar_t *format, const wchar_t *userName); + CFolderItem(HPLUGIN, const char *sectionName, const char *name, const wchar_t *format); virtual ~CFolderItem(); CMStringW Expand(); void Save(); - int IsEqual(const CFolderItem *other); - int IsEqual(const char *section, const wchar_t *name); - int IsEqualTranslated(const char *trSection, const wchar_t *trName); + bool IsEqual(const CFolderItem *other); + bool IsEqual(const char *section, const char *name); int operator ==(const CFolderItem *other); - __inline const char* GetSection() const { return m_szSection; } - __inline const char* GetName() const { return m_szName; } - __inline const wchar_t* GetUserName() const { return m_tszUserName; } + __inline HPLUGIN GetPlugin() const { return m_hPlugin; } + __inline const char* GetSection() const { return m_szSection; } + __inline const char* GetName() const { return m_szName; } __inline const wchar_t* GetFormat() const { return m_tszFormat; } void SetFormat(const wchar_t *newFormat); }; -typedef CFolderItem *PFolderItem; - -#endif //M_FOLDERS_FOLDER_ITEM_H \ No newline at end of file +#endif //M_FOLDERS_FOLDER_ITEM_H diff --git a/plugins/Folders/src/services.cpp b/plugins/Folders/src/services.cpp index 3fb2ab07fb..61e598694a 100644 --- a/plugins/Folders/src/services.cpp +++ b/plugins/Folders/src/services.cpp @@ -33,14 +33,11 @@ INT_PTR RegisterPathService(WPARAM, LPARAM lParam) if (data == nullptr) return NULL; - if (data->cbSize != sizeof(FOLDERSDATA)) - return NULL; - CFolderItem *pNew; if (data->flags & FF_UNICODE) - pNew = new CFolderItem(data->szSection, data->szName, data->szFormat.w, data->szUserName.w); + pNew = new CFolderItem(data->plugin, data->szSection, data->szName, data->szFormat.w); else - pNew = new CFolderItem(data->szSection, data->szName, _A2T(data->szFormat.a), _A2T(data->szUserName.a)); + pNew = new CFolderItem(data->plugin, data->szSection, data->szName, _A2T(data->szFormat.a)); lstRegisteredFolders.insert(pNew); return (INT_PTR)pNew; @@ -64,8 +61,6 @@ INT_PTR GetPathService(WPARAM wParam, LPARAM lParam) return 1; FOLDERSGETDATA* data = (FOLDERSGETDATA*)lParam; - if (data->cbSize != sizeof(FOLDERSGETDATA)) - return 1; CMStringW buf(p->Expand()); if (data->flags & FF_UNICODE) diff --git a/plugins/Folders/src/stdafx.h b/plugins/Folders/src/stdafx.h index 1c56ec4f1d..8136929058 100644 --- a/plugins/Folders/src/stdafx.h +++ b/plugins/Folders/src/stdafx.h @@ -42,11 +42,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "version.h" +#include "folderItem.h" #include "utils.h" #include "resource.h" #include "services.h" #include "events.h" -#include "folderItem.h" #ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA #define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic" diff --git a/plugins/Folders/src/version.h b/plugins/Folders/src/version.h index 3269dab53f..9bbb93dc7c 100644 --- a/plugins/Folders/src/version.h +++ b/plugins/Folders/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 2 +#define __MINOR_VERSION 3 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 1 #include -- cgit v1.2.3