[NEW_FEATURE] Add plugin Black list.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@547 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/x64
Don Ho 15 years ago
parent 2478059b5d
commit b45df0db24

@ -232,12 +232,21 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
plugins1stFullPath += foundData.cFileName;
dllNames.push_back(plugins1stFullPath);
NppParameters * nppParams = NppParameters::getInstance();
while (::FindNextFile(hFindFile, &foundData))
{
generic_string fullPath = (dir && dir[0])?dir:nppPath;
fullPath += TEXT("\\plugins\\");
fullPath += foundData.cFileName;
dllNames.push_back(fullPath);
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);

@ -515,7 +515,7 @@ int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion
NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserStylerDoc(NULL),\
_pXmlUserLangDoc(NULL), /*_pXmlNativeLangDoc(NULL), */_pXmlNativeLangDocA(NULL),\
_nbLang(0), _nbFile(0), _nbMaxFile(10), _pXmlToolIconsDoc(NULL),\
_pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL),\
_pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL), _pXmlBlacklistDoc(NULL),\
_nbUserLang(0), _nbExternalLang(0), _hUser32(NULL), _hUXTheme(NULL),\
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
@ -950,6 +950,22 @@ bool NppParameters::load()
_pXmlSessionDoc = NULL;
}
//------------------------------//
// blacklist.xml : for per user //
//------------------------------//
_blacklistPath = _userPath;
PathAppend(_blacklistPath, TEXT("blacklist.xml"));
if (PathFileExists(_blacklistPath.c_str()))
{
_pXmlBlacklistDoc = new TiXmlDocument(_blacklistPath);
loadOkay = _pXmlBlacklistDoc->LoadFile();
if (loadOkay)
{
getBlackListFromXmlTree();
}
}
return isAllLaoded;
}
@ -989,6 +1005,9 @@ void NppParameters::destroyInstance()
if (_pXmlSessionDoc)
delete _pXmlSessionDoc;
if (_pXmlBlacklistDoc)
delete _pXmlBlacklistDoc;
delete _pSelf;
}
@ -1152,6 +1171,18 @@ bool NppParameters::getScintKeysFromXmlTree()
return true;
}
bool NppParameters::getBlackListFromXmlTree()
{
if (!_pXmlBlacklistDoc)
return false;
TiXmlNode *root = _pXmlBlacklistDoc->FirstChild(TEXT("NotepadPlus"));
if (!root)
return false;
return feedBlacklist(root);
}
void NppParameters::initMenuKeys()
{
int nrCommands = sizeof(winKeyDefs)/sizeof(WinMenuKeyDefinition);
@ -1819,6 +1850,24 @@ void NppParameters::feedScintKeys(TiXmlNode *node)
}
}
bool NppParameters::feedBlacklist(TiXmlNode *node)
{
TiXmlNode *blackListRoot = node->FirstChildElement(TEXT("PluginBlackList"));
if (!blackListRoot) return false;
for (TiXmlNode *childNode = blackListRoot->FirstChildElement(TEXT("Plugin"));
childNode ;
childNode = childNode->NextSibling(TEXT("Plugin")) )
{
const TCHAR *name = (childNode->ToElement())->Attribute(TEXT("name"));
if (name)
{
_blacklist.push_back(name);
}
}
return true;
}
bool NppParameters::getShortcuts(TiXmlNode *node, Shortcut & sc)
{
if (!node) return false;

@ -1063,8 +1063,16 @@ private :
generic_string _stylesXmlPath;
};
const int NB_LANG = 80;
class PluginList {
public :
void add(generic_string fn, bool isInBL){
_list.push_back(pair<generic_string, bool>(fn, isInBL));
};
private :
vector<pair<generic_string, bool>>_list;
};
const int NB_LANG = 80;
const bool DUP = true;
const bool FREE = false;
@ -1393,6 +1401,17 @@ public:
return _themeSwitcher;
};
vector<generic_string> & getBlackList() {return _blacklist;};
bool isInBlackList(TCHAR *fn) {
for (size_t i = 0 ; i < _blacklist.size() ; i++)
if (_blacklist[i] == fn)
return true;
return false;
};
PluginList & getPluginList() {return _pluginList;};
private:
NppParameters();
~NppParameters();
@ -1400,7 +1419,8 @@ private:
static NppParameters *_pSelf;
TiXmlDocument *_pXmlDoc, *_pXmlUserDoc, *_pXmlUserStylerDoc, *_pXmlUserLangDoc,\
*_pXmlToolIconsDoc, *_pXmlShortcutDoc, *_pXmlContextMenuDoc, *_pXmlSessionDoc;
*_pXmlToolIconsDoc, *_pXmlShortcutDoc, *_pXmlContextMenuDoc, *_pXmlSessionDoc,\
*_pXmlBlacklistDoc;
TiXmlDocumentA *_pXmlNativeLangDocA;
@ -1432,6 +1452,8 @@ private:
StyleArray _widgetStyleArray;
vector<generic_string> _fontlist;
vector<generic_string> _blacklist;
PluginList _pluginList;
HMODULE _hUser32;
HMODULE _hUXTheme;
@ -1461,6 +1483,7 @@ private:
generic_string _shortcutsPath;
generic_string _contextMenuPath;
generic_string _sessionPath;
generic_string _blacklistPath;
generic_string _nppPath;
generic_string _userPath;
generic_string _stylerPath;
@ -1502,6 +1525,7 @@ private:
bool getPluginCmdsFromXmlTree();
bool getScintKeysFromXmlTree();
bool getSessionFromXmlTree(TiXmlDocument *pSessionDoc = NULL, Session *session = NULL);
bool getBlackListFromXmlTree();
void feedGUIParameters(TiXmlNode *node);
void feedKeyWordsParameters(TiXmlNode *node);
@ -1524,6 +1548,7 @@ private:
void feedUserCmds(TiXmlNode *node);
void feedPluginCustomizedCmds(TiXmlNode *node);
void feedScintKeys(TiXmlNode *node);
bool feedBlacklist(TiXmlNode *node);
void getActions(TiXmlNode *node, Macro & macro);
bool getShortcuts(TiXmlNode *node, Shortcut & sc);

Loading…
Cancel
Save