Skip to content

Commit

Permalink
Sorting columns, Settings dialog info
Browse files Browse the repository at this point in the history
Plugin config path and status of appdata plugins now shown in settings dialog.
Sorting by clicking the column header now possible.
Defaults changed so if appdata plugins is switched on (after previously disabled), the default is to install per user.
  • Loading branch information
bruderstein committed Dec 4, 2011
1 parent 77b53a7 commit f4bbefb
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 26 deletions.
20 changes: 17 additions & 3 deletions pluginManager/src/PluginList.cpp
Expand Up @@ -832,7 +832,15 @@ void PluginList::downloadList()
string serverMD5; string serverMD5;


#ifdef ALLOW_OVERRIDE_XML_URL #ifdef ALLOW_OVERRIDE_XML_URL
BOOL downloadResult = downloadManager.getUrl(g_options.downloadMD5Url.c_str(), serverMD5, &g_options.proxyInfo, &g_options.moduleInfo); BOOL downloadResult;
if (!g_options.downloadMD5Url.empty())
{
downloadResult = downloadManager.getUrl(g_options.downloadMD5Url.c_str(), serverMD5, &g_options.proxyInfo, &g_options.moduleInfo);
}
else
{
downloadResult = downloadManager.getUrl(PLUGINS_MD5_URL, serverMD5, &g_options.proxyInfo, &g_options.moduleInfo);
}
#else #else
BOOL downloadResult = downloadManager.getUrl(PLUGINS_MD5_URL, serverMD5, &g_options.proxyInfo, &g_options.moduleInfo); BOOL downloadResult = downloadManager.getUrl(PLUGINS_MD5_URL, serverMD5, &g_options.proxyInfo, &g_options.moduleInfo);
#endif #endif
Expand All @@ -846,15 +854,21 @@ void PluginList::downloadList()
// Also, don't unzip it - assume if it's overridden, it's a test version and hence easier to treat it // Also, don't unzip it - assume if it's overridden, it's a test version and hence easier to treat it
// as a plain xml file // as a plain xml file
#ifdef ALLOW_OVERRIDE_XML_URL #ifdef ALLOW_OVERRIDE_XML_URL
if (!g_options.downloadUrl.empty())
{
downloadManager.getUrl(g_options.downloadUrl.c_str(), pluginsListFilename, contentType, &g_options.proxyInfo, &g_options.moduleInfo); downloadManager.getUrl(g_options.downloadUrl.c_str(), pluginsListFilename, contentType, &g_options.proxyInfo, &g_options.moduleInfo);
#else }
else
#endif
{
downloadManager.getUrl(PLUGINS_URL, pluginsListZipFilename, contentType, &g_options.proxyInfo, &g_options.moduleInfo); downloadManager.getUrl(PLUGINS_URL, pluginsListZipFilename, contentType, &g_options.proxyInfo, &g_options.moduleInfo);


// Unzip the plugins.zip to PluginManagerPlugins.xml // Unzip the plugins.zip to PluginManagerPlugins.xml
tstring unzipPath(pluginConfig); tstring unzipPath(pluginConfig);
unzipPath.append(_T("\\")); unzipPath.append(_T("\\"));
Decompress::unzip(pluginsListZipFilename, unzipPath); Decompress::unzip(pluginsListZipFilename, unzipPath);
#endif }

} }




Expand Down
108 changes: 104 additions & 4 deletions pluginManager/src/PluginListView.cpp
Expand Up @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "precompiled_headers.h" #include "precompiled_headers.h"
#include "PluginListView.h" #include "PluginListView.h"
#include "PluginList.h" #include "PluginList.h"

#include "PluginVersion.h"
using namespace std; using namespace std;




Expand Down Expand Up @@ -101,6 +101,50 @@ LRESULT PluginListView::notify(WPARAM /*wParam*/, LPARAM lParam)
break; break;
} }


case LVN_COLUMNCLICK:
{
NMLISTVIEW *colInfo = reinterpret_cast<NMLISTVIEW*>(lParam);
int (CALLBACK *compareFunc)(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) = NULL;
LVSORTCOLUMN sortColumn = LVSORTCOLUMN_NAME;

if (colInfo->iSubItem < 2 || colInfo->iSubItem == _nVersionColumns + 2)
{
compareFunc = PluginListView::stringComparer;

if (colInfo->iSubItem == 1)
{
sortColumn = LVSORTCOLUMN_CATEGORY;
}
else if (colInfo->iSubItem == _nVersionColumns + 2)
{
sortColumn = LVSORTCOLUMN_STABILITY;
}
}
else
{
compareFunc = PluginListView::versionComparer;

switch(_columns[colInfo->iSubItem - 2])
{
case VERSION_AVAILABLE:
sortColumn = LVSORTCOLUMN_VERSIONAVAILABLE;
break;

case VERSION_INSTALLED:
sortColumn = LVSORTCOLUMN_VERSIONINSTALLED;
break;

// Just in case there's another one introduced at some point (beta version or something)
default:
sortColumn = LVSORTCOLUMN_VERSIONAVAILABLE;
break;
}
}

ListView_SortItems(_hListView, compareFunc, static_cast<LPARAM>(sortColumn));
}
break;

case NM_CLICK: case NM_CLICK:
if (_hDescription && lParam) if (_hDescription && lParam)
{ {
Expand Down Expand Up @@ -214,7 +258,7 @@ void PluginListView::setList(PluginListContainer &list)
++iter; ++iter;
} }


ListView_SortItems(_hListView, PluginListView::itemComparer, NULL); ListView_SortItems(_hListView, PluginListView::stringComparer, LVSORTCOLUMN_NAME);


} }


Expand Down Expand Up @@ -334,7 +378,63 @@ BOOL PluginListView::empty()
return (ListView_GetItemCount(_hListView) == 0); return (ListView_GetItemCount(_hListView) == 0);
} }


int CALLBACK PluginListView::itemComparer(LPARAM lParam1, LPARAM lParam2, LPARAM /*lParamSort*/) int CALLBACK PluginListView::stringComparer(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{ {
return _tcscmp(reinterpret_cast<Plugin*>(lParam1)->getName().c_str(), reinterpret_cast<Plugin*>(lParam2)->getName().c_str()); const TCHAR *text1;
const TCHAR *text2;

switch(static_cast<LVSORTCOLUMN>(lParamSort))
{
case LVSORTCOLUMN_NAME:
text1 = reinterpret_cast<Plugin*>(lParam1)->getName().c_str();
text2 = reinterpret_cast<Plugin*>(lParam2)->getName().c_str();
break;

case LVSORTCOLUMN_STABILITY:
text1 = reinterpret_cast<Plugin*>(lParam1)->getStability().c_str();
text2 = reinterpret_cast<Plugin*>(lParam2)->getStability().c_str();
break;

case LVSORTCOLUMN_CATEGORY:
text1 = reinterpret_cast<Plugin*>(lParam1)->getCategory().c_str();
text2 = reinterpret_cast<Plugin*>(lParam2)->getCategory().c_str();
break;

default:
text1 = _T("");
text2 = _T("");
break;
}


return _tcsicmp(text1, text2);
}


int CALLBACK PluginListView::versionComparer(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
PluginVersion version1, version2;

switch(static_cast<LVSORTCOLUMN>(lParamSort))
{
case LVSORTCOLUMN_VERSIONAVAILABLE:
version1 = reinterpret_cast<Plugin*>(lParam1)->getVersion();
version2 = reinterpret_cast<Plugin*>(lParam2)->getVersion();
break;

case LVSORTCOLUMN_VERSIONINSTALLED:
version1 = reinterpret_cast<Plugin*>(lParam1)->getInstalledVersion();
version2 = reinterpret_cast<Plugin*>(lParam2)->getInstalledVersion();
break;

}

int retVal = 0;

if (version1 < version2)
retVal = -1;
else if (version1 > version2)
retVal = 1;

return retVal;
} }
13 changes: 12 additions & 1 deletion pluginManager/src/PluginListView.h
Expand Up @@ -75,7 +75,18 @@ class PluginListView
void initColumns(void); void initColumns(void);
int getCurrentSelectedIndex(); int getCurrentSelectedIndex();
void setAllCheckState(BOOL checked); void setAllCheckState(BOOL checked);
static int CALLBACK itemComparer(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
enum LVSORTCOLUMN
{
LVSORTCOLUMN_NAME,
LVSORTCOLUMN_VERSIONAVAILABLE,
LVSORTCOLUMN_VERSIONINSTALLED,
LVSORTCOLUMN_CATEGORY,
LVSORTCOLUMN_STABILITY
};

static int CALLBACK stringComparer(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
static int CALLBACK versionComparer(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
}; };




Expand Down
10 changes: 8 additions & 2 deletions pluginManager/src/PluginManager.cpp
Expand Up @@ -272,6 +272,12 @@ void loadSettings(void)
g_options.installLocation = INSTALLLOC_ALLUSERSNOAPPDATA; g_options.installLocation = INSTALLLOC_ALLUSERSNOAPPDATA;
} }
} }
// Else, if we've "upgraded" to support for all users, assume we want appdata plugins
else if (TRUE == g_options.appDataPluginsSupported
&& g_options.installLocation == INSTALLLOC_ALLUSERSNOAPPDATA)
{
g_options.installLocation = INSTALLLOC_APPDATA;
}


TCHAR tmpLastCheck[20]; TCHAR tmpLastCheck[20];
::GetPrivateProfileString(SETTINGS_GROUP, KEY_LASTCHECK, _T("0"), tmpLastCheck, 20, iniFilePath); ::GetPrivateProfileString(SETTINGS_GROUP, KEY_LASTCHECK, _T("0"), tmpLastCheck, 20, iniFilePath);
Expand All @@ -280,10 +286,10 @@ void loadSettings(void)


#ifdef ALLOW_OVERRIDE_XML_URL #ifdef ALLOW_OVERRIDE_XML_URL
TCHAR tmpUrl[MAX_PATH]; TCHAR tmpUrl[MAX_PATH];
::GetPrivateProfileString(SETTINGS_GROUP, KEY_OVERRIDEMD5URL, PLUGINS_MD5_URL, tmpUrl, MAX_PATH, iniFilePath); ::GetPrivateProfileString(SETTINGS_GROUP, KEY_OVERRIDEMD5URL, _T(""), tmpUrl, MAX_PATH, iniFilePath);
g_options.downloadMD5Url = tmpUrl; g_options.downloadMD5Url = tmpUrl;


::GetPrivateProfileString(SETTINGS_GROUP, KEY_OVERRIDEURL, PLUGINS_URL, tmpUrl, MAX_PATH, iniFilePath); ::GetPrivateProfileString(SETTINGS_GROUP, KEY_OVERRIDEURL, _T(""), tmpUrl, MAX_PATH, iniFilePath);
g_options.downloadUrl = tmpUrl; g_options.downloadUrl = tmpUrl;
#endif #endif


Expand Down
19 changes: 11 additions & 8 deletions pluginManager/src/PluginManager.rc
Expand Up @@ -62,24 +62,26 @@ BEGIN
LTEXT "Overall Progress:",IDC_STATIC,7,64,56,8 LTEXT "Overall Progress:",IDC_STATIC,7,64,56,8
END END


IDD_CONFIGDIALOG DIALOGEX 0, 0, 266, 154 IDD_CONFIGDIALOG DIALOGEX 0, 0, 293, 228
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Plugin Manager Settings" CAPTION "Plugin Manager Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "OK",IDOK,74,127,63,14
PUSHBUTTON "Cancel",IDCANCEL,154,127,63,14
EDITTEXT IDC_PROXYADDRESS,59,7,200,14,ES_AUTOHSCROLL EDITTEXT IDC_PROXYADDRESS,59,7,200,14,ES_AUTOHSCROLL
EDITTEXT IDC_PROXYPORT,59,30,40,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 "Notify of plugin updates at startup",IDC_NOTIFY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,59,54,127,10
LTEXT "Check for plugin updates every ",IDC_STATIC,59,68,103,8
EDITTEXT IDC_DAYSTOCHECK,164,65,20,14,ES_AUTOHSCROLL
CONTROL "Show unstable plugins",IDC_SHOWUNSTABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,92,87,10 CONTROL "Show unstable plugins",IDC_SHOWUNSTABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,92,87,10
CONTROL "Install plugins for all users",IDC_INSTALLALLUSERS, CONTROL "Install plugins for all users",IDC_INSTALLALLUSERS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,109,99,10 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,109,99,10
LTEXT "Check for plugin updates every ",IDC_STATIC,59,68,103,8 DEFPUSHBUTTON "OK",IDOK,71,204,63,14
EDITTEXT IDC_DAYSTOCHECK,164,65,20,14,ES_AUTOHSCROLL PUSHBUTTON "Cancel",IDCANCEL,151,204,63,14
LTEXT "Proxy address:",IDC_STATIC,7,9,50,8
LTEXT "Proxy port:",IDC_STATIC,7,34,38,8
LTEXT "days",IDC_STATIC,189,68,69,8 LTEXT "days",IDC_STATIC,189,68,69,8
GROUPBOX "Information",IDC_STATIC,12,129,278,72
EDITTEXT IDC_INFOTEXT,19,142,264,51,ES_MULTILINE | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
END END


IDD_UPDATESNOTIFY DIALOGEX 0, 0, 402, 164 IDD_UPDATESNOTIFY DIALOGEX 0, 0, 402, 164
Expand All @@ -106,7 +108,8 @@ GUIDELINES DESIGNINFO
BEGIN BEGIN
IDD_CONFIGDIALOG, DIALOG IDD_CONFIGDIALOG, DIALOG
BEGIN BEGIN
BOTTOMMARGIN, 136 RIGHTMARGIN, 290
BOTTOMMARGIN, 218
END END
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
Expand Down
6 changes: 3 additions & 3 deletions pluginManager/src/PluginManagerVersion.h
@@ -1,9 +1,9 @@
#ifndef _PLUGINMANAGERVERSION_H #ifndef _PLUGINMANAGERVERSION_H
#define _PLUGINMANAGERVERSION_H #define _PLUGINMANAGERVERSION_H


#define PLUGINMANAGERVERSION_STRING "1.0.1.0" #define PLUGINMANAGERVERSION_STRING "1.0.2.0"
#define PLUGINMANAGERVERSION_RESOURCE 1,0,1,0 #define PLUGINMANAGERVERSION_RESOURCE 1,0,2,0
#define PLUGINMANAGERVERSION_RESOURCE_STRING "1, 0, 1, 0" #define PLUGINMANAGERVERSION_RESOURCE_STRING "1, 0, 2, 0"
#define PLUGINMANAGERVERSION_RELEASEDATE "December 2011" #define PLUGINMANAGERVERSION_RELEASEDATE "December 2011"


#endif #endif
21 changes: 20 additions & 1 deletion pluginManager/src/SettingsDialog.cpp
Expand Up @@ -23,8 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "SettingsDialog.h" #include "SettingsDialog.h"
#include "resource.h" #include "resource.h"


void SettingsDialog::doModal(HWND parent) void SettingsDialog::doModal(NppData *nppData, HWND parent)
{ {
_nppData = nppData;
::DialogBoxParam((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDD_CONFIGDIALOG), parent, SettingsDialog::dlgProc, reinterpret_cast<LPARAM>(this)); ::DialogBoxParam((HINSTANCE)g_hModule, MAKEINTRESOURCE(IDD_CONFIGDIALOG), parent, SettingsDialog::dlgProc, reinterpret_cast<LPARAM>(this));
} }


Expand Down Expand Up @@ -106,6 +107,24 @@ void SettingsDialog::initialiseOptions()
::SendMessage(GetDlgItem(_hSelf, IDC_INSTALLALLUSERS), BM_SETCHECK, g_options.installLocation == INSTALLLOC_APPDATA ? BST_UNCHECKED : BST_CHECKED, 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); ::EnableWindow(GetDlgItem(_hSelf, IDC_INSTALLALLUSERS), g_options.appDataPluginsSupported);

tstring info(_T("Plugin Config path is:\r\n"));
TCHAR path[MAX_PATH];
path[0] = _T('\0');
::SendMessage(_nppData->_nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, reinterpret_cast<LPARAM>(path));
info.append(path);
info.append(_T("\r\n"));
if (g_options.appDataPluginsSupported)
{
info.append(_T("Plugins in user's AppData directory are enabled. Remove the allowAppDataPlugins.xml file from the Notepad++ directory to disable."));
}
else
{
info.append(_T("Plugins in user's AppData directory are disabled - to enable in Notepad++ version 5.9.7 onwards place an empty file called allowAppDataPlugins.xml in the Notepad++ directory."));
}

SetWindowText(GetDlgItem(_hSelf, IDC_INFOTEXT), info.c_str());

} }


void SettingsDialog::setOptions() void SettingsDialog::setOptions()
Expand Down
5 changes: 3 additions & 2 deletions pluginManager/src/SettingsDialog.h
@@ -1,6 +1,7 @@
#ifndef _SETTINGSDIALOG_H #ifndef _SETTINGSDIALOG_H
#define _SETTINGSDIALOG_H #define _SETTINGSDIALOG_H


struct NppData;






Expand All @@ -11,7 +12,7 @@ class SettingsDialog
SettingsDialog() {}; SettingsDialog() {};
~SettingsDialog() {}; ~SettingsDialog() {};


void doModal(HWND parent); void doModal(NppData *nppData, HWND parent);






Expand All @@ -26,7 +27,7 @@ protected :
void initialiseOptions(); void initialiseOptions();
void setOptions(); void setOptions();



NppData *_nppData;
HWND _hSelf; HWND _hSelf;
}; };


Expand Down
2 changes: 1 addition & 1 deletion pluginManager/src/pluginmanagerdialog.cpp
Expand Up @@ -438,7 +438,7 @@ BOOL CALLBACK PluginManagerDialog::run_dlgProc(HWND hWnd, UINT Message, WPARAM w
std::string oldProxy (g_options.proxyInfo.getProxy()); std::string oldProxy (g_options.proxyInfo.getProxy());
int oldProxyPort = g_options.proxyInfo.getProxyPort(); int oldProxyPort = g_options.proxyInfo.getProxyPort();


settingsDlg.doModal(_hSelf); settingsDlg.doModal(&_nppData, _hSelf);


std::string newProxy (g_options.proxyInfo.getProxy()); std::string newProxy (g_options.proxyInfo.getProxy());
if (oldProxyPort != g_options.proxyInfo.getProxyPort() if (oldProxyPort != g_options.proxyInfo.getProxyPort()
Expand Down
3 changes: 2 additions & 1 deletion pluginManager/src/resource.h
Expand Up @@ -39,14 +39,15 @@
#define IDC_BUTTON2 1022 #define IDC_BUTTON2 1022
#define IDC_UPDATEDESC 1023 #define IDC_UPDATEDESC 1023
#define IDC_DAYSTOCHECK 1024 #define IDC_DAYSTOCHECK 1024
#define IDC_INFOTEXT 1026


// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 116 #define _APS_NEXT_RESOURCE_VALUE 116
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1025 #define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

0 comments on commit f4bbefb

Please sign in to comment.