Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support for Appdata plugins

Option added to install for all users, if appdata plugins are enabled.
Gpup is only invoked as admin if doing stuff in N++ directory, not if only installing to appdata
Option added to not save proxy credentials
Bug fixed with copystep not returning correct status
GetUrl for string result now has support for proxy-auth
  • Loading branch information...
commit ca5bb3559b31357f52e4928a489d569a0f7d8f29 1 parent b6e528c
@bruderstein authored
View
73 NppPlugin/include/Notepad_plus_msgs.h
@@ -18,18 +18,17 @@
#ifndef NOTEPAD_PLUS_MSGS_H
#define NOTEPAD_PLUS_MSGS_H
-//#include "menuCmdID.h"
-enum LangType {L_TXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
- L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_NFO, L_USER,\
+enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
+ L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
- L_CMAKE, L_YAML,\
+ L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
// The end of enumated language type, so it should be always at the end
L_EXTERNAL};
-enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA};
+enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7};
//#include "deprecatedSymbols.h"
@@ -123,7 +122,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//BOOL NPPM_SWITCHTOFILE(0, TCHAR *filePathName2switch)
#define NPPM_SAVECURRENTFILE (NPPMSG + 38)
- //BOOL WM_SWITCHTOFILE(0, 0)
+ //BOOL NPPM_SAVECURRENTFILE(0, 0)
#define NPPM_SAVEALLFILES (NPPMSG + 39)
//BOOL NPPM_SAVEALLFILES(0, 0)
@@ -192,8 +191,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// returned value : TRUE if tab bar is hidden, otherwise FALSE
#define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57)
- // INT NPPM_GETPOSFROMBUFFERID(INT bufferID, 0)
+ // INT NPPM_GETPOSFROMBUFFERID(INT bufferID, INT priorityView)
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
+ // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
//
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
// Here's the values for the view :
@@ -267,6 +267,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// BOOL NPPM_ADDREBAR(INT ID, 0)
//Use ID assigned with NPPM_ADDREBAR
*/
+
#define NPPM_HIDETOOLBAR (NPPMSG + 70)
// BOOL NPPM_HIDETOOLBAR(0, BOOL hideOrNot)
// if hideOrNot is set as TRUE then tool bar will be hidden
@@ -308,6 +309,57 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// fullPathName2Open indicates the full file path name to be opened.
// The return value is TRUE (1) if the operation is successful, otherwise FALSE (0).
+ #define NPPM_SAVECURRENTFILEAS (NPPMSG + 78)
+ // BOOL NPPM_SAVECURRENTFILEAS (BOOL asCopy, const TCHAR* filename)
+
+ #define NPPM_GETCURRENTNATIVELANGENCODING (NPPMSG + 79)
+ // INT NPPM_GETCURRENTNATIVELANGENCODING(0, 0)
+ // returned value : the current native language enconding
+
+ #define NPPM_ALLOCATESUPPORTED (NPPMSG + 80)
+ // returns TRUE if NPPM_ALLOCATECMDID is supported
+ // Use to identify if subclassing is necessary
+
+ #define NPPM_ALLOCATECMDID (NPPMSG + 81)
+ // BOOL NPPM_ALLOCATECMDID(int numberRequested, int* startNumber)
+ // sets startNumber to the initial command ID if successful
+ // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful
+
+ #define NPPM_ALLOCATEMARKER (NPPMSG + 82)
+ // BOOL NPPM_ALLOCATEMARKER(int numberRequested, int* startNumber)
+ // sets startNumber to the initial command ID if successful
+ // Allocates a marker number to a plugin
+ // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful
+
+ #define NPPM_GETLANGUAGENAME (NPPMSG + 83)
+ // INT NPPM_GETLANGUAGENAME(int langType, TCHAR *langName)
+ // Get programing language name from the given language type (LangType)
+ // Return value is the number of copied character / number of character to copy (\0 is not included)
+ // You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy.
+ // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
+ // by passing allocated buffer as argument langName
+
+ #define NPPM_GETLANGUAGEDESC (NPPMSG + 84)
+ // INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc)
+ // Get programing language short description from the given language type (LangType)
+ // Return value is the number of copied character / number of character to copy (\0 is not included)
+ // You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy.
+ // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
+ // by passing allocated buffer as argument langDesc
+
+ #define NPPM_SHOWDOCSWITCHER (NPPMSG + 85)
+ // VOID NPPM_ISDOCSWITCHERSHOWN(0, BOOL toShowOrNot)
+ // Send this message to show or hide doc switcher.
+ // if toShowOrNot is TRUE then show doc switcher, otherwise hide it.
+
+ #define NPPM_ISDOCSWITCHERSHOWN (NPPMSG + 86)
+ // BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0)
+ // Check to see if doc switcher is shown.
+
+ #define NPPM_GETAPPDATAPLUGINSALLOWED (NPPMSG + 87)
+ // BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0)
+ // Check to see if loading plugins from "%APPDATA%\Notepad++\plugins" is allowed.
+
#define RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
@@ -379,7 +431,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved
- //scnNotification->nmhdr.code = NPPN_FILECLOSED;
+ //scnNotification->nmhdr.code = NPPN_FILESAVED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;
@@ -435,4 +487,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
#define DOCSTAUS_READONLY 1
#define DOCSTAUS_BUFFERDIRTY 2
+ #define NPPN_DOCORDERCHANGED (NPPN_FIRST + 16) // To notify plugins that document order is changed
+ //scnNotification->nmhdr.code = NPPN_DOCORDERCHANGED;
+ //scnNotification->nmhdr.hwndFrom = newIndex;
+ //scnNotification->nmhdr.idFrom = BufferID;
+
#endif //NOTEPAD_PLUS_MSGS_H
View
17 libinstall/include/libinstall/ProxyInfo.h
@@ -4,6 +4,14 @@
#include <curl/curl.h>
+enum SAVECRED
+{
+ SAVECRED_UNKNOWN = 0,
+ SAVECRED_YES = 1,
+ SAVECRED_NO = 2
+};
+
+
class ProxyInfo
{
public:
@@ -12,16 +20,19 @@ class ProxyInfo
void setProxyPort(int proxyPort) { _proxyPort = proxyPort;}
void setUsername(const char *username) { _username = username; }
void setPassword(const char *password) { _password = password; }
-
+ void setSaveCredentials(const SAVECRED saveCredentials) { _saveCred = saveCredentials; }
+
const char *getProxy() { return _proxy.c_str(); }
int getProxyPort() { return _proxyPort; }
- const char *getUsername() { return _username.c_str(); }
- const char *getPassword() { return _password.c_str(); }
+ const char *getUsername() const { return _username.c_str(); }
+ const char *getPassword() const { return _password.c_str(); }
+ const SAVECRED getSaveCredentials() const { return _saveCred; }
private:
std::string _proxy;
int _proxyPort;
+ SAVECRED _saveCred;
std::string _username;
std::string _password;
View
5 libinstall/src/CopyStep.cpp
@@ -126,10 +126,7 @@ StepStatus CopyStep::perform(tstring &basePath, TiXmlElement* forGpup,
return STEPSTATUS_SUCCESS;
}
- copyDirectory(fromPath, toPath, forGpup, setStatus, stepProgress, moduleInfo);
-
-
- return status;
+ return copyDirectory(fromPath, toPath, forGpup, setStatus, stepProgress, moduleInfo);
}
View
36 libinstall/src/DownloadManager.cpp
@@ -115,21 +115,37 @@ BOOL DownloadManager::getUrl(CONST TCHAR *url, string& result, ProxyInfo *proxyI
{
std::tr1::shared_ptr<char> charUrl = WcharMbcsConverter::tchar2char(url);
curl_easy_setopt(_curl, CURLOPT_URL, charUrl.get());
+ CURLcode code;
+ int httpCode = 0;
+ bool cancelClicked = false;
- proxyInfo->setCurlOptions(_curl);
+ do
+ {
+ proxyInfo->setCurlOptions(_curl);
- curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, DownloadManager::curlWriteStringCallback);
- curl_easy_setopt(_curl, CURLOPT_WRITEDATA, &result);
- curl_easy_setopt(_curl, CURLOPT_PROGRESSFUNCTION, DownloadManager::curlProgressCallback);
- curl_easy_setopt(_curl, CURLOPT_PROGRESSDATA, this);
- curl_easy_setopt(_curl, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt(_curl, CURLOPT_FOLLOWLOCATION, 1);
- CURLcode code = curl_easy_perform(_curl);
+ curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, DownloadManager::curlWriteStringCallback);
+ curl_easy_setopt(_curl, CURLOPT_WRITEDATA, &result);
+ curl_easy_setopt(_curl, CURLOPT_PROGRESSFUNCTION, DownloadManager::curlProgressCallback);
+ curl_easy_setopt(_curl, CURLOPT_PROGRESSDATA, this);
+ curl_easy_setopt(_curl, CURLOPT_NOPROGRESS, 0);
+ curl_easy_setopt(_curl, CURLOPT_FOLLOWLOCATION, 1);
+ code = curl_easy_perform(_curl);
+
+ curl_easy_getinfo(_curl, CURLINFO_HTTP_CODE, &httpCode);
- // TODO: Need to check curl_easy_getinfo(HTTP_RESPONSE) for 407 (ProxyAuth)
+ if (httpCode == 407)
+ {
+ ProxyCredentialsDlg proxyCreds;
+ if (!proxyCreds.getCredentials(moduleInfo, proxyInfo))
+ {
+ cancelClicked = true;
+ }
+ }
- if (CURLE_OK == code)
+ } while(cancelClicked == false && (code == CURLE_LOGIN_DENIED || httpCode == 407));
+
+ if (CURLE_OK == code && cancelClicked == false)
return TRUE;
else
return FALSE;
View
18 libinstall/src/ProxyCredentialsDlg.cpp
@@ -88,6 +88,15 @@ void ProxyCredentialsDlg::initialiseCredentials()
::SetFocus(GetDlgItem(_hSelf, IDC_USERNAME));
}
+ if (_proxyInfo->getSaveCredentials() == SAVECRED_UNKNOWN
+ || _proxyInfo->getSaveCredentials() == SAVECRED_YES)
+ {
+ ::SendMessage(GetDlgItem(_hSelf, IDC_SAVECREDS), BM_SETCHECK, BST_CHECKED, 0);
+ }
+ else
+ {
+ ::SendMessage(GetDlgItem(_hSelf, IDC_SAVECREDS), BM_SETCHECK, BST_UNCHECKED, 0);
+ }
}
void ProxyCredentialsDlg::setCredentials()
@@ -99,6 +108,15 @@ void ProxyCredentialsDlg::setCredentials()
::GetWindowTextA(GetDlgItem(_hSelf, IDC_PASSWORD), tmp, MAX_PATH);
_proxyInfo->setPassword(tmp);
+ LRESULT result = ::SendMessage(GetDlgItem(_hSelf, IDC_SAVECREDS), BM_GETCHECK, 0, 0);
+ if (result == BST_CHECKED)
+ {
+ _proxyInfo->setSaveCredentials(SAVECRED_YES);
+ }
+ else
+ {
+ _proxyInfo->setSaveCredentials(SAVECRED_NO);
+ }
}
View
BIN  libinstall/src/libinstall.rc
Binary file not shown
View
BIN  libinstall/src/resource.h
Binary file not shown
View
2  paths.props
@@ -6,7 +6,7 @@
<BoostPath>e:\libs\boost</BoostPath>
<CurlPath>e:\libs\curl-7.19.5</CurlPath>
<ZlibPath>e:\libs\zlib-1.2.3</ZlibPath>
- <TestNotepadPlusPlusUnicode>e:\NotepadTest\unicode</TestNotepadPlusPlusUnicode>
+ <TestNotepadPlusPlusUnicode>E:\NotepadTest\unicodeAppDataPlugins</TestNotepadPlusPlusUnicode>
<TestNotepadPlusPlusAnsi>e:\NotepadTest\ansi</TestNotepadPlusPlusAnsi>
</PropertyGroup>
View
1  pluginManager/projects/2008/PluginManager.vcxproj
@@ -415,6 +415,7 @@ copy "$(TargetPath)" "$(TestNotepadPlusPlusAnsi)\plugins"</Command>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClInclude Include="..\..\..\libinstall\src\resource.h" />
<ClInclude Include="..\..\src\Encrypter.h" />
<ClInclude Include="..\..\src\Plugin.h" />
<ClInclude Include="..\..\src\PluginList.h" />
View
3  pluginManager/projects/2008/PluginManager.vcxproj.filters
@@ -72,6 +72,9 @@
<ClInclude Include="..\..\src\Encrypter.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\libinstall\src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\PluginManager.rc">
View
11 pluginManager/src/Plugin.cpp
@@ -126,6 +126,11 @@ void Plugin::setInstalledVersionFromHash(const tstring &hash)
_isInstalled = TRUE;
}
+void Plugin::setInstalledForAllUsers(BOOL installedForAllUsers)
+{
+ _installedForAllUsers = installedForAllUsers;
+}
+
/* Getters */
tstring& Plugin::getDescription()
@@ -251,6 +256,12 @@ tstring& Plugin::getLatestUpdate()
return _latestUpdate;
}
+BOOL Plugin::getInstalledForAllUsers()
+{
+ return _installedForAllUsers;
+}
+
+
BOOL Plugin::isInstalled()
{
return _isInstalled;
View
4 pluginManager/src/Plugin.h
@@ -56,6 +56,7 @@ class Plugin
void setCategory(const TCHAR* category);
void setLatestUpdate(const TCHAR* latestUpdate);
void setStability(const TCHAR* stability);
+ void setInstalledForAllUsers(BOOL installedForAllUsers);
/* Getters */
tstring& getName();
@@ -68,9 +69,11 @@ class Plugin
tstring& getLatestUpdate();
tstring& getStability();
tstring& getUpdateDescription();
+ BOOL getInstalledForAllUsers();
/* General methods */
BOOL isInstalled();
+
void addVersion(const TCHAR* hash, const PluginVersion &version);
void addBadVersion(const PluginVersion &version, const TCHAR* report);
@@ -118,6 +121,7 @@ class Plugin
BOOL _isInstalled;
BOOL _detailsAdded;
BOOL _updateDetailsAdded;
+ BOOL _installedForAllUsers;
/* Dependencies on other plugins */
std::list<tstring> _dependencies;
View
213 pluginManager/src/PluginList.cpp
@@ -64,7 +64,7 @@ void PluginList::init(NppData *nppData)
_nppData = nppData;
TCHAR configDir[MAX_PATH];
TCHAR nppDir[MAX_PATH];
- TCHAR pluginDir[MAX_PATH];
+ TCHAR allUsersPluginDir[MAX_PATH];
::SendMessage(nppData->_nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, reinterpret_cast<LPARAM>(configDir));
::SendMessage(nppData->_nppHandle, NPPM_GETNPPDIRECTORY, MAX_PATH, reinterpret_cast<LPARAM>(nppDir));
@@ -86,18 +86,46 @@ void PluginList::init(NppData *nppData)
}
_nppVersion = versionString;
-
-
- _tcscpy_s(pluginDir, MAX_PATH, nppDir);
- _tcscat_s(pluginDir, MAX_PATH, _T("\\plugins"));
+
+ _tcscpy_s(allUsersPluginDir, MAX_PATH, nppDir);
+ ::PathAppend(allUsersPluginDir, _T("plugins"));
_variableHandler = new VariableHandler();
_variableHandler->setVariable(_T("NPPDIR"), nppDir);
- _variableHandler->setVariable(_T("PLUGINDIR"), pluginDir);
- _variableHandler->setVariable(_T("CONFIGDIR"), configDir);
+ _variableHandler->setVariable(_T("ALLUSERSPLUGINDIR"), allUsersPluginDir);
+
+ ITEMIDLIST *pidl;
+ HRESULT result = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
+ if (result == S_OK)
+ {
+ TCHAR appDataPluginDir[MAX_PATH];
+
+ if (SHGetPathFromIDList(pidl, appDataPluginDir))
+ {
+ PathAppend(appDataPluginDir, _T("Notepad++\\plugins"));
+ _variableHandler->setVariable(_T("USERPLUGINDIR"), appDataPluginDir);
+ }
+ else
+ {
+ _variableHandler->setVariable(_T("USERPLUGINDIR"), allUsersPluginDir);
+ }
+ }
+ else
+ {
+ _variableHandler->setVariable(_T("USERPLUGINDIR"), allUsersPluginDir);
+ }
+
+ if (g_options.installLocation == INSTALLLOC_APPDATA)
+ {
+ _variableHandler->setVariable(_T("PLUGINDIR"), _variableHandler->getVariable(_T("USERPLUGINDIR")).c_str());
+ }
+ else
+ {
+ _variableHandler->setVariable(_T("PLUGINDIR"), _variableHandler->getVariable(_T("ALLUSERSPLUGINDIR")).c_str());
+ }
+ _variableHandler->setVariable(_T("CONFIGDIR"), configDir);
-
}
@@ -369,14 +397,39 @@ void PluginList::addSteps(Plugin* plugin, TiXmlElement* installElement, InstallO
}
}
+BOOL PluginList::checkInstalledPlugins()
+{
+ const tstring& nppDirectory = _variableHandler->getVariable(_T("ALLUSERSPLUGINDIR"));
+ _installedPlugins.clear();
+ _availablePlugins.clear();
+ _updateablePlugins.clear();
+ // Check in the default location
+ checkInstalledPlugins(nppDirectory.c_str(), TRUE);
+
+ if (g_options.appDataPluginsSupported)
+ {
+ const tstring& appDataPluginDir = _variableHandler->getVariable(_T("USERPLUGINDIR"));
-BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
+ if (!::PathFileExists(appDataPluginDir.c_str()))
+ {
+ DirectoryUtil::createDirectories(appDataPluginDir.c_str());
+ }
+ else
+ {
+ // No point checking what's installed if we've just created the directory!
+ checkInstalledPlugins(appDataPluginDir.c_str(), FALSE);
+ }
+ }
+ addAvailablePlugins();
+ return TRUE;
+}
+
+
+BOOL PluginList::checkInstalledPlugins(const TCHAR *pluginPath, BOOL allUsers)
{
- tstring pluginsFullPathFilter;
+ tstring pluginsFullPathFilter(pluginPath);
- pluginsFullPathFilter.append(pluginPath);
-
- pluginsFullPathFilter += _T("\\plugins\\*.dll");
+ pluginsFullPathFilter += _T("\\*.dll");
WIN32_FIND_DATA foundData;
HANDLE hFindFile = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData);
@@ -388,7 +441,7 @@ BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
{
tstring pluginFilename(pluginPath);
- pluginFilename += _T("\\plugins\\");
+ pluginFilename += _T("\\");
pluginFilename += foundData.cFileName;
BOOL pluginOK = false;
tstring pluginName;
@@ -451,6 +504,8 @@ BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
setInstalledVersion(pluginFilename, plugin);
+ plugin->setInstalledForAllUsers(allUsers);
+
TCHAR hashBuffer[(MD5LEN * 2) + 1];
if (MD5::hash(pluginFilename.c_str(), hashBuffer, (MD5LEN * 2) + 1))
@@ -459,6 +514,44 @@ BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
plugin->setInstalledVersionFromHash(hash);
}
+ // If this is a user's plugin (in AppData), and there's already a version
+ // for all users, and AppData plugins are supported, then remove the
+ // allusers version of the plugin, as the appdata one will take precedence
+ if (g_options.appDataPluginsSupported && FALSE == allUsers)
+ {
+ list<Plugin*>::iterator it = _installedPlugins.begin();
+ while (it != _installedPlugins.end())
+ {
+ if (plugin->getName() == (*it)->getName()
+ && (*it)->getInstalledForAllUsers())
+ {
+ it = _installedPlugins.erase(it);
+ }
+ else
+ {
+ ++it;
+ }
+ }
+
+ // Remove the plugin from updateable plugins too, as whether or not it can be
+ // updated depends on THIS version, not the all users version
+ it = _updateablePlugins.begin();
+ while (it != _updateablePlugins.end())
+ {
+ if (plugin->getName() == (*it)->getName()
+ && (*it)->getInstalledForAllUsers())
+ {
+ it = _updateablePlugins.erase(it);
+ }
+ else
+ {
+ ++it;
+ }
+ }
+
+ }
+
+
if (plugin->getInstalledVersion().getIsBad()
|| plugin->getVersion() > plugin->getInstalledVersion())
_updateablePlugins.push_back(plugin);
@@ -482,17 +575,7 @@ BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
} while(::FindNextFile(hFindFile, &foundData));
- PluginContainer::iterator iter = _plugins.begin();
- while (iter != _plugins.end())
- {
- if (!iter->second->isInstalled())
- {
- if (g_options.showUnstable || iter->second->getStability() == _T("Good"))
- _availablePlugins.push_back(iter->second);
- }
- ++iter;
- }
-
+
}
@@ -500,6 +583,19 @@ BOOL PluginList::checkInstalledPlugins(TCHAR *pluginPath)
return TRUE;
}
+void PluginList::addAvailablePlugins()
+{
+ PluginContainer::iterator iter = _plugins.begin();
+ while (iter != _plugins.end())
+ {
+ if (!iter->second->isInstalled())
+ {
+ if (g_options.showUnstable || iter->second->getStability() == _T("Good"))
+ _availablePlugins.push_back(iter->second);
+ }
+ ++iter;
+ }
+}
tstring PluginList::getPluginName(tstring pluginFilename)
{
@@ -767,10 +863,8 @@ void PluginList::downloadList()
parsePluginFile(pluginsListFilename.c_str());
// Check for what is installed
- TCHAR nppDirectory[MAX_PATH];
- ::SendMessage(_nppData->_nppHandle, NPPM_GETNPPDIRECTORY, MAX_PATH, reinterpret_cast<LPARAM>(nppDirectory));
-
- checkInstalledPlugins(nppDirectory);
+ checkInstalledPlugins();
+
::SetEvent(_hListsAvailableEvent);
@@ -785,7 +879,7 @@ void PluginList::reparseFile(const tstring& pluginsListFilename)
TCHAR nppDirectory[MAX_PATH];
::SendMessage(_nppData->_nppHandle, NPPM_GETNPPDIRECTORY, MAX_PATH, reinterpret_cast<LPARAM>(nppDirectory));
- checkInstalledPlugins(nppDirectory);
+ checkInstalledPlugins();
}
@@ -927,6 +1021,7 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
BOOL somethingInstalled = FALSE;
TCHAR pluginCountChar[10];
+ bool needAdmin = false;
while(pluginIter != selectedPlugins->end())
{
@@ -954,8 +1049,28 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
pluginTemp.append(_T("\\"));
-
- if (isUpgrade)
+ /* If we're upgrading, and
+ either:
+ The current plugin is installed in appdata, and the new one will be installed in appdata
+ or:
+ The current plugin is installed for all users, and the new one will be installed for all users
+
+ If the old version is in all users, and the new one going to appdata, then we don't need to remove it,
+ so that a normal user can install an upgrade (when this feature is enabled by the admin)
+ N++ will use the plugin in AppData to override N++\plugins dir
+ */
+ if (isUpgrade
+ && ( ((*pluginIter)->getInstalledForAllUsers() == FALSE
+ && g_options.installLocation == INSTALLLOC_APPDATA
+ )
+ ||
+
+ ((*pluginIter)->getInstalledForAllUsers() == TRUE
+ && g_options.installLocation != INSTALLLOC_APPDATA
+ )
+
+ )
+ )
{
/* Remove the existing file if is an upgrade
* This will be done in gpup, but the copy will come afterwards, also in gpup
@@ -968,12 +1083,24 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
TiXmlElement* removeElement = new TiXmlElement(_T("delete"));
- tstring fullFilename(pluginDir);
+ tstring fullFilename;
+ if ((*pluginIter)->getInstalledForAllUsers())
+ {
+ // If the old plugin is installed for all users, then we need admin rights to remove it
+ needAdmin = true;
+ fullFilename.append(_variableHandler->getVariable(_T("ALLUSERSPLUGINDIR")));
+ }
+ else
+ {
+ fullFilename.append(_variableHandler->getVariable(_T("USERPLUGINDIR")));
+ }
+
fullFilename.push_back(_T('\\'));
fullFilename.append((*pluginIter)->getFilename());
removeElement->SetAttribute(_T("file"), fullFilename.c_str());
installElement->LinkEndChild(removeElement);
+
}
InstallStatus status = (*pluginIter)->install(pluginTemp, installElement,
@@ -985,11 +1112,19 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
switch(status)
{
case INSTALL_SUCCESS:
+ if (g_options.installLocation != INSTALLLOC_APPDATA)
+ {
+ needAdmin =true;
+ }
Utility::removeDirectory(pluginTemp.c_str());
somethingInstalled = TRUE;
break;
case INSTALL_NEEDRESTART:
+ if (g_options.installLocation != INSTALLLOC_APPDATA)
+ {
+ needAdmin =true;
+ }
needRestart = TRUE;
somethingInstalled = TRUE;
break;
@@ -1029,7 +1164,7 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
gpupArguments.append(gpupFile);
gpupArguments.append(_T("\""));
- Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), gpupArguments.c_str(), TRUE);
+ Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), gpupArguments.c_str(), needAdmin);
}
}
else if (somethingInstalled)
@@ -1039,7 +1174,7 @@ void PluginList::installPlugins(HWND hMessageBoxParent, ProgressDialog* progress
int restartNow = ::MessageBox(hMessageBoxParent, _T("Notepad++ needs to be restarted for changes to take effect. Would you like to do this now?"), _T("Plugin Manager"), MB_YESNO | MB_ICONINFORMATION);
if (restartNow == IDYES)
{
- Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), _T(""), FALSE);
+ Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), _T(""), needAdmin);
}
}
else
@@ -1088,9 +1223,13 @@ void PluginList::removePlugins(HWND hMessageBoxParent, ProgressDialog* progressD
tstring removeBasePath;
pluginIter = selectedPlugins->begin();
-
+ bool needAdmin = false;
while(pluginIter != selectedPlugins->end())
{
+ if ((*pluginIter)->getInstalledForAllUsers())
+ {
+ needAdmin = true;
+ }
(*pluginIter)->remove(removeBasePath, installElement,
boost::bind(&ProgressDialog::setCurrentStatus, progressDialog, _1),
@@ -1116,7 +1255,7 @@ void PluginList::removePlugins(HWND hMessageBoxParent, ProgressDialog* progressD
gpupArguments.append(gpupFile);
gpupArguments.append(_T("\""));
- Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), gpupArguments.c_str(), TRUE);
+ Utility::startGpup(hMessageBoxParent, _variableHandler->getVariable(_T("NPPDIR")).c_str(), gpupArguments.c_str(), needAdmin);
}
else
{
View
7 pluginManager/src/PluginList.h
@@ -42,7 +42,8 @@ class PluginList
void reparseFile(const tstring& pluginsListFilename);
BOOL parsePluginFile(CONST TCHAR *filename);
- BOOL checkInstalledPlugins(TCHAR *nppDirectory);
+ BOOL checkInstalledPlugins();
+
PluginListContainer& getInstalledPlugins();
PluginListContainer& getUpdateablePlugins();
PluginListContainer& getAvailablePlugins();
@@ -80,6 +81,7 @@ class PluginList
/* Returns true if the lists have been downloaded and processed already */
BOOL listsAvailable();
+
private:
/* Plugin name map */
PluginContainer _plugins;
@@ -115,6 +117,9 @@ class PluginList
TiXmlDocument* getGpupDocument(const TCHAR* filename);
+ BOOL checkInstalledPlugins(const TCHAR *nppDirectory, BOOL allUsers);
+ void addAvailablePlugins();
+
void installPlugins(HWND hMessageBoxParent, ProgressDialog* progressDialog, PluginListView* pluginListView, BOOL isUpgrade);
void removePlugins(HWND hMessageBoxParent, ProgressDialog* progressDialog, PluginListView* pluginListView);
void addPluginNames(TiXmlElement* pluginNamesElement);
View
34 pluginManager/src/PluginManager.cpp
@@ -220,12 +220,16 @@ void loadSettings(void)
g_options.proxyInfo.setProxy(WcharMbcsConverter::tchar2char(tmp).get());
g_options.proxyInfo.setProxyPort(::GetPrivateProfileInt(SETTINGS_GROUP, KEY_PROXYPORT, 0, iniFilePath));
+ g_options.proxyInfo.setSaveCredentials(static_cast<SAVECRED>(::GetPrivateProfileInt(SETTINGS_GROUP, KEY_SAVECRED, (int)SAVECRED_UNKNOWN, iniFilePath)));
::GetPrivateProfileString(SETTINGS_GROUP, KEY_PROXYUSERNAME, _T(""), tmp, MAX_PATH, iniFilePath);
g_options.proxyInfo.setUsername(WcharMbcsConverter::tchar2char(tmp).get());
TCHAR encBuffer[1000];
::GetPrivateProfileString(SETTINGS_GROUP, KEY_PROXYPASSWORD, _T(""), encBuffer, 1000, iniFilePath);
+
+
+
if ((g_winVer >= WV_W2K || g_winVer == WV_UNKNOWN)
&& encBuffer[0])
{
@@ -247,6 +251,22 @@ void loadSettings(void)
g_options.showUnstable = ::GetPrivateProfileInt(SETTINGS_GROUP, KEY_SHOWUNSTABLE, 0, iniFilePath);
+ g_options.installLocation = static_cast<INSTALLLOCATION>(::GetPrivateProfileInt(SETTINGS_GROUP, KEY_INSTALLLOCATION, 2, iniFilePath));
+ g_options.appDataPluginsSupported = static_cast<BOOL>(::SendMessage(nppData._nppHandle, NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0));
+ // TODO Test
+
+
+
+ // If AppData plugins are not supported, then reset the install location.
+ if (FALSE == g_options.appDataPluginsSupported)
+ {
+ if (g_options.installLocation == INSTALLLOC_APPDATA
+ || g_options.installLocation == INSTALLLOC_ALLUSERS)
+ {
+ g_options.installLocation = INSTALLLOC_ALLUSERSNOAPPDATA;
+ }
+ }
+
TCHAR tmpLastCheck[20];
::GetPrivateProfileString(SETTINGS_GROUP, KEY_LASTCHECK, _T("0"), tmpLastCheck, 20, iniFilePath);
@@ -286,12 +306,16 @@ void saveSettings(void)
{
::WritePrivateProfileString(SETTINGS_GROUP, KEY_PROXY, _T(""), iniFilePath);
}
+
+ // Install location
+ _itot_s(g_options.installLocation, temp, 16, 10);
+ ::WritePrivateProfileString(SETTINGS_GROUP, KEY_INSTALLLOCATION, temp, iniFilePath);
std::tr1::shared_ptr<TCHAR> username = WcharMbcsConverter::char2tchar(g_options.proxyInfo.getUsername());
::WritePrivateProfileString(SETTINGS_GROUP, KEY_PROXYUSERNAME, username.get(), iniFilePath);
const char *pass = g_options.proxyInfo.getPassword();
- if (pass && pass[0])
+ if (g_options.proxyInfo.getSaveCredentials() == SAVECRED_YES && pass && pass[0])
{
if (g_winVer >= WV_W2K || g_winVer == WV_UNKNOWN)
{
@@ -311,6 +335,14 @@ void saveSettings(void)
}
}
+ if (g_options.proxyInfo.getSaveCredentials() != SAVECRED_UNKNOWN)
+ {
+ _itot_s(g_options.proxyInfo.getSaveCredentials(), temp, 16, 10);
+ ::WritePrivateProfileString(SETTINGS_GROUP, KEY_SAVECRED, temp, iniFilePath);
+ }
+
+
+
::WritePrivateProfileString(SETTINGS_GROUP, KEY_PROXYUSERNAME, WcharMbcsConverter::char2tchar(g_options.proxyInfo.getUsername()).get(), iniFilePath);
_itot_s(g_options.notifyUpdates, temp, 16, 10);
::WritePrivateProfileString(SETTINGS_GROUP, KEY_NOTIFYUPDATES, temp, iniFilePath);
View
11 pluginManager/src/PluginManager.h
@@ -45,8 +45,10 @@ CONST TCHAR PLUGINMANAGER_INI[] = _T("\\PluginManager.ini");
#define KEY_PROXYPORT _T("ProxyPort")
#define KEY_LASTCHECK _T("LastCheck")
#define KEY_SHOWUNSTABLE _T("ShowUnstable")
+#define KEY_INSTALLLOCATION _T("InstallLocation")
#define KEY_PROXYUSERNAME _T("ProxyUsername")
#define KEY_PROXYPASSWORD _T("ProxyPassword")
+#define KEY_SAVECRED _T("SaveCredentials")
#define KEY_KEY _T("Key")
#ifdef ALLOW_OVERRIDE_XML_URL
#define KEY_OVERRIDEMD5URL _T("md5url")
@@ -73,12 +75,21 @@ extern HANDLE g_hModule;
extern BOOL g_isUnicode;
extern winVer g_winVer;
+enum INSTALLLOCATION
+{
+ INSTALLLOC_APPDATA = 0,
+ INSTALLLOC_ALLUSERS = 1,
+ INSTALLLOC_ALLUSERSNOAPPDATA = 2
+};
+
struct Options
{
ProxyInfo proxyInfo;
BOOL notifyUpdates;
time_t lastCheck;
BOOL showUnstable;
+ INSTALLLOCATION installLocation;
+ BOOL appDataPluginsSupported;
ModuleInfo moduleInfo;
#ifdef ALLOW_OVERRIDE_XML_URL
tstring downloadMD5Url;
View
9 pluginManager/src/PluginManager.rc
@@ -62,19 +62,21 @@ BEGIN
LTEXT "Overall Progress:",IDC_STATIC,7,64,56,8
END
-IDD_CONFIGDIALOG DIALOGEX 0, 0, 266, 110
+IDD_CONFIGDIALOG DIALOGEX 0, 0, 266, 128
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Plugin Manager Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "OK",IDOK,73,89,63,14
- PUSHBUTTON "Cancel",IDCANCEL,153,89,63,14
+ DEFPUSHBUTTON "OK",IDOK,74,105,63,14
+ PUSHBUTTON "Cancel",IDCANCEL,154,105,63,14
EDITTEXT IDC_PROXYADDRESS,59,7,200,14,ES_AUTOHSCROLL
EDITTEXT IDC_PROXYPORT,59,30,40,14,ES_AUTOHSCROLL
LTEXT "Proxy address:",IDC_STATIC,7,9,50,8
LTEXT "Proxy port:",IDC_STATIC,7,34,38,8
CONTROL "Notify of plugin updates at startup",IDC_NOTIFY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,59,54,127,10
CONTROL "Show unstable plugins",IDC_SHOWUNSTABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,70,87,10
+ CONTROL "Install plugins for all users",IDC_INSTALLALLUSERS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,87,99,10
END
IDD_UPDATESNOTIFY DIALOGEX 0, 0, 402, 164
@@ -101,6 +103,7 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_CONFIGDIALOG, DIALOG
BEGIN
+ BOTTOMMARGIN, 110
END
END
#endif // APSTUDIO_INVOKED
View
2  pluginManager/src/PluginManagerVersion.h
@@ -4,6 +4,6 @@
#define PLUGINMANAGERVERSION_STRING "1.0.0.0"
#define PLUGINMANAGERVERSION_RESOURCE 1,0,0,0
#define PLUGINMANAGERVERSION_RESOURCE_STRING "1, 0, 0, 0"
-#define PLUGINMANAGERVERSION_RELEASEDATE "November 2011"
+#define PLUGINMANAGERVERSION_RELEASEDATE "December 2011"
#endif
View
17 pluginManager/src/SettingsDialog.cpp
@@ -99,6 +99,11 @@ void SettingsDialog::initialiseOptions()
::SendMessage(GetDlgItem(_hSelf, IDC_SHOWUNSTABLE), BM_SETCHECK, g_options.showUnstable ? BST_CHECKED : BST_UNCHECKED, 0);
+
+
+ ::SendMessage(GetDlgItem(_hSelf, IDC_INSTALLALLUSERS), BM_SETCHECK, g_options.installLocation == INSTALLLOC_APPDATA ? BST_UNCHECKED : BST_CHECKED, 0);
+
+ ::EnableWindow(GetDlgItem(_hSelf, IDC_INSTALLALLUSERS), g_options.appDataPluginsSupported);
}
void SettingsDialog::setOptions()
@@ -122,5 +127,17 @@ void SettingsDialog::setOptions()
else
g_options.showUnstable = FALSE;
+ if (g_options.appDataPluginsSupported)
+ {
+ result = ::SendMessage(GetDlgItem(_hSelf, IDC_INSTALLALLUSERS), BM_GETCHECK, 0, 0);
+ if (BST_CHECKED == result)
+ g_options.installLocation = INSTALLLOC_ALLUSERS;
+ else
+ g_options.installLocation = INSTALLLOC_APPDATA;
+ }
+ else
+ {
+ g_options.installLocation = INSTALLLOC_ALLUSERSNOAPPDATA;
+ }
}
View
2  pluginManager/src/Utility.cpp
@@ -64,7 +64,7 @@ BOOL Utility::removeDirectory(const TCHAR* directory)
}
-void Utility::startGpup(HWND errorParent, const TCHAR *nppDir, const TCHAR *arguments, BOOL needAdmin)
+void Utility::startGpup(HWND errorParent, const TCHAR *nppDir, const TCHAR *arguments, bool needAdmin)
{
tstring gpupExe(nppDir);
View
2  pluginManager/src/Utility.h
@@ -22,7 +22,7 @@ class Utility
{
public:
static BOOL removeDirectory(const TCHAR* directory);
- static void startGpup(const HWND errorParent, const TCHAR* nppDir, const TCHAR* arguments, BOOL needAdmin);
+ static void startGpup(const HWND errorParent, const TCHAR* nppDir, const TCHAR* arguments, bool needAdmin);
};
View
16 pluginManager/src/pluginmanagerdialog.cpp
@@ -435,8 +435,22 @@ BOOL CALLBACK PluginManagerDialog::run_dlgProc(HWND hWnd, UINT Message, WPARAM w
{
SettingsDialog settingsDlg;
BOOL oldShowUnstable = g_options.showUnstable;
+ std::string oldProxy (g_options.proxyInfo.getProxy());
+ int oldProxyPort = g_options.proxyInfo.getProxyPort();
+
settingsDlg.doModal(_hSelf);
- if (g_options.showUnstable != oldShowUnstable)
+
+ std::string newProxy (g_options.proxyInfo.getProxy());
+ if (oldProxyPort != g_options.proxyInfo.getProxyPort()
+ || oldProxy != newProxy)
+ {
+ _pluginList = NULL;
+ _installedListView.setMessage(_T("Redownloading plugin list..."));
+ _updatesListView.setMessage(_T("Redownloading plugin list..."));
+ _availableListView.setMessage(_T("Redownloading plugin list..."));
+ _beginthread(downloadAndPopulate, 0, this);
+ }
+ else if (g_options.showUnstable != oldShowUnstable)
{
TCHAR pluginConfig[MAX_PATH];
::SendMessage(_nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH - 26, reinterpret_cast<LPARAM>(pluginConfig));
View
2  pluginManager/src/resource.h
@@ -33,6 +33,7 @@
#define IDC_NOTIFY2 1019
#define IDC_SHOWUNSTABLE 1019
#define IDC_IGNORE 1020
+#define IDC_INSTALLALLUSERS 1020
#define IDC_BUTTON3 1021
#define IDC_REINSTALL 1021
#define IDC_BUTTON2 1022
@@ -48,4 +49,3 @@
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
-
Please sign in to comment.
Something went wrong with that request. Please try again.