mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-24 22:34:54 +02:00
Plugin Admin (in progress)
This commit is contained in:
parent
67b0ed9b42
commit
1d59e3ed0e
@ -71,14 +71,13 @@ void Notepad_plus::command(int id)
|
|||||||
{
|
{
|
||||||
fileNew();
|
fileNew();
|
||||||
/*
|
/*
|
||||||
|
|
||||||
bool isFirstTime = not _pluginsAdminDlg.isCreated();
|
bool isFirstTime = not _pluginsAdminDlg.isCreated();
|
||||||
_pluginsAdminDlg.setPluginsManager(&_pluginsManager);
|
_pluginsAdminDlg.setPluginsManager(&_pluginsManager);
|
||||||
_pluginsAdminDlg.doDialog(_nativeLangSpeaker.isRTL());
|
_pluginsAdminDlg.doDialog(_nativeLangSpeaker.isRTL());
|
||||||
if (isFirstTime)
|
if (isFirstTime)
|
||||||
{
|
{
|
||||||
_nativeLangSpeaker.changeConfigLang(_pluginsAdminDlg.getHSelf());
|
_nativeLangSpeaker.changeConfigLang(_pluginsAdminDlg.getHSelf());
|
||||||
_pluginsAdminDlg.getPluginList();
|
_pluginsAdminDlg.downloadPluginList();
|
||||||
_pluginsAdminDlg.loadFomList();
|
_pluginsAdminDlg.loadFomList();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -942,20 +942,30 @@ bool NppParameters::reloadLang()
|
|||||||
return loadOkay;
|
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()
|
generic_string NppParameters::getSettingsFolder()
|
||||||
{
|
{
|
||||||
if (_isLocal)
|
if (_isLocal)
|
||||||
return _nppPath;
|
return _nppPath;
|
||||||
|
|
||||||
ITEMIDLIST *pidl;
|
generic_string settingsFolderPath = getSpecialFolderLocation(CSIDL_APPDATA);
|
||||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
|
|
||||||
if (!SUCCEEDED( specialLocationResult))
|
if (settingsFolderPath.empty())
|
||||||
return generic_string();
|
return _nppPath;
|
||||||
|
|
||||||
TCHAR tmp[MAX_PATH];
|
|
||||||
SHGetPathFromIDList(pidl, tmp);
|
|
||||||
generic_string settingsFolderPath{tmp};
|
|
||||||
PathAppend(settingsFolderPath, TEXT("Notepad++"));
|
PathAppend(settingsFolderPath, TEXT("Notepad++"));
|
||||||
return settingsFolderPath;
|
return settingsFolderPath;
|
||||||
}
|
}
|
||||||
@ -984,18 +994,12 @@ bool NppParameters::load()
|
|||||||
// We check if OS is Vista or greater version
|
// We check if OS is Vista or greater version
|
||||||
if (_winVersion >= WV_VISTA)
|
if (_winVersion >= WV_VISTA)
|
||||||
{
|
{
|
||||||
ITEMIDLIST *pidl;
|
generic_string progPath = getSpecialFolderLocation(CSIDL_PROGRAM_FILES);
|
||||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidl);
|
|
||||||
if (!SUCCEEDED( specialLocationResult))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TCHAR progPath[MAX_PATH];
|
|
||||||
SHGetPathFromIDList(pidl, progPath);
|
|
||||||
TCHAR nppDirLocation[MAX_PATH];
|
TCHAR nppDirLocation[MAX_PATH];
|
||||||
lstrcpy(nppDirLocation, _nppPath.c_str());
|
lstrcpy(nppDirLocation, _nppPath.c_str());
|
||||||
::PathRemoveFileSpec(nppDirLocation);
|
::PathRemoveFileSpec(nppDirLocation);
|
||||||
|
|
||||||
if (lstrcmp(progPath, nppDirLocation) == 0)
|
if (progPath == nppDirLocation)
|
||||||
_isLocal = false;
|
_isLocal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,14 +1010,7 @@ bool NppParameters::load()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ITEMIDLIST *pidl;
|
_userPath = getSpecialFolderLocation(CSIDL_APPDATA);
|
||||||
const HRESULT specialLocationResult = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
|
|
||||||
if (!SUCCEEDED( specialLocationResult))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TCHAR tmp[MAX_PATH];
|
|
||||||
SHGetPathFromIDList(pidl, tmp);
|
|
||||||
_userPath = tmp;
|
|
||||||
|
|
||||||
PathAppend(_userPath, TEXT("Notepad++"));
|
PathAppend(_userPath, TEXT("Notepad++"));
|
||||||
_appdataNppDir = _userPath;
|
_appdataNppDir = _userPath;
|
||||||
|
@ -1550,6 +1550,8 @@ public:
|
|||||||
}
|
}
|
||||||
DPIManager _dpiManager;
|
DPIManager _dpiManager;
|
||||||
|
|
||||||
|
generic_string static getSpecialFolderLocation(int folderKind);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NppParameters();
|
NppParameters();
|
||||||
|
@ -187,24 +187,11 @@ long PluginsAdminDlg::searchFromCurrentSel(generic_string str2search, bool inWhi
|
|||||||
return -1;
|
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)
|
void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
||||||
{
|
{
|
||||||
|
// get plugin installation path and launch mode (Admin or normal)
|
||||||
|
collectNppCurrentStatusInfos();
|
||||||
|
|
||||||
StaticDialog::create(dialogID, isRTL);
|
StaticDialog::create(dialogID, isRTL);
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
@ -334,11 +321,52 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
|||||||
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
|
enableDlgTheme(_hSelf, ETDT_ENABLETAB);
|
||||||
|
|
||||||
goToCenter();
|
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"));
|
generic_string pluginListXmlPath(TEXT("c:\\tmp\\pl.xml"));
|
||||||
_pPluginsXmlDoc = new TiXmlDocument(pluginListXmlPath);
|
_pPluginsXmlDoc = new TiXmlDocument(pluginListXmlPath);
|
||||||
if (not _pPluginsXmlDoc->LoadFile())
|
if (not _pPluginsXmlDoc->LoadFile())
|
||||||
@ -573,6 +601,20 @@ INT_PTR CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
case IDC_PLUGINADM_RESEARCH_NEXT:
|
case IDC_PLUGINADM_RESEARCH_NEXT:
|
||||||
searchInPlugins(true);
|
searchInPlugins(true);
|
||||||
return 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 :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,24 @@ struct LoadedPluginInfo
|
|||||||
LoadedPluginInfo(const generic_string & fullFilePath, const generic_string & filename);
|
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
|
class PluginsAdminDlg final : public StaticDialog
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
@ -103,11 +121,14 @@ public :
|
|||||||
|
|
||||||
void switchDialog(int indexToSwitch);
|
void switchDialog(int indexToSwitch);
|
||||||
|
|
||||||
bool getPluginList(); // call WinGup fo the 1st time
|
bool downloadPluginList(); // call GitUup for the 1st time
|
||||||
bool loadFomList();
|
bool loadFomList();
|
||||||
void setPluginsManager(PluginsManager *pluginsManager) { _pPluginsManager = pluginsManager; };
|
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:
|
protected:
|
||||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
@ -127,6 +148,9 @@ private :
|
|||||||
|
|
||||||
std::vector<LoadedPluginInfo> _loadedPluginInfos;
|
std::vector<LoadedPluginInfo> _loadedPluginInfos;
|
||||||
|
|
||||||
|
NppCurrentStatus _nppCurrentStatus;
|
||||||
|
|
||||||
|
void collectNppCurrentStatusInfos();
|
||||||
bool readFromXml();
|
bool readFromXml();
|
||||||
bool searchInPlugins(bool isNextMode) const;
|
bool searchInPlugins(bool isNextMode) const;
|
||||||
const bool inNames = true;
|
const bool inNames = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user