summaryrefslogtreecommitdiff
path: root/plugins/HTTPServer
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-18 12:33:23 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-18 12:33:23 +0300
commitd07899c7630040511591755c86371a9fbd58da34 (patch)
tree6e778c5047d914ab3f57b4ff57f948e4d334981a /plugins/HTTPServer
parent64b64a283ac4cc8920f27ea2c45916084766b0cd (diff)
fixes #2783 (HTTPServer: remove menu-related options)
Diffstat (limited to 'plugins/HTTPServer')
-rw-r--r--plugins/HTTPServer/res/resource.rc34
-rw-r--r--plugins/HTTPServer/src/FileShareNode.h30
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp54
-rw-r--r--plugins/HTTPServer/src/HttpUser.cpp8
-rw-r--r--plugins/HTTPServer/src/main.cpp37
-rw-r--r--plugins/HTTPServer/src/resource.h8
6 files changed, 61 insertions, 110 deletions
diff --git a/plugins/HTTPServer/res/resource.rc b/plugins/HTTPServer/res/resource.rc
index fb98cca4a2..72bd6204fb 100644
--- a/plugins/HTTPServer/res/resource.rc
+++ b/plugins/HTTPServer/res/resource.rc
@@ -7,13 +7,13 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include "afxres.h"
+#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// Русский (Россия) resources
+// Russian (Russia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
@@ -27,8 +27,10 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_DISABLE_SERVER ICON "dis_srv.ico"
+
IDI_SHARE_NEW_FILE ICON "share_ne.ico"
+
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
@@ -69,17 +71,12 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
EDITTEXT IDC_EXTERNAL_SRV_NAME,15,73,284,21,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
- CONTROL "Show HTTP server statistics",IDC_ADD_STATISTICS_MENU_ITEM,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,30,137,10
PUSHBUTTON "Set to default",IDC_EXTERNAL_SRV_DEFAULT,244,55,56,14
GROUPBOX "External server name",IDC_STATIC,10,47,294,106
LTEXT "This is the link pasted to the message window",IDC_STATIC,15,61,206,8
- CONTROL "Write log file",IDC_WRITE_LOG_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,31,86,10
- CONTROL "Enable HTTP server",IDC_ACCEPT_COM_MENU_ITEM,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,15,135,10
- GROUPBOX "Main menu items",IDC_STATIC,10,3,141,42
- PUSHBUTTON "Open log",IDC_OPEN_LOG,250,27,50,14
- CONTROL "Show popups",IDC_SHOW_POPUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,15,137,10
+ CONTROL "Write log file",IDC_WRITE_LOG_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,31,86,10
+ PUSHBUTTON "Open log",IDC_OPEN_LOG,244,27,56,14
+ CONTROL "Show popups",IDC_SHOW_POPUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,15,137,10
LTEXT "Page keyword",IDC_STATIC,20,129,46,8
LTEXT "URL address",IDC_STATIC,20,110,42,8
GROUPBOX "%ExternalIP% variable",IDC_STATIC,15,96,284,51
@@ -95,7 +92,7 @@ BEGIN
CONTROL "Disable",IDC_INDEX_OFF,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,169,168,125,10
CONTROL "Create HTML (compatibility)",IDC_INDEX_HTML,"Button",BS_AUTORADIOBUTTON,169,182,125,10
CONTROL "Create XML",IDC_INDEX_XML,"Button",BS_AUTORADIOBUTTON,169,196,125,10
- GROUPBOX "Notifications",IDC_STATIC,157,3,147,42
+ GROUPBOX "Notifications",IDC_STATIC,10,3,294,42
LTEXT "Total connection limit",IDC_STATIC,42,197,113,8
LTEXT "Connections per user limit",IDC_STATIC,42,211,113,8
EDITTEXT IDC_MAX_CONN_TOTAL,15,195,24,12,ES_AUTOHSCROLL
@@ -160,7 +157,7 @@ END
2 TEXTINCLUDE
BEGIN
- "#include ""afxres.h""\r\n"
+ "#include ""winres.h""\r\n"
"\0"
END
@@ -190,7 +187,18 @@ BEGIN
END
END
-#endif // Русский (Россия) resources
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPT_HTTP_SERVER AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/HTTPServer/src/FileShareNode.h b/plugins/HTTPServer/src/FileShareNode.h
index 032bc34510..c47117291f 100644
--- a/plugins/HTTPServer/src/FileShareNode.h
+++ b/plugins/HTTPServer/src/FileShareNode.h
@@ -58,8 +58,8 @@ public://, DWORD dwAllowedIP, DWORD dwAllowedMask, int nMaxDownloads );
CLFileShareNode * pclNext;
//CLHttpUser * pclAddHttpUser( HANDLE hConnection, in_addr stAddr );
//bool bRemoveHttpUser( CLHttpUser * pclUser );
- bool bAddUser(CLShareUser * pclUser);
- bool bRemoveUser(CLShareUser * pclUser);
+ bool bAddUser(CLShareUser *pclUser);
+ bool bRemoveUser(CLShareUser *pclUser);
bool bAnyUsers() {
return pclCurrentUsers != nullptr;
}
@@ -72,31 +72,7 @@ private:
};
-extern CLFileShareNode * pclFirstNode;
+extern CLFileShareNode *pclFirstNode;
extern mir_cs csFileShareListAccess;
-class CLFileShareListAccess {
- bool bLocked;
-public:
- CLFileShareListAccess() {
- bLocked = false;
- Lock();
- }
- ~CLFileShareListAccess() {
- Unlock();
- }
- void Lock() {
- if (bLocked)
- return;
- mir_cslock lck(csFileShareListAccess);
- bLocked = true;
- }
- void Unlock() {
- if (!bLocked)
- return;
- bLocked = false;
- }
-
-};
-
#endif \ No newline at end of file
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index ebb4f0587f..ab8219230f 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -530,7 +530,7 @@ void UpdateStatisticView(HWND hwndDlg, bool bRefressUsersOnly = false)
ListView_DeleteAllItems(hShareList);
ListView_DeleteAllItems(hUserList);
- CLFileShareListAccess scCrit;
+ mir_cslock lck(csFileShareListAccess);
char szTmp[50];
in_addr stAddr;
@@ -681,8 +681,7 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
switch (msg) {
case WM_INITDIALOG:
{
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
- (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)g_plugin.getIcon(IDI_SHARE_NEW_FILE));
TranslateDialogDefault(hwndDlg);
@@ -1073,15 +1072,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
string sDefExt = DBGetString(0, MODULENAME, "ExternalSrvName", szDefaultExternalSrvName);
SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
- bool b = g_plugin.getByte("AddStatisticsMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
-
- b = g_plugin.getByte("AddAcceptConMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
-
- b = g_plugin.getByte("WriteLogFile", 0) != 0;
- CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, b ? BST_CHECKED : BST_UNCHECKED);
-
+ CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, g_plugin.getByte("WriteLogFile", 0) != 0 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SHOW_POPUPS, bShowPopups ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE, bLimitOnlyWhenOnline ? BST_CHECKED : BST_UNCHECKED);
@@ -1159,8 +1150,6 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case IDC_LIMIT_ONLY_WHEN_ONLINE:
case IDC_SHOW_POPUPS:
case IDC_WRITE_LOG_FILE:
- case IDC_ADD_STATISTICS_MENU_ITEM:
- case IDC_ACCEPT_COM_MENU_ITEM:
if (HIWORD(wParam) == BN_CLICKED)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
@@ -1201,22 +1190,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp)))
g_plugin.setString("ExternalSrvName", szTemp);
- bool b = g_plugin.getByte("AddStatisticsMenuItem", 1) != 0;
- bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- g_plugin.setByte("AddStatisticsMenuItem", bNew);
- MessageBoxW(hwndDlg, TranslateT("You need to restart Miranda to change the main menu"), TranslateW(_A2W(MSG_BOX_TITLE)), MB_OK);
- }
-
- b = g_plugin.getByte("AddAcceptConMenuItem", 1) != 0;
- bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- g_plugin.setByte("AddAcceptConMenuItem", bNew);
- MessageBoxW(hwndDlg, TranslateT("You need to restart Miranda to change the main menu"), TranslateW(_A2W(MSG_BOX_TITLE)), MB_OK);
- }
-
- bNew = IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED;
- g_plugin.setByte("WriteLogFile", bNew);
+ g_plugin.setByte("WriteLogFile", IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED);
bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
g_plugin.setByte("ShowPopups", bShowPopups);
@@ -1398,7 +1372,7 @@ void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorB
POPUPDATA *pclData = new POPUPDATA;
memset(pclData, 0, sizeof(POPUPDATA));
- pclData->lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ pclData->lchIcon = g_plugin.getIcon(IDI_SHARE_NEW_FILE);
strncpy(pclData->lpzContactName, pszName, sizeof(pclData->lpzContactName) - 1); // -1 so that there aways will be a null termination !!
strncpy(pclData->lpzText, pszText, sizeof(pclData->lpzText) - 1);
pclData->colorBack = ColorBack;
@@ -1433,21 +1407,19 @@ void InitGuiElements()
hShowStatisticsViewService = CreateServiceFunction(MS_SHOW_STATISTICS_VIEW, nShowStatisticsView);
CMenuItem mi(&g_plugin);
- mi.flags = CMIF_UNICODE;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_SHARE_NEW_FILE);
+
SET_UID(mi, 0xb30a6ab5, 0x17a8, 0x4e2e, 0x84, 0x52, 0x5f, 0xbc, 0x83, 0x35, 0xf2, 0x6);
- mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = -2000019955;
- mi.name.w = LPGENW("HTTP Share new file");
+ mi.name.a = LPGEN("HTTP Share new file");
mi.pszService = MS_SHARE_NEW_FILE;
hShareNewFileMenuItem = Menu_AddContactMenuItem(&mi);
- if (g_plugin.getByte("AddStatisticsMenuItem", 1) != 0) {
- SET_UID(mi, 0x68db84c9, 0xe6b4, 0x4b4f, 0x93, 0x4b, 0xfd, 0x34, 0x2d, 0x83, 0x11, 0xe7);
- mi.position = 1000085005;
- mi.name.w = LPGENW("Show HTTP server statistics");
- mi.pszService = MS_SHOW_STATISTICS_VIEW;
- hShowStatisticsViewMenuItem = Menu_AddMainMenuItem(&mi);
- }
+ SET_UID(mi, 0x68db84c9, 0xe6b4, 0x4b4f, 0x93, 0x4b, 0xfd, 0x34, 0x2d, 0x83, 0x11, 0xe7);
+ mi.position = 1000085005;
+ mi.name.a = LPGEN("Show HTTP server statistics");
+ mi.pszService = MS_SHOW_STATISTICS_VIEW;
+ hShowStatisticsViewMenuItem = Menu_AddMainMenuItem(&mi);
bShowPopups = g_plugin.getByte("ShowPopups", bShowPopups) != 0;
}
diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp
index 1f28cdac5d..5b738240b0 100644
--- a/plugins/HTTPServer/src/HttpUser.cpp
+++ b/plugins/HTTPServer/src/HttpUser.cpp
@@ -377,11 +377,11 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand)
if (nUriLength <= 0)
return false;
- CLFileShareListAccess clCritSection;
-
if (bShutdownInProgress)
return false;
+ mir_cslockfull lck(csFileShareListAccess);
+
static char szTempfile[MAX_PATH + 1];
szTempfile[0] = '\0';
@@ -561,7 +561,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand)
ShowPopupWindow(inet_ntoa(stAddr), pszSrvPath);
}
- clCritSection.Unlock();
+ lck.unlock();
DWORD dwFileStart = 0;
DWORD dwDataToSend = nDataSize;
@@ -740,7 +740,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand)
DeleteFile(szTempfile);
}
- clCritSection.Lock();
+ lck.lock();
nThreadCount--;
bool bNeedToWriteConfig = false;
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index d6a4a78566..16c328fbf9 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -229,7 +229,7 @@ DWORD dwReadIPAddress(char * pszStr, bool &bError)
bool bReadConfigurationFile()
{
- CLFileShareListAccess clCritSection;
+ mir_cslock lck(csFileShareListAccess);
CLFileShareNode * pclLastNode = nullptr;
@@ -334,7 +334,7 @@ bool bReadConfigurationFile()
bool bWriteConfigurationFile()
{
- CLFileShareListAccess clCritSection;
+ mir_cslock lck(csFileShareListAccess);
char szBuf[1000];
mir_strcpy(szBuf, szPluginPath);
mir_strcat(szBuf, szConfigFile);
@@ -396,7 +396,7 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam)
if (pclNew->lStructSize != sizeof(STFileShareInfo))
return 1002;
- CLFileShareListAccess clCritSection;
+ mir_cslockfull lck(csFileShareListAccess);
bool bIsDirectory = (pclNew->pszSrvPath[mir_strlen(pclNew->pszSrvPath) - 1] == '/');
CLFileShareNode **pclPrev = &pclFirstNode;
@@ -421,9 +421,9 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam)
nTryCount++;
if (nTryCount >= 100)
return 1004;
- clCritSection.Unlock();
+ lck.unlock();
Sleep(50);
- clCritSection.Lock();
+ lck.lock();
} while (pclCur->bAnyUsers());
}
@@ -474,7 +474,7 @@ static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam)
if (!lParam)
return 1001;
- CLFileShareListAccess clCritSection;
+ mir_cslock lck(csFileShareListAccess);
STFileShareInfo * pclShare = (STFileShareInfo*)lParam;
CLFileShareNode * pclCur = pclFirstNode;
@@ -731,13 +731,12 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/)
{
+ bShutdownInProgress = true;
{
- CLFileShareListAccess clCrit;
- bShutdownInProgress = true;
+ mir_cslock lck(csFileShareListAccess);
- for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext) {
+ for (CLFileShareNode * pclCur = pclFirstNode; pclCur; pclCur = pclCur->pclNext)
pclCur->CloseAllTransfers();
- }
}
if (hDirectBoundPort)
@@ -823,16 +822,14 @@ int CMPlugin::Load()
bLimitOnlyWhenOnline = g_plugin.getByte("LimitOnlyWhenOnline", bLimitOnlyWhenOnline) != 0;
indexCreationMode = (eIndexCreationMode)g_plugin.getByte("IndexCreationMode", 2);
- if (g_plugin.getByte("AddAcceptConMenuItem", 1)) {
- CMenuItem mi(&g_plugin);
- SET_UID(mi, 0xf0a68784, 0xc30e, 0x4245, 0xb6, 0x2b, 0xb8, 0x71, 0x7e, 0xe6, 0xe1, 0x73);
- mi.flags = CMIF_UNICODE;
- mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
- mi.position = 1000085000;
- mi.name.a = LPGEN("Enable HTTP server");
- mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
- hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
- }
+ CMenuItem mi(&g_plugin);
+ SET_UID(mi, 0xf0a68784, 0xc30e, 0x4245, 0xb6, 0x2b, 0xb8, 0x71, 0x7e, 0xe6, 0xe1, 0x73);
+ mi.flags = CMIF_UNICODE;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_SHARE_NEW_FILE);
+ mi.position = 1000085000;
+ mi.name.a = LPGEN("Enable HTTP server");
+ mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
+ hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
if (indexCreationMode == INDEX_CREATION_HTML || indexCreationMode == INDEX_CREATION_DETECT)
if (!LoadIndexHTMLTemplate()) {
diff --git a/plugins/HTTPServer/src/resource.h b/plugins/HTTPServer/src/resource.h
index 3f2a2df98d..5e911d2ce1 100644
--- a/plugins/HTTPServer/src/resource.h
+++ b/plugins/HTTPServer/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
-// Включаемый файл, созданный в Microsoft Visual C++.
-// Используется D:\MNG_orig\plugins\HTTPServer\res\resource.rc
+// Microsoft Visual C++ generated include file.
+// Used by w:\miranda-ng\plugins\HTTPServer\res\resource.rc
//
#define IDD_NEW_SHARE_PROPERTIES 101
#define IDI_DISABLE_SERVER 101
@@ -16,10 +16,8 @@
#define IDC_CURRENT_SHARES 1071
#define IDC_CURRENT_USERS 1072
#define IDC_EXTERNAL_SRV_NAME 1073
-#define IDC_ADD_STATISTICS_MENU_ITEM 1074
#define IDC_EXTERNAL_SRV_DEFAULT 1075
#define IDC_WRITE_LOG_FILE 1076
-#define IDC_ACCEPT_COM_MENU_ITEM 1078
#define IDC_TOGGLE_MASK 1080
#define IDC_OPEN_LOG 1081
#define IDC_SHOW_POPUPS 1082
@@ -48,7 +46,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 126
+#define _APS_NEXT_RESOURCE_VALUE 127
#define _APS_NEXT_COMMAND_VALUE 40009
#define _APS_NEXT_CONTROL_VALUE 1095
#define _APS_NEXT_SYMED_VALUE 101