summaryrefslogtreecommitdiff
path: root/plugins/HTTPServer/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-25 21:53:56 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-25 21:53:56 +0000
commit06bb38dfa357a731e16980d03ab100b84e5cb989 (patch)
tree686bd8edc9e71087bb943ec3fe6dbb5193d09247 /plugins/HTTPServer/src
parentcc6abc9eed963a2659c121ddec136f1ab4256535 (diff)
MS_CLUI_GETHWND & MS_CLUI_GETHWNDTREE replaced with pcli->hwndContactList & pcli->hwndContactTree respectively
git-svn-id: http://svn.miranda-ng.org/main/trunk@14386 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HTTPServer/src')
-rw-r--r--plugins/HTTPServer/src/Glob.h1
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp3
-rw-r--r--plugins/HTTPServer/src/main.cpp296
3 files changed, 152 insertions, 148 deletions
diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h
index 2b5fe8e8c3..48d4c18479 100644
--- a/plugins/HTTPServer/src/Glob.h
+++ b/plugins/HTTPServer/src/Glob.h
@@ -31,6 +31,7 @@ using namespace std;
#include <newpluginapi.h>
#include <m_database.h>
#include <m_clist.h>
+#include <m_clistint.h>
#include <m_langpack.h>
#include <m_clui.h>
#include <m_userinfo.h>
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index 257a89b772..0e98449539 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -15,7 +15,6 @@
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
#include "Glob.h"
#define MS_SHARE_NEW_FILE "HTTPServer/ShareNewFile"
@@ -1041,7 +1040,7 @@ static INT_PTR nShareNewFile(WPARAM hContact, LPARAM lParam)
stNewShare.dwAllowedMask = 0;
}
- if (! bShowShareNewFileDlg((HWND)(lParam ? lParam : CallService(MS_CLUI_GETHWND, 0, 0)), &stNewShare))
+ if (!bShowShareNewFileDlg((lParam ? HWND(lParam) : pcli->hwndContactList), &stNewShare))
return 0;
if (stNewShare.dwAllowedIP)
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index bdca6bfcf0..a885f8fe9f 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -49,6 +49,7 @@ HANDLE hNetlibUser;
HANDLE hDirectBoundPort;
HINSTANCE hInstance = NULL;
+CLIST_INTERFACE *pcli;
string sLogFilePath;
@@ -223,7 +224,8 @@ DWORD dwReadIPAddress(char * pszStr, bool &bError) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bReadConfigurationFile() {
+bool bReadConfigurationFile()
+{
CLFileShareListAccess clCritSection;
CLFileShareNode * pclLastNode = NULL;
@@ -326,7 +328,8 @@ bool bReadConfigurationFile() {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-bool bWriteConfigurationFile() {
+bool bWriteConfigurationFile()
+{
CLFileShareListAccess clCritSection;
char szBuf[1000];
mir_strcpy(szBuf, szPluginPath);
@@ -389,7 +392,8 @@ bool bWriteConfigurationFile() {
// Developer : KN, Houdini, changed By Sergio Vieira Rolanski
/////////////////////////////////////////////////////////////////////
-static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
+static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam)
+{
if (!lParam)
return 1001;
@@ -477,7 +481,8 @@ static INT_PTR nAddChangeRemoveShare(WPARAM wParam, LPARAM lParam) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam) {
+static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam)
+{
if (!lParam)
return 1001;
@@ -516,7 +521,8 @@ static INT_PTR nGetShare(WPARAM /*wParam*/, LPARAM lParam) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-static INT_PTR nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/) {/*
+static INT_PTR nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/)
+{/*
STFileShareInfo ** pTarget = (STFileShareInfo**)lParam;
CLFileShareNode * pclCur;
@@ -539,7 +545,6 @@ static INT_PTR nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/) {/*
return 0;
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : HandleNewConnection
// Type : Global
@@ -553,7 +558,8 @@ static INT_PTR nHttpGetAllShares(WPARAM /*wParam*/, LPARAM /*lParam*/) {/*
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void HandleNewConnection(void *ch) {
+void HandleNewConnection(void *ch)
+{
CLHttpUser * pclUser = (CLHttpUser *)ch;
pclUser->HandleNewConnection();
delete pclUser;
@@ -573,7 +579,8 @@ void HandleNewConnection(void *ch) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-void ConnectionOpen(HANDLE hNewConnection, DWORD dwRemoteIP) {
+void ConnectionOpen(HANDLE hNewConnection, DWORD dwRemoteIP)
+{
in_addr stAddr;
stAddr.S_un.S_addr = htonl(dwRemoteIP);
@@ -596,7 +603,8 @@ void ConnectionOpen(HANDLE hNewConnection, DWORD dwRemoteIP) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) {
+static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam)
+{
//todo: ignore weather protos
ACKDATA *ack = (ACKDATA *)lParam;
if (ack->type != ACKTYPE_STATUS || //only send for statuses
@@ -607,7 +615,6 @@ static int nProtoAck(WPARAM /*wParam*/, LPARAM lParam) {
return 0;
}
-
/////////////////////////////////////////////////////////////////////
// Member Function : nToggelAcceptConnections
// Type : Global
@@ -679,7 +686,8 @@ INT_PTR nToggelAcceptConnections(WPARAM wparam, LPARAM /*lparam*/)
// Developer : KN
/////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/) {
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/)
+{
hInstance = hinst;
return 1;
}
@@ -698,15 +706,9 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) {
- /*
- STFileShareInfo * pShares = (STFileShareInfo *)5;
- CallService(MS_HTTP_GET_ALL_SHARES, 0, (LPARAM) &pShares);
- MirandaFree( pShares );*/
-
- if (! bReadConfigurationFile()) {
- //MessageBox( NULL, "Failed to read configuration file : " szConfigFile, MSG_BOX_TITEL, MB_OK );
-
+int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/)
+{
+ if (!bReadConfigurationFile()) {
char szRealPath[MAX_PATH];
char szSrvPath[MAX_PATH] = {0};
STFileShareInfo share;
@@ -736,7 +738,6 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) {
bWriteConfigurationFile();
}
-
NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_TCHAR;
@@ -770,7 +771,8 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
+int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/)
+{
{
CLFileShareListAccess clCrit;
bShutdownInProgress = true;
@@ -802,7 +804,8 @@ int PreShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
// Developer : KN
/////////////////////////////////////////////////////////////////////
-int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
+int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/)
+{
while (pclFirstNode) {
CLFileShareNode * pclCur = pclFirstNode;
pclFirstNode = pclFirstNode->pclNext;
@@ -818,142 +821,143 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
return 0;
}
- /////////////////////////////////////////////////////////////////////
- // Member Function : MirandaPluginInfoEx
- // Type : Global
- // Parameters : mirandaVersion - ?
- // Returns :
- // Description :
- //
- // References : -
- // Remarks : -
- // Created : 020422, 22 April 2002
- // Developer : KN, Houdini
- /////////////////////////////////////////////////////////////////////
-
- extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /*mirandaVersion*/) {
- return &pluginInfo;
- }
+/////////////////////////////////////////////////////////////////////
+// Member Function : MirandaPluginInfoEx
+// Type : Global
+// Parameters : mirandaVersion - ?
+// Returns :
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422, 22 April 2002
+// Developer : KN, Houdini
+/////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- // Member Function : Load
- // Type : Global
- // Parameters : link - ?
- // Returns : int
- // Description :
- //
- // References : -
- // Remarks : -
- // Created : 020422, 22 April 2002
- // Developer : KN
- /////////////////////////////////////////////////////////////////////
-
- extern "C" __declspec(dllexport) int Load() {
- mir_getLP(&pluginInfo);
-
- hHttpAcceptConnectionsService = CreateServiceFunction(MS_HTTP_ACCEPT_CONNECTIONS, nToggelAcceptConnections);
- if (! hHttpAcceptConnectionsService) {
- MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ACCEPT_CONNECTIONS"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /*mirandaVersion*/) {
+ return &pluginInfo;
+}
- hHttpAddChangeRemoveService = CreateServiceFunction(MS_HTTP_ADD_CHANGE_REMOVE, nAddChangeRemoveShare);
- if (! hHttpAddChangeRemoveService) {
- MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ADD_CHANGE_REMOVE"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+/////////////////////////////////////////////////////////////////////
+// Member Function : Load
+// Type : Global
+// Parameters : link - ?
+// Returns : int
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422, 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
- hHttpGetShareService = CreateServiceFunction(MS_HTTP_GET_SHARE, nGetShare);
- if (! hHttpGetShareService) {
- MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_SHARE"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+extern "C" __declspec(dllexport) int Load()
+{
+ mir_getLP(&pluginInfo);
+ mir_getCLI();
- hHttpGetAllShares = CreateServiceFunction(MS_HTTP_GET_ALL_SHARES, nHttpGetAllShares);
- if (! hHttpGetAllShares) {
- MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_ALL_SHARES"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+ hHttpAcceptConnectionsService = CreateServiceFunction(MS_HTTP_ACCEPT_CONNECTIONS, nToggelAcceptConnections);
+ if (! hHttpAcceptConnectionsService) {
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ACCEPT_CONNECTIONS"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
+ hHttpAddChangeRemoveService = CreateServiceFunction(MS_HTTP_ADD_CHANGE_REMOVE, nAddChangeRemoveShare);
+ if (! hHttpAddChangeRemoveService) {
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_ADD_CHANGE_REMOVE"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
- hEventSystemInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
- if (!hEventSystemInit) {
- MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_MODULESLOADED"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+ hHttpGetShareService = CreateServiceFunction(MS_HTTP_GET_SHARE, nGetShare);
+ if (! hHttpGetShareService) {
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_SHARE"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
- hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
- if (!hPreShutdown) {
- MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_PRESHUTDOWN"), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
+ hHttpGetAllShares = CreateServiceFunction(MS_HTTP_GET_ALL_SHARES, nHttpGetAllShares);
+ if (! hHttpGetAllShares) {
+ MessageBox(NULL, _T("Failed to CreateServiceFunction MS_HTTP_GET_ALL_SHARES"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
- if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath))
- {
- MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
- mir_tstrncat(szPluginPath, _T("\\HTTPServer\\"), _countof(szPluginPath) - mir_tstrlen(szPluginPath));
- int err = CreateDirectoryTree(szPluginPath);
- if((err != 0) && (err != ERROR_ALREADY_EXISTS))
- {
- MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK);
- return 1;
- }
- nPluginPathLen = (int)mir_strlen(szPluginPath);
+ hEventSystemInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
+ if (!hEventSystemInit) {
+ MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_MODULESLOADED"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
- sLogFilePath = szPluginPath;
- sLogFilePath += "HTTPServer.log";
+ hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ if (!hPreShutdown) {
+ MessageBox(NULL, _T("Failed to HookEvent ME_SYSTEM_PRESHUTDOWN"), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
- if (! bInitMimeHandling()) {
- MessageBox(NULL, "Failed to read configuration file : " szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
- }
+ if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath))
+ {
+ MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
+ mir_tstrncat(szPluginPath, _T("\\HTTPServer\\"), _countof(szPluginPath) - mir_tstrlen(szPluginPath));
+ int err = CreateDirectoryTree(szPluginPath);
+ if((err != 0) && (err != ERROR_ALREADY_EXISTS))
+ {
+ MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK);
+ return 1;
+ }
+
+ nPluginPathLen = (int)mir_strlen(szPluginPath);
+
+ sLogFilePath = szPluginPath;
+ sLogFilePath += "HTTPServer.log";
+
+ if (!bInitMimeHandling())
+ MessageBox(NULL, "Failed to read configuration file : " szMimeTypeConfigFile, MSG_BOX_TITEL, MB_OK);
+
+ nMaxUploadSpeed = db_get_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
+ nMaxConnectionsTotal = db_get_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
+ nMaxConnectionsPerUser = db_get_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
+ bLimitOnlyWhenOnline = db_get_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline) != 0;
+ indexCreationMode = (eIndexCreationMode) db_get_b(NULL, MODULE, "IndexCreationMode", 2);
+
+ if (db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1)) {
+ CLISTMENUITEM mi = { 0 };
+ mi.flags = CMIF_TCHAR;
+ mi.pszContactOwner = NULL; //all contacts
+ mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
+ mi.position = 1000085000;
+ mi.pszName = LPGENT("Enable HTTP server");
+ mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
+ hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
+ }
- nMaxUploadSpeed = db_get_dw(NULL, MODULE, "MaxUploadSpeed", nMaxUploadSpeed);
- nMaxConnectionsTotal = db_get_dw(NULL, MODULE, "MaxConnectionsTotal", nMaxConnectionsTotal);
- nMaxConnectionsPerUser = db_get_dw(NULL, MODULE, "MaxConnectionsPerUser", nMaxConnectionsPerUser);
- bLimitOnlyWhenOnline = db_get_b(NULL, MODULE, "LimitOnlyWhenOnline", bLimitOnlyWhenOnline) != 0;
- indexCreationMode = (eIndexCreationMode) db_get_b(NULL, MODULE, "IndexCreationMode", 2);
-
- if (db_get_b(NULL, MODULE, "AddAcceptConMenuItem", 1)) {
- CLISTMENUITEM mi = { 0 };
- mi.flags = CMIF_TCHAR;
- mi.pszContactOwner = NULL; //all contacts
- mi.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SHARE_NEW_FILE));
- mi.position = 1000085000;
- mi.pszName = LPGENT("Enable HTTP server");
- mi.pszService = MS_HTTP_ACCEPT_CONNECTIONS;
- hAcceptConnectionsMenuItem = Menu_AddMainMenuItem(&mi);
+ if (indexCreationMode == INDEX_CREATION_HTML || indexCreationMode == INDEX_CREATION_DETECT)
+ if (!LoadIndexHTMLTemplate()) {
+ indexCreationMode = INDEX_CREATION_DISABLE;
+ db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
}
- if (indexCreationMode == INDEX_CREATION_HTML ||
- indexCreationMode == INDEX_CREATION_DETECT)
- if (!LoadIndexHTMLTemplate()) {
- indexCreationMode = INDEX_CREATION_DISABLE;
- db_set_b(NULL, MODULE, "IndexCreationMode", (BYTE)indexCreationMode);
- }
+ hEventProtoAck = HookEvent(ME_PROTO_ACK, nProtoAck);
+ return 0;
+}
- hEventProtoAck = HookEvent(ME_PROTO_ACK, nProtoAck);
- return 0;
- }
+/////////////////////////////////////////////////////////////////////
+// Member Function : Unload
+// Type : Global
+// Parameters : none
+// Returns :
+// Description :
+//
+// References : -
+// Remarks : -
+// Created : 020422, 22 April 2002
+// Developer : KN
+/////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- // Member Function : Unload
- // Type : Global
- // Parameters : none
- // Returns :
- // Description :
- //
- // References : -
- // Remarks : -
- // Created : 020422, 22 April 2002
- // Developer : KN
- /////////////////////////////////////////////////////////////////////
-
- extern "C" __declspec(dllexport) int Unload() {
- nSystemShutdown(0, 0);
- if(hwndStatsticView)
- DestroyWindow(hwndStatsticView);
- return 0;
- } \ No newline at end of file
+extern "C" __declspec(dllexport) int Unload()
+{
+ nSystemShutdown(0, 0);
+ if(hwndStatsticView)
+ DestroyWindow(hwndStatsticView);
+ return 0;
+}