Plugin Admin (in progress)
This commit is contained in:
parent
67b0ed9b42
commit
1d59e3ed0e
|
@ -71,14 +71,13 @@ void Notepad_plus::command(int id)
|
|||
{
|
||||
fileNew();
|
||||
/*
|
||||
|
||||
bool isFirstTime = not _pluginsAdminDlg.isCreated();
|
||||
_pluginsAdminDlg.setPluginsManager(&_pluginsManager);
|
||||
_pluginsAdminDlg.doDialog(_nativeLangSpeaker.isRTL());
|
||||
if (isFirstTime)
|
||||
{
|
||||
_nativeLangSpeaker.changeConfigLang(_pluginsAdminDlg.getHSelf());
|
||||
_pluginsAdminDlg.getPluginList();
|
||||
_pluginsAdminDlg.downloadPluginList();
|
||||
_pluginsAdminDlg.loadFomList();
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -942,20 +942,30 @@ bool NppParameters::reloadLang()
|
|||
return loadOkay;
|
||||
}
|
||||
|
||||
generic_string NppParameters::getSpecialFolderLocation(int folderKind)
|
||||
{
|
||||
ITEMIDLIST *pidl;
|
||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, folderKind, &pidl);
|
||||
if (!SUCCEEDED( specialLocationResult))
|
||||
return generic_string();
|
||||
|
||||
TCHAR path[MAX_PATH];
|
||||
SHGetPathFromIDList(pidl, path);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
generic_string NppParameters::getSettingsFolder()
|
||||
{
|
||||
if (_isLocal)
|
||||
return _nppPath;
|
||||
|
||||
ITEMIDLIST *pidl;
|
||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
|
||||
if (!SUCCEEDED( specialLocationResult))
|
||||
return generic_string();
|
||||
generic_string settingsFolderPath = getSpecialFolderLocation(CSIDL_APPDATA);
|
||||
|
||||
if (settingsFolderPath.empty())
|
||||
return _nppPath;
|
||||
|
||||
TCHAR tmp[MAX_PATH];
|
||||
SHGetPathFromIDList(pidl, tmp);
|
||||
generic_string settingsFolderPath{tmp};
|
||||
PathAppend(settingsFolderPath, TEXT("Notepad++"));
|
||||
return settingsFolderPath;
|
||||
}
|
||||
|
@ -984,18 +994,12 @@ bool NppParameters::load()
|
|||
// We check if OS is Vista or greater version
|
||||
if (_winVersion >= WV_VISTA)
|
||||
{
|
||||
ITEMIDLIST *pidl;
|
||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidl);
|
||||
if (!SUCCEEDED( specialLocationResult))
|
||||
return false;
|
||||
|
||||
TCHAR progPath[MAX_PATH];
|
||||
SHGetPathFromIDList(pidl, progPath);
|
||||
generic_string progPath = getSpecialFolderLocation(CSIDL_PROGRAM_FILES);
|
||||
TCHAR nppDirLocation[MAX_PATH];
|
||||
lstrcpy(nppDirLocation, _nppPath.c_str());
|
||||
::PathRemoveFileSpec(nppDirLocation);
|
||||
|
||||
if (lstrcmp(progPath, nppDirLocation) == 0)
|
||||
if (progPath == nppDirLocation)
|
||||
_isLocal = false;
|
||||
}
|
||||
}
|
||||
|
@ -1006,14 +1010,7 @@ bool NppParameters::load()
|
|||
}
|
||||
else
|
||||
{
|
||||
ITEMIDLIST *pidl;
|
||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
|
||||
if (!SUCCEEDED( specialLocationResult))
|
||||
return false;
|
||||
|
||||
TCHAR tmp[MAX_PATH];
|
||||
SHGetPathFromIDList(pidl, tmp);
|
||||
_userPath = tmp;
|
||||
_userPath = getSpecialFolderLocation(CSIDL_APPDATA);
|
||||
|
||||
PathAppend(_userPath, TEXT("Notepad++"));
|
||||
_appdataNppDir = _userPath;
|
||||
|
|
|
@ -1550,6 +1550,8 @@ public:
|
|||
}
|
||||
DPIManager _dpiManager;
|
||||
|
||||
generic_string static getSpecialFolderLocation(int folderKind);
|
||||
|
||||
|
||||
private:
|
||||
NppParameters();
|
||||
|
|
|
@ -187,24 +187,11 @@ long PluginsAdminDlg::searchFromCurrentSel(generic_string str2search, bool inWhi
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
// Search only in the list of current panel
|
||||
// return -1 if not found
|
||||
long PluginsAdminDlg::searchPlugin(generic_string str2search, bool isNextMode)
|
||||
{
|
||||
// search in the names of plugins
|
||||
long i = searchInNamesFromCurrentSel(str2search, isNextMode);
|
||||
|
||||
// if not found, search in description
|
||||
if (i == -1)
|
||||
i = searchInDescsFromCurrentSel(str2search, isNextMode);
|
||||
|
||||
return i;
|
||||
}
|
||||
*/
|
||||
|
||||
void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
||||
{
|
||||
// get plugin installation path and launch mode (Admin or normal)
|
||||
collectNppCurrentStatusInfos();
|
||||
|
||||
StaticDialog::create(dialogID, isRTL);
|
||||
|
||||
RECT rect;
|
||||
|
@ -334,11 +321,52 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
|||
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
|
||||
|
||||
goToCenter();
|
||||
}
|
||||
|
||||
void PluginsAdminDlg::collectNppCurrentStatusInfos()
|
||||
{
|
||||
NppParameters *pNppParam = NppParameters::getInstance();
|
||||
_nppCurrentStatus._nppInstallPath = pNppParam->getNppPath();
|
||||
|
||||
_nppCurrentStatus._isAppDataPluginsAllowed = ::SendMessage(_hParent, NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE;
|
||||
_nppCurrentStatus._appdataPath = pNppParam->getAppDataNppDir();
|
||||
generic_string programFilesPath = NppParameters::getSpecialFolderLocation(CSIDL_PROGRAM_FILES);
|
||||
_nppCurrentStatus._isInProgramFiles = (_nppCurrentStatus._nppInstallPath.find(programFilesPath) == 0);
|
||||
|
||||
}
|
||||
|
||||
bool PluginsAdminDlg::getPluginList()
|
||||
bool PluginsAdminDlg::installPlugins()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PluginsAdminDlg::updatePlugins()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PluginsAdminDlg::removePlugins()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PluginsAdminDlg::downloadPluginList()
|
||||
{
|
||||
// check on default location : %APPDATA%\Notepad++\plugins\config\pl\pl.json or NPP_INST_DIR\plugins\config\pl\pl.json
|
||||
|
||||
|
||||
// if absent then download it
|
||||
|
||||
|
||||
// check the update ofpl.json
|
||||
|
||||
|
||||
// download update if present
|
||||
|
||||
// check integrity of pl.json
|
||||
|
||||
// load pl.json
|
||||
|
||||
generic_string pluginListXmlPath(TEXT("c:\\tmp\\pl.xml"));
|
||||
_pPluginsXmlDoc = new TiXmlDocument(pluginListXmlPath);
|
||||
if (not _pPluginsXmlDoc->LoadFile())
|
||||
|
@ -573,6 +601,20 @@ INT_PTR CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||
case IDC_PLUGINADM_RESEARCH_NEXT:
|
||||
searchInPlugins(true);
|
||||
return true;
|
||||
|
||||
case IDC_PLUGINADM_INSTALL:
|
||||
installPlugins();
|
||||
return true;
|
||||
|
||||
case IDC_PLUGINADM_UPDATE:
|
||||
updatePlugins();
|
||||
return true;
|
||||
|
||||
case IDC_PLUGINADM_REMOVE:
|
||||
removePlugins();
|
||||
return true;
|
||||
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,24 @@ struct LoadedPluginInfo
|
|||
LoadedPluginInfo(const generic_string & fullFilePath, const generic_string & filename);
|
||||
};
|
||||
|
||||
struct NppCurrentStatus
|
||||
{
|
||||
bool _isAdminMode; // can launch gitup en Admin mode directly
|
||||
|
||||
bool _isInProgramFiles; // true: install/update/remove on "Program files" (ADMIN MODE)
|
||||
// false: install/update/remove on NPP_INST or install on %APPDATA%, update/remove on %APPDATA% & NPP_INST (NORMAL MODE)
|
||||
|
||||
bool _isAppDataPluginsAllowed; // true: install on %APPDATA%, update / remove on %APPDATA% & "Program files" or NPP_INST
|
||||
|
||||
generic_string _nppInstallPath;
|
||||
generic_string _appdataPath;
|
||||
|
||||
// it should determinate :
|
||||
// 1. deployment location : %ProgramFile% %appdata% %other%
|
||||
// 2. gitup launch mode: ADM ADM NOMAL
|
||||
bool shouldLaunchInAdmMode() { return _isInProgramFiles; };
|
||||
};
|
||||
|
||||
class PluginsAdminDlg final : public StaticDialog
|
||||
{
|
||||
public :
|
||||
|
@ -103,11 +121,14 @@ public :
|
|||
|
||||
void switchDialog(int indexToSwitch);
|
||||
|
||||
bool getPluginList(); // call WinGup fo the 1st time
|
||||
bool downloadPluginList(); // call GitUup for the 1st time
|
||||
bool loadFomList();
|
||||
void setPluginsManager(PluginsManager *pluginsManager) { _pPluginsManager = pluginsManager; };
|
||||
void setAdminMode(bool isAdm) { _nppCurrentStatus._isAdminMode = isAdm; };
|
||||
|
||||
//long searchPlugin(generic_string str2search, bool isNextMode);
|
||||
bool installPlugins();
|
||||
bool updatePlugins();
|
||||
bool removePlugins();
|
||||
|
||||
protected:
|
||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
@ -127,6 +148,9 @@ private :
|
|||
|
||||
std::vector<LoadedPluginInfo> _loadedPluginInfos;
|
||||
|
||||
NppCurrentStatus _nppCurrentStatus;
|
||||
|
||||
void collectNppCurrentStatusInfos();
|
||||
bool readFromXml();
|
||||
bool searchInPlugins(bool isNextMode) const;
|
||||
const bool inNames = true;
|
||||
|
|
Loading…
Reference in New Issue