summaryrefslogtreecommitdiff
path: root/plugins/HTTPServer
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/HTTPServer')
-rw-r--r--plugins/HTTPServer/src/Glob.h10
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp920
-rw-r--r--plugins/HTTPServer/src/main.cpp31
3 files changed, 472 insertions, 489 deletions
diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h
index 24a1ab9268..0509444dfc 100644
--- a/plugins/HTTPServer/src/Glob.h
+++ b/plugins/HTTPServer/src/Glob.h
@@ -27,7 +27,6 @@
#include <string>
using namespace std;
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -59,7 +58,12 @@ using namespace std;
#define SplitIpAddress( p ) (BYTE)(p>>24),(BYTE)(p>>16),(BYTE)(p>>8),(BYTE)(p)
-extern HINSTANCE hInstance;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
extern HNETLIBUSER hNetlibUser;
@@ -84,6 +88,6 @@ extern bool bIsOnline;
extern bool bLimitOnlyWhenOnline;
extern void* (*MirandaMalloc)(size_t);
-extern void (*MirandaFree)(void*);
+extern void(*MirandaFree)(void*);
#endif \ No newline at end of file
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index 11b179b4b6..edc0c5ceac 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -105,7 +105,7 @@ string DBGetString(MCONTACT hContact, const char *szModule, const char *szSettin
else ret = dbv.pszVal;
}
else ret = pszError;
-
+
db_free(&dbv);
return ret;
}
@@ -248,7 +248,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
UINT uiMsg, // message identifier
WPARAM wParam, // message parameter
LPARAM lParam // message parameter
- )
+)
{
static const char* pszShareDirStr = Translate("Share Current Directory");
@@ -272,152 +272,152 @@ UINT_PTR CALLBACK ShareNewFileDialogHook(
return false;
case WM_NOTIFY:
+ {
+ OFNOTIFY * pNotify = (OFNOTIFY*)lParam;
+ switch (pNotify->hdr.code) {
+ case CDN_FOLDERCHANGE:
+ case CDN_SELCHANGE:
{
- OFNOTIFY * pNotify = (OFNOTIFY*)lParam;
- switch (pNotify->hdr.code) {
- case CDN_FOLDERCHANGE:
- case CDN_SELCHANGE:
- {
- static char szSelection[MAX_PATH] = "";
- HWND hWndFileDlg = GetParent(hDlg);
-
- *szSelection = '/';
- CommDlg_OpenSave_GetSpec(hWndFileDlg, (LPARAM)&szSelection[1], _MAX_PATH);
-
- HWND hFileName = GetDlgItem(hWndFileDlg, edt1);
- char pszFileName[MAX_PATH];
- GetWindowText(hFileName, pszFileName, _countof(pszFileName));
-
- if (mir_strcmp(pstShare->pszSrvPath, szSelection) &&
- mir_strcmp(pszFileName, pszShareDirStr)) {
- // a file was selected
-
- // only reenable windows / set default values when a folder was selected before
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/') {
- pNotify->lpOFN->Flags |= OFN_FILEMUSTEXIST;
- EnableWindow(hFileName, TRUE);
- EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), TRUE);
- SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, nDefaultDownloadLimit, true);
- }
- }
- else {
- // a directory was selected
- pNotify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
- mir_strcpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
- CommDlg_OpenSave_SetControlText(hWndFileDlg, edt1, pszShareDirStr);
- EnableWindow(hFileName, FALSE);
- EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), FALSE);
- SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, (UINT)-1, true);
-
- CommDlg_OpenSave_GetFolderPath(hWndFileDlg, szSelection, MAX_PATH);
- char* pszFolder = szSelection;
- char* pszTmp = szSelection;
- while (*pszTmp != '\0') {
- if (*pszTmp == '\\' && *(pszTmp + 1))
- pszFolder = pszTmp + 1;
- pszTmp++;
- }
+ static char szSelection[MAX_PATH] = "";
+ HWND hWndFileDlg = GetParent(hDlg);
+
+ *szSelection = '/';
+ CommDlg_OpenSave_GetSpec(hWndFileDlg, (LPARAM)&szSelection[1], _MAX_PATH);
+
+ HWND hFileName = GetDlgItem(hWndFileDlg, edt1);
+ char pszFileName[MAX_PATH];
+ GetWindowText(hFileName, pszFileName, _countof(pszFileName));
+
+ if (mir_strcmp(pstShare->pszSrvPath, szSelection) &&
+ mir_strcmp(pszFileName, pszShareDirStr)) {
+ // a file was selected
+
+ // only reenable windows / set default values when a folder was selected before
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/') {
+ pNotify->lpOFN->Flags |= OFN_FILEMUSTEXIST;
+ EnableWindow(hFileName, TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), TRUE);
+ SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, nDefaultDownloadLimit, true);
+ }
+ }
+ else {
+ // a directory was selected
+ pNotify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
+ mir_strcpy(pNotify->lpOFN->lpstrFile, pszShareDirStr);
+ CommDlg_OpenSave_SetControlText(hWndFileDlg, edt1, pszShareDirStr);
+ EnableWindow(hFileName, FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_MAX_DOWNLOADS), FALSE);
+ SetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, (UINT)-1, true);
+
+ CommDlg_OpenSave_GetFolderPath(hWndFileDlg, szSelection, MAX_PATH);
+ char* pszFolder = szSelection;
+ char* pszTmp = szSelection;
+ while (*pszTmp != '\0') {
+ if (*pszTmp == '\\' && *(pszTmp + 1))
+ pszFolder = pszTmp + 1;
+ pszTmp++;
+ }
- pszTmp = strchr(szSelection, ':');
- if (pszTmp != nullptr)
- *pszTmp = '\0';
+ pszTmp = strchr(szSelection, ':');
+ if (pszTmp != nullptr)
+ *pszTmp = '\0';
- memmove(&szSelection[1], pszFolder, mir_strlen(pszFolder) + 1);
- szSelection[0] = '/';
- if (szSelection[mir_strlen(szSelection) - 1] != '/')
- mir_strcat(szSelection, "/");
+ memmove(&szSelection[1], pszFolder, mir_strlen(pszFolder) + 1);
+ szSelection[0] = '/';
+ if (szSelection[mir_strlen(szSelection) - 1] != '/')
+ mir_strcat(szSelection, "/");
- // only write to IDC_SHARE_NAME when a file / other folder was selected before
- if (!mir_strcmp(szSelection, pstShare->pszSrvPath))
- return false;
- }
+ // only write to IDC_SHARE_NAME when a file / other folder was selected before
+ if (!mir_strcmp(szSelection, pstShare->pszSrvPath))
+ return false;
+ }
- if (nInit != 0) {
- // when the dialog is created a CDN_FOLDERCHANGE and a CDN_SELCHANGE message
- // is posted. When the dialog is used for editting make sure the right server
- // path (not the auto generated) is written to IDC_SHARE_NAME
- if (nInit == 2)
- SetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath);
+ if (nInit != 0) {
+ // when the dialog is created a CDN_FOLDERCHANGE and a CDN_SELCHANGE message
+ // is posted. When the dialog is used for editting make sure the right server
+ // path (not the auto generated) is written to IDC_SHARE_NAME
+ if (nInit == 2)
+ SetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath);
- nInit--;
- }
- else {
- SetDlgItemText(hDlg, IDC_SHARE_NAME, szSelection);
- }
+ nInit--;
+ }
+ else {
+ SetDlgItemText(hDlg, IDC_SHARE_NAME, szSelection);
+ }
- mir_strcpy(pstShare->pszSrvPath, szSelection);
+ mir_strcpy(pstShare->pszSrvPath, szSelection);
- return false;
- }
+ return false;
+ }
- case CDN_FILEOK:
- {
- GetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath, _MAX_PATH);
+ case CDN_FILEOK:
+ {
+ GetDlgItemText(hDlg, IDC_SHARE_NAME, pstShare->pszSrvPath, _MAX_PATH);
- char* pszTmp = strstr(pstShare->pszRealPath, pszShareDirStr);
- if (pszTmp) {
- *pszTmp = '\0';
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] != '/')
- mir_strcat(pstShare->pszSrvPath, "/");
- }
- else {
- if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/')
- pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] = '\0';
- }
+ char* pszTmp = strstr(pstShare->pszRealPath, pszShareDirStr);
+ if (pszTmp) {
+ *pszTmp = '\0';
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] != '/')
+ mir_strcat(pstShare->pszSrvPath, "/");
+ }
+ else {
+ if (pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] == '/')
+ pstShare->pszSrvPath[mir_strlen(pstShare->pszSrvPath) - 1] = '\0';
+ }
- BOOL bTranslated = false;
- pstShare->nMaxDownloads = GetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, &bTranslated, true);
- if (pstShare->nMaxDownloads <= 0 && pstShare->nMaxDownloads != -1)
- bTranslated = false;
+ BOOL bTranslated = false;
+ pstShare->nMaxDownloads = GetDlgItemInt(hDlg, IDC_MAX_DOWNLOADS, &bTranslated, true);
+ if (pstShare->nMaxDownloads <= 0 && pstShare->nMaxDownloads != -1)
+ bTranslated = false;
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IPADDRESS, IPM_GETADDRESS, 0, (LPARAM)&(pstShare->dwAllowedIP));
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&(pstShare->dwAllowedMask));
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IPADDRESS, IPM_GETADDRESS, 0, (LPARAM)&(pstShare->dwAllowedIP));
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&(pstShare->dwAllowedMask));
- //if( ! (pstShare->dwAllowedIP & pstShare->dwAllowedMask)
+ //if( ! (pstShare->dwAllowedIP & pstShare->dwAllowedMask)
- if (!bTranslated || (mir_strlen(pstShare->pszSrvPath) <= 0)) {
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 1);
- return true;
- }
- return false;
- }
+ if (!bTranslated || (mir_strlen(pstShare->pszSrvPath) <= 0)) {
+ SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 1);
+ return true;
}
- break;
+ return false;
+ }
}
+ break;
+ }
case WM_DROPFILES:
- {
- HDROP hDrop = (HDROP)wParam;
- char szDropedFile[MAX_PATH];
- int nLen = DragQueryFile(hDrop, 0, szDropedFile, sizeof(szDropedFile));
- if (nLen > 0) {
- char * psz = strrchr(szDropedFile, '\\');
- if (psz) {
- char oldNext = psz[1];
- psz[1] = '\0';
- // Fill in the directory
- SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)szDropedFile);
- // click on the OK button. to move to dir
- SendMessage(GetParent(hDlg), WM_COMMAND, IDOK, 0);
- psz[1] = oldNext;
- // Fill in the file name this will cause a call to the CDN_SELCHANGE
- // and there by set the share name
- SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)&psz[1]);
- }
+ {
+ HDROP hDrop = (HDROP)wParam;
+ char szDropedFile[MAX_PATH];
+ int nLen = DragQueryFile(hDrop, 0, szDropedFile, sizeof(szDropedFile));
+ if (nLen > 0) {
+ char * psz = strrchr(szDropedFile, '\\');
+ if (psz) {
+ char oldNext = psz[1];
+ psz[1] = '\0';
+ // Fill in the directory
+ SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)szDropedFile);
+ // click on the OK button. to move to dir
+ SendMessage(GetParent(hDlg), WM_COMMAND, IDOK, 0);
+ psz[1] = oldNext;
+ // Fill in the file name this will cause a call to the CDN_SELCHANGE
+ // and there by set the share name
+ SendMessage(GetParent(hDlg), CDM_SETCONTROLTEXT, edt1, (LPARAM)&psz[1]);
}
- DragFinish(hDrop);
- return 0;
}
+ DragFinish(hDrop);
+ return 0;
+ }
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_TOGGLE_MASK:
- {
- DWORD dwCur;
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&dwCur);
- SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, (LPARAM)dwCur == 0xFFFFFFFF ? 0 : 0xFFFFFFFF);
- return TRUE;
- }
+ {
+ DWORD dwCur;
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_GETADDRESS, 0, (LPARAM)&dwCur);
+ SendDlgItemMessage(hDlg, IDC_ALLOWED_IP_MASK, IPM_SETADDRESS, 0, (LPARAM)dwCur == 0xFFFFFFFF ? 0 : 0xFFFFFFFF);
+ return TRUE;
+ }
}
}
return false;
@@ -461,7 +461,7 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare)
| OFN_ENABLEHOOK | OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLESIZING
| OFN_ALLOWMULTISELECT;
ofn.hwndOwner = hwndOwner;
- ofn.hInstance = hInstance;
+ ofn.hInstance = g_plugin.getInst();
ofn.lpstrTitle = Translate("Specify a file to share");
ofn.lpTemplateName = MAKEINTRESOURCE(IDD_NEW_SHARE_PROPERTIES);
ofn.lpfnHook = ShareNewFileDialogHook;
@@ -699,70 +699,70 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
{
switch (msg) {
case WM_INITDIALOG:
- {
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
- (LPARAM)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
-
- TranslateDialogDefault(hwndDlg);
+ {
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG,
+ (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
- HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS);
+ TranslateDialogDefault(hwndDlg);
- { // init adv. win styles
- DWORD dw = ListView_GetExtendedListViewStyle(hShareList);
- dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
- ListView_SetExtendedListViewStyle(hShareList, dw /*| LVS_EX_LABELTIP*/);
- }
- { // init adv. win styles
- DWORD dw = ListView_GetExtendedListViewStyle(hUserList);
- dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
- ListView_SetExtendedListViewStyle(hUserList, dw /*| LVS_EX_LABELTIP*/);
- }
+ HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
+ HWND hUserList = GetDlgItem(hwndDlg, IDC_CURRENT_USERS);
- LVCOLUMN cCol = { 0 };
- cCol.mask = LVCF_TEXT | LVCF_WIDTH;
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx1", 126);
- cCol.pszText = Translate("Share name");
- ListView_InsertColumn(hShareList, 0, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx2", 48);
- cCol.pszText = Translate("Max Downloads");
- ListView_InsertColumn(hShareList, 1, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx3", 96);
- cCol.pszText = Translate("Allowed IP");
- ListView_InsertColumn(hShareList, 2, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx4", 104);
- cCol.pszText = Translate("Allowed Mask");
- ListView_InsertColumn(hShareList, 3, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx5", 252);
- cCol.pszText = Translate("Real path");
- ListView_InsertColumn(hShareList, 4, &cCol);
-
- cCol.mask = LVCF_TEXT | LVCF_WIDTH;
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx6", 142);
- cCol.pszText = Translate("Share name");
- ListView_InsertColumn(hUserList, 0, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx7", 111);
- cCol.pszText = Translate("User");
- ListView_InsertColumn(hUserList, 1, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx8", 100);
- cCol.pszText = Translate("Agent");
- ListView_InsertColumn(hUserList, 2, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx9", 100);
- cCol.pszText = Translate("Completed");
- ListView_InsertColumn(hUserList, 3, &cCol);
- cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx10", 100);
- cCol.pszText = Translate("Speed");
- ListView_InsertColumn(hUserList, 4, &cCol);
-
- bool b = db_get_b(NULL, MODULE, "StatWnd_ShowHidden", 0) != 0;
- CheckDlgButton(hwndDlg, IDC_SHOWHIDDENSHARES, b ? BST_CHECKED : BST_UNCHECKED);
-
- bLastAutoRefress = false;
- UpdateStatisticView(hwndDlg);
- Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "StatWnd_");
- SetWindowsCtrls(hwndDlg);
+ { // init adv. win styles
+ DWORD dw = ListView_GetExtendedListViewStyle(hShareList);
+ dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
+ ListView_SetExtendedListViewStyle(hShareList, dw /*| LVS_EX_LABELTIP*/);
+ }
+ { // init adv. win styles
+ DWORD dw = ListView_GetExtendedListViewStyle(hUserList);
+ dw |= LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT;
+ ListView_SetExtendedListViewStyle(hUserList, dw /*| LVS_EX_LABELTIP*/);
}
- return TRUE;
+
+ LVCOLUMN cCol = { 0 };
+ cCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx1", 126);
+ cCol.pszText = Translate("Share name");
+ ListView_InsertColumn(hShareList, 0, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx2", 48);
+ cCol.pszText = Translate("Max Downloads");
+ ListView_InsertColumn(hShareList, 1, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx3", 96);
+ cCol.pszText = Translate("Allowed IP");
+ ListView_InsertColumn(hShareList, 2, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx4", 104);
+ cCol.pszText = Translate("Allowed Mask");
+ ListView_InsertColumn(hShareList, 3, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx5", 252);
+ cCol.pszText = Translate("Real path");
+ ListView_InsertColumn(hShareList, 4, &cCol);
+
+ cCol.mask = LVCF_TEXT | LVCF_WIDTH;
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx6", 142);
+ cCol.pszText = Translate("Share name");
+ ListView_InsertColumn(hUserList, 0, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx7", 111);
+ cCol.pszText = Translate("User");
+ ListView_InsertColumn(hUserList, 1, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx8", 100);
+ cCol.pszText = Translate("Agent");
+ ListView_InsertColumn(hUserList, 2, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx9", 100);
+ cCol.pszText = Translate("Completed");
+ ListView_InsertColumn(hUserList, 3, &cCol);
+ cCol.cx = db_get_w(NULL, MODULE, "StatWnd_cx10", 100);
+ cCol.pszText = Translate("Speed");
+ ListView_InsertColumn(hUserList, 4, &cCol);
+
+ bool b = db_get_b(NULL, MODULE, "StatWnd_ShowHidden", 0) != 0;
+ CheckDlgButton(hwndDlg, IDC_SHOWHIDDENSHARES, b ? BST_CHECKED : BST_UNCHECKED);
+
+ bLastAutoRefress = false;
+ UpdateStatisticView(hwndDlg);
+ Utils_RestoreWindowPosition(hwndDlg, 0, MODULE, "StatWnd_");
+ SetWindowsCtrls(hwndDlg);
+ }
+ return TRUE;
case WM_SIZE:
case WM_SIZING:
@@ -782,178 +782,178 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara
return 0;
case WM_DROPFILES:
- {
- HDROP hDrop = (HDROP)wParam;
- char szDropedFile[MAX_PATH];
- char szServPath[MAX_PATH] = { 0 };
-
- int nLen = DragQueryFile(hDrop, 0xFFFFFFFF, nullptr, 0);
- for (int i = 0; i < nLen; i++) {
- DragQueryFile(hDrop, i, szDropedFile, sizeof(szDropedFile));
-
- STFileShareInfo stNewShare = { 0 };
- stNewShare.lStructSize = sizeof(STFileShareInfo);
- stNewShare.nMaxDownloads = nDefaultDownloadLimit;
- stNewShare.pszRealPath = szDropedFile;
- stNewShare.dwMaxRealPath = sizeof(szDropedFile);
- stNewShare.pszSrvPath = szServPath;
- stNewShare.dwMaxSrvPath = sizeof(szServPath);
-
- szServPath[0] = '/';
- char* fileName = strrchr(szDropedFile, '\\');
- if (fileName)
- strncpy(&szServPath[1], fileName + 1, MAX_PATH - 2);
-
- if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stNewShare)) {
- MessageBox(nullptr, Translate("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
- return false;
- }
+ {
+ HDROP hDrop = (HDROP)wParam;
+ char szDropedFile[MAX_PATH];
+ char szServPath[MAX_PATH] = { 0 };
+
+ int nLen = DragQueryFile(hDrop, 0xFFFFFFFF, nullptr, 0);
+ for (int i = 0; i < nLen; i++) {
+ DragQueryFile(hDrop, i, szDropedFile, sizeof(szDropedFile));
+
+ STFileShareInfo stNewShare = { 0 };
+ stNewShare.lStructSize = sizeof(STFileShareInfo);
+ stNewShare.nMaxDownloads = nDefaultDownloadLimit;
+ stNewShare.pszRealPath = szDropedFile;
+ stNewShare.dwMaxRealPath = sizeof(szDropedFile);
+ stNewShare.pszSrvPath = szServPath;
+ stNewShare.dwMaxSrvPath = sizeof(szServPath);
+
+ szServPath[0] = '/';
+ char* fileName = strrchr(szDropedFile, '\\');
+ if (fileName)
+ strncpy(&szServPath[1], fileName + 1, MAX_PATH - 2);
+
+ if (CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stNewShare)) {
+ MessageBox(nullptr, Translate("Failed to share new file"), MSG_BOX_TITEL, MB_OK);
+ return false;
}
-
- UpdateStatisticsView();
- DragFinish(hDrop);
- return 0;
}
+ UpdateStatisticsView();
+ DragFinish(hDrop);
+ return 0;
+ }
+
case WM_CONTEXTMENU:
- {
- if (wParam != (WPARAM)GetDlgItem(hwndDlg, IDC_CURRENT_SHARES))
- return FALSE;
-
- HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- if (ListView_GetNextItem(hShareList, -1, LVIS_SELECTED) == -1)
- return FALSE;
-
- HMENU hMainMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
- if (hMainMenu) {
- HMENU hMenu = GetSubMenu(hMainMenu, 0);
-
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
- if (pt.x == -1 && pt.y == -1) {
- HWND hMapUser = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- int nFirst = ListView_GetNextItem(hMapUser, -1, LVNI_FOCUSED);
- if (nFirst >= 0) {
- ListView_GetItemPosition(hMapUser, nFirst, &pt);
- }
+ {
+ if (wParam != (WPARAM)GetDlgItem(hwndDlg, IDC_CURRENT_SHARES))
+ return FALSE;
- if (pt.y < 16)
- pt.y = 16;
- else {
- RECT rUserList;
- GetClientRect(hMapUser, &rUserList);
- if (pt.y > rUserList.bottom - 16)
- pt.y = rUserList.bottom - 16;
- else
- pt.y += 8;
- }
- pt.x = 8;
- ClientToScreen(hMapUser, &pt);
+ HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
+ if (ListView_GetNextItem(hShareList, -1, LVIS_SELECTED) == -1)
+ return FALSE;
+
+ HMENU hMainMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
+ if (hMainMenu) {
+ HMENU hMenu = GetSubMenu(hMainMenu, 0);
+
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+ if (pt.x == -1 && pt.y == -1) {
+ HWND hMapUser = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
+ int nFirst = ListView_GetNextItem(hMapUser, -1, LVNI_FOCUSED);
+ if (nFirst >= 0) {
+ ListView_GetItemPosition(hMapUser, nFirst, &pt);
}
- TranslateMenu(hMenu);
- TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
- pt.x, pt.y, 0, hwndDlg, nullptr);
-
- DestroyMenu(hMainMenu);
+ if (pt.y < 16)
+ pt.y = 16;
+ else {
+ RECT rUserList;
+ GetClientRect(hMapUser, &rUserList);
+ if (pt.y > rUserList.bottom - 16)
+ pt.y = rUserList.bottom - 16;
+ else
+ pt.y += 8;
+ }
+ pt.x = 8;
+ ClientToScreen(hMapUser, &pt);
}
- return TRUE;
+
+ TranslateMenu(hMenu);
+ TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
+ pt.x, pt.y, 0, hwndDlg, nullptr);
+
+ DestroyMenu(hMainMenu);
}
+ return TRUE;
+ }
case WM_COMMAND:
+ {
+ HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
+ char szTmp[MAX_PATH];
+ LVITEM sItem = { 0 };
+ sItem.mask = LVIF_TEXT;
+ sItem.pszText = szTmp;
+ sItem.cchTextMax = _countof(szTmp);
+
+ switch (LOWORD(wParam)) {
+ case IDC_SHOWHIDDENSHARES:
{
- HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
- char szTmp[MAX_PATH];
- LVITEM sItem = { 0 };
- sItem.mask = LVIF_TEXT;
- sItem.pszText = szTmp;
- sItem.cchTextMax = _countof(szTmp);
+ UpdateStatisticView(hwndDlg);
+ return TRUE;
+ }
- switch (LOWORD(wParam)) {
- case IDC_SHOWHIDDENSHARES:
- {
- UpdateStatisticView(hwndDlg);
- return TRUE;
- }
+ case ID_SHARELIST_NEWSHARE:
+ {
+ CallService(MS_SHARE_NEW_FILE, 0, (LPARAM)hwndDlg);
+ return TRUE;
+ }
- case ID_SHARELIST_NEWSHARE:
- {
- CallService(MS_SHARE_NEW_FILE, 0, (LPARAM)hwndDlg);
- return TRUE;
+ case ID_SHARELIST_EDITSHARE:
+ case ID_SHARELIST_REMOVESHARE:
+ {
+ STFileShareInfo stShareInfo = { 0 };
+ stShareInfo.lStructSize = sizeof(STFileShareInfo);
+ stShareInfo.pszSrvPath = szTmp;
+ stShareInfo.dwMaxSrvPath = sizeof(szTmp);
+
+ sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
+ while (sItem.iItem != -1) {
+ if (ListView_GetItem(hShareList, &sItem)) {
+ if (LOWORD(wParam) == ID_SHARELIST_REMOVESHARE)
+ CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stShareInfo);
+ else {
+ char szRealPath[MAX_PATH];
+ stShareInfo.pszRealPath = szRealPath;
+ stShareInfo.dwMaxRealPath = sizeof(szRealPath);
+ CallService(MS_HTTP_GET_SHARE, 0, (LPARAM)&stShareInfo);
+ bShowShareNewFileDlg(hwndDlg, &stShareInfo);
+ }
}
+ sItem.iItem = ListView_GetNextItem(hShareList, sItem.iItem, LVIS_SELECTED);
+ }
+ UpdateStatisticView(hwndDlg);
+ return TRUE;
+ }
- case ID_SHARELIST_EDITSHARE:
- case ID_SHARELIST_REMOVESHARE:
- {
- STFileShareInfo stShareInfo = { 0 };
- stShareInfo.lStructSize = sizeof(STFileShareInfo);
- stShareInfo.pszSrvPath = szTmp;
- stShareInfo.dwMaxSrvPath = sizeof(szTmp);
-
- sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
- while (sItem.iItem != -1) {
- if (ListView_GetItem(hShareList, &sItem)) {
- if (LOWORD(wParam) == ID_SHARELIST_REMOVESHARE)
- CallService(MS_HTTP_ADD_CHANGE_REMOVE, 0, (LPARAM)&stShareInfo);
- else {
- char szRealPath[MAX_PATH];
- stShareInfo.pszRealPath = szRealPath;
- stShareInfo.dwMaxRealPath = sizeof(szRealPath);
- CallService(MS_HTTP_GET_SHARE, 0, (LPARAM)&stShareInfo);
- bShowShareNewFileDlg(hwndDlg, &stShareInfo);
- }
- }
- sItem.iItem = ListView_GetNextItem(hShareList, sItem.iItem, LVIS_SELECTED);
+ case ID_SHARELIST_OPEN:
+ case ID_SHARELIST_COPYLINK:
+ sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
+ if (sItem.iItem != -1) {
+ if (ListView_GetItem(hShareList, &sItem)) {
+ string sLink = sCreateLink(sItem.pszText);
+ if (sLink.size() <= 0) {
+ MessageBox(hwndDlg, Translate("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
+ return TRUE;
}
- UpdateStatisticView(hwndDlg);
- return TRUE;
- }
- case ID_SHARELIST_OPEN:
- case ID_SHARELIST_COPYLINK:
- sItem.iItem = ListView_GetNextItem(hShareList, -1, LVIS_SELECTED);
- if (sItem.iItem != -1) {
- if (ListView_GetItem(hShareList, &sItem)) {
- string sLink = sCreateLink(sItem.pszText);
- if (sLink.size() <= 0) {
- MessageBox(hwndDlg, Translate("Selected link size is 0"), MSG_BOX_TITEL, MB_OK);
+ if (LOWORD(wParam) == ID_SHARELIST_COPYLINK) {
+ if (!OpenClipboard(hwndDlg)) {
+ MessageBox(hwndDlg, Translate("Failed to get access to clipboard"), MSG_BOX_TITEL, MB_OK);
return TRUE;
}
- if (LOWORD(wParam) == ID_SHARELIST_COPYLINK) {
- if (!OpenClipboard(hwndDlg)) {
- MessageBox(hwndDlg, Translate("Failed to get access to clipboard"), MSG_BOX_TITEL, MB_OK);
- return TRUE;
- }
-
- if (!EmptyClipboard()) {
- MessageBox(hwndDlg, Translate("Failed to get close the clipboard"), MSG_BOX_TITEL, MB_OK);
- return TRUE;
- }
+ if (!EmptyClipboard()) {
+ MessageBox(hwndDlg, Translate("Failed to get close the clipboard"), MSG_BOX_TITEL, MB_OK);
+ return TRUE;
+ }
- HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, sLink.size() + 1);
- // Lock the handle and copy the text to the buffer.
- char * lptstrCopy = (char *)GlobalLock(hglbCopy);
- mir_strcpy(lptstrCopy, sLink.c_str());
- GlobalUnlock(hglbCopy);
+ HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, sLink.size() + 1);
+ // Lock the handle and copy the text to the buffer.
+ char * lptstrCopy = (char *)GlobalLock(hglbCopy);
+ mir_strcpy(lptstrCopy, sLink.c_str());
+ GlobalUnlock(hglbCopy);
- // Place the handle on the clipboard.
+ // Place the handle on the clipboard.
- HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
- if (!hMyData)
- MessageBox(hwndDlg, Translate("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
+ HANDLE hMyData = SetClipboardData(CF_TEXT, hglbCopy);
+ if (!hMyData)
+ MessageBox(hwndDlg, Translate("Failed to set clipboard data"), MSG_BOX_TITEL, MB_OK);
- CloseClipboard();
- }
- else Utils_OpenUrl(sLink.c_str());
+ CloseClipboard();
}
- else MessageBox(hwndDlg, Translate("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
+ else Utils_OpenUrl(sLink.c_str());
}
- else MessageBox(hwndDlg, Translate("No share selected"), MSG_BOX_TITEL, MB_OK);
-
- return TRUE;
+ else MessageBox(hwndDlg, Translate("ListView_GetItem failed"), MSG_BOX_TITEL, MB_OK);
}
- break;
+ else MessageBox(hwndDlg, Translate("No share selected"), MSG_BOX_TITEL, MB_OK);
+
+ return TRUE;
}
+ break;
+ }
case WM_CLOSE:
HWND hShareList = GetDlgItem(hwndDlg, IDC_CURRENT_SHARES);
@@ -1077,7 +1077,7 @@ static INT_PTR nShowStatisticsView(WPARAM /*wParam*/, LPARAM /*lParam*/)
BringWindowToTop(hwndStatsticView);
return 0;
}
- hwndStatsticView = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_STATISTICS_VIEW), nullptr, DlgProcStatsticView, (LPARAM)NULL);
+ hwndStatsticView = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_STATISTICS_VIEW), nullptr, DlgProcStatsticView, (LPARAM)NULL);
ShowWindow(hwndStatsticView, SW_SHOWNORMAL);
return 0;
}
@@ -1102,72 +1102,72 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
switch (msg) {
case WM_INITDIALOG:
- {
- string sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
- SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
+ {
+ string sDefExt = DBGetString(NULL, MODULE, "ExternalSrvName", szDefaultExternalSrvName);
+ SetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, sDefExt.c_str());
- bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+ bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
+ CheckDlgButton(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
- b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
- CheckDlgButton(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
+ b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
+ CheckDlgButton(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM, b ? BST_CHECKED : BST_UNCHECKED);
- b = db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0;
- CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, b ? BST_CHECKED : BST_UNCHECKED);
+ b = db_get_b(NULL, MODULE, "WriteLogFile", 0) != 0;
+ CheckDlgButton(hwndDlg, IDC_WRITE_LOG_FILE, b ? 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);
+ CheckDlgButton(hwndDlg, IDC_SHOW_POPUPS, bShowPopups ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE, bLimitOnlyWhenOnline ? BST_CHECKED : BST_UNCHECKED);
- {// Url Address
- SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, sUrlAddress.c_str());
- HWND hComboBox = GetDlgItem(hwndDlg, IDC_URL_ADDRESS);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://checkip.dyndns.org");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://checkip.dyndns.org:8245/");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://dynamic.zoneedit.com/checkip.html");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://ipdetect.dnspark.com/");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://update.dynu.com/basic/ipcheck.asp");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://www.dnsart.com/myip.php");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://www.dnsart.com:7777/myip.php");
- }
+ {// Url Address
+ SetDlgItemText(hwndDlg, IDC_URL_ADDRESS, sUrlAddress.c_str());
+ HWND hComboBox = GetDlgItem(hwndDlg, IDC_URL_ADDRESS);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://checkip.dyndns.org");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://checkip.dyndns.org:8245/");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://dynamic.zoneedit.com/checkip.html");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://ipdetect.dnspark.com/");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://update.dynu.com/basic/ipcheck.asp");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://www.dnsart.com/myip.php");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"http://www.dnsart.com:7777/myip.php");
+ }
- {// Page keyword
- SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, sPageKeyword.c_str());
- HWND hComboBox = GetDlgItem(hwndDlg, IDC_PAGE_KEYWORD);
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"");
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("Current IP Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("Current Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("IP Address: "));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("You are browsing from"));
- SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"<HTML><BODY>");
- }
+ {// Page keyword
+ SetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, sPageKeyword.c_str());
+ HWND hComboBox = GetDlgItem(hwndDlg, IDC_PAGE_KEYWORD);
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"");
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("Current IP Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("Current Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("IP Address: "));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)LPGEN("You are browsing from"));
+ SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)"<HTML><BODY>");
+ }
- SetDlgItemInt(hwndDlg, IDC_MAX_SPEED, nMaxUploadSpeed >> 10, true);
- SetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, nMaxConnectionsTotal, true);
- SetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, nMaxConnectionsPerUser, true);
- SetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, nDefaultDownloadLimit, true);
-
- indexCreationMode =
- (eIndexCreationMode)db_get_b(NULL, MODULE, "IndexCreationMode", 3);
-
- switch (indexCreationMode) {
- case INDEX_CREATION_HTML:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_HTML);
- break;
- case INDEX_CREATION_XML:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_XML);
- break;
- case INDEX_CREATION_DETECT:
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_DETECT);
- break;
- default: // INDEX_CREATION_DISABLE
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_OFF);
- break;
- }
+ SetDlgItemInt(hwndDlg, IDC_MAX_SPEED, nMaxUploadSpeed >> 10, true);
+ SetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, nMaxConnectionsTotal, true);
+ SetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, nMaxConnectionsPerUser, true);
+ SetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, nDefaultDownloadLimit, true);
- TranslateDialogDefault(hwndDlg);
+ indexCreationMode =
+ (eIndexCreationMode)db_get_b(NULL, MODULE, "IndexCreationMode", 3);
+
+ switch (indexCreationMode) {
+ case INDEX_CREATION_HTML:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_HTML);
+ break;
+ case INDEX_CREATION_XML:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_XML);
+ break;
+ case INDEX_CREATION_DETECT:
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_DETECT);
+ break;
+ default: // INDEX_CREATION_DISABLE
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_DETECT, IDC_INDEX_OFF);
+ break;
}
- return TRUE;
+
+ TranslateDialogDefault(hwndDlg);
+ }
+ return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
@@ -1229,94 +1229,94 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
NMHDR * p = ((LPNMHDR)lParam);
switch (p->code) {
case PSN_APPLY:
- {
- char szTemp[500];
- if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp)))
- db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
-
- bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
- bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- db_set_b(NULL, MODULE, "AddStatisticsMenuItem", bNew);
- MessageBox(hwndDlg, Translate("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
- }
+ {
+ char szTemp[500];
+ if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp)))
+ db_set_s(NULL, MODULE, "ExternalSrvName", szTemp);
- b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
- bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
- if (b != bNew) {
- db_set_b(NULL, MODULE, "AddAcceptConMenuItem", bNew);
- MessageBox(hwndDlg, Translate("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
- }
+ bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0;
+ bool bNew = IsDlgButtonChecked(hwndDlg, IDC_ADD_STATISTICS_MENU_ITEM) == BST_CHECKED;
+ if (b != bNew) {
+ db_set_b(NULL, MODULE, "AddStatisticsMenuItem", bNew);
+ MessageBox(hwndDlg, Translate("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
+ }
- bNew = IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED;
- db_set_b(NULL, MODULE, "WriteLogFile", bNew);
+ b = db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1) != 0;
+ bNew = IsDlgButtonChecked(hwndDlg, IDC_ACCEPT_COM_MENU_ITEM) == BST_CHECKED;
+ if (b != bNew) {
+ db_set_b(NULL, MODULE, "AddAcceptConMenuItem", bNew);
+ MessageBox(hwndDlg, Translate("You need to restart Miranda to change the main menu"), MSG_BOX_TITEL, MB_OK);
+ }
- bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
- db_set_b(NULL, MODULE, "ShowPopups", bShowPopups);
+ bNew = IsDlgButtonChecked(hwndDlg, IDC_WRITE_LOG_FILE) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "WriteLogFile", bNew);
- GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, _countof(szTemp));
- sUrlAddress = szTemp;
- db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
+ bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "ShowPopups", bShowPopups);
- GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, _countof(szTemp));
- sPageKeyword = szTemp;
- db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
- dwExternalIpAddress = 0;
+ GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, _countof(szTemp));
+ sUrlAddress = szTemp;
+ db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str());
- BOOL bTranslated = false;
- int nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_SPEED, &bTranslated, true);
- if (bTranslated) {
- nMaxUploadSpeed = nTemp << 10;
- db_set_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
- }
+ GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, _countof(szTemp));
+ sPageKeyword = szTemp;
+ db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str());
+ dwExternalIpAddress = 0;
- nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, &bTranslated, true);
- if (bTranslated) {
- nMaxConnectionsTotal = nTemp;
- db_set_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
- }
+ BOOL bTranslated = false;
+ int nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_SPEED, &bTranslated, true);
+ if (bTranslated) {
+ nMaxUploadSpeed = nTemp << 10;
+ db_set_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
+ }
- nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, &bTranslated, true);
- if (bTranslated) {
- nMaxConnectionsPerUser = nTemp;
- db_set_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
- }
+ nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_TOTAL, &bTranslated, true);
+ if (bTranslated) {
+ nMaxConnectionsTotal = nTemp;
+ db_set_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
+ }
- nTemp = GetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, &bTranslated, true);
- if (bTranslated) {
- nDefaultDownloadLimit = nTemp;
- db_set_dw(NULL, MODULE, "DefaultDownloadLimit", nDefaultDownloadLimit);
- }
+ nTemp = GetDlgItemInt(hwndDlg, IDC_MAX_CONN_PER_USER, &bTranslated, true);
+ if (bTranslated) {
+ nMaxConnectionsPerUser = nTemp;
+ db_set_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
+ }
- bLimitOnlyWhenOnline = IsDlgButtonChecked(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE) == BST_CHECKED;
- db_set_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline);
+ nTemp = GetDlgItemInt(hwndDlg, IDC_DEFAULT_DOWNLOAD_LIMIT, &bTranslated, true);
+ if (bTranslated) {
+ nDefaultDownloadLimit = nTemp;
+ db_set_dw(NULL, MODULE, "DefaultDownloadLimit", nDefaultDownloadLimit);
+ }
- if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED ||
- IsDlgButtonChecked(hwndDlg, IDC_INDEX_DETECT) == BST_CHECKED) {
- if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED)
- indexCreationMode = INDEX_CREATION_HTML;
- else
- indexCreationMode = INDEX_CREATION_DETECT;
+ bLimitOnlyWhenOnline = IsDlgButtonChecked(hwndDlg, IDC_LIMIT_ONLY_WHEN_ONLINE) == BST_CHECKED;
+ db_set_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline);
- if (!LoadIndexHTMLTemplate()) {
- CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_XML, IDC_INDEX_OFF);
- indexCreationMode = INDEX_CREATION_DISABLE;
- }
- }
- else if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_XML) == BST_CHECKED) {
- FreeIndexHTMLTemplate();
- indexCreationMode = INDEX_CREATION_XML;
- }
- else {
- FreeIndexHTMLTemplate();
+ if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED ||
+ IsDlgButtonChecked(hwndDlg, IDC_INDEX_DETECT) == BST_CHECKED) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_HTML) == BST_CHECKED)
+ indexCreationMode = INDEX_CREATION_HTML;
+ else
+ indexCreationMode = INDEX_CREATION_DETECT;
+
+ if (!LoadIndexHTMLTemplate()) {
+ CheckRadioButton(hwndDlg, IDC_INDEX_OFF, IDC_INDEX_XML, IDC_INDEX_OFF);
indexCreationMode = INDEX_CREATION_DISABLE;
}
+ }
+ else if (IsDlgButtonChecked(hwndDlg, IDC_INDEX_XML) == BST_CHECKED) {
+ FreeIndexHTMLTemplate();
+ indexCreationMode = INDEX_CREATION_XML;
+ }
+ else {
+ FreeIndexHTMLTemplate();
+ indexCreationMode = INDEX_CREATION_DISABLE;
+ }
- db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
+ db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
- return TRUE;
- }
- break;
+ return TRUE;
+ }
+ break;
}
}
return FALSE;
@@ -1340,7 +1340,7 @@ int OptionsInitialize(WPARAM wParam, LPARAM /*lParam*/)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 900000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_HTTP_SERVER);
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szTitle.w = LPGENW("HTTP Server");
@@ -1432,7 +1432,7 @@ void ShowPopupWindow(const char * pszName, const char * pszText, COLORREF ColorB
POPUPDATAT *pclData = new POPUPDATAT;
memset(pclData, 0, sizeof(POPUPDATAT));
- pclData->lchIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ pclData->lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(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;
@@ -1476,7 +1476,7 @@ void InitGuiElements()
CMenuItem mi;
mi.flags = CMIF_UNICODE;
SET_UID(mi, 0xb30a6ab5, 0x17a8, 0x4e2e, 0x84, 0x52, 0x5f, 0xbc, 0x83, 0x35, 0xf2, 0x6);
- mi.hIcolibItem = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
mi.position = -2000019955;
mi.name.w = LPGENW("HTTP Share new file");
mi.pszService = MS_SHARE_NEW_FILE;
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index 5409b6f430..d66eb04dc9 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -48,7 +48,6 @@ int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/);
HNETLIBUSER hNetlibUser;
HANDLE hDirectBoundPort;
-HINSTANCE hInstance = nullptr;
CLIST_INTERFACE *pcli;
string sLogFilePath;
@@ -83,6 +82,7 @@ bool bLimitOnlyWhenOnline = true;
bool bShutdownInProgress = false;
+CMPlugin g_plugin;
int hLangpack = 0;
extern HWND hwndStatsticView;
@@ -654,12 +654,12 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
dwLocalPortUsed = nlb.wPort;
dwLocalIpAddress = nlb.dwInternalIP;
- Menu_ModifyItem(hAcceptConnectionsMenuItem, LPGENW("Disable HTTP server"), LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DISABLE_SERVER)));
+ Menu_ModifyItem(hAcceptConnectionsMenuItem, LPGENW("Disable HTTP server"), LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DISABLE_SERVER)));
}
else if (hDirectBoundPort && wparam == 0) {
Netlib_CloseHandle(hDirectBoundPort);
hDirectBoundPort = nullptr;
- Menu_ModifyItem(hAcceptConnectionsMenuItem, LPGENW("Enable HTTP server"), LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
+ Menu_ModifyItem(hAcceptConnectionsMenuItem, LPGENW("Enable HTTP server"), LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHARE_NEW_FILE)));
}
else return 0; // no changes;
@@ -670,27 +670,6 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
}
/////////////////////////////////////////////////////////////////////
-// Member Function : DllMain
-// Type : Global
-// Parameters : hinst - ?
-// fdwReason - ?
-// lpvReserved - ?
-// Returns : BOOL WINAPI
-// Description :
-//
-// References : -
-// Remarks : -
-// Created : 020422, 22 April 2002
-// Developer : KN
-/////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/)
-{
- hInstance = hinst;
- return 1;
-}
-
-/////////////////////////////////////////////////////////////////////
// Member Function : MainInit
// Type : Global
// Parameters : wparam - ?
@@ -740,7 +719,7 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
nlu.flags = NUF_OUTGOING | NUF_INCOMING;
nlu.szSettingsModule = MODULE;
nlu.szDescriptiveName.a = Translate("HTTP Server");
- hNetlibUser = Netlib_RegisterUser(& nlu);
+ hNetlibUser = Netlib_RegisterUser(&nlu);
if (!hNetlibUser) {
MessageBox(nullptr, "Failed to register NetLib user", MSG_BOX_TITEL, MB_OK);
return 0;
@@ -920,7 +899,7 @@ extern "C" __declspec(dllexport) int Load()
CMenuItem mi;
SET_UID(mi, 0xf0a68784, 0xc30e, 0x4245, 0xb6, 0x2b, 0xb8, 0x71, 0x7e, 0xe6, 0xe1, 0x73);
mi.flags = CMIF_UNICODE;
- mi.hIcolibItem = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ 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;