mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-21 21:04:54 +02:00
Remove the legasy plugin loading way and apply only the new plugin loading method
1. Load plugins only from the new plugin folder structure. example: Notepad++\plugins\myAwesomePlugin\myAwesomePlugin.dll 2. Load plugins from only one directory. If doLocalConf.xml is present, then it will be <NPP_INSTALLATION_DIR>\plugins\ otherwise %USERPROFILE%\AppData\Local\Notepad++\plugins\
This commit is contained in:
parent
ee763ca0ad
commit
7e555b67fc
@ -289,67 +289,11 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PluginsManager::loadPlugins(const TCHAR *dir)
|
|
||||||
{
|
|
||||||
if (_isDisabled)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
vector<generic_string> dllNames;
|
|
||||||
vector<generic_string> dll2Remove;
|
|
||||||
NppParameters * nppParams = NppParameters::getInstance();
|
|
||||||
generic_string nppPath = nppParams->getNppPath();
|
|
||||||
generic_string pluginsFullPathFilter = (dir && dir[0])?dir:nppPath;
|
|
||||||
|
|
||||||
pluginsFullPathFilter += TEXT("\\plugins\\*.dll");
|
|
||||||
|
|
||||||
WIN32_FIND_DATA foundData;
|
|
||||||
HANDLE hFindFile = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
|
|
||||||
if (hFindFile != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
generic_string plugins1stFullPath = (dir && dir[0])?dir:nppPath;
|
|
||||||
plugins1stFullPath += TEXT("\\plugins\\");
|
|
||||||
plugins1stFullPath += foundData.cFileName;
|
|
||||||
dllNames.push_back(plugins1stFullPath);
|
|
||||||
|
|
||||||
while (::FindNextFile(hFindFile, &foundData))
|
|
||||||
{
|
|
||||||
bool isInBlackList = nppParams->isInBlackList(foundData.cFileName);
|
|
||||||
if (!isInBlackList)
|
|
||||||
{
|
|
||||||
generic_string fullPath = (dir && dir[0])?dir:nppPath;
|
|
||||||
fullPath += TEXT("\\plugins\\");
|
|
||||||
|
|
||||||
fullPath += foundData.cFileName;
|
|
||||||
dllNames.push_back(fullPath);
|
|
||||||
}
|
|
||||||
PluginList & pl = nppParams->getPluginList();
|
|
||||||
pl.add(foundData.cFileName, isInBlackList);
|
|
||||||
}
|
|
||||||
::FindClose(hFindFile);
|
|
||||||
|
|
||||||
|
|
||||||
for (size_t i = 0, len = dllNames.size(); i < len ; ++i)
|
|
||||||
{
|
|
||||||
loadPlugin(dllNames[i].c_str(), dll2Remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t j = 0, len = dll2Remove.size() ; j < len ; ++j)
|
|
||||||
::DeleteFile(dll2Remove[j].c_str());
|
|
||||||
|
|
||||||
std::sort(_pluginInfos.begin(), _pluginInfos.end(), [](const PluginInfo *a, const PluginInfo *b) { return a->_funcName < b->_funcName; });
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
bool PluginsManager::loadPluginsV2(const TCHAR* dir)
|
||||||
{
|
{
|
||||||
if (_isDisabled)
|
if (_isDisabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
vector<generic_string> dllNames;
|
vector<generic_string> dllNames;
|
||||||
vector<generic_string> dll2Remove;
|
vector<generic_string> dll2Remove;
|
||||||
|
|
||||||
@ -517,10 +461,6 @@ void PluginsManager::addInMenuFromPMIndex(int i)
|
|||||||
if (_pluginInfos[i]->_funcItems[j]._init2Check)
|
if (_pluginInfos[i]->_funcItems[j]._init2Check)
|
||||||
::CheckMenuItem(_hPluginsMenu, cmdID, MF_BYCOMMAND | MF_CHECKED);
|
::CheckMenuItem(_hPluginsMenu, cmdID, MF_BYCOMMAND | MF_CHECKED);
|
||||||
}
|
}
|
||||||
/*UNLOAD
|
|
||||||
::InsertMenu(_pluginInfos[i]->_pluginMenu, j++, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
|
|
||||||
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION, ID_PLUGINS_REMOVING + i, TEXT("Remove this plugin"));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HMENU PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName, bool enablePluginAdmin)
|
HMENU PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName, bool enablePluginAdmin)
|
||||||
|
@ -100,7 +100,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
||||||
bool loadPlugins(const TCHAR *dir = NULL);
|
|
||||||
bool loadPluginsV2(const TCHAR *dir = NULL);
|
bool loadPluginsV2(const TCHAR *dir = NULL);
|
||||||
|
|
||||||
bool unloadPlugin(int index, HWND nppHandle);
|
bool unloadPlugin(int index, HWND nppHandle);
|
||||||
|
@ -406,19 +406,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
PathAppend(localAppDataNppPluginsDir, TEXT("plugins"));
|
PathAppend(localAppDataNppPluginsDir, TEXT("plugins"));
|
||||||
_pluginsManager.loadPluginsV2(localAppDataNppPluginsDir.c_str());
|
_pluginsManager.loadPluginsV2(localAppDataNppPluginsDir.c_str());
|
||||||
}
|
}
|
||||||
|
else // localConf mode
|
||||||
// obsolet
|
{
|
||||||
bool isLoadFromAppDataAllow = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE;
|
|
||||||
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
|
|
||||||
if (appDataNpp[0] && isLoadFromAppDataAllow)
|
|
||||||
_pluginsManager.loadPlugins(appDataNpp);
|
|
||||||
|
|
||||||
|
|
||||||
// Load plugins from its installation directory.
|
// Load plugins from its installation directory.
|
||||||
// All loaded dll will be ignored
|
// All loaded dll will be ignored
|
||||||
_pluginsManager.loadPluginsV2();
|
_pluginsManager.loadPluginsV2();
|
||||||
_pluginsManager.loadPlugins(); // obsolet
|
}
|
||||||
|
|
||||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user