From 3101a2f39518d1f20975b5929c24c6b43e6ead9f Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 28 Jan 2018 17:42:00 +0100 Subject: [PATCH] Plugins Admin (in progress) --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 1 - .../WinControls/PluginsAdmin/pluginsAdmin.cpp | 64 ++++++++++++++++++- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index a6c0fb45b..770ad3a9e 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -691,7 +691,6 @@ bool FileManager::deleteFile(BufferID id) if (!PathFileExists(fileNamePath.c_str())) return false; - //return ::DeleteFile(fileNamePath) != 0; SHFILEOPSTRUCT fileOpStruct = {0}; fileOpStruct.hwnd = NULL; diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index 3e667a529..acf457140 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -37,6 +37,7 @@ #include "pluginsAdmin.h" #include "ScintillaEditView.h" #include "localization.h" +#include "Processus.h" #include "PluginsManager.h" #include "md5.h" @@ -351,9 +352,30 @@ void PluginsAdminDlg::collectNppCurrentStatusInfos() bool PluginsAdminDlg::installPlugins() { vector indexes = _availableListView.getCheckedIndexes(); + + NppParameters *pNppParameters = NppParameters::getInstance(); + generic_string updaterDir = pNppParameters->getNppPath(); + updaterDir += TEXT("\\updater\\"); + + generic_string updaterFullPath = updaterDir + TEXT("gup.exe"); + generic_string updaterParams = TEXT("-unzipTo -clean "); + for (auto i : indexes) { - printStr(_availablePluginList[i]._name .c_str()); + //printStr(_availablePluginList[i]._name .c_str()); + + // add folder to operate + generic_string destFolder = pNppParameters->getAppDataNppDir(); + PathAppend(destFolder, _availablePluginList[i]._name); + + updaterParams += destFolder; + + // add zipFile's url + updaterParams += TEXT(" "); + updaterParams += _availablePluginList[i]._repository; + + Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str()); + updater.run(); } return true; } @@ -361,9 +383,28 @@ bool PluginsAdminDlg::installPlugins() bool PluginsAdminDlg::updatePlugins() { vector indexes = _updateListView.getCheckedIndexes(); + + NppParameters *pNppParameters = NppParameters::getInstance(); + generic_string updaterDir = pNppParameters->getNppPath(); + updaterDir += TEXT("\\updater\\"); + + generic_string updaterFullPath = updaterDir + TEXT("gup.exe"); + generic_string updaterParams = TEXT("-unzipTo -clean "); + for (auto i : indexes) { - printStr(_updatePluginList[i]._fullFilePath.c_str()); + // add folder to operate + generic_string destFolder = pNppParameters->getAppDataNppDir(); + PathAppend(destFolder, _availablePluginList[i]._name); + + updaterParams += destFolder; + + // add zipFile's url + updaterParams += TEXT(" "); + updaterParams += _availablePluginList[i]._repository; + + Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str()); + updater.run(); } return true; } @@ -371,9 +412,26 @@ bool PluginsAdminDlg::updatePlugins() bool PluginsAdminDlg::removePlugins() { vector indexes = _installedListView.getCheckedIndexes(); + + NppParameters *pNppParameters = NppParameters::getInstance(); + generic_string updaterDir = pNppParameters->getNppPath(); + updaterDir += TEXT("\\updater\\"); + + generic_string updaterFullPath = updaterDir + TEXT("gup.exe"); + generic_string updaterParams = TEXT("-clean "); + for (auto i : indexes) { - printStr(_installedPluginList[i]._fullFilePath.c_str()); + //printStr(_installedPluginList[i]._fullFilePath.c_str()); + + // add folder to operate + generic_string destFolder = pNppParameters->getAppDataNppDir(); + PathAppend(destFolder, _availablePluginList[i]._name); + + updaterParams += destFolder; + + Process updater(updaterFullPath.c_str(), updaterParams.c_str(), updaterDir.c_str()); + updater.run(); } return true; }