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\pull/4986/head
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)
|
||||
{
|
||||
if (_isDisabled)
|
||||
return false;
|
||||
|
||||
|
||||
vector<generic_string> dllNames;
|
||||
vector<generic_string> dll2Remove;
|
||||
|
||||
|
@ -517,10 +461,6 @@ void PluginsManager::addInMenuFromPMIndex(int i)
|
|||
if (_pluginInfos[i]->_funcItems[j]._init2Check)
|
||||
::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)
|
||||
|
|
|
@ -100,7 +100,6 @@ public:
|
|||
}
|
||||
|
||||
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
||||
bool loadPlugins(const TCHAR *dir = NULL);
|
||||
bool loadPluginsV2(const TCHAR *dir = NULL);
|
||||
|
||||
bool unloadPlugin(int index, HWND nppHandle);
|
||||
|
|
|
@ -406,19 +406,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||
PathAppend(localAppDataNppPluginsDir, TEXT("plugins"));
|
||||
_pluginsManager.loadPluginsV2(localAppDataNppPluginsDir.c_str());
|
||||
}
|
||||
|
||||
// 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.
|
||||
// All loaded dll will be ignored
|
||||
_pluginsManager.loadPluginsV2();
|
||||
_pluginsManager.loadPlugins(); // obsolet
|
||||
|
||||
else // localConf mode
|
||||
{
|
||||
// Load plugins from its installation directory.
|
||||
// All loaded dll will be ignored
|
||||
_pluginsManager.loadPluginsV2();
|
||||
}
|
||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue