Fix a plugin installation problem
Add a new plugins loadding behaviour: if it's not doLocalConf mode, then plugins can be loadded from "AppData\Local\Notepad++\plugins\", without presence of "allowAppDataPlugins.xml".
This commit is contained in:
parent
f3c17e9886
commit
3325da03a0
@ -26,8 +26,7 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
#ifndef ENCODINGMAPPER_H
|
||||
#define ENCODINGMAPPER_H
|
||||
#pragma once
|
||||
|
||||
struct EncodingUnit {
|
||||
int _codePage;
|
||||
@ -48,4 +47,3 @@ private:
|
||||
EncodingUnit *_encodings;
|
||||
};
|
||||
|
||||
#endif // ENCODINGMAPPER_H
|
||||
|
@ -235,7 +235,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
|
||||
int tabBarStatus = nppGUI._tabStatus;
|
||||
_toReduceTabBar = ((tabBarStatus & TAB_REDUCE) != 0);
|
||||
int iconDpiDynamicalSize = NppParameters::getInstance()->_dpiManager.scaleY(_toReduceTabBar?13:20);
|
||||
int iconDpiDynamicalSize = pNppParam->_dpiManager.scaleY(_toReduceTabBar?13:20);
|
||||
_docTabIconList.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs, sizeof(docTabIconIDs)/sizeof(int));
|
||||
|
||||
_mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, &_docTabIconList);
|
||||
@ -345,8 +345,8 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
|
||||
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
|
||||
}
|
||||
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(22);
|
||||
int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(45);
|
||||
int tabDpiDynamicalHeight = pNppParam->_dpiManager.scaleY(22);
|
||||
int tabDpiDynamicalWidth = pNppParam->_dpiManager.scaleX(45);
|
||||
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
|
||||
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
|
||||
}
|
||||
@ -370,11 +370,11 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
//--Status Bar Section--//
|
||||
bool willBeShown = nppGUI._statusBarShow;
|
||||
_statusBar.init(_pPublicInterface->getHinst(), hwnd, 6);
|
||||
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, NppParameters::getInstance()->_dpiManager.scaleX(200));
|
||||
_statusBar.setPartWidth(STATUSBAR_CUR_POS, NppParameters::getInstance()->_dpiManager.scaleX(260));
|
||||
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, NppParameters::getInstance()->_dpiManager.scaleX(110));
|
||||
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, NppParameters::getInstance()->_dpiManager.scaleX(120));
|
||||
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, NppParameters::getInstance()->_dpiManager.scaleX(30));
|
||||
_statusBar.setPartWidth(STATUSBAR_DOC_SIZE, pNppParam->_dpiManager.scaleX(200));
|
||||
_statusBar.setPartWidth(STATUSBAR_CUR_POS, pNppParam->_dpiManager.scaleX(260));
|
||||
_statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, pNppParam->_dpiManager.scaleX(110));
|
||||
_statusBar.setPartWidth(STATUSBAR_UNICODE_TYPE, pNppParam->_dpiManager.scaleX(120));
|
||||
_statusBar.setPartWidth(STATUSBAR_TYPING_MODE, pNppParam->_dpiManager.scaleX(30));
|
||||
_statusBar.display(willBeShown);
|
||||
|
||||
_pMainWindow = &_mainDocTab;
|
||||
@ -398,26 +398,26 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
_scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd);
|
||||
_pluginsManager.init(nppData);
|
||||
|
||||
// If Notepad++ is not in localConf mode, load plugins firstly from "%APPDATA%/Notepad++/plugins"
|
||||
// If Notepad++ is not in localConf mode, load plugins firstly from "%APPDATA%/Local/Notepad++/plugins"
|
||||
// All the dll loaded are marked.
|
||||
bool isLoadFromAppDataAllow = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE;
|
||||
|
||||
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
|
||||
if (appDataNpp[0] && isLoadFromAppDataAllow)
|
||||
_pluginsManager.loadPlugins(appDataNpp);
|
||||
|
||||
generic_string localAppDataNppPluginsDir = pNppParam->getLocalAppDataNppDir();
|
||||
if (!localAppDataNppPluginsDir.empty() && isLoadFromAppDataAllow)
|
||||
if (!localAppDataNppPluginsDir.empty() && !pNppParam->isLocal())
|
||||
{
|
||||
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.loadPlugins();
|
||||
_pluginsManager.loadPluginsV2();
|
||||
|
||||
_pluginsManager.loadPlugins(); // obsolet
|
||||
|
||||
_restoreButton.init(_pPublicInterface->getHinst(), hwnd);
|
||||
|
||||
@ -691,13 +691,13 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
// Initialize the default foreground & background color
|
||||
//
|
||||
{
|
||||
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
|
||||
StyleArray & globalStyles = pNppParam->getGlobalStylers();
|
||||
int i = globalStyles.getStylerIndexByID(STYLE_DEFAULT);
|
||||
if (i != -1)
|
||||
{
|
||||
Style & style = globalStyles.getStyler(i);
|
||||
(NppParameters::getInstance())->setCurrentDefaultFgColor(style._fgColor);
|
||||
(NppParameters::getInstance())->setCurrentDefaultBgColor(style._bgColor);
|
||||
pNppParam->setCurrentDefaultFgColor(style._fgColor);
|
||||
pNppParam->setCurrentDefaultBgColor(style._bgColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2263,10 +2263,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
return _pFileSwitcherPanel->isVisible();
|
||||
}
|
||||
|
||||
case NPPM_GETAPPDATAPLUGINSALLOWED:
|
||||
{
|
||||
case NPPM_GETAPPDATAPLUGINSALLOWED: // if doLocal, it's always false - having doLocal environment cannot load plugins outside
|
||||
{ // the presence of file "allowAppDataPlugins.xml" will be checked only when not doLocal
|
||||
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
|
||||
if (appDataNpp[0])
|
||||
if (appDataNpp[0]) // if not doLocal
|
||||
{
|
||||
generic_string allowAppDataPluginsPath(pNppParam->getNppPath());
|
||||
PathAppend(allowAppDataPluginsPath, allowAppDataPluginsFile);
|
||||
|
@ -889,6 +889,12 @@ bool NppParameters::reloadStylers(TCHAR* stylePath)
|
||||
|
||||
bool loadOkay = _pXmlUserStylerDoc->LoadFile();
|
||||
if (!loadOkay)
|
||||
{
|
||||
if (!_pNativeLangSpeaker)
|
||||
{
|
||||
::MessageBox(NULL, stylePathToLoad, TEXT("Load stylers.xml failed"), MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pNativeLangSpeaker->messageBox("LoadStylersFailed",
|
||||
NULL,
|
||||
@ -897,7 +903,7 @@ bool NppParameters::reloadStylers(TCHAR* stylePath)
|
||||
MB_OK,
|
||||
0,
|
||||
stylePathToLoad);
|
||||
|
||||
}
|
||||
delete _pXmlUserStylerDoc;
|
||||
_pXmlUserStylerDoc = NULL;
|
||||
return false;
|
||||
@ -1079,13 +1085,24 @@ bool NppParameters::load()
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
|
||||
if (GetFileAttributesEx(langs_xml_path.c_str(), GetFileExInfoStandard, &attributes) != 0)
|
||||
{
|
||||
if (attributes.nFileSizeLow == 0 && attributes.nFileSizeHigh == 0)
|
||||
{
|
||||
if (_pNativeLangSpeaker)
|
||||
{
|
||||
doRecover = _pNativeLangSpeaker->messageBox("LoadLangsFailed",
|
||||
NULL,
|
||||
TEXT("Load langs.xml failed!\rDo you want to recover your langs.xml?"),
|
||||
TEXT("Configurator"),
|
||||
MB_YESNO);
|
||||
}
|
||||
else
|
||||
{
|
||||
doRecover = ::MessageBox(NULL, TEXT("Load langs.xml failed!\rDo you want to recover your langs.xml?"), TEXT("Configurator"), MB_YESNO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
doRecover = true;
|
||||
|
||||
@ -1101,12 +1118,19 @@ bool NppParameters::load()
|
||||
|
||||
bool loadOkay = _pXmlDoc->LoadFile();
|
||||
if (!loadOkay)
|
||||
{
|
||||
if (_pNativeLangSpeaker)
|
||||
{
|
||||
_pNativeLangSpeaker->messageBox("LoadLangsFailedFinal",
|
||||
NULL,
|
||||
TEXT("Load langs.xml failed!"),
|
||||
TEXT("Configurator"),
|
||||
MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
::MessageBox(NULL, TEXT("Load langs.xml failed!"), TEXT("Configurator"), MB_OK);
|
||||
}
|
||||
|
||||
delete _pXmlDoc;
|
||||
_pXmlDoc = nullptr;
|
||||
@ -1162,6 +1186,8 @@ bool NppParameters::load()
|
||||
|
||||
loadOkay = _pXmlUserStylerDoc->LoadFile();
|
||||
if (!loadOkay)
|
||||
{
|
||||
if (_pNativeLangSpeaker)
|
||||
{
|
||||
_pNativeLangSpeaker->messageBox("LoadStylersFailed",
|
||||
NULL,
|
||||
@ -1170,7 +1196,11 @@ bool NppParameters::load()
|
||||
MB_OK,
|
||||
0,
|
||||
_stylerPath.c_str());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
::MessageBox(NULL, _stylerPath.c_str(), TEXT("Load stylers.xml failed"), MB_OK);
|
||||
}
|
||||
delete _pXmlUserStylerDoc;
|
||||
_pXmlUserStylerDoc = NULL;
|
||||
isAllLaoded = false;
|
||||
|
@ -26,8 +26,7 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
#ifndef FILEBROWSER_H
|
||||
#define FILEBROWSER_H
|
||||
#pragma once
|
||||
|
||||
//#include <windows.h>
|
||||
#ifndef DOCKINGDLGINTERFACE_H
|
||||
@ -179,5 +178,3 @@ protected:
|
||||
void getDirectoryStructure(const TCHAR *dir, const std::vector<generic_string> & patterns, FolderInfo & directoryStructure, bool isRecursive, bool isInHiddenDir);
|
||||
HTREEITEM createFolderItemsFromDirStruct(HTREEITEM hParentItem, const FolderInfo & directoryStructure);
|
||||
};
|
||||
|
||||
#endif // FILEBROWSER_H
|
||||
|
@ -384,8 +384,18 @@ bool PluginsAdminDlg::installPlugins()
|
||||
vector<PluginUpdateInfo*> puis = _availableList.fromUiIndexesToPluginInfos(indexes);
|
||||
|
||||
generic_string updaterParams = TEXT("-unzipTo ");
|
||||
NppParameters *pNppParameters = NppParameters::getInstance();
|
||||
generic_string nppPluginsDir;
|
||||
|
||||
if (pNppParameters->isLocal())
|
||||
{
|
||||
nppPluginsDir = pNppParameters->getNppPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
nppPluginsDir = pNppParameters->getLocalAppDataNppDir();
|
||||
}
|
||||
|
||||
generic_string nppPluginsDir = NppParameters::getInstance()->getUserPath();
|
||||
PathAppend(nppPluginsDir, TEXT("plugins"));
|
||||
|
||||
if (!::PathFileExists(nppPluginsDir.c_str()))
|
||||
@ -393,13 +403,13 @@ bool PluginsAdminDlg::installPlugins()
|
||||
::CreateDirectory(nppPluginsDir.c_str(), NULL);
|
||||
}
|
||||
|
||||
generic_string quoted_nppPluginsDir = TEXT("\"");
|
||||
quoted_nppPluginsDir += nppPluginsDir;
|
||||
quoted_nppPluginsDir += TEXT("\"");
|
||||
|
||||
for (auto i : puis)
|
||||
{
|
||||
// add folder to operate
|
||||
generic_string destFolder = nppPluginsDir;
|
||||
PathAppend(destFolder, i->_folderName);
|
||||
|
||||
updaterParams += destFolder;
|
||||
updaterParams += quoted_nppPluginsDir;
|
||||
|
||||
// add zipFile's url
|
||||
updaterParams += TEXT(" ");
|
||||
@ -407,8 +417,6 @@ bool PluginsAdminDlg::installPlugins()
|
||||
|
||||
Process updater(_updaterFullPath.c_str(), updaterParams.c_str(), _updaterDir.c_str());
|
||||
|
||||
printStr(updaterParams.c_str());
|
||||
printStr(_updaterDir.c_str());
|
||||
int result = updater.runSync();
|
||||
if (result == 0) // wingup return 0 -> OK
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user