Add Npp Pugin List update capacity (in progress)

This commit is contained in:
Don HO 2019-08-13 23:51:05 +02:00
parent 938dae9b2a
commit f80b0ed293
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -410,12 +410,13 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
NppParameters *pNppParameters = NppParameters::getInstance(); NppParameters *pNppParameters = NppParameters::getInstance();
NppGUI & nppGui = const_cast<NppGUI &>(pNppParameters->getNppGUI()); NppGUI & nppGui = const_cast<NppGUI &>(pNppParameters->getNppGUI());
bool doUpdate = nppGui._autoUpdateOpt._doAutoUpdate; bool doUpdateNpp = nppGui._autoUpdateOpt._doAutoUpdate;
bool doUpdatePluginList = nppGui._autoUpdateOpt._doAutoUpdate;
if (doFunctionListExport || doPrintAndQuit) // export functionlist feature will serialize fuctionlist on the disk, then exit Notepad++. So it's important to not launch into existing instance, and keep it silent. if (doFunctionListExport || doPrintAndQuit) // export functionlist feature will serialize fuctionlist on the disk, then exit Notepad++. So it's important to not launch into existing instance, and keep it silent.
{ {
isMultiInst = true; isMultiInst = true;
doUpdate = false; doUpdateNpp = doUpdatePluginList = false;
cmdLineParams._isNoSession = true; cmdLineParams._isNoSession = true;
} }
@ -525,12 +526,17 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE); bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE);
if (doUpdate) // check more detail if (doUpdateNpp) // check more detail
{ {
Date today(0); Date today(0);
if (today < nppGui._autoUpdateOpt._nextUpdateDate) if (today < nppGui._autoUpdateOpt._nextUpdateDate)
doUpdate = false; doUpdateNpp = false;
}
if (doUpdatePluginList)
{
// TODO: detect update frequency
} }
// wingup doesn't work with the obsolet security layer (API) under xp since downloadings are secured with SSL on notepad_plus_plus.org // wingup doesn't work with the obsolet security layer (API) under xp since downloadings are secured with SSL on notepad_plus_plus.org
@ -540,13 +546,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
SecurityGard securityGard; SecurityGard securityGard;
bool isSignatureOK = securityGard.checkModule(updaterFullPath, nm_gup); bool isSignatureOK = securityGard.checkModule(updaterFullPath, nm_gup);
if (TheFirstOne && isUpExist && doUpdate && isGtXP && isSignatureOK) if (TheFirstOne && isUpExist && isGtXP && isSignatureOK)
{ {
if (pNppParameters->isx64()) if (pNppParameters->isx64())
{ {
updaterParams += TEXT(" -px64"); updaterParams += TEXT(" -px64");
} }
if (doUpdateNpp)
{
Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str()); Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str());
updater.run(); updater.run();
@ -556,6 +564,25 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
nppGui._autoUpdateOpt._nextUpdateDate = Date(nppGui._autoUpdateOpt._intervalDays); nppGui._autoUpdateOpt._nextUpdateDate = Date(nppGui._autoUpdateOpt._intervalDays);
} }
// to be removed
doUpdatePluginList = false;
if (doUpdatePluginList)
{
// Update Plugin List
updaterParams += TEXT(" -upPL");
// overrided "InfoUrl" in gup.xml
updaterParams += TEXT(" https://notepad-plus-plus.org/update/pluginListDownloadUrl.php");
Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str());
updater.run();
// TODO: Update next update date
}
}
MSG msg; MSG msg;
msg.wParam = 0; msg.wParam = 0;
Win32Exception::installHandler(); Win32Exception::installHandler();