[MODIF_BEHAVIOUR] Make plugins in %APPDATA%/Notepad++/plugins/ override les plugins in Notepad++ installation directory.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@844 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-11-16 23:24:11 +00:00
parent 150304a5a0
commit 6c4eef8cb7
5 changed files with 36 additions and 10 deletions

View File

@ -47,6 +47,10 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove)
{
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
if (isInLoadedDlls(pluginFileName))
return 0;
PluginInfo *pi = new PluginInfo;
try {
pi->_moduleName = PathFindFileName(pluginFilePath);
@ -181,7 +185,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName);
}
addInLoadedDlls(pluginFileName);
_pluginInfos.push_back(pi);
return (_pluginInfos.size() - 1);
} catch(std::exception e) {
@ -217,8 +221,8 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
vector<generic_string> dllNames;
vector<generic_string> dll2Remove;
generic_string nppPath = (NppParameters::getInstance())->getNppPath();
NppParameters * nppParams = NppParameters::getInstance();
generic_string nppPath = nppParams->getNppPath();
generic_string pluginsFullPathFilter = (dir && dir[0])?dir:nppPath;
pluginsFullPathFilter += TEXT("\\plugins\\*.dll");
@ -232,8 +236,6 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
plugins1stFullPath += foundData.cFileName;
dllNames.push_back(plugins1stFullPath);
NppParameters * nppParams = NppParameters::getInstance();
while (::FindNextFile(hFindFile, &foundData))
{
bool isInBlackList = nppParams->isInBlackList(foundData.cFileName);

View File

@ -120,6 +120,7 @@ private:
vector<PluginInfo *> _pluginInfos;
vector<PluginCommand> _pluginsCommands;
vector<generic_string> _loadedDlls;
bool _isDisabled;
IDAllocator _dynamicIDAlloc;
IDAllocator _markerAlloc;
@ -129,6 +130,16 @@ private:
msg += funcSignature;
::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP);
};
bool isInLoadedDlls(const TCHAR *fn) const {
for (size_t i = 0; i < _loadedDlls.size(); i++)
if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0)
return true;
return false;
};
void addInLoadedDlls(const TCHAR *fn) {
_loadedDlls.push_back(fn);
};
};
#define EXT_LEXER_DECL __stdcall

View File

@ -341,11 +341,19 @@ LRESULT Notepad_plus::init(HWND hwnd)
_scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd);
_pluginsManager.init(nppData);
_pluginsManager.loadPlugins();
// Load plugins firstly from "%APPDATA%/Notepad++/plugins"
// if Notepad++ is not in localConf mode.
// All the dll loaded are marked.
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
if (appDataNpp[0])
_pluginsManager.loadPlugins(appDataNpp);
// Load plugins from its installation directory.
// All loaded dll will be ignored
_pluginsManager.loadPlugins();
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);

View File

@ -771,11 +771,11 @@ bool NppParameters::load()
PathAppend(localConfPath, localConfFile);
// Test if localConf.xml exist
bool isLocal = (PathFileExists(localConfPath.c_str()) == TRUE);
_isLocal = (PathFileExists(localConfPath.c_str()) == TRUE);
// Under vista and windows 7, the usage of doLocalConf.xml is not allowed
// if Notepad++ is installed in "program files" directory, because of UAC
if (isLocal)
if (_isLocal)
{
// We check if OS is Vista or above
if (_winVersion >= WV_VISTA)
@ -789,11 +789,11 @@ bool NppParameters::load()
::PathRemoveFileSpec(nppDirLocation);
if (lstrcmp(progPath, nppDirLocation) == 0)
isLocal = false;
_isLocal = false;
}
}
if (isLocal)
if (_isLocal)
{
_userPath = _nppPath;
}

View File

@ -1422,6 +1422,10 @@ public:
_pNativeLangSpeaker = nls;
};
bool isLocal() const {
return _isLocal;
};
private:
NppParameters();
~NppParameters();
@ -1478,6 +1482,7 @@ private:
WNDPROC _transparentFuncAddr;
WNDPROC _enableThemeDialogTextureFuncAddr;
bool _isLocal;
vector<CommandShortcut> _shortcuts; //main menu shortuts. Static size