Permalink
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...
1 parent b6e528c commit ca5bb3559b31357f52e4928a489d569a0f7d8f29 @bruderstein committed Dec 2, 2011
@@ -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
@@ -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;
@@ -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);
}
@@ -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;
@@ -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);
+ }
}
Binary file not shown.
View
Binary file not shown.
View
@@ -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>
@@ -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" />
@@ -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">
@@ -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;
@@ -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;
Oops, something went wrong.

0 comments on commit ca5bb35

Please sign in to comment.