summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/ExternalAPI/m_folders.h10
-rw-r--r--plugins/Folders/folders.vcxproj1
-rw-r--r--plugins/Folders/folders.vcxproj.filters3
-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.h2
-rw-r--r--plugins/Folders/src/version.h4
-rw-r--r--plugins/MirLua/src/plugin.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp2
-rw-r--r--protocols/Tox/src/main.cpp2
12 files changed, 47 insertions, 59 deletions
diff --git a/plugins/ExternalAPI/m_folders.h b/plugins/ExternalAPI/m_folders.h
index 1f49cec9c8..765472c6c0 100644
--- a/plugins/ExternalAPI/m_folders.h
+++ b/plugins/ExternalAPI/m_folders.h
@@ -57,15 +57,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct FOLDERSDATA
{
- int cbSize; // size of struct
DWORD flags; // FF_* flags
+ HPLUGIN plugin; // plugin which owns a folder
LPCSTR szSection; // section name, if it doesn't exist it will be created otherwise it will just add this entry to it
LPCSTR szName; // entry name - will be shown in options
MAllCStrings szFormat; // default string format. Fallback string in case there's no entry in the database for this folder.
// This should be the initial value for the path, users will be able to change it later.
// String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
- MAllCStrings szUserName; // for display purposes. if NULL, plugins gets it as the translated szName
- // String is dup()'d so you can free it later. If you set the unicode string don't forget to set the flag accordingly.
};
/*Folders/Register/Path service
@@ -88,7 +86,6 @@ struct FOLDERSDATA
struct FOLDERSGETDATA
{
- int cbSize;
int nMaxPathSize; // maximum size of buffer. This represents the number of characters that can be copied to it (so for unicode strings you don't send the number of bytes but the length of the string).
MAllStrings szPath; // pointer to the buffer that receives the path without the last "\\"
DWORD flags; // FF_* flags
@@ -114,6 +111,7 @@ __inline static HANDLE FoldersRegisterCustomPath(const char *section, const char
return nullptr;
FOLDERSDATA fd = { sizeof(fd) };
+ fd.plugin = (HPLUGIN)&g_plugin;
fd.szSection = section;
fd.szName = name;
fd.szFormat.a = defaultPath;
@@ -121,16 +119,16 @@ __inline static HANDLE FoldersRegisterCustomPath(const char *section, const char
}
#ifdef _UNICODE
-__inline static HANDLE FoldersRegisterCustomPathW(const char *section, const char *name, const wchar_t *defaultPathW, const wchar_t *userNameW = nullptr)
+__inline static HANDLE FoldersRegisterCustomPathW(const char *section, const char *name, const wchar_t *defaultPathW)
{
if (!ServiceExists(MS_FOLDERS_REGISTER_PATH))
return nullptr;
FOLDERSDATA fd = { sizeof(fd) };
+ fd.plugin = (HPLUGIN)&g_plugin;
fd.szSection = section;
fd.szName = name;
fd.szFormat.w = defaultPathW;
- fd.szUserName.w = userNameW;
fd.flags = FF_UNICODE;
return (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd);
}
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 @@
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\utils.cpp" />
+ <ClInclude Include="..\ExternalAPI\m_folders.h" />
<ClInclude Include="src\events.h" />
<ClInclude Include="src\folderItem.h" />
<ClInclude Include="src\resource.h" />
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 @@
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\ExternalAPI\m_folders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\folders.rc">
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 <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 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 <stdver.h>
diff --git a/plugins/MirLua/src/plugin.cpp b/plugins/MirLua/src/plugin.cpp
index b6dba83f2e..11c1f33c42 100644
--- a/plugins/MirLua/src/plugin.cpp
+++ b/plugins/MirLua/src/plugin.cpp
@@ -106,8 +106,8 @@ int CMPlugin::OnOptionsInit(WPARAM wParam, LPARAM)
int CMPlugin::OnModulesLoaded(WPARAM, LPARAM)
{
- g_hCLibsFolder = FoldersRegisterCustomPathW(MODULENAME, "CLibsFolder", MIRLUA_PATHT, TranslateT("C libs folder"));
- g_hScriptsFolder = FoldersRegisterCustomPathW(MODULENAME, "ScriptsFolder", MIRLUA_PATHT, TranslateT("Scripts folder"));
+ g_hCLibsFolder = FoldersRegisterCustomPathW(MODULENAME, LPGEN("C Libs Folder"), MIRLUA_PATHT);
+ g_hScriptsFolder = FoldersRegisterCustomPathW(MODULENAME, LPGEN("Scripts folder"), MIRLUA_PATHT);
LoadLuaScripts();
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index a083507708..4a9954195e 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -79,7 +79,7 @@ GaduProto::GaduProto(const char *pszProtoName, const wchar_t *tszUserName) :
wchar_t szPath[MAX_PATH];
mir_snwprintf(szPath, L"%s\\%s\\ImageCache", (wchar_t*)VARSW(L"%miranda_userdata%"), m_tszUserName);
- hImagesFolder = FoldersRegisterCustomPathW(LPGEN("Images"), m_szModuleName, szPath, m_tszUserName);
+ hImagesFolder = FoldersRegisterCustomPathW(LPGEN("Images"), m_szModuleName, szPath);
uint32_t pluginVersion = getDword(GG_PLUGINVERSION, 0);
if (pluginVersion < pluginInfoEx.version)
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp
index 7b509b9378..3d9c520cf9 100644
--- a/protocols/Tox/src/main.cpp
+++ b/protocols/Tox/src/main.cpp
@@ -36,7 +36,7 @@ int OnModulesLoaded(WPARAM, LPARAM)
{
CToxProto::InitIcons();
- hProfileFolderPath = FoldersRegisterCustomPathW("Tox", "ProfilesFolder", MIRANDA_USERDATAW, TranslateT("Profiles folder"));
+ hProfileFolderPath = FoldersRegisterCustomPathW("Tox", LPGEN("Profiles folder"), MIRANDA_USERDATAW);
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CreateServiceFunction(MODULE "/ParseUri", CToxProto::ParseToxUri);