summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/newpluginapi.h10
-rw-r--r--libs/win32/mir_app.libbin219744 -> 220308 bytes
-rw-r--r--libs/win64/mir_app.libbin215586 -> 216164 bytes
-rw-r--r--plugins/Import/src/stdafx.h2
-rw-r--r--plugins/Import/src/wizard.cpp6
-rw-r--r--src/mir_app/src/db_upgrade.cpp2
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/newplugins.cpp79
-rw-r--r--src/mir_app/src/pluginopts.cpp6
-rw-r--r--src/mir_app/src/plugins.h5
-rw-r--r--src/mir_app/src/profilemanager.cpp2
-rw-r--r--src/mir_app/src/proto_opts.cpp2
13 files changed, 70 insertions, 48 deletions
diff --git a/include/newpluginapi.h b/include/newpluginapi.h
index 97ef743701..515fda9205 100644
--- a/include/newpluginapi.h
+++ b/include/newpluginapi.h
@@ -58,9 +58,13 @@ __forceinline bool operator!=(const MUUID &p1, const MUUID &p2)
return memcmp(&p1, &p2, sizeof(MUUID)) != 0;
}
-MIR_APP_DLL(int) GetPluginLangId(const MUUID &uuid, int langId);
-MIR_APP_DLL(int) IsPluginLoaded(const MUUID &uuid);
-MIR_APP_DLL(int) SetServiceModePlugin(const wchar_t *wszPluginName, WPARAM = 0, LPARAM = 0);
+MIR_APP_DLL(int) GetPluginLangId(const MUUID &uuid, int langId);
+MIR_APP_DLL(int) IsPluginLoaded(const MUUID &uuid);
+MIR_APP_DLL(int) SetServiceModePlugin(const char *szPluginName, WPARAM = 0, LPARAM = 0);
+
+// manually get/set flag specified at Options - Plugins - Enabled
+MIR_APP_DLL(bool) IsPluginOnWhiteList(const char *szPluginName);
+MIR_APP_DLL(void) SetPluginOnWhiteList(const char *szPluginName, bool bAllow);
/////////////////////////////////////////////////////////////////////////////////////////
// Used to define the end of the MirandaPluginInterface list
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index b699bc461f..a470d81fbd 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index aa4a40118e..8e219531ec 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h
index 2382cf261f..a8629c7a13 100644
--- a/plugins/Import/src/stdafx.h
+++ b/plugins/Import/src/stdafx.h
@@ -222,6 +222,8 @@ public:
class CFinishedPageDlg : public CWizardPageDlg
{
+ typedef CWizardPageDlg CSuper;
+
public:
CFinishedPageDlg();
int Resizer(UTILRESIZECONTROL *urc) override;
diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp
index 9693717214..4345f30986 100644
--- a/plugins/Import/src/wizard.cpp
+++ b/plugins/Import/src/wizard.cpp
@@ -53,7 +53,7 @@ void CIntroPageDlg::OnNext()
// Final wizard page
CFinishedPageDlg::CFinishedPageDlg() :
- CWizardPageDlg(IDD_FINISHED)
+ CSuper(IDD_FINISHED)
{}
bool CFinishedPageDlg::OnInitDialog()
@@ -77,9 +77,9 @@ void CFinishedPageDlg::OnNext()
void CFinishedPageDlg::OnCancel()
{
if (IsDlgButtonChecked(m_hwnd, IDC_DONTLOADPLUGIN))
- db_set_b(0, "PluginDisable", "import", 1);
+ SetPluginOnWhiteList("import", false);
- CWizardPageDlg::OnCancel();
+ CSuper::OnCancel();
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/db_upgrade.cpp b/src/mir_app/src/db_upgrade.cpp
index 9b6c83cfb5..95323a7968 100644
--- a/src/mir_app/src/db_upgrade.cpp
+++ b/src/mir_app/src/db_upgrade.cpp
@@ -61,7 +61,7 @@ LBL_Error:
return nullptr;
}
- if (SetServiceModePlugin(L"import", 1) != ERROR_SUCCESS) {
+ if (SetServiceModePlugin("import", 1) != ERROR_SUCCESS) {
if (IDYES == MessageBoxW(nullptr, TranslateT(MISSING_PLUG_MSG), L"Miranda NG", MB_YESNO))
Utils_OpenUrl("https://miranda-ng.org/p/Import");
goto LBL_Error;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 89f5e022ce..c86156eb00 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -775,3 +775,5 @@ _Netlib_GetTlsUnique@8 @831 NONAME
?getIcon@CHAT_MANAGER@@QBGPAUHICON__@@H@Z @863 NONAME
?getSoundName@GCSessionInfoBase@@QBEPBDH@Z @864 NONAME
?Upgrade@DB@@YGPAVMDatabaseCommon@@PB_W@Z @865 NONAME
+?IsPluginOnWhiteList@@YG_NPBD@Z @866 NONAME
+?SetPluginOnWhiteList@@YGXPBD_N@Z @867 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 91e38bbdfc..ab19f1360a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -775,3 +775,5 @@ Netlib_GetTlsUnique @831 NONAME
?getIcon@CHAT_MANAGER@@QEBAPEAUHICON__@@H@Z @863 NONAME
?getSoundName@GCSessionInfoBase@@QEBAPEBDH@Z @864 NONAME
?Upgrade@DB@@YAPEAVMDatabaseCommon@@PEB_W@Z @865 NONAME
+?IsPluginOnWhiteList@@YA_NPEBD@Z @866 NONAME
+?SetPluginOnWhiteList@@YAXPEBD_N@Z @867 NONAME
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 3af7efc073..12918f3426 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -30,6 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "langpack.h"
#include "netlib.h"
+#define PLUGINDISABLELIST "PluginDisable"
+
bool g_bReadyToInitClist = false;
void LoadExtraIconsModule();
@@ -37,7 +39,7 @@ void freePluginInstance(HINSTANCE hInst);
static int sttComparePluginsByName(const pluginEntry *p1, const pluginEntry *p2)
{
- return mir_wstrcmpi(p1->pluginname, p2->pluginname);
+ return mir_strcmpi(p1->pluginname, p2->pluginname);
}
LIST<pluginEntry>
@@ -51,8 +53,6 @@ MUUID miid_last = MIID_LAST;
/////////////////////////////////////////////////////////////////////////////////////////
-#define MAX_MIR_VER ULONG_MAX
-
static bool bModuleInitialized = FALSE;
HANDLE hevLoadModule, hevUnloadModule;
@@ -61,7 +61,18 @@ static int askAboutIgnoredPlugins;
pluginEntry *plugin_checker, *plugin_crshdmp, *plugin_service, *plugin_ssl, *plugin_clist;
-#define PLUGINDISABLELIST "PluginDisable"
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CPluginName : public CMStringA
+{
+ CPluginName(const char *szName) :
+ CMStringA(szName)
+ {
+ MakeLower();
+ if (Find(".dll") == -1)
+ Append(".dll");
+ }
+};
/////////////////////////////////////////////////////////////////////////////////////////
// basic functions
@@ -349,7 +360,7 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
return nullptr;
pluginEntry *p = (pluginEntry*)mir_calloc(sizeof(pluginEntry));
- wcsncpy_s(p->pluginname, tszFileName, _TRUNCATE);
+ strncpy_s(p->pluginname, _T2A(tszFileName), _TRUNCATE);
// add it to the list anyway
pluginList.insert(p);
@@ -408,20 +419,25 @@ pluginEntry* OpenPlugin(wchar_t *tszFileName, wchar_t *dir, wchar_t *path)
return p;
}
-void SetPluginOnWhiteList(const wchar_t* pluginname, int allow)
+MIR_APP_DLL(void) SetPluginOnWhiteList(const char* szPluginName, bool bAllow)
{
- db_set_b(0, PLUGINDISABLELIST, _strlwr(_T2A(pluginname)), allow == 0);
+ if (szPluginName != nullptr)
+ db_set_b(0, PLUGINDISABLELIST, CPluginName(szPluginName).c_str(), !bAllow);
}
// returns 1 if the plugin should be enabled within this profile, filename is always lower case
-int isPluginOnWhiteList(const wchar_t* pluginname)
+MIR_APP_DLL(bool) IsPluginOnWhiteList(const char *szPluginName)
{
- int rc = db_get_b(0, PLUGINDISABLELIST, _strlwr(_T2A(pluginname)), 0);
+ if (szPluginName == nullptr)
+ return false;
+
+ CPluginName tmp(szPluginName);
+ int rc = db_get_b(0, PLUGINDISABLELIST, tmp, 0);
if (rc != 0 && askAboutIgnoredPlugins) {
wchar_t buf[256];
- mir_snwprintf(buf, TranslateT("'%s' is disabled, re-enable?"), pluginname);
- if (MessageBox(nullptr, buf, TranslateT("Re-enable Miranda plugin?"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
- SetPluginOnWhiteList(pluginname, 1);
+ mir_snwprintf(buf, TranslateT("'%S' is disabled, re-enable?"), tmp.c_str());
+ if (MessageBoxW(nullptr, buf, TranslateT("Re-enable Miranda plugin?"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
+ SetPluginOnWhiteList(szPluginName, true);
rc = 0;
}
}
@@ -431,7 +447,7 @@ int isPluginOnWhiteList(const wchar_t* pluginname)
bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
{
- if (!bDynamic && !isPluginOnWhiteList(p->pluginname))
+ if (!bDynamic && !IsPluginOnWhiteList(p->pluginname))
return false;
if (p->m_pPlugin == nullptr) {
@@ -442,7 +458,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
if (slice)
*slice = 0;
- mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
+ mir_snwprintf(tszFullPath, L"%s\\%s\\%S", exe, (p->bIsCore) ? L"Core" : L"Plugins", p->pluginname);
if (!p->checkAPI(tszFullPath))
return false;
}
@@ -453,7 +469,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
int idx = getDefaultPluginIdx(piface[i]);
if (idx != -1 && pluginDefault[idx].pImpl) {
if (!bDynamic) { // this place is already occupied, skip & disable
- SetPluginOnWhiteList(p->pluginname, 0);
+ SetPluginOnWhiteList(p->pluginname, false);
return false;
}
@@ -561,10 +577,10 @@ static pluginEntry* getCListModule(wchar_t *exe)
wchar_t tszFullPath[MAX_PATH];
for (auto &p : clistPlugins) {
- if (!isPluginOnWhiteList(p->pluginname))
+ if (!IsPluginOnWhiteList(p->pluginname))
continue;
- mir_snwprintf(tszFullPath, L"%s\\Plugins\\%s", exe, p->pluginname);
+ mir_snwprintf(tszFullPath, L"%s\\Plugins\\%S", exe, p->pluginname);
if (loadClistModule(tszFullPath, p))
return p;
}
@@ -581,8 +597,9 @@ static pluginEntry* getCListModule(wchar_t *exe)
int UnloadPlugin(wchar_t* buf, int bufLen)
{
+ ptrA szShortName(mir_u2a(buf));
for (auto &it : pluginList.rev_iter()) {
- if (!mir_wstrcmpi(it->pluginname, buf)) {
+ if (!mir_strcmpi(it->pluginname, szShortName)) {
GetModuleFileName(it->m_pPlugin->getInst(), buf, bufLen);
Plugin_Uninit(it);
return TRUE;
@@ -612,19 +629,17 @@ int LaunchServicePlugin(pluginEntry *p)
if (res != CALLSERVICE_NOTFOUND)
return res;
- MessageBox(nullptr, TranslateT("Unable to load plugin in service mode!"), p->pluginname, MB_ICONSTOP);
+ MessageBox(nullptr, TranslateT("Unable to load plugin in service mode!"), _A2T(p->pluginname), MB_ICONSTOP);
Plugin_Uninit(p);
return SERVICE_FAILED;
}
-MIR_APP_DLL(int) SetServiceModePlugin(const wchar_t *wszPluginName, WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(int) SetServiceModePlugin(const char *szPluginName, WPARAM wParam, LPARAM lParam)
{
- size_t cbLen = mir_wstrlen(wszPluginName);
- if (cbLen == 0)
- return 1;
+ CPluginName tmp(szPluginName);
for (auto &p : servicePlugins) {
- if (!wcsnicmp(p->pluginname, wszPluginName, cbLen)) {
+ if (!stricmp(tmp, p->pluginname)) {
plugin_service = p;
g_srvWParam = wParam;
g_srvLParam = lParam;
@@ -632,7 +647,7 @@ MIR_APP_DLL(int) SetServiceModePlugin(const wchar_t *wszPluginName, WPARAM wPara
}
}
- return 2;
+ return 1;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -684,7 +699,7 @@ int LoadProtocolPlugins(void)
continue;
wchar_t tszFullPath[MAX_PATH];
- mir_snwprintf(tszFullPath, L"%s\\%s\\%s", exe, L"Plugins", p->pluginname);
+ mir_snwprintf(tszFullPath, L"%s\\%s\\%S", exe, L"Plugins", p->pluginname);
p->checkAPI(tszFullPath);
}
@@ -707,7 +722,7 @@ int LoadNewPluginsModule(void)
askAboutIgnoredPlugins = (UINT)GetPrivateProfileInt(L"PluginLoader", L"AskAboutIgnoredPlugins", 0, mirandabootini);
// if Crash Dumper is present, load it to provide Crash Reports
- if (plugin_crshdmp != nullptr && isPluginOnWhiteList(plugin_crshdmp->pluginname))
+ if (plugin_crshdmp != nullptr && IsPluginOnWhiteList(plugin_crshdmp->pluginname))
if (!TryLoadPlugin(plugin_crshdmp, false))
Plugin_Uninit(plugin_crshdmp);
@@ -724,11 +739,11 @@ int LoadNewPluginsModule(void)
return 1;
}
- /* enable and disable as needed */
+ // enable and disable as needed
for (auto &p : clistPlugins)
- SetPluginOnWhiteList(p->pluginname, plugin_clist != p ? 0 : 1);
+ SetPluginOnWhiteList(p->pluginname, plugin_clist == p);
- /* now loop thru and load all the other plugins, do this in one pass */
+ // now loop thru and load all the other plugins, do this in one pass
for (int i = 0; i < pluginList.getCount(); i++) {
pluginEntry *p = pluginList[i];
if (!TryLoadPlugin(p, false)) {
@@ -738,7 +753,7 @@ int LoadNewPluginsModule(void)
}
for (auto &it : servicePlugins.rev_iter())
- if (!isPluginOnWhiteList(it->pluginname))
+ if (!IsPluginOnWhiteList(it->pluginname))
Plugin_Uninit(it);
HookEvent(ME_OPT_INITIALISE, PluginOptionsInit);
@@ -773,7 +788,7 @@ int LoadNewPluginsModuleInfos(void)
if (!LoadCorePlugin(stdCrypt))
return 1;
- SetServiceModePlugin(CmdLine_GetOption(L"svc"));
+ SetServiceModePlugin(_T2A(CmdLine_GetOption(L"svc")));
return 0;
}
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp
index 3c75861424..4f63a727bd 100644
--- a/src/mir_app/src/pluginopts.cpp
+++ b/src/mir_app/src/pluginopts.cpp
@@ -147,7 +147,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM
it.lParam = (LPARAM)dat;
pCtrl->InsertItem(&it);
- if (!bNoCheckbox && isPluginOnWhiteList(fd->cFileName))
+ if (!bNoCheckbox && IsPluginOnWhiteList(_T2A(fd->cFileName)))
dat->bWasChecked = true;
if (dat->iRow != -1) {
@@ -328,7 +328,7 @@ public:
// set checkboxes for all loaded plugins
for (auto &it : arPluginList) {
- if (!isPluginOnWhiteList(it->fileName))
+ if (!IsPluginOnWhiteList(_T2A(it->fileName)))
continue;
if (it->flags & STATIC_PLUGIN)
@@ -362,7 +362,7 @@ public:
wchar_t buf[1024];
m_plugList.GetItemText(iRow, 0, buf, _countof(buf));
int iState = m_plugList.GetItemState(iRow, LVIS_STATEIMAGEMASK);
- SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0);
+ SetPluginOnWhiteList(_T2A(buf), (iState & 0x2000) != 0);
if (iState != 0x3000) {
LVITEM lvi = { 0 };
diff --git a/src/mir_app/src/plugins.h b/src/mir_app/src/plugins.h
index 9525c27417..6c6d8153b2 100644
--- a/src/mir_app/src/plugins.h
+++ b/src/mir_app/src/plugins.h
@@ -10,7 +10,7 @@ typedef int(__cdecl *Miranda_Plugin_Unload) (void);
struct pluginEntry
{
- wchar_t pluginname[64];
+ char pluginname[64];
struct
{
bool bFailed : 1; // not a valid plugin, or API is invalid, pluginname is valid
@@ -58,9 +58,6 @@ extern MUUID miid_last;
int PluginOptionsInit(WPARAM, LPARAM);
-int isPluginOnWhiteList(const wchar_t *pluginname);
-void SetPluginOnWhiteList(const wchar_t *pluginname, int allow);
-
int getDefaultPluginIdx(const MUUID &muuid);
bool hasMuuid(const MUUID *pFirst, const MUUID&);
bool isPluginBanned(const MUUID &u1);
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp
index b77880e4cf..5c4453cb45 100644
--- a/src/mir_app/src/profilemanager.cpp
+++ b/src/mir_app/src/profilemanager.cpp
@@ -636,7 +636,7 @@ public:
else {
for (int i = 0; i < servicePlugins.getCount(); i++) {
pluginEntry *p = servicePlugins[i];
- m_servicePlugs.AddString(TranslateW(p->pluginname), i);
+ m_servicePlugs.AddStringA(p->pluginname, i);
}
m_servicePlugs.Disable();
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index 3742a04f4a..5e5094bc1f 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -882,7 +882,7 @@ bool CAccountFormDlg::OnApply()
if (oldProto && UnloadPlugin(szPlugin, _countof(szPlugin))) {
wchar_t szNewName[MAX_PATH];
mir_snwprintf(szNewName, L"%s~", szPlugin);
- MoveFile(szPlugin, szNewName);
+ MoveFileW(szPlugin, szNewName);
}
m_action = PRAC_ADDED;
}