From 8eb630a6605fed621fd7acd5b0cafa4143149aa8 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 22 Jan 2013 16:56:01 +0000 Subject: - fixed r3219 - all HTTPServer files are read and created in ProfileDir\HTTPServer. You need to copy your files manually. git-svn-id: http://svn.miranda-ng.org/main/trunk@3232 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HTTPServer/src/Glob.h | 1 + plugins/HTTPServer/src/GuiElements.cpp | 2 +- plugins/HTTPServer/src/main.cpp | 30 +++++++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/HTTPServer/src/Glob.h b/plugins/HTTPServer/src/Glob.h index 7a2001b0a3..a358e54587 100644 --- a/plugins/HTTPServer/src/Glob.h +++ b/plugins/HTTPServer/src/Glob.h @@ -26,6 +26,7 @@ #include #include #include +#include using namespace std; #include diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp index cd303b04a9..fcfdc16a90 100644 --- a/plugins/HTTPServer/src/GuiElements.cpp +++ b/plugins/HTTPServer/src/GuiElements.cpp @@ -95,7 +95,7 @@ void ReplaceAll(string &sSrc, const char * pszReplace, const char * pszNew) { string DBGetString(HANDLE hContact, const char *szModule, const char *szSetting, const char * pszError) { string ret; DBVARIANT dbv = {0}; - if (! DBGetContactSetting(hContact, szModule, szSetting, &dbv)) { + if (! db_get(hContact, szModule, szSetting, &dbv)) { if (dbv.type != DBVT_ASCIIZ) { MessageBox(NULL, "DB: Attempt to get wrong type of value, string", MSG_BOX_TITEL, MB_OK); ret = pszError; diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index 182c50ea31..91ac702a0d 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -331,19 +331,20 @@ bool bReadConfigurationFile() { bool bWriteConfigurationFile() { CLFileShareListAccess clCritSection; char szBuf[1000]; - TCHAR * temp = ""; strcpy(szBuf, szPluginPath); strcat(szBuf, szConfigFile); HANDLE hFile = CreateFile(szBuf, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to open or create file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to open or create file "), _T(szConfigFile)); MessageBox(NULL, temp , MSG_BOX_TITEL, MB_OK); return false; } DWORD dwBytesWriten = 0; if (! WriteFile(hFile, szXmlHeader, sizeof(szXmlHeader) - 1, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml header to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml header to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); } else { CLFileShareNode * pclCur = pclFirstNode; @@ -356,7 +357,8 @@ bool bWriteConfigurationFile() { SplitIpAddress(pclCur->st.dwAllowedMask)); if (! WriteFile(hFile, szBuf, dwBytesToWrite, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml data to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml data to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); break; } @@ -364,7 +366,8 @@ bool bWriteConfigurationFile() { } if (! WriteFile(hFile, szXmlTail, sizeof(szXmlTail) - 1, &dwBytesWriten, NULL)) { - mir_sntprintf(temp, sizeof(temp), "%s%s", TranslateT("Failed to write xml tail to file "), _T(szConfigFile)); + TCHAR temp[200]; + mir_sntprintf(temp, SIZEOF(temp), _T("%s%s"), TranslateT("Failed to write xml tail to file "), _T(szConfigFile)); MessageBox(NULL, temp, MSG_BOX_TITEL, MB_OK); } } @@ -911,13 +914,18 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) { return 0; } - szPluginPath[0] = 0; - if (GetModuleFileName(hInstance, szPluginPath, sizeof(szPluginPath))) { - char *str2 = strrchr(szPluginPath, '\\'); - if (str2 != NULL) { - str2[1] = NULL; - } + if(CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)szPluginPath)) + { + MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK); + return 0; } + _tcscat(szPluginPath,_T("\\HTTPServer\\")); + if(CreateDirectoryTree(szPluginPath)) + { + MessageBox(NULL, _T("Failed to create HTTPServer directory."), MSG_BOX_TITEL, MB_OK); + return 0; + } + nPluginPathLen = strlen(szPluginPath); sLogFilePath = szPluginPath; -- cgit v1.2.3