summaryrefslogtreecommitdiff
path: root/plugins/WhoUsesMyFiles
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-12-22 14:35:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-12-22 14:35:27 +0000
commitbdf88550d1e2807a9c719259385917ba3d0dd91e (patch)
tree81f29fadd86ae85e0bee1427b3c43081d4b903ae /plugins/WhoUsesMyFiles
parent29f62500c6b297dae647c75d62fdb0b9f9c7de85 (diff)
WUMF to use the kernel logger instead of reinventing the wheel
git-svn-id: http://svn.miranda-ng.org/main/trunk@11581 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WhoUsesMyFiles')
-rw-r--r--plugins/WhoUsesMyFiles/src/Version.h14
-rw-r--r--plugins/WhoUsesMyFiles/src/wumf.cpp38
-rw-r--r--plugins/WhoUsesMyFiles/src/wumf.h2
-rw-r--r--plugins/WhoUsesMyFiles/src/wumfplug.cpp3
4 files changed, 23 insertions, 34 deletions
diff --git a/plugins/WhoUsesMyFiles/src/Version.h b/plugins/WhoUsesMyFiles/src/Version.h
index c61141f928..dbacb3b253 100644
--- a/plugins/WhoUsesMyFiles/src/Version.h
+++ b/plugins/WhoUsesMyFiles/src/Version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 1
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>
#define __PLUGIN_NAME "Who Use My Files"
#define __FILENAME "WhoUsesMyFiles.dll"
-#define __DESCRIPTION "Scans for network users of your shared files and notify you with popups."
-#define __AUTHOR "Nikolay Redko"
+#define __DESCRIPTION "Scans for network users of your shared files and notify you with popups."
+#define __AUTHOR "Nikolay Redko"
#define __AUTHOREMAIL "nike000@users.sf.net"
-#define __AUTHORWEB "http://miranda-ng.org/p/WhoUsesMyFiles/"
-#define __COPYRIGHT "© 2003 Nike"
+#define __AUTHORWEB "http://miranda-ng.org/p/WhoUsesMyFiles/"
+#define __COPYRIGHT "© 2003 Nike"
diff --git a/plugins/WhoUsesMyFiles/src/wumf.cpp b/plugins/WhoUsesMyFiles/src/wumf.cpp
index 5e194414b7..034d84f460 100644
--- a/plugins/WhoUsesMyFiles/src/wumf.cpp
+++ b/plugins/WhoUsesMyFiles/src/wumf.cpp
@@ -8,7 +8,7 @@
static PWumf list = NULL;
static PWumf lst = NULL;
-HANDLE hLog = INVALID_HANDLE_VALUE;
+HANDLE hLogger = NULL;
BOOL wumf();
static int DlgResizer(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
@@ -142,38 +142,26 @@ INT_PTR CALLBACK ConnDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
void LogWumf(PWumf w)
{
- TCHAR str[256];
- LPTSTR lpstr;
- TCHAR lpDateStr[20];
- TCHAR lpTimeStr[20];
- SYSTEMTIME time;
- DWORD bytes;
-
if (!WumfOptions.LogFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return;
- if (hLog == INVALID_HANDLE_VALUE || hLog == NULL)
- {
- hLog = CreateFile(WumfOptions.LogFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hLog == INVALID_HANDLE_VALUE)
- {
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpstr, 0, NULL);
- mir_sntprintf(str, SIZEOF(str), _T("Can't open log file %s\nError:%s"), WumfOptions.LogFile, lpstr);
- LocalFree(lpstr);
- MessageBox( NULL, str, TranslateT("Error opening file"), MB_OK | MB_ICONSTOP);
+ if (hLogger == NULL) {
+ hLogger = mir_createLog("wumf", _T("WhoIsUsingMyFiles log file"), WumfOptions.LogFile, 0);
+ if (hLogger == NULL) {
+ TCHAR str[256];
+ mir_sntprintf(str, SIZEOF(str), _T("Can't open log file %s"), WumfOptions.LogFile);
+ MessageBox(NULL, str, TranslateT("Error opening file"), MB_OK | MB_ICONSTOP);
WumfOptions.LogToFile = FALSE;
+ return;
}
}
+
+ SYSTEMTIME time;
GetLocalTime(&time);
+
+ TCHAR lpDateStr[20], lpTimeStr[20];
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, lpDateStr, 20);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &time, NULL, lpTimeStr, 20);
- mir_sntprintf(str, SIZEOF(str), _T("%s %s %20s\t%s\r\n\0"), lpDateStr, lpTimeStr, w->szUser, w->szPath);
- SetFilePointer(hLog, 0, NULL, FILE_END);
- WriteFile(hLog, str, (DWORD)_tcslen(str), &bytes, NULL);
+ mir_writeLogT(hLogger, _T("%s %s %20s\t%s\r\n"), lpDateStr, lpTimeStr, w->szUser, w->szPath);
}
BOOL wumf()
diff --git a/plugins/WhoUsesMyFiles/src/wumf.h b/plugins/WhoUsesMyFiles/src/wumf.h
index 104e6d50a2..e0707f8481 100644
--- a/plugins/WhoUsesMyFiles/src/wumf.h
+++ b/plugins/WhoUsesMyFiles/src/wumf.h
@@ -114,7 +114,7 @@ BOOL del_marked(PWumf* l);
extern WUMF_OPTIONS WumfOptions;
extern HINSTANCE hInst;
-extern HANDLE hLog;
+extern HANDLE hLogger;
static HANDLE hWumfBut;
extern PWumf list;
diff --git a/plugins/WhoUsesMyFiles/src/wumfplug.cpp b/plugins/WhoUsesMyFiles/src/wumfplug.cpp
index f2daa8b25f..7febec32e0 100644
--- a/plugins/WhoUsesMyFiles/src/wumfplug.cpp
+++ b/plugins/WhoUsesMyFiles/src/wumfplug.cpp
@@ -530,7 +530,8 @@ extern "C" __declspec(dllexport) int Load(void)
extern "C" __declspec(dllexport) int Unload(void)
{
KillTimer(NULL, 777);
- CloseHandle(hLog);
+ if (hLogger)
+ mir_closeLog(hLogger);
FreeAll();
return 0;
}