Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 127 #130

Merged
merged 2 commits into from
Sep 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: 1.4.11.{build}
image: Visual Studio 2015
image: Visual Studio 2017


environment:
matrix:
- PlatformToolset: v120_xp
#- PlatformToolset: v120_xp
- PlatformToolset: v140_xp
#- PlatformToolset: v141_xp

platform:
- x64
Expand All @@ -19,8 +20,14 @@ configuration:
install:
- git submodule -q update --init
- if "%platform%"=="x64" set archi=amd64
- if "%platform%"=="x64" set platform_input=x64

- if "%platform%"=="Win32" set archi=x86
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi%
- if "%platform%"=="Win32" set platform_input=Win32

- if "%PlatformToolset%"=="v141_xp" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %archi%
- if "%PlatformToolset%"=="v140_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi%
- if "%PlatformToolset%"=="v120_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %archi%

build_script:
- cd "%APPVEYOR_BUILD_FOLDER%"
Expand All @@ -29,12 +36,12 @@ build_script:
- mkdir NotepadTest\x64\plugins
- mkdir NotepadTest\x64\updater
- copy paths.props.appveyor paths.props
- msbuild PluginManager.sln /m /p:configuration="%configuration%" /p:platform="%platform%" /p:PlatformToolset="%PlatformToolset%" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- msbuild PluginManager.sln /m /p:configuration="%configuration%" /p:platform="%platform_input%" /p:PlatformToolset="%PlatformToolset%" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"

after_build:
- cd "%APPVEYOR_BUILD_FOLDER%"
- ps: >-
if ($($env:APPVEYOR_REPO_TAG) -eq "true" -and $env:CONFIGURATION -eq "Release" -and $env:PLATFORMTOOLSET -eq "v120_xp") {
if ($($env:APPVEYOR_REPO_TAG) -eq "true" -and $env:CONFIGURATION -eq "Release" -and $env:PLATFORMTOOLSET -eq "v140_xp") {
if ($env:PLATFORM -eq "x64" -and $env:CONFIGURATION -eq "Release") {
$PluginManagerZipFileName = "PluginManager_$($env:APPVEYOR_REPO_TAG_NAME)_x64.zip"
7z a $PluginManagerZipFileName .\NotepadTest\x64\*
Expand All @@ -60,6 +67,6 @@ deploy:
force_update: true
on:
appveyor_repo_tag: true
PlatformToolset: v120_xp
PlatformToolset: v140_xp
configuration: Release

156 changes: 106 additions & 50 deletions pluginManager/src/PluginList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ BOOL PluginList::checkInstalledPlugins()
_updateablePlugins.clear();
// Check in the default location
checkInstalledPlugins(nppDirectory.c_str(), TRUE);
//added for N++ 7.5.8 subdir feature
checkInstalledPluginsInSubdirs(nppDirectory.c_str(), TRUE);

if (g_options.appDataPluginsSupported)
{
Expand All @@ -452,13 +454,49 @@ BOOL PluginList::checkInstalledPlugins()
{
// No point checking what's installed if we've just created the directory!
checkInstalledPlugins(appDataPluginDir.c_str(), FALSE);
//added for N++ 7.5.8 subdir feature
checkInstalledPluginsInSubdirs(appDataPluginDir.c_str(), FALSE);
}
}
addAvailablePlugins();
return TRUE;
}


BOOL PluginList::checkInstalledPluginsInSubdirs(const TCHAR *pluginPath, BOOL allUsers)
{
tstring pluginsFullPathFilter(pluginPath);

pluginsFullPathFilter += _T("\\*");

WIN32_FIND_DATA foundData;
HANDLE hFindFile = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);

if (hFindFile != INVALID_HANDLE_VALUE)
{
do
{
if ((_tcsncmp(_T("."), foundData.cFileName, 1) != 0) && (_tcsncmp(_T(".."), foundData.cFileName, 2) != 0)
&& (_tcsncmp(_T("APIs"), foundData.cFileName, 4) != 0) && (_tcsncmp(_T("Config"), foundData.cFileName, 6) != 0)
&& (_tcsncmp(_T("disabled"), foundData.cFileName, 8) != 0) && (_tcsncmp(_T("doc"), foundData.cFileName, 3) != 0))
{
if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
tstring subDirName(pluginPath);
subDirName += _T("\\");
subDirName += foundData.cFileName;

checkInstalledPlugins(subDirName.c_str(), allUsers);
}
}
} while (::FindNextFile(hFindFile, &foundData));

FindClose(hFindFile);
}

return TRUE;
}

BOOL PluginList::checkInstalledPlugins(const TCHAR *pluginPath, BOOL allUsers)
{
tstring pluginsFullPathFilter(pluginPath);
Expand Down Expand Up @@ -707,9 +745,9 @@ BOOL PluginList::setInstalledVersion(tstring pluginFilename, Plugin* plugin)
UINT cbFileInfo;

VerQueryValue(buffer,
_T("\\"),
(LPVOID*)&lpFileInfo,
&cbFileInfo);
_T("\\"),
(LPVOID*)&lpFileInfo,
&cbFileInfo);

if (cbFileInfo)
{
Expand Down Expand Up @@ -889,7 +927,7 @@ void PluginList::downloadList()


// Download the plugins.xml from the repository
CancelToken cancelToken;
CancelToken cancelToken;
DownloadManager downloadManager(cancelToken);
tstring contentType;
TCHAR hashBuffer[(MD5LEN * 2) + 1];
Expand Down Expand Up @@ -929,20 +967,20 @@ void PluginList::downloadList()
if (!g_options.downloadUrl.empty())
{
downloadSuccess = downloadManager.getUrl(g_options.downloadUrl.c_str(), pluginsListFilename, contentType, &g_options.moduleInfo);
/*
tstring unzipPath(pluginConfig);
/*
tstring unzipPath(pluginConfig);
unzipPath.append(_T("\\"));
Decompress::unzip(pluginsListZipFilename, unzipPath);
*/
*/
}
else
#endif
{
// OSes less than vista don't support SNI, which cloudflare uses to support HTTPS, so we have to use HTTP on old OSes
TCHAR *pluginsUrl = getPluginsUrl();
// OSes less than vista don't support SNI, which cloudflare uses to support HTTPS, so we have to use HTTP on old OSes
TCHAR *pluginsUrl = getPluginsUrl();
downloadSuccess = downloadManager.getUrl(pluginsUrl, pluginsListZipFilename, contentType, &g_options.moduleInfo);

if (downloadSuccess) {
if (downloadSuccess) {
// Unzip the plugins.zip to PluginManagerPlugins.xml
tstring unzipPath(pluginConfig);
unzipPath.append(_T("\\"));
Expand All @@ -962,42 +1000,42 @@ void PluginList::downloadList()

::SetEvent(_hListsAvailableEvent);
} else {
MessageBox(_nppData->_nppHandle, _T("There was an error downloading the plugin list. Please check your internet connection, and your proxy settings in Internet Explorer, Edge or Chrome"),
MessageBox(_nppData->_nppHandle, _T("There was an error downloading the plugin list. Please check your internet connection, and your proxy settings in Internet Explorer, Edge or Chrome"),
_T("Download Error"), MB_ICONERROR);
}

}

TCHAR* PluginList::getPluginsMd5Url() {
if (g_options.useDevPluginList) {
return DEV_PLUGINS_MD5_URL;
if (g_options.useDevPluginList) {
return DEV_PLUGINS_MD5_URL;
}

if (g_options.forceHttp || g_winVer < WV_VISTA) {
return PLUGINS_HTTP_MD5_URL;
if (g_options.forceHttp || g_winVer < WV_VISTA) {
return PLUGINS_HTTP_MD5_URL;
}

return PLUGINS_MD5_URL;
}

TCHAR* PluginList::getPluginsUrl() {
if (g_options.useDevPluginList) {
return DEV_PLUGINS_URL;
if (g_options.useDevPluginList) {
return DEV_PLUGINS_URL;
}

if (g_options.forceHttp || g_winVer < WV_VISTA) {
return PLUGINS_HTTP_URL;
if (g_options.forceHttp || g_winVer < WV_VISTA) {
return PLUGINS_HTTP_URL;
}

return PLUGINS_URL;
}

TCHAR* PluginList::getValidateUrl() {
if (g_options.useDevPluginList) {
return DEV_VALIDATE_BASE_URL;
if (g_options.useDevPluginList) {
return DEV_VALIDATE_BASE_URL;
}

if (g_options.forceHttp || g_winVer < WV_VISTA) {
if (g_options.forceHttp || g_winVer < WV_VISTA) {
return VALIDATE_BASE_HTTP_URL;
}

Expand Down Expand Up @@ -1227,8 +1265,6 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
* replace="false" (default) on the actual plugin file copy step
*/

TiXmlElement* removeElement = new TiXmlElement(_T("delete"));

tstring fullFilename;
if ((*pluginIter)->getInstalledForAllUsers())
{
Expand All @@ -1242,20 +1278,40 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
}

fullFilename.push_back(_T('\\'));
fullFilename.append((*pluginIter)->getFilename());

removeElement->SetAttribute(_T("file"), fullFilename.c_str());
installElement->LinkEndChild(removeElement);
tstring pluginFilename = (*pluginIter)->getFilename();
tstring fullFilenameForExistanceTest = fullFilename;
fullFilenameForExistanceTest.append(pluginFilename);
if (::PathFileExists(fullFilenameForExistanceTest.c_str()))
{
TiXmlElement* removeElement = new TiXmlElement(_T("delete"));
removeElement->SetAttribute(_T("file"), fullFilenameForExistanceTest.c_str());
installElement->LinkEndChild(removeElement);
}

//since N++ 7.5.8 plugin dlls could be also at path with pluginname as dir name
//delete both plugin dlls if they exist before the update
tstring fullFilenameForExistanceTestInSubdir = fullFilename;
tstring pluginFilenameCopy = pluginFilename;
//erase ".dll" from plugin filename and use as subdir name
tstring pluginSubPath = pluginFilenameCopy.erase((pluginFilename.length() - 4), pluginFilename.length());
fullFilenameForExistanceTestInSubdir.append(pluginSubPath);
fullFilenameForExistanceTestInSubdir.push_back(_T('\\'));
fullFilenameForExistanceTestInSubdir.append(pluginFilename);
if (::PathFileExists(fullFilenameForExistanceTestInSubdir.c_str()))
{
TiXmlElement* removeSubDirElement = new TiXmlElement(_T("delete"));
removeSubDirElement->SetAttribute(_T("file"), fullFilenameForExistanceTestInSubdir.c_str());
installElement->LinkEndChild(removeSubDirElement);
}
}

InstallStatus status = (*pluginIter)->install(pluginTemp, installElement,
std::bind(&ProgressDialog::setCurrentStatus, progressDialog, _1),
std::bind(&ProgressDialog::setStepProgress, progressDialog, _1),
std::bind(&ProgressDialog::stepComplete, progressDialog),
&g_options.moduleInfo,
_variableHandler,
cancelToken);
_variableHandler,
cancelToken);

switch(status)
{
Expand Down Expand Up @@ -1388,8 +1444,8 @@ void PluginList::removePlugins(HWND hMessageBoxParent, ProgressDialog* progressD
std::bind(&ProgressDialog::setStepProgress, progressDialog, _1),
std::bind(&ProgressDialog::stepComplete, progressDialog),
&g_options.moduleInfo,
_variableHandler,
cancelToken);
_variableHandler,
cancelToken);
++pluginIter;
}

Expand Down Expand Up @@ -1426,17 +1482,17 @@ struct InstallParam
{
PluginList* pluginList;
PluginListView* pluginListView;
ProgressDialog* progressDialog;
ProgressDialog* progressDialog;
HWND hMessageBoxParent;
BOOL isUpdate;
CancelToken cancelToken;
CancelToken cancelToken;
};

void PluginList::startInstall(HWND hMessageBoxParent,
ProgressDialog* progressDialog,
PluginListView *pluginListView,
BOOL isUpdate,
CancelToken& cancelToken)
ProgressDialog* progressDialog,
PluginListView *pluginListView,
BOOL isUpdate,
CancelToken& cancelToken)
{
InstallParam *ip = new InstallParam;

Expand All @@ -1445,7 +1501,7 @@ void PluginList::startInstall(HWND hMessageBoxParent,
ip->pluginList = this;
ip->isUpdate = isUpdate;
ip->hMessageBoxParent = hMessageBoxParent;
ip->cancelToken = cancelToken;
ip->cancelToken = cancelToken;

(void)::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)PluginList::installThreadProc,
(LPVOID)ip, 0, 0);
Expand All @@ -1457,10 +1513,10 @@ UINT PluginList::installThreadProc(LPVOID param)
InstallParam *ip = reinterpret_cast<InstallParam*>(param);

ip->pluginList->installPlugins(ip->hMessageBoxParent,
ip->progressDialog,
ip->pluginListView,
ip->isUpdate,
ip->cancelToken);
ip->progressDialog,
ip->pluginListView,
ip->isUpdate,
ip->cancelToken);

// clean up the parameter
delete ip;
Expand All @@ -1472,17 +1528,17 @@ UINT PluginList::installThreadProc(LPVOID param)


void PluginList::startRemove(HWND hMessageBoxParent,
ProgressDialog* progressDialog,
PluginListView *pluginListView,
CancelToken& cancelToken)
ProgressDialog* progressDialog,
PluginListView *pluginListView,
CancelToken& cancelToken)
{
InstallParam *ip = new InstallParam;

ip->pluginListView = pluginListView;
ip->progressDialog = progressDialog;
ip->pluginList = this;
ip->hMessageBoxParent = hMessageBoxParent;
ip->cancelToken = cancelToken;
ip->cancelToken = cancelToken;

(void)::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)PluginList::removeThreadProc,
(LPVOID)ip, 0, 0);
Expand All @@ -1493,9 +1549,9 @@ UINT PluginList::removeThreadProc(LPVOID param)
InstallParam *ip = reinterpret_cast<InstallParam*>(param);

ip->pluginList->removePlugins(ip->hMessageBoxParent,
ip->progressDialog,
ip->pluginListView,
ip->cancelToken);
ip->progressDialog,
ip->pluginListView,
ip->cancelToken);

// clean up the parameter
delete ip;
Expand Down
Loading