summaryrefslogtreecommitdiff
path: root/plugins/Folders/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Folders/src')
-rw-r--r--plugins/Folders/src/dlg_handlers.cpp27
-rw-r--r--plugins/Folders/src/folderItem.cpp21
-rw-r--r--plugins/Folders/src/folderItem.h21
-rw-r--r--plugins/Folders/src/services.cpp9
-rw-r--r--plugins/Folders/src/stdafx.cxx2
-rw-r--r--plugins/Folders/src/stdafx.h2
-rw-r--r--plugins/Folders/src/version.h6
7 files changed, 37 insertions, 51 deletions
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.cxx b/plugins/Folders/src/stdafx.cxx
index 13f28e1314..f111565f38 100644
--- a/plugins/Folders/src/stdafx.cxx
+++ b/plugins/Folders/src/stdafx.cxx
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2012-24 Miranda NG team (https://miranda-ng.org)
+Copyright (C) 2012-25 Miranda NG team (https://miranda-ng.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
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 <m_langpack.h>
#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 3870428697..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 <stdver.h>
@@ -10,4 +10,4 @@
#define __DESCRIPTION "Allows plugins to save their data to user selected folders; supports variables."
#define __AUTHOR "Cristian Libotean, Miranda NG team"
#define __AUTHORWEB "https://miranda-ng.org/p/Folders"
-#define __COPYRIGHT "© 2005-2012 Cristian Libotean, 2012-24 Miranda NG team"
+#define __COPYRIGHT "© 2005-2012 Cristian Libotean, 2012-25 Miranda NG team"